Mercurial > hg > xemacs-beta
comparison lib-src/gnuclient.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | e7ef97881643 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
24 Author: Andy Norman (ange@hplb.hpl.hp.com), based on | 24 Author: Andy Norman (ange@hplb.hpl.hp.com), based on |
25 'etc/emacsclient.c' from the GNU Emacs 18.52 distribution. | 25 'etc/emacsclient.c' from the GNU Emacs 18.52 distribution. |
26 | 26 |
27 Please mail bugs and suggestions to the XEmacs maintainer. | 27 Please mail bugs and suggestions to the XEmacs maintainer. |
28 */ | 28 */ |
29 | |
30 /* #### This file should be a windows-mode, not console-mode program under | |
31 Windows. (i.e. its entry point should be WinMain.) gnuattach functionality, | |
32 to the extent it's used at all, should be retrieved using a script that | |
33 calls the i.exe wrapper program, to obtain stdio handles. | |
34 | |
35 #### For that matter, both the functionality of gnuclient and gnuserv | |
36 should be merged into XEmacs itself using a -remote arg, just like | |
37 Netscape and other modern programs. | |
38 | |
39 --ben */ | |
29 | 40 |
30 /* | 41 /* |
31 * This file incorporates new features added by Bob Weiner <weiner@mot.com>, | 42 * This file incorporates new features added by Bob Weiner <weiner@mot.com>, |
32 * Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>. | 43 * Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>. |
33 * GNUATTACH support added by Ben Wing <wing@xemacs.org>. | 44 * GNUATTACH support added by Ben Wing <wing@xemacs.org>. |
46 #include "getopt.h" | 57 #include "getopt.h" |
47 | 58 |
48 #include <stdio.h> | 59 #include <stdio.h> |
49 #include <stdlib.h> | 60 #include <stdlib.h> |
50 #include <sys/types.h> | 61 #include <sys/types.h> |
51 #define DONT_ENCAPSULATE | |
52 #include <sysfile.h> | 62 #include <sysfile.h> |
53 | 63 |
54 #ifdef HAVE_STRING_H | 64 #ifdef HAVE_STRING_H |
55 #include <string.h> | 65 #include <string.h> |
56 #endif /* HAVE_STRING_H */ | 66 #endif /* HAVE_STRING_H */ |
119 } | 129 } |
120 initialize_signals (); | 130 initialize_signals (); |
121 } | 131 } |
122 | 132 |
123 void | 133 void |
124 initialize_signals () | 134 initialize_signals (void) |
125 { | 135 { |
126 /* Set up signal handler to pass relevant signals to emacs process. | 136 /* Set up signal handler to pass relevant signals to emacs process. |
127 We used to send SIGSEGV, SIGBUS, SIGPIPE, SIGILL and others to | 137 We used to send SIGSEGV, SIGBUS, SIGPIPE, SIGILL and others to |
128 Emacs, but I think it's better not to. I can see no reason why | 138 Emacs, but I think it's better not to. I can see no reason why |
129 Emacs should SIGSEGV whenever gnuclient SIGSEGV-s, etc. */ | 139 Emacs should SIGSEGV whenever gnuclient SIGSEGV-s, etc. */ |
188 if (filename[0] && filename[0] == '/') | 198 if (filename[0] && filename[0] == '/') |
189 { | 199 { |
190 /* Absolute (unix-style) pathname. Do nothing */ | 200 /* Absolute (unix-style) pathname. Do nothing */ |
191 strcat (fullpath, filename); | 201 strcat (fullpath, filename); |
192 } | 202 } |
193 #ifdef __CYGWIN32__ | 203 #ifdef CYGWIN |
194 else if (filename[0] && filename[0] == '\\' && | 204 else if (filename[0] && filename[0] == '\\' && |
195 filename[1] && filename[1] == '\\') | 205 filename[1] && filename[1] == '\\') |
196 { | 206 { |
197 /* This path includes the server name (something like | 207 /* This path includes the server name (something like |
198 "\\server\path"), so we assume it's absolute. Do nothing to | 208 "\\server\path"), so we assume it's absolute. Do nothing to |
213 else | 223 else |
214 { | 224 { |
215 /* Assume relative Unix style path. Get the current directory | 225 /* Assume relative Unix style path. Get the current directory |
216 and prepend it. FIXME: need to fix the case of DOS paths like | 226 and prepend it. FIXME: need to fix the case of DOS paths like |
217 "\foo", where we need to get the current drive. */ | 227 "\foo", where we need to get the current drive. */ |
218 | 228 |
219 strcat (fullpath, get_current_working_directory ()); | 229 strcat (fullpath, get_current_working_directory ()); |
220 len = strlen (fullpath); | 230 len = strlen (fullpath); |
221 | 231 |
222 if (len > 0 && fullpath[len-1] == '/') /* trailing slash already? */ | 232 if (len > 0 && fullpath[len-1] == '/') /* trailing slash already? */ |
223 ; /* yep */ | 233 ; /* yep */ |
229 } /* filename_expand */ | 239 } /* filename_expand */ |
230 | 240 |
231 /* Encase the string in quotes, escape all the backslashes and quotes | 241 /* Encase the string in quotes, escape all the backslashes and quotes |
232 in string. */ | 242 in string. */ |
233 static char * | 243 static char * |
234 clean_string (CONST char *s) | 244 clean_string (const char *s) |
235 { | 245 { |
236 int i = 0; | 246 int i = 0; |
237 char *p, *res; | 247 char *p, *res; |
238 | 248 |
239 { | 249 { |
240 CONST char *const_p; | 250 const char *const_p; |
241 for (const_p = s; *const_p; const_p++, i++) | 251 for (const_p = s; *const_p; const_p++, i++) |
242 { | 252 { |
243 if (*const_p == '\\' || *const_p == '\"') | 253 if (*const_p == '\\' || *const_p == '\"') |
244 ++i; | 254 ++i; |
245 else if (*const_p == '\004') | 255 else if (*const_p == '\004') |
291 over = 1; \ | 301 over = 1; \ |
292 } while (0) | 302 } while (0) |
293 | 303 |
294 /* A strdup imitation. */ | 304 /* A strdup imitation. */ |
295 static char * | 305 static char * |
296 my_strdup (CONST char *s) | 306 my_strdup (const char *s) |
297 { | 307 { |
298 char *new_s = (char *) malloc (strlen (s) + 1); | 308 char *new_s = (char *) malloc (strlen (s) + 1); |
299 if (new_s) | 309 if (new_s) |
300 strcpy (new_s, s); | 310 strcpy (new_s, s); |
301 return new_s; | 311 return new_s; |
449 | 459 |
450 if (errflg) | 460 if (errflg) |
451 { | 461 { |
452 fprintf (stderr, | 462 fprintf (stderr, |
453 #ifdef INTERNET_DOMAIN_SOCKETS | 463 #ifdef INTERNET_DOMAIN_SOCKETS |
454 "usage: %s [-nw] [-display display] [-q] [-v] [-l library]\n" | 464 "Usage: %s [-nw] [-display display] [-q] [-v] [-l library]\n" |
455 " [-batch] [-f function] [-eval form]\n" | 465 " [-batch] [-f function] [-eval form]\n" |
456 " [-h host] [-p port] [-r remote-path] [[+line] file] ...\n", | 466 " [-h host] [-p port] [-r remote-path] [[+line] file] ...\n", |
457 #else /* !INTERNET_DOMAIN_SOCKETS */ | 467 #else /* !INTERNET_DOMAIN_SOCKETS */ |
458 "usage: %s [-nw] [-q] [-v] [-l library] [-f function] [-eval form] " | 468 "Usage: %s [-nw] [-q] [-v] [-l library] [-f function] [-eval form] " |
459 "[[+line] path] ...\n", | 469 "[[+line] path] ...\n", |
460 #endif /* !INTERNET_DOMAIN_SOCKETS */ | 470 #endif /* !INTERNET_DOMAIN_SOCKETS */ |
461 progname); | 471 progname); |
462 exit (1); | 472 exit (1); |
463 } | 473 } |
561 { | 571 { |
562 fprintf (stderr, "%s: Could not establish Emacs process id\n", | 572 fprintf (stderr, "%s: Could not establish Emacs process id\n", |
563 progname); | 573 progname); |
564 exit (1); | 574 exit (1); |
565 } | 575 } |
566 /* Don't do disconnect_from_server becasue we have already read | 576 /* Don't do disconnect_from_server because we have already read |
567 data, and disconnect doesn't do anything else. */ | 577 data, and disconnect doesn't do anything else. */ |
568 #ifndef INTERNET_DOMAIN_SOCKETS | 578 #ifndef INTERNET_DOMAIN_SOCKETS |
569 if (connect_type == (int) CONN_IPC) | 579 if (connect_type == (int) CONN_IPC) |
570 disconnect_from_ipc_server (s, msgp, FALSE); | 580 disconnect_from_ipc_server (s, msgp, FALSE); |
571 #endif /* !SYSV_IPC */ | 581 #endif /* !SYSV_IPC */ |