X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/749ae7700e52dceac494785072ba9a199c2d1bc7..34663a742b6403d54f18eb5f650e7f2413ee40a2:/lib-src/emacsclient.c diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index b74cc26d16..07d446b7aa 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -29,10 +29,15 @@ Boston, MA 02111-1307, USA. */ #include #include +#ifdef STDC_HEADERS +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#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 */ #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 #include #include +#include +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); }