67 |
is not running. --alternate-editor. */ |
is not running. --alternate-editor. */ |
68 |
const char * alternate_editor = NULL; |
const char * alternate_editor = NULL; |
69 |
|
|
70 |
|
/* If non-NULL, thefilename of the UNIX socket */ |
71 |
|
char *socket_name = NULL; |
72 |
|
|
73 |
void print_help_and_exit (); |
void print_help_and_exit (); |
74 |
|
|
75 |
struct option longopts[] = |
struct option longopts[] = |
79 |
{ "help", no_argument, NULL, 'H' }, |
{ "help", no_argument, NULL, 'H' }, |
80 |
{ "version", no_argument, NULL, 'V' }, |
{ "version", no_argument, NULL, 'V' }, |
81 |
{ "alternate-editor", required_argument, NULL, 'a' }, |
{ "alternate-editor", required_argument, NULL, 'a' }, |
82 |
|
{ "socket-name", required_argument, NULL, 's' }, |
83 |
{ "display", required_argument, NULL, 'd' }, |
{ "display", required_argument, NULL, 'd' }, |
84 |
{ 0, 0, 0, 0 } |
{ 0, 0, 0, 0 } |
85 |
}; |
}; |
95 |
while (1) |
while (1) |
96 |
{ |
{ |
97 |
int opt = getopt_long (argc, argv, |
int opt = getopt_long (argc, argv, |
98 |
"VHnea:d:", longopts, 0); |
"VHnea:s:d:", longopts, 0); |
99 |
|
|
100 |
if (opt == EOF) |
if (opt == EOF) |
101 |
break; |
break; |
113 |
alternate_editor = optarg; |
alternate_editor = optarg; |
114 |
break; |
break; |
115 |
|
|
116 |
|
case 's': |
117 |
|
socket_name = optarg; |
118 |
|
break; |
119 |
|
|
120 |
case 'd': |
case 'd': |
121 |
display = optarg; |
display = optarg; |
122 |
break; |
break; |
160 |
-n, --no-wait Don't wait for the server to return\n\ |
-n, --no-wait Don't wait for the server to return\n\ |
161 |
-e, --eval Evaluate the FILE arguments as ELisp expressions\n\ |
-e, --eval Evaluate the FILE arguments as ELisp expressions\n\ |
162 |
-d, --display=DISPLAY Visit the file in the given display\n\ |
-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\ |
165 |
-a, --alternate-editor=EDITOR\n\ |
-a, --alternate-editor=EDITOR\n\ |
166 |
Editor to fallback to if the server is not running\n\ |
Editor to fallback to if the server is not running\n\ |
167 |
\n\ |
\n\ |
357 |
{ |
{ |
358 |
int sock_status = 0; |
int sock_status = 0; |
359 |
|
|
360 |
sprintf (server.sun_path, "/tmp/emacs%d-%s/server", (int) geteuid (), system_name); |
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); |
372 |
|
|
373 |
/* See if the socket exists, and if it's owned by us. */ |
/* See if the socket exists, and if it's owned by us. */ |
374 |
sock_status = socket_status (server.sun_path); |
sock_status = socket_status (server.sun_path); |