comparison lib-src/emacsclient.c @ 83590:dab011361c2a

(s): Remove. (main): Define here instead. (main) [WINDOWSNT]: Don't call ttyname. Don't recognize -suspend option. (main) [NO_SOCKETS_IN_FILE_SYSTEM]: Don't call init_signals. (strprefix): Define unconditionally.
author Jason Rumney <jasonr@gnu.org>
date Tue, 15 May 2007 23:30:30 +0000
parents 07774e5c3ff5
children 9aa8a3a78f9e
comparison
equal deleted inserted replaced
83589:fb93eb23056b 83590:dab011361c2a
170 170
171 /* PID of the Emacs server process. */ 171 /* PID of the Emacs server process. */
172 int emacs_pid = 0; 172 int emacs_pid = 0;
173 173
174 /* Socket used to communicate with the Emacs server process. */ 174 /* Socket used to communicate with the Emacs server process. */
175 HSOCKET s; 175 /*HSOCKET s;*/
176 176
177 void print_help_and_exit () NO_RETURN; 177 void print_help_and_exit () NO_RETURN;
178 178
179 struct option longopts[] = 179 struct option longopts[] =
180 { 180 {
887 SEND_STRING ("\n"); 887 SEND_STRING ("\n");
888 888
889 return s; 889 return s;
890 } 890 }
891 891
892
893 /* Returns 1 if PREFIX is a prefix of STRING. */
894 static int
895 strprefix (char *prefix, char *string)
896 {
897 int i;
898 if (! prefix)
899 return 1;
900
901 if (!string)
902 return 0;
903
904 for (i = 0; prefix[i]; i++)
905 if (!string[i] || string[i] != prefix[i])
906 return 0;
907 return 1;
908 }
909
910
892 #if !defined (NO_SOCKETS_IN_FILE_SYSTEM) 911 #if !defined (NO_SOCKETS_IN_FILE_SYSTEM)
893 912
894 /* Three possibilities: 913 /* Three possibilities:
895 2 - can't be `stat'ed (sets errno) 914 2 - can't be `stat'ed (sets errno)
896 1 - isn't owned by us 915 1 - isn't owned by us
974 sigprocmask (SIG_SETMASK, &set, NULL); /* Let's the above signal through. */ 993 sigprocmask (SIG_SETMASK, &set, NULL); /* Let's the above signal through. */
975 signal (signalnum, handle_sigtstp); 994 signal (signalnum, handle_sigtstp);
976 995
977 errno = old_errno; 996 errno = old_errno;
978 } 997 }
979
980 /* Set up signal handlers before opening a frame on the current tty. */ 998 /* Set up signal handlers before opening a frame on the current tty. */
981 999
982 void 1000 void
983 init_signals (void) 1001 init_signals (void)
984 { 1002 {
994 #endif 1012 #endif
995 1013
996 signal (SIGCONT, handle_sigcont); 1014 signal (SIGCONT, handle_sigcont);
997 signal (SIGTSTP, handle_sigtstp); 1015 signal (SIGTSTP, handle_sigtstp);
998 signal (SIGTTOU, handle_sigtstp); 1016 signal (SIGTTOU, handle_sigtstp);
999 }
1000
1001
1002
1003 /* Returns 1 if PREFIX is a prefix of STRING. */
1004 static int
1005 strprefix (char *prefix, char *string)
1006 {
1007 int i;
1008 if (! prefix)
1009 return 1;
1010
1011 if (!string)
1012 return 0;
1013
1014 for (i = 0; prefix[i]; i++)
1015 if (!string[i] || string[i] != prefix[i])
1016 return 0;
1017 return 1;
1018 } 1017 }
1019 1018
1020 1019
1021 HSOCKET 1020 HSOCKET
1022 set_local_socket () 1021 set_local_socket ()
1264 int 1263 int
1265 main (argc, argv) 1264 main (argc, argv)
1266 int argc; 1265 int argc;
1267 char **argv; 1266 char **argv;
1268 { 1267 {
1268 HSOCKET s;
1269 int i, rl, needlf = 0; 1269 int i, rl, needlf = 0;
1270 char *cwd, *str; 1270 char *cwd, *str;
1271 char string[BUFSIZ+1]; 1271 char string[BUFSIZ+1];
1272 1272
1273 main_argc = argc; 1273 main_argc = argc;
1345 SEND_STRING (" "); 1345 SEND_STRING (" ");
1346 } 1346 }
1347 1347
1348 if (tty) 1348 if (tty)
1349 { 1349 {
1350 char *tty_name = ttyname (fileno (stdin)); 1350 char *tty_name = NULL;
1351 #ifndef WINDOWSNT
1352 tty_name = ttyname (fileno (stdin));
1353 #endif
1351 char *type = getenv ("TERM"); 1354 char *type = getenv ("TERM");
1352 1355
1353 if (! tty_name) 1356 if (! tty_name)
1354 { 1357 {
1355 message (TRUE, "%s: could not get terminal name\n", progname); 1358 message (TRUE, "%s: could not get terminal name\n", progname);
1368 /* This causes nasty, MULTI_KBOARD-related input lockouts. */ 1371 /* This causes nasty, MULTI_KBOARD-related input lockouts. */
1369 message (TRUE, "%s: opening a frame in an Emacs term buffer" 1372 message (TRUE, "%s: opening a frame in an Emacs term buffer"
1370 " is not supported\n", progname); 1373 " is not supported\n", progname);
1371 fail (); 1374 fail ();
1372 } 1375 }
1373 1376 #if !defined (NO_SOCKETS_IN_FILE_SYSTEM)
1374 init_signals (); 1377 init_signals ();
1378 #endif
1375 1379
1376 SEND_STRING ("-tty "); 1380 SEND_STRING ("-tty ");
1377 SEND_QUOTED (tty_name); 1381 SEND_QUOTED (tty_name);
1378 SEND_STRING (" "); 1382 SEND_STRING (" ");
1379 SEND_QUOTED (type); 1383 SEND_QUOTED (type);
1496 if (needlf) 1500 if (needlf)
1497 printf ("\n"); 1501 printf ("\n");
1498 fprintf (stderr, "*ERROR*: %s", str); 1502 fprintf (stderr, "*ERROR*: %s", str);
1499 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; 1503 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
1500 } 1504 }
1505 #ifndef WINDOWSNT
1501 else if (strprefix ("-suspend ", string)) 1506 else if (strprefix ("-suspend ", string))
1502 { 1507 {
1503 /* -suspend: Suspend this terminal, i.e., stop the process. */ 1508 /* -suspend: Suspend this terminal, i.e., stop the process. */
1504 if (needlf) 1509 if (needlf)
1505 printf ("\n"); 1510 printf ("\n");
1506 needlf = 0; 1511 needlf = 0;
1507 kill (0, SIGSTOP); 1512 kill (0, SIGSTOP);
1508 } 1513 }
1514 #endif
1509 else 1515 else
1510 { 1516 {
1511 /* Unknown command. */ 1517 /* Unknown command. */
1512 if (needlf) 1518 if (needlf)
1513 printf ("\n"); 1519 printf ("\n");