let's make server work out of the box if u set:
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 21 May 2012 08:44:55 +0000 (08:44 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 21 May 2012 08:44:55 +0000 (08:44 +0000)
 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
src/bin/evas_cserve2_main_loop_linux.c
src/lib/cserve2/evas_cs2_client.c

index ab50932..d8add9c 100644 (file)
 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)
      {
index ad28518..e8cc33d 100644 (file)
@@ -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
index 00485d7..1b93ccd 100644 (file)
@@ -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