0
|
1 /* -*-C-*-
|
|
2 Client code to allow local and remote editing of files by XEmacs.
|
|
3 Copyright (C) 1989 Free Software Foundation, Inc.
|
|
4 Copyright (C) 1995 Sun Microsystems, Inc.
|
149
|
5 Copyright (C) 1997 Free Software Foundation, Inc.
|
0
|
6
|
|
7 This file is part of XEmacs.
|
|
8
|
|
9 XEmacs is free software; you can redistribute it and/or modify it
|
|
10 under the terms of the GNU General Public License as published by the
|
|
11 Free Software Foundation; either version 2, or (at your option) any
|
|
12 later version.
|
|
13
|
|
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
17 for more details.
|
|
18
|
|
19 You should have received a copy of the GNU General Public License
|
|
20 along with XEmacs; see the file COPYING. If not, write to
|
|
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 Boston, MA 02111-1307, USA.
|
|
23
|
|
24 Author: Andy Norman (ange@hplb.hpl.hp.com), based on
|
|
25 'etc/emacsclient.c' from the GNU Emacs 18.52 distribution.
|
|
26
|
|
27 Please mail bugs and suggestions to the author at the above address.
|
|
28 */
|
|
29
|
|
30 /*
|
|
31 * This file incorporates new features added by Bob Weiner <weiner@mot.com>,
|
|
32 * Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
|
|
33 * GNUATTACH support added by Ben Wing <wing@xemacs.org>.
|
|
34 * Please see the note at the end of the README file for details.
|
|
35 *
|
|
36 * (If gnuserv came bundled with your emacs, the README file is probably
|
|
37 * ../etc/gnuserv.README relative to the directory containing this file)
|
|
38 */
|
|
39
|
|
40 #if 0
|
|
41 /* Hand-munged RCS header */
|
|
42 static char rcsid [] = "!Header: gnuclient.c,v 2.2 95/12/12 01:39:21 wing nene !";
|
|
43 #endif
|
|
44
|
|
45 #include "gnuserv.h"
|
|
46 #include "getopt.h"
|
|
47
|
|
48 #include <stdio.h>
|
|
49 #include <stdlib.h>
|
171
|
50 #include <sys/types.h>
|
|
51
|
149
|
52 #ifdef HAVE_STRING_H
|
0
|
53 #include <string.h>
|
149
|
54 #endif /* HAVE_STRING_H */
|
171
|
55
|
149
|
56 #ifdef HAVE_UNISTD_H
|
0
|
57 #include <unistd.h>
|
149
|
58 #endif /* HAVE_UNISTD_H */
|
171
|
59
|
149
|
60 #include <signal.h>
|
|
61
|
0
|
62 #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && \
|
|
63 !defined(INTERNET_DOMAIN_SOCKETS)
|
78
|
64 int
|
|
65 main (int argc, char *argv[])
|
0
|
66 {
|
|
67 fprintf (stderr, "Sorry, the Emacs server is only "
|
|
68 "supported on systems that have\n");
|
|
69 fprintf (stderr, "Unix Domain sockets, Internet Domain "
|
|
70 "sockets or System V IPC.\n");
|
|
71 exit (1);
|
|
72 } /* main */
|
|
73 #else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
|
|
74
|
|
75 static char cwd[MAXPATHLEN+2]; /* current working directory when calculated */
|
|
76 static char *cp = NULL; /* ptr into valid bit of cwd above */
|
|
77
|
108
|
78 static pid_t emacs_pid; /* Process id for emacs process */
|
|
79
|
149
|
80 void initialize_signals (void);
|
|
81
|
167
|
82 static void
|
149
|
83 tell_emacs_to_resume (int sig)
|
108
|
84 {
|
149
|
85 char buffer[GSERV_BUFSZ+1];
|
|
86 int s; /* socket / msqid to server */
|
|
87 int connect_type; /* CONN_UNIX, CONN_INTERNET, or
|
|
88 ONN_IPC */
|
108
|
89
|
|
90 /* Why is SYSV so retarded? */
|
|
91 /* We want emacs to realize that we are resuming */
|
149
|
92 signal(SIGCONT, tell_emacs_to_resume);
|
108
|
93
|
149
|
94 connect_type = make_connection (NULL, (u_short) 0, &s);
|
108
|
95
|
153
|
96 sprintf(buffer,"(gnuserv-eval '(resume-pid-console %d))", (int)getpid());
|
149
|
97 send_string(s, buffer);
|
|
98
|
108
|
99 #ifdef SYSV_IPC
|
|
100 if (connect_type == (int) CONN_IPC)
|
|
101 disconnect_from_ipc_server (s, msgp, FALSE);
|
|
102 #else /* !SYSV_IPC */
|
|
103 if (connect_type != (int) CONN_IPC)
|
|
104 disconnect_from_server (s, FALSE);
|
|
105 #endif /* !SYSV_IPC */
|
|
106 }
|
|
107
|
167
|
108 static void
|
149
|
109 pass_signal_to_emacs (int sig)
|
108
|
110 {
|
149
|
111 if (kill (emacs_pid, sig) == -1)
|
|
112 {
|
|
113 fprintf (stderr, "gnuattach: Could not pass signal to emacs process\n");
|
|
114 exit (1);
|
|
115 }
|
|
116 initialize_signals ();
|
108
|
117 }
|
|
118
|
149
|
119 void
|
|
120 initialize_signals ()
|
108
|
121 {
|
149
|
122 /* Set up signal handler to pass relevant signals to emacs process.
|
|
123 We used to send SIGSEGV, SIGBUS, SIGPIPE, SIGILL and others to
|
|
124 Emacs, but I think it's better not to. I can see no reason why
|
|
125 Emacs should SIGSEGV whenever gnuclient SIGSEGV-s, etc. */
|
|
126 signal (SIGHUP, pass_signal_to_emacs);
|
|
127 signal (SIGQUIT, pass_signal_to_emacs);
|
|
128 signal (SIGINT, pass_signal_to_emacs);
|
151
|
129 #ifdef SIGWINCH
|
|
130 signal (SIGWINCH, pass_signal_to_emacs);
|
|
131 #endif
|
108
|
132
|
|
133 /* We want emacs to realize that we are resuming */
|
149
|
134 signal (SIGCONT, tell_emacs_to_resume);
|
108
|
135 }
|
|
136
|
0
|
137
|
|
138 /*
|
|
139 get_current_working_directory -- return the cwd.
|
|
140 */
|
|
141 static char *
|
|
142 get_current_working_directory (void)
|
|
143 {
|
|
144 if (cp == NULL)
|
|
145 { /* haven't calculated it yet */
|
|
146 #ifdef BSD
|
|
147 if (getwd (cwd) == 0)
|
|
148 #else /* !BSD */
|
|
149 if (getcwd (cwd,MAXPATHLEN) == NULL)
|
|
150 #endif /* !BSD */
|
|
151 {
|
|
152 perror (progname);
|
|
153 fprintf (stderr, "%s: unable to get current working directory\n",
|
|
154 progname);
|
|
155 exit (1);
|
|
156 } /* if */
|
|
157
|
|
158 /* on some systems, cwd can look like '@machine/' ... */
|
|
159 /* ignore everything before the first '/' */
|
|
160 for (cp = cwd; *cp && *cp != '/'; ++cp)
|
|
161 ;
|
|
162
|
|
163 } /* if */
|
|
164
|
|
165 return cp;
|
|
166
|
|
167 } /* get_current_working_directory */
|
|
168
|
|
169
|
|
170 /*
|
|
171 filename_expand -- try to convert the given filename into a fully-qualified
|
|
172 pathname.
|
|
173 */
|
|
174 static void
|
|
175 filename_expand (char *fullpath, char *filename)
|
|
176 /* fullpath - returned full pathname */
|
|
177 /* filename - filename to expand */
|
|
178 {
|
|
179 int len;
|
|
180
|
|
181 fullpath[0] = '\0';
|
|
182
|
|
183 if (filename[0] && filename[0] != '/')
|
|
184 { /* relative filename */
|
|
185 strcat (fullpath, get_current_working_directory ());
|
|
186 len = strlen (fullpath);
|
|
187
|
|
188 if (len > 0 && fullpath[len-1] == '/') /* trailing slash already? */
|
|
189 ; /* yep */
|
|
190 else
|
|
191 strcat (fullpath, "/"); /* nope, append trailing slash */
|
|
192 } /* if */
|
|
193
|
|
194 strcat (fullpath,filename);
|
|
195
|
|
196 } /* filename_expand */
|
|
197
|
151
|
198 /* Encase the string in quotes, escape all the backslashes and quotes
|
|
199 in string. */
|
167
|
200 static char *
|
151
|
201 clean_string (CONST char *s)
|
|
202 {
|
|
203 int i = 0;
|
|
204 char *p, *res;
|
|
205
|
|
206 for (p = s; *p; p++, i++)
|
|
207 {
|
|
208 if (*p == '\\' || *p == '\"')
|
|
209 ++i;
|
|
210 else if (*p == '\004')
|
|
211 i += 3;
|
|
212 }
|
|
213 p = res = (char *)malloc (i + 2 + 1);
|
|
214 *p++ = '\"';
|
|
215 for (; *s; p++, s++)
|
|
216 {
|
|
217 switch (*s)
|
|
218 {
|
|
219 case '\\':
|
|
220 *p++ = '\\';
|
|
221 *p = '\\';
|
|
222 break;
|
|
223 case '\"':
|
|
224 *p++ = '\\';
|
|
225 *p = '\"';
|
|
226 break;
|
|
227 case '\004':
|
|
228 *p++ = '\\';
|
|
229 *p++ = 'C';
|
|
230 *p++ = '-';
|
|
231 *p = 'd';
|
|
232 break;
|
|
233 default:
|
|
234 *p = *s;
|
|
235 }
|
|
236 }
|
|
237 *p++ = '\"';
|
|
238 *p = '\0';
|
|
239 return res;
|
|
240 }
|
|
241
|
|
242 #define GET_ARGUMENT(var, desc) do { \
|
|
243 if (*(p + 1)) (var) = p + 1; \
|
|
244 else \
|
|
245 { \
|
|
246 if (!argv[++i]) \
|
|
247 { \
|
|
248 fprintf (stderr, "%s: `%s' must be followed by an argument\n", \
|
|
249 progname, desc); \
|
|
250 exit (1); \
|
|
251 } \
|
|
252 (var) = argv[i]; \
|
|
253 } \
|
|
254 over = 1; \
|
|
255 } while (0)
|
|
256
|
153
|
257 /* A strdup immitation. */
|
|
258 static char *
|
|
259 my_strdup (CONST char *s)
|
|
260 {
|
|
261 char *new = malloc (strlen (s) + 1);
|
|
262 if (new)
|
|
263 strcpy (new, s);
|
|
264 return new;
|
|
265 }
|
151
|
266
|
78
|
267 int
|
|
268 main (int argc, char *argv[])
|
0
|
269 {
|
151
|
270 int starting_line = 1; /* line to start editing at */
|
|
271 char command[MAXPATHLEN+50]; /* emacs command buffer */
|
|
272 char fullpath[MAXPATHLEN+1]; /* full pathname to file */
|
|
273 char *eval_form = NULL; /* form to evaluate with `-eval' */
|
|
274 char *eval_function = NULL; /* function to evaluate with `-f' */
|
|
275 char *load_library = NULL; /* library to load */
|
|
276 int quick = 0; /* quick edit, don't wait for user to
|
|
277 finish */
|
|
278 int batch = 0; /* batch mode */
|
|
279 int view = 0; /* view only. */
|
|
280 int nofiles = 0;
|
|
281 int errflg = 0; /* option error */
|
|
282 int s; /* socket / msqid to server */
|
|
283 int connect_type; /* CONN_UNIX, CONN_INTERNET, or
|
|
284 * CONN_IPC */
|
149
|
285 int suppress_windows_system = 0;
|
153
|
286 char *display = NULL;
|
0
|
287 #ifdef INTERNET_DOMAIN_SOCKETS
|
151
|
288 char *hostarg = NULL; /* remote hostname */
|
|
289 char *remotearg;
|
|
290 char thishost[HOSTNAMSZ]; /* this hostname */
|
|
291 char remotepath[MAXPATHLEN+1]; /* remote pathname */
|
|
292 char *path;
|
|
293 int rflg = 0; /* pathname given on cmdline */
|
|
294 char *portarg;
|
|
295 u_short port = 0; /* port to server */
|
0
|
296 #endif /* INTERNET_DOMAIN_SOCKETS */
|
|
297 #ifdef SYSV_IPC
|
151
|
298 struct msgbuf *msgp; /* message */
|
0
|
299 #endif /* SYSV_IPC */
|
173
|
300 char *tty = NULL;
|
151
|
301 char buffer[GSERV_BUFSZ + 1]; /* buffer to read pid */
|
|
302 char result[GSERV_BUFSZ + 1];
|
|
303 int i;
|
0
|
304
|
|
305 #ifdef INTERNET_DOMAIN_SOCKETS
|
|
306 memset (remotepath, 0, sizeof (remotepath));
|
|
307 #endif /* INTERNET_DOMAIN_SOCKETS */
|
|
308
|
151
|
309 progname = strrchr (argv[0], '/');
|
|
310 if (progname)
|
|
311 ++progname;
|
|
312 else
|
|
313 progname = argv[0];
|
0
|
314
|
259
|
315 #ifdef USE_TMPDIR
|
|
316 tmpdir = getenv ("TMPDIR");
|
|
317 #endif
|
|
318 if (!tmpdir)
|
|
319 tmpdir = "/tmp";
|
|
320
|
149
|
321 display = getenv ("DISPLAY");
|
|
322 if (!display)
|
|
323 suppress_windows_system = 1;
|
153
|
324 else
|
|
325 display = my_strdup (display);
|
149
|
326
|
151
|
327 for (i = 1; argv[i] && !errflg; i++)
|
|
328 {
|
|
329 if (*argv[i] != '-')
|
0
|
330 break;
|
153
|
331 else if (*argv[i] == '-'
|
|
332 && (*(argv[i] + 1) == '\0'
|
|
333 || (*(argv[i] + 1) == '-' && *(argv[i] + 2) == '\0')))
|
|
334 {
|
|
335 /* `-' or `--' */
|
|
336 ++i;
|
|
337 break;
|
|
338 }
|
|
339
|
|
340 if (!strcmp (argv[i], "-batch") || !strcmp (argv[i], "--batch"))
|
151
|
341 batch = 1;
|
153
|
342 else if (!strcmp (argv[i], "-eval") || !strcmp (argv[i], "--eval"))
|
151
|
343 {
|
|
344 if (!argv[++i])
|
|
345 {
|
|
346 fprintf (stderr, "%s: `-eval' must be followed by an argument\n",
|
|
347 progname);
|
|
348 exit (1);
|
|
349 }
|
|
350 eval_form = argv[i];
|
|
351 }
|
153
|
352 else if (!strcmp (argv[i], "-display") || !strcmp (argv[i], "--display"))
|
151
|
353 {
|
|
354 suppress_windows_system = 0;
|
|
355 if (!argv[++i])
|
|
356 {
|
153
|
357 fprintf (stderr,
|
|
358 "%s: `-display' must be followed by an argument\n",
|
151
|
359 progname);
|
|
360 exit (1);
|
|
361 }
|
153
|
362 if (display)
|
|
363 free (display);
|
|
364 /* no need to strdup. */
|
151
|
365 display = argv[i];
|
|
366 }
|
|
367 else if (!strcmp (argv[i], "-nw"))
|
|
368 suppress_windows_system = 1;
|
|
369 else
|
|
370 {
|
|
371 /* Iterate over one-letter options. */
|
|
372 char *p;
|
|
373 int over = 0;
|
|
374 for (p = argv[i] + 1; *p && !over; p++)
|
|
375 {
|
|
376 switch (*p)
|
|
377 {
|
|
378 case 'q':
|
|
379 quick = 1;
|
|
380 break;
|
|
381 case 'v':
|
|
382 view = 1;
|
|
383 break;
|
|
384 case 'f':
|
|
385 GET_ARGUMENT (eval_function, "-f");
|
|
386 break;
|
|
387 case 'l':
|
|
388 GET_ARGUMENT (load_library, "-l");
|
|
389 break;
|
0
|
390 #ifdef INTERNET_DOMAIN_SOCKETS
|
151
|
391 case 'h':
|
|
392 GET_ARGUMENT (hostarg, "-h");
|
|
393 break;
|
|
394 case 'p':
|
|
395 GET_ARGUMENT (portarg, "-p");
|
|
396 port = atoi (portarg);
|
|
397 break;
|
|
398 case 'r':
|
|
399 GET_ARGUMENT (remotearg, "-r");
|
|
400 strcpy (remotepath, remotearg);
|
|
401 rflg = 1;
|
|
402 break;
|
0
|
403 #endif /* INTERNET_DOMAIN_SOCKETS */
|
151
|
404 default:
|
|
405 errflg = 1;
|
|
406 }
|
|
407 } /* for */
|
|
408 } /* else */
|
|
409 } /* for */
|
0
|
410
|
|
411 if (errflg)
|
|
412 {
|
|
413 fprintf (stderr,
|
|
414 #ifdef INTERNET_DOMAIN_SOCKETS
|
181
|
415 "usage: %s [-nw] [-display display] [-q] [-v] [-l library]\n"
|
|
416 " [-batch] [-f function] [-eval form]\n"
|
|
417 " [-h host] [-p port] [-r remote-path] [[+line] file] ...\n",
|
151
|
418 #else /* !INTERNET_DOMAIN_SOCKETS */
|
181
|
419 "usage: %s [-nw] [-q] [-v] [-l library] [-f function] [-eval form] "
|
0
|
420 "[[+line] path] ...\n",
|
|
421 #endif /* !INTERNET_DOMAIN_SOCKETS */
|
|
422 progname);
|
|
423 exit (1);
|
151
|
424 }
|
|
425 if (batch && argv[i])
|
0
|
426 {
|
151
|
427 fprintf (stderr, "%s: Cannot specify `-batch' with file names\n",
|
149
|
428 progname);
|
|
429 exit (1);
|
|
430 }
|
153
|
431 if (suppress_windows_system && hostarg)
|
|
432 {
|
|
433 fprintf (stderr, "%s: Remote editing is available only on X\n",
|
|
434 progname);
|
|
435 exit (1);
|
|
436 }
|
|
437
|
151
|
438 *result = '\0';
|
|
439 if (eval_function || eval_form || load_library)
|
|
440 {
|
|
441 #if defined(INTERNET_DOMAIN_SOCKETS)
|
|
442 connect_type = make_connection (hostarg, port, &s);
|
|
443 #else
|
|
444 connect_type = make_connection (NULL, (u_short) 0, &s);
|
|
445 #endif
|
|
446 sprintf (command, "(gnuserv-eval%s '(progn ", quick ? "-quickly" : "");
|
|
447 send_string (s, command);
|
|
448 if (load_library)
|
|
449 {
|
267
|
450 send_string (s , "(load-library ");
|
|
451 send_string (s, clean_string(load_library));
|
|
452 send_string (s, ") ");
|
151
|
453 }
|
|
454 if (eval_form)
|
|
455 {
|
267
|
456 send_string (s, eval_form);
|
151
|
457 }
|
|
458 if (eval_function)
|
|
459 {
|
267
|
460 send_string (s, "(");
|
|
461 send_string (s, eval_function);
|
|
462 send_string (s, ")");
|
151
|
463 }
|
|
464 send_string (s, "))");
|
|
465 send_string (s, EOT_STR);
|
|
466 if (read_line (s, result) == 0)
|
|
467 {
|
|
468 fprintf (stderr, "%s: Could not read\n", progname);
|
|
469 exit (1);
|
|
470 }
|
|
471 } /* eval_function || eval_form || load_library */
|
|
472 else if (batch)
|
|
473 {
|
|
474 fprintf (stderr, "%s: `-batch' requires an evaluation\n",
|
|
475 progname);
|
|
476 exit (1);
|
|
477 }
|
|
478
|
|
479 if (!batch)
|
|
480 {
|
|
481 if (suppress_windows_system)
|
|
482 {
|
|
483 tty = ttyname (0);
|
|
484 if (!tty)
|
|
485 {
|
|
486 fprintf (stderr, "%s: Not connected to a tty", progname);
|
|
487 exit (1);
|
|
488 }
|
|
489 #if defined(INTERNET_DOMAIN_SOCKETS)
|
153
|
490 connect_type = make_connection (hostarg, port, &s);
|
151
|
491 #else
|
153
|
492 connect_type = make_connection (NULL, (u_short) 0, &s);
|
151
|
493 #endif
|
153
|
494 send_string (s, "(gnuserv-eval '(emacs-pid))");
|
|
495 send_string (s, EOT_STR);
|
151
|
496
|
153
|
497 if (read_line (s, buffer) == 0)
|
|
498 {
|
|
499 fprintf (stderr, "%s: Could not establish Emacs procces id\n",
|
|
500 progname);
|
|
501 exit (1);
|
|
502 }
|
151
|
503 /* Don't do disconnect_from_server becasue we have already read
|
|
504 data, and disconnect doesn't do anything else. */
|
|
505 #ifndef INTERNET_DOMAIN_SOCKETS
|
153
|
506 if (connect_type == (int) CONN_IPC)
|
|
507 disconnect_from_ipc_server (s, msgp, FALSE);
|
108
|
508 #endif /* !SYSV_IPC */
|
|
509
|
153
|
510 emacs_pid = (pid_t)atol(buffer);
|
|
511 initialize_signals();
|
|
512 } /* suppress_windows_system */
|
108
|
513
|
151
|
514 #if defined(INTERNET_DOMAIN_SOCKETS)
|
|
515 connect_type = make_connection (hostarg, port, &s);
|
0
|
516 #else
|
151
|
517 connect_type = make_connection (NULL, (u_short) 0, &s);
|
0
|
518 #endif
|
|
519
|
|
520 #ifdef INTERNET_DOMAIN_SOCKETS
|
151
|
521 if (connect_type == (int) CONN_INTERNET)
|
|
522 {
|
|
523 char *ptr;
|
|
524 gethostname (thishost, HOSTNAMSZ);
|
|
525 if (!rflg)
|
|
526 { /* attempt to generate a path
|
0
|
527 * to this machine */
|
151
|
528 if ((ptr = getenv ("GNU_NODE")) != NULL)
|
|
529 /* user specified a path */
|
|
530 strcpy (remotepath, ptr);
|
|
531 }
|
0
|
532 #if 0 /* This is really bogus... re-enable it if you must have it! */
|
|
533 #if defined (hp9000s300) || defined (hp9000s800)
|
151
|
534 else if (strcmp (thishost,hostarg))
|
|
535 { /* try /net/thishost */
|
|
536 strcpy (remotepath, "/net/"); /* (this fails using internet
|
|
537 addresses) */
|
|
538 strcat (remotepath, thishost);
|
|
539 }
|
0
|
540 #endif
|
|
541 #endif
|
151
|
542 }
|
|
543 else
|
|
544 { /* same machines, no need for path */
|
|
545 remotepath[0] = '\0'; /* default is the empty path */
|
|
546 }
|
0
|
547 #endif /* INTERNET_DOMAIN_SOCKETS */
|
|
548
|
|
549 #ifdef SYSV_IPC
|
151
|
550 if ((msgp = (struct msgbuf *)
|
|
551 malloc (sizeof *msgp + GSERV_BUFSZ)) == NULL)
|
|
552 {
|
|
553 fprintf (stderr, "%s: not enough memory for message buffer\n", progname);
|
|
554 exit (1);
|
|
555 } /* if */
|
0
|
556
|
151
|
557 msgp->mtext[0] = '\0'; /* ready for later strcats */
|
0
|
558 #endif /* SYSV_IPC */
|
|
559
|
151
|
560 if (suppress_windows_system)
|
149
|
561 {
|
151
|
562 char *term = getenv ("TERM");
|
|
563 if (!term)
|
|
564 {
|
|
565 fprintf (stderr, "%s: unknown terminal type\n", progname);
|
|
566 exit (1);
|
|
567 }
|
|
568 sprintf (command, "(gnuserv-edit-files '(tty %s %s %d) '(",
|
153
|
569 clean_string (tty), clean_string (term), (int)getpid ());
|
149
|
570 }
|
151
|
571 else /* !suppress_windows_system */
|
|
572 {
|
|
573 sprintf (command, "(gnuserv-edit-files '(x %s) '(",
|
|
574 clean_string (display));
|
|
575 } /* !suppress_windows_system */
|
|
576 send_string (s, command);
|
149
|
577
|
151
|
578 if (!argv[i])
|
|
579 nofiles = 1;
|
0
|
580
|
151
|
581 for (; argv[i]; i++)
|
0
|
582 {
|
151
|
583 if (i < argc - 1 && *argv[i] == '+')
|
|
584 starting_line = atoi (argv[i++]);
|
|
585 else
|
|
586 starting_line = 1;
|
|
587 /* If the last argument is +something, treat it as a file. */
|
|
588 if (i == argc)
|
|
589 {
|
|
590 starting_line = 1;
|
|
591 --i;
|
|
592 }
|
|
593 filename_expand (fullpath, argv[i]);
|
0
|
594 #ifdef INTERNET_DOMAIN_SOCKETS
|
151
|
595 path = malloc (strlen (remotepath) + strlen (fullpath) + 1);
|
|
596 sprintf (path, "%s%s", remotepath, fullpath);
|
|
597 #else
|
153
|
598 path = my_strdup (fullpath);
|
0
|
599 #endif
|
151
|
600 sprintf (command, "(%d . %s)", starting_line, clean_string (path));
|
|
601 send_string (s, command);
|
|
602 free (path);
|
|
603 } /* for */
|
|
604
|
|
605 sprintf (command, ")%s%s",
|
|
606 (quick || (nofiles && !suppress_windows_system)) ? " 'quick" : "",
|
|
607 view ? " 'view" : "");
|
149
|
608 send_string (s, command);
|
151
|
609 send_string (s, ")");
|
0
|
610
|
|
611 #ifdef SYSV_IPC
|
151
|
612 if (connect_type == (int) CONN_IPC)
|
|
613 disconnect_from_ipc_server (s, msgp, FALSE);
|
0
|
614 #else /* !SYSV_IPC */
|
151
|
615 if (connect_type != (int) CONN_IPC)
|
|
616 disconnect_from_server (s, FALSE);
|
0
|
617 #endif /* !SYSV_IPC */
|
151
|
618 } /* not batch */
|
|
619
|
|
620 if (batch && !quick)
|
|
621 printf ("%s\n", result);
|
0
|
622
|
78
|
623 return 0;
|
0
|
624
|
|
625 } /* main */
|
|
626
|
|
627 #endif /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
|