comparison lib-src/gnuclient.c @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents 8626e4521993
children b8cc9ab3f761
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
46 #include "getopt.h" 46 #include "getopt.h"
47 47
48 #include <stdio.h> 48 #include <stdio.h>
49 #include <stdlib.h> 49 #include <stdlib.h>
50 #include <sys/types.h> 50 #include <sys/types.h>
51 #define DONT_ENCAPSULATE
52 #include <sysfile.h>
51 53
52 #ifdef HAVE_STRING_H 54 #ifdef HAVE_STRING_H
53 #include <string.h> 55 #include <string.h>
54 #endif /* HAVE_STRING_H */ 56 #endif /* HAVE_STRING_H */
55 57
87 int connect_type; /* CONN_UNIX, CONN_INTERNET, or 89 int connect_type; /* CONN_UNIX, CONN_INTERNET, or
88 ONN_IPC */ 90 ONN_IPC */
89 91
90 /* Why is SYSV so retarded? */ 92 /* Why is SYSV so retarded? */
91 /* We want emacs to realize that we are resuming */ 93 /* We want emacs to realize that we are resuming */
94 #ifdef SIGCONT
92 signal(SIGCONT, tell_emacs_to_resume); 95 signal(SIGCONT, tell_emacs_to_resume);
96 #endif
93 97
94 connect_type = make_connection (NULL, (u_short) 0, &s); 98 connect_type = make_connection (NULL, (u_short) 0, &s);
95 99
96 sprintf(buffer,"(gnuserv-eval '(resume-pid-console %d))", (int)getpid()); 100 sprintf(buffer,"(gnuserv-eval '(resume-pid-console %d))", (int)getpid());
97 send_string(s, buffer); 101 send_string(s, buffer);
127 signal (SIGINT, pass_signal_to_emacs); 131 signal (SIGINT, pass_signal_to_emacs);
128 #ifdef SIGWINCH 132 #ifdef SIGWINCH
129 signal (SIGWINCH, pass_signal_to_emacs); 133 signal (SIGWINCH, pass_signal_to_emacs);
130 #endif 134 #endif
131 135
136 #ifdef SIGCONT
132 /* We want emacs to realize that we are resuming */ 137 /* We want emacs to realize that we are resuming */
133 signal (SIGCONT, tell_emacs_to_resume); 138 signal (SIGCONT, tell_emacs_to_resume);
139 #endif
134 } 140 }
135 141
136 142
137 /* 143 /*
138 get_current_working_directory -- return the cwd. 144 get_current_working_directory -- return the cwd.
223 } /* filename_expand */ 229 } /* filename_expand */
224 230
225 /* Encase the string in quotes, escape all the backslashes and quotes 231 /* Encase the string in quotes, escape all the backslashes and quotes
226 in string. */ 232 in string. */
227 static char * 233 static char *
228 clean_string (CONST char *s) 234 clean_string (const char *s)
229 { 235 {
230 int i = 0; 236 int i = 0;
231 char *p, *res; 237 char *p, *res;
232 238
233 { 239 {
234 CONST char *const_p; 240 const char *const_p;
235 for (const_p = s; *const_p; const_p++, i++) 241 for (const_p = s; *const_p; const_p++, i++)
236 { 242 {
237 if (*const_p == '\\' || *const_p == '\"') 243 if (*const_p == '\\' || *const_p == '\"')
238 ++i; 244 ++i;
239 else if (*const_p == '\004') 245 else if (*const_p == '\004')
283 (var) = argv[i]; \ 289 (var) = argv[i]; \
284 } \ 290 } \
285 over = 1; \ 291 over = 1; \
286 } while (0) 292 } while (0)
287 293
288 /* A strdup immitation. */ 294 /* A strdup imitation. */
289 static char * 295 static char *
290 my_strdup (CONST char *s) 296 my_strdup (const char *s)
291 { 297 {
292 char *new = malloc (strlen (s) + 1); 298 char *new_s = (char *) malloc (strlen (s) + 1);
293 if (new) 299 if (new_s)
294 strcpy (new, s); 300 strcpy (new_s, s);
295 return new; 301 return new_s;
296 } 302 }
297 303
298 int 304 int
299 main (int argc, char *argv[]) 305 main (int argc, char *argv[])
300 { 306 {
652 starting_line = 1; 658 starting_line = 1;
653 --i; 659 --i;
654 } 660 }
655 filename_expand (fullpath, argv[i]); 661 filename_expand (fullpath, argv[i]);
656 #ifdef INTERNET_DOMAIN_SOCKETS 662 #ifdef INTERNET_DOMAIN_SOCKETS
657 path = malloc (strlen (remotepath) + strlen (fullpath) + 1); 663 path = (char *) malloc (strlen (remotepath) + strlen (fullpath) + 1);
658 sprintf (path, "%s%s", remotepath, fullpath); 664 sprintf (path, "%s%s", remotepath, fullpath);
659 #else 665 #else
660 path = my_strdup (fullpath); 666 path = my_strdup (fullpath);
661 #endif 667 #endif
662 sprintf (command, "(%d . %s)", starting_line, clean_string (path)); 668 sprintf (command, "(%d . %s)", starting_line, clean_string (path));