changeset 10124:baab57e76991

[HAVE_SYSVIPC]: Include sys/utsname.h. (main): If socket/mqueue name is in home dir, add in the host name. Rename .emacs_server to .emacs-server-.... [!HAVE_SYSVIPC] (main): Fix error message diction.
author Richard M. Stallman <rms@gnu.org>
date Wed, 07 Dec 1994 07:39:23 +0000
parents bb3d25f73eaf
children 317294dfa695
files lib-src/emacsclient.c
diffstat 1 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/emacsclient.c	Wed Dec 07 07:38:00 1994 +0000
+++ b/lib-src/emacsclient.c	Wed Dec 07 07:39:23 1994 +0000
@@ -27,7 +27,7 @@
 #undef signal
 
 
-#if !defined(HAVE_SOCKETS) && !defined(HAVE_SYSVIPC)
+#if !defined (HAVE_SOCKETS) && !defined (HAVE_SYSVIPC)
 #include <stdio.h>
 
 main (argc, argv)
@@ -103,9 +103,9 @@
 	  perror ("stat");
 	exit (1);
       }
-    if (statbfr.st_uid != geteuid())
+    if (statbfr.st_uid != geteuid ())
       {
-	fprintf (stderr, "Illegal socket owner\n");
+	fprintf (stderr, "Invalid socket owner\n");
 	exit (1);
       }
   }
@@ -116,7 +116,9 @@
       exit (1);
     }
   strcpy (server.sun_path, homedir);
-  strcat (server.sun_path, "/.emacs_server");
+  strcat (server.sun_path, "/.emacs-server-");
+  gethostname (system_name, sizeof (system_name));
+  strcat (server.sun_path, system_name);
 #endif
 
   if (connect (s, (struct sockaddr *) &server, strlen (server.sun_path) + 2)
@@ -176,9 +178,11 @@
 #include <sys/types.h>
 #include <sys/ipc.h>
 #include <sys/msg.h>
+#include <sys/utsname.h>
 #include <stdio.h>
 
 char *getwd (), *getcwd (), *getenv ();
+struct utsname system_name;
 
 main (argc, argv)
      int argc;
@@ -206,7 +210,7 @@
     }
 
   /*
-   * Create a message queue using ~/.emacs_server as the path for ftok
+   * Create a message queue using ~/.emacs-server as the path for ftok
    */
   if ((homedir = getenv ("HOME")) == NULL)
     {
@@ -214,7 +218,14 @@
       exit (1);
     }
   strcpy (buf, homedir);
-  strcat (buf, "/.emacs_server");
+#ifndef HAVE_LONG_FILE_NAMES
+  /* If file names are short, we can't fit the host name.  */
+  strcat (buf, "/.emacs-server");
+#else
+  strcat (buf, "/.emacs-server-");
+  uname (&system_name);
+  strcat (buf, system_name.nodename);
+#endif
   creat (buf, 0600);
   key = ftok (buf, 1);	/* unlikely to be anyone else using it */
   s = msgget (key, 0600 | IPC_CREAT);