diff options
| author | Richard M. Stallman | 2003-09-12 00:48:03 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2003-09-12 00:48:03 +0000 |
| commit | 254107e49743f3900782aebb2e42e0e72303b4c2 (patch) | |
| tree | ca82a6b07f921962b8876eb0caa0f3e4f054805d /lib-src | |
| parent | f6537e033c165670e59d5229979968b4f6184840 (diff) | |
| download | emacs-254107e49743f3900782aebb2e42e0e72303b4c2.tar.gz emacs-254107e49743f3900782aebb2e42e0e72303b4c2.zip | |
(socket_name): New variable.
(longopts, decode_options, print_help_and_exit):
Handle --socket-name argument.
(main): Use socket_name.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/emacsclient.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 2a53b162693..820d172a9a1 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -67,6 +67,9 @@ char *display = NULL; | |||
| 67 | is not running. --alternate-editor. */ | 67 | is not running. --alternate-editor. */ |
| 68 | const char * alternate_editor = NULL; | 68 | const char * alternate_editor = NULL; |
| 69 | 69 | ||
| 70 | /* If non-NULL, thefilename of the UNIX socket */ | ||
| 71 | char *socket_name = NULL; | ||
| 72 | |||
| 70 | void print_help_and_exit (); | 73 | void print_help_and_exit (); |
| 71 | 74 | ||
| 72 | struct option longopts[] = | 75 | struct option longopts[] = |
| @@ -76,6 +79,7 @@ struct option longopts[] = | |||
| 76 | { "help", no_argument, NULL, 'H' }, | 79 | { "help", no_argument, NULL, 'H' }, |
| 77 | { "version", no_argument, NULL, 'V' }, | 80 | { "version", no_argument, NULL, 'V' }, |
| 78 | { "alternate-editor", required_argument, NULL, 'a' }, | 81 | { "alternate-editor", required_argument, NULL, 'a' }, |
| 82 | { "socket-name", required_argument, NULL, 's' }, | ||
| 79 | { "display", required_argument, NULL, 'd' }, | 83 | { "display", required_argument, NULL, 'd' }, |
| 80 | { 0, 0, 0, 0 } | 84 | { 0, 0, 0, 0 } |
| 81 | }; | 85 | }; |
| @@ -91,7 +95,7 @@ decode_options (argc, argv) | |||
| 91 | while (1) | 95 | while (1) |
| 92 | { | 96 | { |
| 93 | int opt = getopt_long (argc, argv, | 97 | int opt = getopt_long (argc, argv, |
| 94 | "VHnea:d:", longopts, 0); | 98 | "VHnea:s:d:", longopts, 0); |
| 95 | 99 | ||
| 96 | if (opt == EOF) | 100 | if (opt == EOF) |
| 97 | break; | 101 | break; |
| @@ -109,6 +113,10 @@ decode_options (argc, argv) | |||
| 109 | alternate_editor = optarg; | 113 | alternate_editor = optarg; |
| 110 | break; | 114 | break; |
| 111 | 115 | ||
| 116 | case 's': | ||
| 117 | socket_name = optarg; | ||
| 118 | break; | ||
| 119 | |||
| 112 | case 'd': | 120 | case 'd': |
| 113 | display = optarg; | 121 | display = optarg; |
| 114 | break; | 122 | break; |
| @@ -152,6 +160,8 @@ The following OPTIONS are accepted:\n\ | |||
| 152 | -n, --no-wait Don't wait for the server to return\n\ | 160 | -n, --no-wait Don't wait for the server to return\n\ |
| 153 | -e, --eval Evaluate the FILE arguments as ELisp expressions\n\ | 161 | -e, --eval Evaluate the FILE arguments as ELisp expressions\n\ |
| 154 | -d, --display=DISPLAY Visit the file in the given display\n\ | 162 | -d, --display=DISPLAY Visit the file in the given display\n\ |
| 163 | -s, --socket-name=FILENAME\n\ | ||
| 164 | Set the filename of the UNIX socket for communication\n\ | ||
| 155 | -a, --alternate-editor=EDITOR\n\ | 165 | -a, --alternate-editor=EDITOR\n\ |
| 156 | Editor to fallback to if the server is not running\n\ | 166 | Editor to fallback to if the server is not running\n\ |
| 157 | \n\ | 167 | \n\ |
| @@ -347,7 +357,18 @@ main (argc, argv) | |||
| 347 | { | 357 | { |
| 348 | int sock_status = 0; | 358 | int sock_status = 0; |
| 349 | 359 | ||
| 350 | sprintf (server.sun_path, "/tmp/emacs%d-%s/server", (int) geteuid (), system_name); | 360 | if (! socket_name) |
| 361 | { | ||
| 362 | socket_name = alloca (system_name_length + 100); | ||
| 363 | sprintf (socket_name, "/tmp/emacs%d-%s/server", | ||
| 364 | (int) geteuid (), system_name); | ||
| 365 | } | ||
| 366 | |||
| 367 | if (strlen (socket_name) < sizeof (server.sun_path)) | ||
| 368 | strcpy (server.sun_path, socket_name); | ||
| 369 | else | ||
| 370 | fprintf (stderr, "%s: socket-name %s too long", | ||
| 371 | argv[0], socket_name); | ||
| 351 | 372 | ||
| 352 | /* See if the socket exists, and if it's owned by us. */ | 373 | /* See if the socket exists, and if it's owned by us. */ |
| 353 | sock_status = socket_status (server.sun_path); | 374 | sock_status = socket_status (server.sun_path); |