comparison lib-src/gnuclient.c @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents 966663fcf606
children 90d73dddcdc4
comparison
equal deleted inserted replaced
271:c7b7086b0a39 272:c5d627a313b1
19 You should have received a copy of the GNU General Public License 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 20 along with XEmacs; see the file COPYING. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. 22 Boston, MA 02111-1307, USA.
23 23
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 author at the above address. 27 Please mail bugs and suggestions to the author at the above address.
28 */ 28 */
29 29
87 int connect_type; /* CONN_UNIX, CONN_INTERNET, or 87 int connect_type; /* CONN_UNIX, CONN_INTERNET, or
88 ONN_IPC */ 88 ONN_IPC */
89 89
90 /* Why is SYSV so retarded? */ 90 /* Why is SYSV so retarded? */
91 /* We want emacs to realize that we are resuming */ 91 /* We want emacs to realize that we are resuming */
92 signal(SIGCONT, tell_emacs_to_resume); 92 signal(SIGCONT, tell_emacs_to_resume);
93 93
94 connect_type = make_connection (NULL, (u_short) 0, &s); 94 connect_type = make_connection (NULL, (u_short) 0, &s);
95 95
96 sprintf(buffer,"(gnuserv-eval '(resume-pid-console %d))", (int)getpid()); 96 sprintf(buffer,"(gnuserv-eval '(resume-pid-console %d))", (int)getpid());
97 send_string(s, buffer); 97 send_string(s, buffer);
152 perror (progname); 152 perror (progname);
153 fprintf (stderr, "%s: unable to get current working directory\n", 153 fprintf (stderr, "%s: unable to get current working directory\n",
154 progname); 154 progname);
155 exit (1); 155 exit (1);
156 } /* if */ 156 } /* if */
157 157
158 /* on some systems, cwd can look like '@machine/' ... */ 158 /* on some systems, cwd can look like '@machine/' ... */
159 /* ignore everything before the first '/' */ 159 /* ignore everything before the first '/' */
160 for (cp = cwd; *cp && *cp != '/'; ++cp) 160 for (cp = cwd; *cp && *cp != '/'; ++cp)
161 ; 161 ;
162 162
177 /* filename - filename to expand */ 177 /* filename - filename to expand */
178 { 178 {
179 int len; 179 int len;
180 180
181 fullpath[0] = '\0'; 181 fullpath[0] = '\0';
182 182
183 if (filename[0] && filename[0] != '/') 183 if (filename[0] && filename[0] != '/')
184 { /* relative filename */ 184 { /* relative filename */
185 strcat (fullpath, get_current_working_directory ()); 185 strcat (fullpath, get_current_working_directory ());
186 len = strlen (fullpath); 186 len = strlen (fullpath);
187 187
201 clean_string (CONST char *s) 201 clean_string (CONST char *s)
202 { 202 {
203 int i = 0; 203 int i = 0;
204 char *p, *res; 204 char *p, *res;
205 205
206 for (p = s; *p; p++, i++) 206 {
207 { 207 CONST char *const_p;
208 if (*p == '\\' || *p == '\"') 208 for (const_p = s; *const_p; const_p++, i++)
209 ++i; 209 {
210 else if (*p == '\004') 210 if (*const_p == '\\' || *const_p == '\"')
211 i += 3; 211 ++i;
212 } 212 else if (*const_p == '\004')
213 p = res = (char *)malloc (i + 2 + 1); 213 i += 3;
214 }
215 }
216
217 p = res = (char *) malloc (i + 2 + 1);
214 *p++ = '\"'; 218 *p++ = '\"';
215 for (; *s; p++, s++) 219 for (; *s; p++, s++)
216 { 220 {
217 switch (*s) 221 switch (*s)
218 { 222 {
521 if (connect_type == (int) CONN_INTERNET) 525 if (connect_type == (int) CONN_INTERNET)
522 { 526 {
523 char *ptr; 527 char *ptr;
524 gethostname (thishost, HOSTNAMSZ); 528 gethostname (thishost, HOSTNAMSZ);
525 if (!rflg) 529 if (!rflg)
526 { /* attempt to generate a path 530 { /* attempt to generate a path
527 * to this machine */ 531 * to this machine */
528 if ((ptr = getenv ("GNU_NODE")) != NULL) 532 if ((ptr = getenv ("GNU_NODE")) != NULL)
529 /* user specified a path */ 533 /* user specified a path */
530 strcpy (remotepath, ptr); 534 strcpy (remotepath, ptr);
531 } 535 }
532 #if 0 /* This is really bogus... re-enable it if you must have it! */ 536 #if 0 /* This is really bogus... re-enable it if you must have it! */
533 #if defined (hp9000s300) || defined (hp9000s800) 537 #if defined (hp9000s300) || defined (hp9000s800)
534 else if (strcmp (thishost,hostarg)) 538 else if (strcmp (thishost,hostarg))
535 { /* try /net/thishost */ 539 { /* try /net/thishost */
536 strcpy (remotepath, "/net/"); /* (this fails using internet 540 strcpy (remotepath, "/net/"); /* (this fails using internet
537 addresses) */ 541 addresses) */
538 strcat (remotepath, thishost); 542 strcat (remotepath, thishost);
539 } 543 }
540 #endif 544 #endif
541 #endif 545 #endif
545 remotepath[0] = '\0'; /* default is the empty path */ 549 remotepath[0] = '\0'; /* default is the empty path */
546 } 550 }
547 #endif /* INTERNET_DOMAIN_SOCKETS */ 551 #endif /* INTERNET_DOMAIN_SOCKETS */
548 552
549 #ifdef SYSV_IPC 553 #ifdef SYSV_IPC
550 if ((msgp = (struct msgbuf *) 554 if ((msgp = (struct msgbuf *)
551 malloc (sizeof *msgp + GSERV_BUFSZ)) == NULL) 555 malloc (sizeof *msgp + GSERV_BUFSZ)) == NULL)
552 { 556 {
553 fprintf (stderr, "%s: not enough memory for message buffer\n", progname); 557 fprintf (stderr, "%s: not enough memory for message buffer\n", progname);
554 exit (1); 558 exit (1);
555 } /* if */ 559 } /* if */