]> code.delx.au - gnu-emacs/blobdiff - lib-src/emacsclient.c
(main): Call strerror instead of using sys_errlist.
[gnu-emacs] / lib-src / emacsclient.c
index 5f1a41a502db21e1bbb38c9cc4d046aab6581acf..b28acb26da01f9b0b145759a7b385536099910a4 100644 (file)
@@ -1,11 +1,11 @@
 /* Client process that communicates with GNU Emacs acting as server.
 /* Client process that communicates with GNU Emacs acting as server.
-   Copyright (C) 1986, 1987 Free Software Foundation, Inc.
+   Copyright (C) 1986, 1987, 1994 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -19,13 +19,12 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 
 #define NO_SHORTNAMES
 
 
 #define NO_SHORTNAMES
-#include "../src/config.h"
+#include <../src/config.h>
 #undef read
 #undef write
 #undef open
 #undef read
 #undef write
 #undef open
-#ifdef close
 #undef close
 #undef close
-#endif
+#undef signal
 
 
 #if !defined(HAVE_SOCKETS) && !defined(HAVE_SYSVIPC)
 
 
 #if !defined(HAVE_SOCKETS) && !defined(HAVE_SYSVIPC)
@@ -53,8 +52,7 @@ main (argc, argv)
 #include <stdio.h>
 #include <errno.h>
 
 #include <stdio.h>
 #include <errno.h>
 
-extern int sys_nerr;
-extern char *sys_errlist[];
+extern char *strerror ();
 extern int errno;
 
 main (argc, argv)
 extern int errno;
 
 main (argc, argv)
@@ -120,7 +118,8 @@ main (argc, argv)
   strcat (server.sun_path, "/.emacs_server");
 #endif
 
   strcat (server.sun_path, "/.emacs_server");
 #endif
 
-  if (connect (s, &server, strlen (server.sun_path) + 2) < 0)
+  if (connect (s, (struct sockaddr *) &server, strlen (server.sun_path) + 2)
+      < 0)
     {
       fprintf (stderr, "%s: ", argv[0]);
       perror ("connect");
     {
       fprintf (stderr, "%s: ", argv[0]);
       perror ("connect");
@@ -137,8 +136,7 @@ main (argc, argv)
   if (cwd == 0)
     {
       /* getwd puts message in STRING if it fails.  */
   if (cwd == 0)
     {
       /* getwd puts message in STRING if it fails.  */
-      fprintf (stderr, "%s: %s (%s)\n", argv[0], string,
-              (errno < sys_nerr) ? sys_errlist[errno] : "unknown error");
+      fprintf (stderr, "%s: %s (%s)\n", argv[0], string, strerror (errno));
       exit (1);
     }
 
       exit (1);
     }
 
@@ -212,7 +210,7 @@ main (argc, argv)
   strcat (buf, "/.emacs_server");
   creat (buf, 0600);
   key = ftok (buf, 1); /* unlikely to be anyone else using it */
   strcat (buf, "/.emacs_server");
   creat (buf, 0600);
   key = ftok (buf, 1); /* unlikely to be anyone else using it */
-  s = msgget (key, 0600);
+  s = msgget (key, 0600 | IPC_CREAT);
   if (s == -1)
     {
       fprintf (stderr, "%s: ", argv[0]);
   if (s == -1)
     {
       fprintf (stderr, "%s: ", argv[0]);