From 9ccbd89a87f2916aff13fdb87ad1259e1ce6d623 Mon Sep 17 00:00:00 2001 From: raster Date: Mon, 21 May 2012 08:44:55 +0000 Subject: [PATCH] let's make server work out of the box if u set: export EVAS_CSERVE2=1 (and run cserve2) git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@71274 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/bin/evas_cserve2_client.c | 16 ++++++++++++++-- src/bin/evas_cserve2_main_loop_linux.c | 6 ++++++ src/lib/cserve2/evas_cs2_client.c | 5 +++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/bin/evas_cserve2_client.c b/src/bin/evas_cserve2_client.c index ab50932..d8add9c 100644 --- a/src/bin/evas_cserve2_client.c +++ b/src/bin/evas_cserve2_client.c @@ -14,6 +14,11 @@ static const char *SOCK_PATH = "/tmp/cserve2.socket"; static unsigned int _rid_count = 0; +static struct sockaddr_un socket_local; +#ifndef UNIX_PATH_MAX +#define UNIX_PATH_MAX sizeof(socket_local.sun_path) +#endif + static void debug_msg(const void *buf, int size) { @@ -323,7 +328,7 @@ int main(void) { int s, t, len, skip_cmd = 0; struct sockaddr_un remote; - char msgbuf[4096]; + char msgbuf[4096], buf[UNIX_PATH_MAX], *env; if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { @@ -334,7 +339,14 @@ int main(void) printf("Trying to connect...\n"); remote.sun_family = AF_UNIX; - strcpy(remote.sun_path, SOCK_PATH); + env = getenv("EVAS_CSERVE2_SOCKET"); + if (!env) + { + snprintf(buf, sizeof(buf), "/tmp/.evas-cserve2-%x.socket", + (int)getuid()); + env = buf; + } + strncpy(remote.sun_path, env, UNIX_PATH_MAX - 1); len = strlen(remote.sun_path) + sizeof(remote.sun_family); if (connect(s, (struct sockaddr *)&remote, len) == -1) { diff --git a/src/bin/evas_cserve2_main_loop_linux.c b/src/bin/evas_cserve2_main_loop_linux.c index ad28518..e8cc33d 100644 --- a/src/bin/evas_cserve2_main_loop_linux.c +++ b/src/bin/evas_cserve2_main_loop_linux.c @@ -207,6 +207,11 @@ _socket_path_set(char *path) return; } + snprintf(buf, sizeof(buf), "/tmp/.evas-cserve2-%x.socket", (int)getuid()); + /* FIXME: check we can actually create this socket */ + strcpy(path, buf); + return; +#if 0 env = getenv("XDG_RUNTIME_DIR"); if (!env || !env[0]) { @@ -222,6 +227,7 @@ _socket_path_set(char *path) snprintf(buf, sizeof(buf), "%s/evas-cserve2-%x.socket", env, getuid()); /* FIXME: check we can actually create this socket */ strcpy(path, buf); +#endif } static int diff --git a/src/lib/cserve2/evas_cs2_client.c b/src/lib/cserve2/evas_cs2_client.c index 00485d7..1b93ccd 100644 --- a/src/lib/cserve2/evas_cs2_client.c +++ b/src/lib/cserve2/evas_cs2_client.c @@ -58,6 +58,10 @@ _socket_path_set(char *path) return; } + snprintf(buf, sizeof(buf), "/tmp/.evas-cserve2-%x.socket", (int)getuid()); + /* FIXME: check we can actually create this socket */ + strcpy(path, buf); +#if 0 env = getenv("XDG_RUNTIME_DIR"); if (!env || !env[0]) { @@ -73,6 +77,7 @@ _socket_path_set(char *path) snprintf(buf, sizeof(buf), "%s/evas-cserve2-%x.socket", env, getuid()); /* FIXME: check we can actually create this socket */ strcpy(path, buf); +#endif } static Eina_Bool -- 2.7.4