[maemo-commits] [maemo-commits] r16284 - in projects/haf/trunk/sapwood: . engine tests
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Sep 29 19:20:35 EEST 2008
- Previous message: [maemo-commits] r16283 - in projects/haf/trunk/sapwood: . engine tests
- Next message: [maemo-commits] r16285 - in projects/haf/trunk/sapwood: . engine tests
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: herzi Date: 2008-09-29 19:20:26 +0300 (Mon, 29 Sep 2008) New Revision: 16284 Modified: projects/haf/trunk/sapwood/ChangeLog projects/haf/trunk/sapwood/engine/sapwood-client.c projects/haf/trunk/sapwood/engine/sapwood-client.h projects/haf/trunk/sapwood/engine/sapwood-pixmap.c projects/haf/trunk/sapwood/tests/double-free.c Log: 2008-09-29 Sven Herzberg <sven at imendio.com> Moved pixbuf_proto_get_socket() into the shared library * engine/sapwood-client.c, * engine/sapwood-client.h: new location for this function * engine/sapwood-pixmap.c, * tests/double-free.c: use the shared function, not two completely identical but separate ones Modified: projects/haf/trunk/sapwood/ChangeLog =================================================================== --- projects/haf/trunk/sapwood/ChangeLog 2008-09-29 16:20:14 UTC (rev 16283) +++ projects/haf/trunk/sapwood/ChangeLog 2008-09-29 16:20:26 UTC (rev 16284) @@ -1,5 +1,15 @@ 2008-09-29 Sven Herzberg <sven at imendio.com> + Moved pixbuf_proto_get_socket() into the shared library + + * engine/sapwood-client.c, + * engine/sapwood-client.h: new location for this function + * engine/sapwood-pixmap.c, + * tests/double-free.c: use the shared function, not two completely + identical but separate ones + +2008-09-29 Sven Herzberg <sven at imendio.com> + Renamed the enumeration value to match the file and library name * engine/sapwood-client.h, Modified: projects/haf/trunk/sapwood/engine/sapwood-client.c =================================================================== --- projects/haf/trunk/sapwood/engine/sapwood-client.c 2008-09-29 16:20:14 UTC (rev 16283) +++ projects/haf/trunk/sapwood/engine/sapwood-client.c 2008-09-29 16:20:26 UTC (rev 16284) @@ -21,6 +21,16 @@ * USA */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <errno.h> +#include <stdio.h> +#include <sys/socket.h> +#include <sys/un.h> +#include <unistd.h> + #include "sapwood-client.h" GQuark @@ -32,3 +42,41 @@ return q; } +int +pixbuf_proto_get_socket (GError **err) +{ + struct sockaddr_un sun; + const char *sock_path; + int fd; + + fd = socket (PF_LOCAL, SOCK_STREAM, 0); + if (fd < 0) + { + g_set_error (err, SAPWOOD_CLIENT_ERROR, SAPWOOD_CLIENT_ERROR_UNKNOWN, + "socket: %s", strerror (errno)); + return -1; + } + + sock_path = sapwood_socket_path_get_default (); + + memset (&sun, '\0', sizeof(sun)); + sun.sun_family = AF_LOCAL; +#ifdef HAVE_ABSTRACT_SOCKETS + strcpy (&sun.sun_path[1], sock_path); +#else + strcpy (&sun.sun_path[0], sock_path); +#endif + if (connect (fd, (struct sockaddr *)&sun, sizeof (sun)) < 0) + { + g_set_error (err, SAPWOOD_CLIENT_ERROR, SAPWOOD_CLIENT_ERROR_UNKNOWN, + "Failed to connect to sapwood server using `%s': %s\n\n" + "\t`%s' MUST be started before applications", + sock_path, strerror (errno), + SAPWOOD_SERVER); + close (fd); + return -1; + } + + return fd; +} + Modified: projects/haf/trunk/sapwood/engine/sapwood-client.h =================================================================== --- projects/haf/trunk/sapwood/engine/sapwood-client.h 2008-09-29 16:20:14 UTC (rev 16283) +++ projects/haf/trunk/sapwood/engine/sapwood-client.h 2008-09-29 16:20:26 UTC (rev 16284) @@ -36,6 +36,8 @@ G_GNUC_INTERNAL GQuark sapwood_client_get_error_quark (void); +G_GNUC_INTERNAL int pixbuf_proto_get_socket (GError **err); + G_END_DECLS #endif /* !SAPWOOD_CLIENT_H */ Modified: projects/haf/trunk/sapwood/engine/sapwood-pixmap.c =================================================================== --- projects/haf/trunk/sapwood/engine/sapwood-pixmap.c 2008-09-29 16:20:14 UTC (rev 16283) +++ projects/haf/trunk/sapwood/engine/sapwood-pixmap.c 2008-09-29 16:20:26 UTC (rev 16284) @@ -28,47 +28,7 @@ #include <stdio.h> #include <string.h> #include <unistd.h> -#include <sys/socket.h> -#include <sys/un.h> -static int -pixbuf_proto_get_socket (GError **err) -{ - struct sockaddr_un sun; - const char *sock_path; - int fd; - - fd = socket (PF_LOCAL, SOCK_STREAM, 0); - if (fd < 0) - { - g_set_error (err, SAPWOOD_CLIENT_ERROR, SAPWOOD_CLIENT_ERROR_UNKNOWN, - "socket: %s", strerror (errno)); - return -1; - } - - sock_path = sapwood_socket_path_get_default (); - - memset (&sun, '\0', sizeof(sun)); - sun.sun_family = AF_LOCAL; -#ifdef HAVE_ABSTRACT_SOCKETS - strcpy (&sun.sun_path[1], sock_path); -#else - strcpy (&sun.sun_path[0], sock_path); -#endif - if (connect (fd, (struct sockaddr *)&sun, sizeof (sun)) < 0) - { - g_set_error (err, SAPWOOD_CLIENT_ERROR, SAPWOOD_CLIENT_ERROR_UNKNOWN, - "Failed to connect to sapwood server using `%s': %s\n\n" - "\t`%s' MUST be started before applications", - sock_path, strerror (errno), - SAPWOOD_SERVER); - close (fd); - return -1; - } - - return fd; -} - static gboolean pixbuf_proto_request (const char *req, ssize_t reqlen, Modified: projects/haf/trunk/sapwood/tests/double-free.c =================================================================== --- projects/haf/trunk/sapwood/tests/double-free.c 2008-09-29 16:20:14 UTC (rev 16283) +++ projects/haf/trunk/sapwood/tests/double-free.c 2008-09-29 16:20:26 UTC (rev 16284) @@ -39,44 +39,6 @@ /* FIXME: refactor this out into a libproto-client.la library for the engine * and the test cases */ -static int -pixbuf_proto_get_socket (GError **err) -{ - struct sockaddr_un sun; - const char *sock_path; - int fd; - - fd = socket (PF_LOCAL, SOCK_STREAM, 0); - if (fd < 0) - { - g_set_error (err, SAPWOOD_CLIENT_ERROR, SAPWOOD_CLIENT_ERROR_UNKNOWN, - "socket: %s", strerror (errno)); - return -1; - } - - sock_path = sapwood_socket_path_get_default (); - - memset (&sun, '\0', sizeof(sun)); - sun.sun_family = AF_LOCAL; -#ifdef HAVE_ABSTRACT_SOCKETS - strcpy (&sun.sun_path[1], sock_path); -#else - strcpy (&sun.sun_path[0], sock_path); -#endif - if (connect (fd, (struct sockaddr *)&sun, sizeof (sun)) < 0) - { - g_set_error (err, SAPWOOD_CLIENT_ERROR, SAPWOOD_CLIENT_ERROR_UNKNOWN, - "Failed to connect to sapwood server using `%s': %s\n\n" - "\t`%s' MUST be started before applications", - sock_path, strerror (errno), - SAPWOOD_SERVER); - close (fd); - return -1; - } - - return fd; -} - static gboolean pixbuf_proto_request (const char *req, ssize_t reqlen,
- Previous message: [maemo-commits] r16283 - in projects/haf/trunk/sapwood: . engine tests
- Next message: [maemo-commits] r16285 - in projects/haf/trunk/sapwood: . engine tests
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]