From feeca8301b4631c5bb19301ba3c2c6e228f81778 Mon Sep 17 00:00:00 2001 From: rephorm Date: Sun, 24 Sep 2006 07:53:47 +0000 Subject: [PATCH] cleaner handling of optional features SVN revision: 26084 --- legacy/ecore/src/lib/ecore_con/Ecore_Con.h | 4 +-- legacy/ecore/src/lib/ecore_con/ecore_con.c | 35 ++++++++----------- .../src/lib/ecore_con/ecore_con_private.h | 8 ++--- .../src/lib/ecore_dbus/ecore_dbus_address.c | 2 -- 4 files changed, 19 insertions(+), 30 deletions(-) diff --git a/legacy/ecore/src/lib/ecore_con/Ecore_Con.h b/legacy/ecore/src/lib/ecore_con/Ecore_Con.h index 1043acae5f..f98057517e 100644 --- a/legacy/ecore/src/lib/ecore_con/Ecore_Con.h +++ b/legacy/ecore/src/lib/ecore_con/Ecore_Con.h @@ -74,8 +74,8 @@ extern "C" { ECORE_CON_LOCAL_USER, ECORE_CON_LOCAL_SYSTEM, ECORE_CON_LOCAL_ABSTRACT, - ECORE_CON_REMOTE_SYSTEM - ,ECORE_CON_USE_SSL = 16 + ECORE_CON_REMOTE_SYSTEM, + ECORE_CON_USE_SSL = 16 } Ecore_Con_Type; #endif diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con.c b/legacy/ecore/src/lib/ecore_con/ecore_con.c index 723cc3dedf..7a05d3c799 100644 --- a/legacy/ecore/src/lib/ecore_con/ecore_con.c +++ b/legacy/ecore/src/lib/ecore_con/ecore_con.c @@ -171,11 +171,8 @@ ecore_con_server_add(Ecore_Con_Type compl_type, #endif if ((type == ECORE_CON_LOCAL_USER) || - (type == ECORE_CON_LOCAL_SYSTEM) -#ifdef HAVE_ABSTRACT_SOCKETS - || (type == ECORE_CON_LOCAL_ABSTRACT) -#endif - ) + (type == ECORE_CON_LOCAL_SYSTEM) || + (type == ECORE_CON_LOCAL_ABSTRACT)) { const char *homedir; struct stat st; @@ -236,24 +233,25 @@ ecore_con_server_add(Ecore_Con_Type compl_type, goto error; } socket_unix.sun_family = AF_UNIX; -#ifdef HAVE_ABSTRACT_SOCKET if (type == ECORE_CON_LOCAL_ABSTRACT) { +#ifdef HAVE_ABSTRACT_SOCKET /* . is a placeholder */ snprintf(socket_unix.sun_path, sizeof(socket_unix.sun_path), ".%s", name); /* first char null indicates abstract namespace */ socket_unix.sun_path[0] = '\0'; socket_unix_len = LENGTH_OF_ABSTRACT_SOCKADDR_UN(&socket_unix, name); +#else + fprintf(stderr, "Your system does not support abstract sockets!\n"); + umask(pmode); + goto error; +#endif } else { strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path)); socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix); } -#else - strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path)); - socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix); -#endif if (bind(svr->fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0) { if (connect(svr->fd, (struct sockaddr *)&socket_unix, @@ -425,11 +423,8 @@ ecore_con_server_connect(Ecore_Con_Type compl_type, if ((type == ECORE_CON_REMOTE_SYSTEM) && (port < 0)) return NULL; if ((type == ECORE_CON_LOCAL_USER) || - (type == ECORE_CON_LOCAL_SYSTEM) -#ifdef HAVE_ABSTRACT_SOCKETS - || (type == ECORE_CON_LOCAL_ABSTRACT) -#endif - ) + (type == ECORE_CON_LOCAL_SYSTEM) || + (type == ECORE_CON_LOCAL_ABSTRACT)) { const char *homedir; int socket_unix_len; @@ -465,23 +460,23 @@ ecore_con_server_connect(Ecore_Con_Type compl_type, if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, &curstate, sizeof(curstate)) < 0) goto error; socket_unix.sun_family = AF_UNIX; -#ifdef HAVE_ABSTRACT_SOCKETS if (type == ECORE_CON_LOCAL_ABSTRACT) { +#ifdef HAVE_ABSTRACT_SOCKETS /* copy name insto sun_path, prefixed by null to indicate abstract namespace */ snprintf(socket_unix.sun_path, sizeof(socket_unix.sun_path), ".%s", name); socket_unix.sun_path[0] = '\0'; socket_unix_len = LENGTH_OF_ABSTRACT_SOCKADDR_UN(&socket_unix, name); +#else + fprintf(stderr, "Your system does not support abstract sockets!\n"); + goto error; +#endif } else { strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path)); socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix); } -#else - strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path)); - socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix); -#endif if (connect(svr->fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0) goto error; svr->path = strdup(buf); diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con_private.h b/legacy/ecore/src/lib/ecore_con/ecore_con_private.h index bbb0c47dfb..a3835c4266 100644 --- a/legacy/ecore/src/lib/ecore_con/ecore_con_private.h +++ b/legacy/ecore/src/lib/ecore_con/ecore_con_private.h @@ -27,13 +27,9 @@ typedef enum _Ecore_Con_Type { ECORE_CON_LOCAL_USER, ECORE_CON_LOCAL_SYSTEM, -#ifdef HAVE_ABSTRACT_SOCKETS ECORE_CON_LOCAL_ABSTRACT, -#endif - ECORE_CON_REMOTE_SYSTEM -#if USE_OPENSSL - ,ECORE_CON_USE_SSL = 16 -#endif + ECORE_CON_REMOTE_SYSTEM, + ECORE_CON_USE_SSL = 16 } Ecore_Con_Type; struct _Ecore_Con_Client diff --git a/legacy/ecore/src/lib/ecore_dbus/ecore_dbus_address.c b/legacy/ecore/src/lib/ecore_dbus/ecore_dbus_address.c index c0c8780ded..24c26dee53 100644 --- a/legacy/ecore/src/lib/ecore_dbus/ecore_dbus_address.c +++ b/legacy/ecore/src/lib/ecore_dbus/ecore_dbus_address.c @@ -184,13 +184,11 @@ ecore_dbus_address_connect(Ecore_DBus_Address *addr, const void *data) type = ECORE_CON_LOCAL_SYSTEM; name = ecore_dbus_address_value_get(addr, "path"); -#ifdef HAVE_ABSTRACT_SOCKETS if (!name) { name = ecore_dbus_address_value_get(addr, "abstract"); type = ECORE_CON_LOCAL_ABSTRACT; } -#endif if (!name) return NULL; port = -1;