]> code.delx.au - gnu-emacs/blobdiff - lib-src/emacsclient.c
(rmail-default-dont-reply-to-names):
[gnu-emacs] / lib-src / emacsclient.c
index b74cc26d162895d899ab37abb13c29dd1a9a4d9f..07d446b7aa41a608cb4f0db51b18682339734cc3 100644 (file)
@@ -29,10 +29,15 @@ Boston, MA 02111-1307, USA.  */
 
 #include <stdio.h>
 #include <getopt.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 char *getenv (), *getwd ();
 char *getcwd ();
-int geteuid ();
 
 /* This is defined with -D from the compilation command,
    which extracts it from ../lisp/version.el.  */
@@ -47,6 +52,8 @@ char *progname;
 /* Nonzero means don't wait for a response from Emacs.  --no-wait.  */
 int nowait = 0;
 
+void print_help_and_exit ();
+
 struct option longopts[] =
 {
   { "no-wait", no_argument,       NULL, 'n' },
@@ -94,6 +101,7 @@ decode_options (argc, argv)
     }
 }
 
+void
 print_help_and_exit ()
 {
   fprintf (stderr,
@@ -137,6 +145,23 @@ quote_file_name (name)
 
   return copy;
 }
+
+#ifdef C_ALLOCA
+/* Like malloc but get fatal error if memory is exhausted.  */
+
+char *
+xmalloc (size)
+     unsigned int size;
+{
+  char *result = (char *) malloc (size);
+  if (result == NULL)
+  {
+    perror ("malloc");
+    exit (1);
+  }
+  return result;
+}
+#endif /* C_ALLOCA */
 \f
 #if !defined (HAVE_SOCKETS) && !defined (HAVE_SYSVIPC)
 
@@ -259,7 +284,7 @@ main (argc, argv)
       exit (1);
     }
 
-#ifdef BSD
+#ifdef BSD_SYSTEM
   cwd = getwd (string);
 #else
   cwd = getcwd (string, sizeof string);
@@ -267,7 +292,13 @@ main (argc, argv)
   if (cwd == 0)
     {
       /* getwd puts message in STRING if it fails.  */
-      fprintf (stderr, "%s: %s (%s)\n", argv[0], string, strerror (errno));
+      fprintf (stderr, "%s: %s (%s)\n", argv[0],
+#ifdef BSD_SYSTEM
+              string,
+#else
+              "Cannot get current working directory",
+#endif
+              strerror (errno));
       exit (1);
     }
 
@@ -316,6 +347,8 @@ main (argc, argv)
 #include <sys/msg.h>
 #include <sys/utsname.h>
 #include <stdio.h>
+#include <errno.h>
+extern int errno;
 
 char *getwd (), *getcwd (), *getenv ();
 struct utsname system_name;
@@ -374,7 +407,7 @@ main (argc, argv)
     }
 
   /* Determine working dir, so we can prefix it to all the arguments.  */
-#ifdef BSD
+#ifdef BSD_SYSTEM
   temp = getwd (gwdirb);
 #else
   temp = getcwd (gwdirb, sizeof gwdirb);
@@ -391,7 +424,12 @@ main (argc, argv)
     }
   else
     {
+#ifdef BSD_SYSTEM
       fprintf (stderr, "%s: %s\n", argv[0], cwd);
+#else
+      fprintf (stderr, "%s: Cannot get current working directory: %s\n",
+              argv[0], strerror (errno));
+#endif
       exit (1);
     }