Mercurial > emacs
annotate lib-src/emacsclient.c @ 83025:c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
lisp/bindings.el (mode-line-buffer-identification): Use the
conditional formatting feature instead of builtin support.
src/buffer.c (Vmode_line_format): Removed %T documentation.
src/xdisp.c (decode_mode_spec): Removed %T processing.
lib-src/emacsclient.c (pass_signal_to_emacs, init_signals): Added
comment.
src/cm.c: Cosmetic changes.
src/termchar.h: Ditto.
src/keyboard.c (interrupt_signal, handle_interrupt): Updated
documentation.
src/process.c (add_keyboard_wait_descriptor): Added docs.
src/sysdep.c (init_all_sys_modes, init_sys_modes)
(reset_all_sys_modes): Added docs.
src/term.c (tty_ring_bell, tty_set_terminal_modes)
(tty_reset_terminal_modes, tty_update_end, set_terminal_window)
(tty_set_terminal_window, clear_to_end, tty_clear_to_end)
(tty_clear_frame, tty_clear_end_of_line, write_glyphs)
(tty_write_glyphs, insert_glyphs, tty_insert_glyphs, delete_glyphs)
(tty_delete_glyphs, tty_ins_del_lines, get_named_tty_display)
(init_initial_display, delete_tty): Added docs.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-65
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sun, 25 Jan 2004 00:43:38 +0000 |
parents | 82c3b4da43ca |
children | 895e130cc8da |
rev | line source |
---|---|
493 | 1 /* Client process that communicates with GNU Emacs acting as server. |
53646
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
2 Copyright (C) 1986, 1987, 1994, 1999, 2000, 2001, 2003, 2004 |
37165
32679fe3e196
(fail, main): Don't use implicit int return type.
Gerd Moellmann <gerd@gnu.org>
parents:
34953
diff
changeset
|
3 Free Software Foundation, Inc. |
412 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
5522
64a936b21f74
Don't declare sys_errlist; declare strerror instead.
Roland McGrath <roland@gnu.org>
parents:
4696
diff
changeset
|
9 the Free Software Foundation; either version 2, or (at your option) |
412 | 10 any later version. |
11 | |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
11486
diff
changeset
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
11486
diff
changeset
|
20 Boston, MA 02111-1307, USA. */ |
412 | 21 |
22 | |
23 #define NO_SHORTNAMES | |
42176
1f5dbeefa536
Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents:
39723
diff
changeset
|
24 |
1f5dbeefa536
Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents:
39723
diff
changeset
|
25 #ifdef HAVE_CONFIG_H |
42412 | 26 #include <config.h> |
42176
1f5dbeefa536
Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents:
39723
diff
changeset
|
27 #endif |
1f5dbeefa536
Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents:
39723
diff
changeset
|
28 |
3595
e10f7473d2e3
* emacsserver.c (main): When we're passing a `struct sockaddr_un'
Jim Blandy <jimb@redhat.com>
parents:
1031
diff
changeset
|
29 #undef signal |
412 | 30 |
42176
1f5dbeefa536
Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents:
39723
diff
changeset
|
31 #include <ctype.h> |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
32 #include <stdio.h> |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
33 #include <getopt.h> |
21431
a080769e8f7d
Move inclusion of unistd.h to top, else fails on
Dave Love <fx@gnu.org>
parents:
21387
diff
changeset
|
34 #ifdef HAVE_UNISTD_H |
a080769e8f7d
Move inclusion of unistd.h to top, else fails on
Dave Love <fx@gnu.org>
parents:
21387
diff
changeset
|
35 #include <unistd.h> |
a080769e8f7d
Move inclusion of unistd.h to top, else fails on
Dave Love <fx@gnu.org>
parents:
21387
diff
changeset
|
36 #endif |
412 | 37 |
27474
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
38 #ifdef VMS |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
39 # include "vms-pwd.h" |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
40 #else |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
41 # include <pwd.h> |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
42 #endif /* not VMS */ |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
43 |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
44 #include <signal.h> |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
45 #include <errno.h> |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
46 |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
47 |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
48 char *getenv (), *getwd (); |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
49 char *getcwd (); |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
50 |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
51 /* This is defined with -D from the compilation command, |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
52 which extracts it from ../lisp/version.el. */ |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
53 |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
54 #ifndef VERSION |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
55 #define VERSION "unspecified" |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
56 #endif |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
57 |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
58 /* Name used to invoke this program. */ |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
59 char *progname; |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
60 |
53341 | 61 /* The first argument to main. */ |
62 int main_argc; | |
63 | |
64 /* The second argument to main. */ | |
65 char **main_argv; | |
66 | |
16146
a649abfefbb1
(longopts): Change nowait to no-wait.
Richard M. Stallman <rms@gnu.org>
parents:
16074
diff
changeset
|
67 /* Nonzero means don't wait for a response from Emacs. --no-wait. */ |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
68 int nowait = 0; |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
69 |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
70 /* Nonzero means args are expressions to be evaluated. --eval. */ |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
71 int eval = 0; |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
72 |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
73 /* The display on which Emacs should work. --display. */ |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
74 char *display = NULL; |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
75 |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
76 /* Nonzero means open a new Emacs frame on the current terminal. */ |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
53342
diff
changeset
|
77 int frame = 0; |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
78 |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
79 /* If non-NULL, the name of an editor to fallback to if the server |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
80 is not running. --alternate-editor. */ |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
81 const char * alternate_editor = NULL; |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
82 |
52532 | 83 /* If non-NULL, the filename of the UNIX socket. */ |
52479
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
84 char *socket_name = NULL; |
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
85 |
21387
4812cf228971
Include <stdlib.h> and <unistd.h> if available.
Andreas Schwab <schwab@suse.de>
parents:
19582
diff
changeset
|
86 void print_help_and_exit (); |
4812cf228971
Include <stdlib.h> and <unistd.h> if available.
Andreas Schwab <schwab@suse.de>
parents:
19582
diff
changeset
|
87 |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
88 struct option longopts[] = |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
89 { |
16146
a649abfefbb1
(longopts): Change nowait to no-wait.
Richard M. Stallman <rms@gnu.org>
parents:
16074
diff
changeset
|
90 { "no-wait", no_argument, NULL, 'n' }, |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
91 { "eval", no_argument, NULL, 'e' }, |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
92 { "help", no_argument, NULL, 'H' }, |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
93 { "version", no_argument, NULL, 'V' }, |
82994
44ffe551079c
Fix longopts option name for --tty.
Karoly Lorentey <lorentey@elte.hu>
parents:
82991
diff
changeset
|
94 { "tty", no_argument, NULL, 't' }, |
47515
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
95 { "alternate-editor", required_argument, NULL, 'a' }, |
52479
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
96 { "socket-name", required_argument, NULL, 's' }, |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
97 { "display", required_argument, NULL, 'd' }, |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
98 { 0, 0, 0, 0 } |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
99 }; |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
100 |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
101 /* Decode the options from argv and argc. |
16061
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
102 The global variable `optind' will say how many arguments we used up. */ |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
103 |
16061
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
104 void |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
105 decode_options (argc, argv) |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
106 int argc; |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
107 char **argv; |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
108 { |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
109 while (1) |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
110 { |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
111 int opt = getopt_long (argc, argv, |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
112 "VHnea:s:d:t", longopts, 0); |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
113 |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
114 if (opt == EOF) |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
115 break; |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
116 |
27305
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
117 alternate_editor = getenv ("ALTERNATE_EDITOR"); |
42176
1f5dbeefa536
Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents:
39723
diff
changeset
|
118 |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
119 switch (opt) |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
120 { |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
121 case 0: |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
122 /* If getopt returns 0, then it has already processed a |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
123 long-named option. We should do nothing. */ |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
124 break; |
42176
1f5dbeefa536
Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents:
39723
diff
changeset
|
125 |
27305
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
126 case 'a': |
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
127 alternate_editor = optarg; |
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
128 break; |
42176
1f5dbeefa536
Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents:
39723
diff
changeset
|
129 |
52479
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
130 case 's': |
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
131 socket_name = optarg; |
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
132 break; |
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
133 |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
134 case 'd': |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
135 display = optarg; |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
136 break; |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
137 |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
138 case 'n': |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
139 nowait = 1; |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
140 break; |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
141 |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
142 case 'e': |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
143 eval = 1; |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
144 break; |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
145 |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
146 case 'V': |
50101
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
147 printf ("emacsclient %s\n", VERSION); |
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
148 exit (0); |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
149 break; |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
150 |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
151 case 't': |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
53342
diff
changeset
|
152 frame = 1; |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
153 break; |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
154 |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
155 case 'H': |
50101
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
156 print_help_and_exit (); |
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
157 break; |
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
158 |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
159 default: |
50101
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
160 fprintf (stderr, "Try `%s --help' for more information\n", progname); |
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
161 exit (1); |
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
162 break; |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
163 } |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
164 } |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
165 |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
53342
diff
changeset
|
166 if (frame) { |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
167 nowait = 0; |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
168 display = 0; |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
169 } |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
170 |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
171 } |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
172 |
21387
4812cf228971
Include <stdlib.h> and <unistd.h> if available.
Andreas Schwab <schwab@suse.de>
parents:
19582
diff
changeset
|
173 void |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
174 print_help_and_exit () |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
175 { |
50101
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
176 printf ( |
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
177 "Usage: %s [OPTIONS] FILE...\n\ |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
178 Tell the Emacs server to visit the specified files.\n\ |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
179 Every FILE can be either just a FILENAME or [+LINE[:COLUMN]] FILENAME.\n\ |
50101
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
180 \n\ |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
181 The following OPTIONS are accepted:\n\ |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
182 -V, --version Just print a version info and return\n\ |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
183 -H, --help Print this usage information message\n\ |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
184 -t, --tty Open a new Emacs frame on the current terminal\n\ |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
185 -n, --no-wait Don't wait for the server to return\n\ |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
186 -e, --eval Evaluate the FILE arguments as ELisp expressions\n\ |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
187 -d, --display=DISPLAY Visit the file in the given display\n\ |
52479
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
188 -s, --socket-name=FILENAME\n\ |
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
189 Set the filename of the UNIX socket for communication\n\ |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
190 -a, --alternate-editor=EDITOR\n\ |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
191 Editor to fallback to if the server is not running\n\ |
50101
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
192 \n\ |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
193 Report bugs to bug-gnu-emacs@gnu.org.\n", progname); |
50101
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
194 exit (0); |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
195 } |
16061
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
196 |
52848 | 197 /* In NAME, insert a & before each &, each space, each newline, and |
198 any initial -. Change spaces to underscores, too, so that the | |
16061
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
199 return value never contains a space. */ |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
200 |
52635
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
201 void |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
202 quote_file_name (name, stream) |
16061
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
203 char *name; |
52635
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
204 FILE *stream; |
16061
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
205 { |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
206 char *copy = (char *) malloc (strlen (name) * 2 + 1); |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
207 char *p, *q; |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
208 |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
209 p = name; |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
210 q = copy; |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
211 while (*p) |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
212 { |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
213 if (*p == ' ') |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
214 { |
16074
25cfff7ffced
(quote_file_name): Quote with &, not \.
Richard M. Stallman <rms@gnu.org>
parents:
16061
diff
changeset
|
215 *q++ = '&'; |
16061
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
216 *q++ = '_'; |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
217 p++; |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
218 } |
47515
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
219 else if (*p == '\n') |
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
220 { |
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
221 *q++ = '&'; |
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
222 *q++ = 'n'; |
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
223 p++; |
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
224 } |
16061
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
225 else |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
226 { |
16074
25cfff7ffced
(quote_file_name): Quote with &, not \.
Richard M. Stallman <rms@gnu.org>
parents:
16061
diff
changeset
|
227 if (*p == '&' || (*p == '-' && p == name)) |
25cfff7ffced
(quote_file_name): Quote with &, not \.
Richard M. Stallman <rms@gnu.org>
parents:
16061
diff
changeset
|
228 *q++ = '&'; |
16061
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
229 *q++ = *p++; |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
230 } |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
231 } |
16074
25cfff7ffced
(quote_file_name): Quote with &, not \.
Richard M. Stallman <rms@gnu.org>
parents:
16061
diff
changeset
|
232 *q++ = 0; |
16061
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
233 |
52635
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
234 fprintf (stream, copy); |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
235 |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
236 free (copy); |
16061
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
237 } |
18701
9c7e0c926ed5
[C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16218
diff
changeset
|
238 |
9c7e0c926ed5
[C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16218
diff
changeset
|
239 /* Like malloc but get fatal error if memory is exhausted. */ |
9c7e0c926ed5
[C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16218
diff
changeset
|
240 |
24169
fbd8d10e80bd
(xmalloc): Declare to return long.
Richard M. Stallman <rms@gnu.org>
parents:
24084
diff
changeset
|
241 long * |
18701
9c7e0c926ed5
[C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16218
diff
changeset
|
242 xmalloc (size) |
9c7e0c926ed5
[C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16218
diff
changeset
|
243 unsigned int size; |
9c7e0c926ed5
[C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16218
diff
changeset
|
244 { |
24180
bc45833cd3c7
(xmalloc): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
24169
diff
changeset
|
245 long *result = (long *) malloc (size); |
18701
9c7e0c926ed5
[C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16218
diff
changeset
|
246 if (result == NULL) |
9c7e0c926ed5
[C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16218
diff
changeset
|
247 { |
9c7e0c926ed5
[C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16218
diff
changeset
|
248 perror ("malloc"); |
9c7e0c926ed5
[C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16218
diff
changeset
|
249 exit (1); |
9c7e0c926ed5
[C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16218
diff
changeset
|
250 } |
9c7e0c926ed5
[C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16218
diff
changeset
|
251 return result; |
9c7e0c926ed5
[C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16218
diff
changeset
|
252 } |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
253 |
27305
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
254 /* |
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
255 Try to run a different command, or --if no alternate editor is |
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
256 defined-- exit with an errorcode. |
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
257 */ |
37165
32679fe3e196
(fail, main): Don't use implicit int return type.
Gerd Moellmann <gerd@gnu.org>
parents:
34953
diff
changeset
|
258 void |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
259 fail (void) |
27305
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
260 { |
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
261 if (alternate_editor) |
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
262 { |
47515
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
263 int i = optind - 1; |
53341 | 264 execvp (alternate_editor, main_argv + i); |
37225 | 265 return; |
27305
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
266 } |
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
267 else |
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
268 { |
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
269 exit (1); |
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
270 } |
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
271 } |
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
272 |
53232
22aaf1e5fbe6
Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents:
53229
diff
changeset
|
273 int emacs_pid; |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
274 |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
275 #ifdef nec_ews_svr4 |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
276 extern char *_sobuf ; |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
277 #else |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
278 #if defined (USG) || defined (DGUX) |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
279 unsigned char _sobuf[BUFSIZ+8]; |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
280 #else |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
281 char _sobuf[BUFSIZ]; |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
282 #endif |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
283 #endif |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
284 |
83025
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83019
diff
changeset
|
285 /* A signal handler that passes the signal to the Emacs process. |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83019
diff
changeset
|
286 Useful for SIGWINCH. */ |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83019
diff
changeset
|
287 |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
288 SIGTYPE |
83004
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
289 pass_signal_to_emacs (int signalnum) |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
290 { |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
291 int old_errno = errno; |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
292 |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
293 if (emacs_pid) |
83004
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
294 kill (emacs_pid, signalnum); |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
295 |
83004
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
296 signal (signalnum, pass_signal_to_emacs); |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
297 errno = old_errno; |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
298 } |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
299 |
83025
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83019
diff
changeset
|
300 /* Set up signal handlers before opening a frame on the current tty. */ |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83019
diff
changeset
|
301 |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
302 void |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
303 init_signals (void) |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
304 { |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
305 /* Set up signal handlers. */ |
83004
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
306 signal (SIGWINCH, pass_signal_to_emacs); |
83012
4aa172a45af1
Fix C-g handling with multiple ttys.
Karoly Lorentey <lorentey@elte.hu>
parents:
83010
diff
changeset
|
307 |
4aa172a45af1
Fix C-g handling with multiple ttys.
Karoly Lorentey <lorentey@elte.hu>
parents:
83010
diff
changeset
|
308 /* Don't pass SIGINT and SIGQUIT to Emacs, because it has no way of |
4aa172a45af1
Fix C-g handling with multiple ttys.
Karoly Lorentey <lorentey@elte.hu>
parents:
83010
diff
changeset
|
309 deciding which terminal the signal came from. C-g is now a |
4aa172a45af1
Fix C-g handling with multiple ttys.
Karoly Lorentey <lorentey@elte.hu>
parents:
83010
diff
changeset
|
310 normal input event on secondary terminals. */ |
4aa172a45af1
Fix C-g handling with multiple ttys.
Karoly Lorentey <lorentey@elte.hu>
parents:
83010
diff
changeset
|
311 #if 0 |
83004
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
312 signal (SIGINT, pass_signal_to_emacs); |
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
313 signal (SIGQUIT, pass_signal_to_emacs); |
83012
4aa172a45af1
Fix C-g handling with multiple ttys.
Karoly Lorentey <lorentey@elte.hu>
parents:
83010
diff
changeset
|
314 #endif |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
315 } |
27305
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
316 |
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
317 |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
318 #if !defined (HAVE_SOCKETS) || defined (NO_SOCKETS_IN_FILE_SYSTEM) |
412 | 319 |
37165
32679fe3e196
(fail, main): Don't use implicit int return type.
Gerd Moellmann <gerd@gnu.org>
parents:
34953
diff
changeset
|
320 int |
412 | 321 main (argc, argv) |
322 int argc; | |
323 char **argv; | |
324 { | |
325 fprintf (stderr, "%s: Sorry, the Emacs server is supported only\n", | |
326 argv[0]); | |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
327 fprintf (stderr, "on systems with Berkeley sockets.\n"); |
27305
4161adef5fd3
Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
328 |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
329 fail (); |
412 | 330 } |
331 | |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
332 #else /* HAVE_SOCKETS */ |
412 | 333 |
334 #include <sys/types.h> | |
335 #include <sys/socket.h> | |
336 #include <sys/un.h> | |
493 | 337 #include <sys/stat.h> |
412 | 338 #include <errno.h> |
339 | |
5522
64a936b21f74
Don't declare sys_errlist; declare strerror instead.
Roland McGrath <roland@gnu.org>
parents:
4696
diff
changeset
|
340 extern char *strerror (); |
412 | 341 extern int errno; |
342 | |
27474
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
343 /* Three possibilities: |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
344 2 - can't be `stat'ed (sets errno) |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
345 1 - isn't owned by us |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
346 0 - success: none of the above */ |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
347 |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
348 static int |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
349 socket_status (socket_name) |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
350 char *socket_name; |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
351 { |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
352 struct stat statbfr; |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
353 |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
354 if (stat (socket_name, &statbfr) == -1) |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
355 return 2; |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
356 |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
357 if (statbfr.st_uid != geteuid ()) |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
358 return 1; |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
359 |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
360 return 0; |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
361 } |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
362 |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
363 /* Returns 1 if PREFIX is a prefix of STRING. */ |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
364 static int |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
365 strprefix (char *prefix, char *string) |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
366 { |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
367 int i; |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
368 if (! prefix) |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
369 return 1; |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
370 |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
371 if (!string) |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
372 return 0; |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
373 |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
374 for (i = 0; prefix[i]; i++) |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
375 if (!string[i] || string[i] != prefix[i]) |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
376 return 0; |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
377 return 1; |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
378 } |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
379 |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
8360
diff
changeset
|
380 int |
412 | 381 main (argc, argv) |
382 int argc; | |
383 char **argv; | |
384 { | |
24084
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
385 char *system_name; |
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
386 int system_name_length; |
47515
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
387 int s, i, needlf = 0; |
15758
7e712d42d371
(main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents:
14610
diff
changeset
|
388 FILE *out, *in; |
412 | 389 struct sockaddr_un server; |
34953
71ff4d0af84f
(main): Remove unused local variable statbfr.
Eli Zaretskii <eliz@gnu.org>
parents:
27474
diff
changeset
|
390 char *cwd, *str; |
412 | 391 char string[BUFSIZ]; |
392 | |
53341 | 393 main_argc = argc; |
394 main_argv = argv; | |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
395 progname = argv[0]; |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
396 |
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
397 /* Process options. */ |
16061
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
398 decode_options (argc, argv); |
16030
fb38057473c8
(decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents:
15995
diff
changeset
|
399 |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
53342
diff
changeset
|
400 if ((argc - optind < 1) && !eval && !frame) |
50101
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
401 { |
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
402 fprintf (stderr, "%s: file name or argument required\n", progname); |
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
403 fprintf (stderr, "Try `%s --help' for more information\n", progname); |
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
404 exit (1); |
e5f56d47b52c
(print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents:
48627
diff
changeset
|
405 } |
412 | 406 |
42176
1f5dbeefa536
Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents:
39723
diff
changeset
|
407 /* |
412 | 408 * Open up an AF_UNIX socket in this person's home directory |
409 */ | |
410 | |
411 if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) | |
412 { | |
413 fprintf (stderr, "%s: ", argv[0]); | |
414 perror ("socket"); | |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
415 fail (); |
412 | 416 } |
42176
1f5dbeefa536
Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents:
39723
diff
changeset
|
417 |
412 | 418 server.sun_family = AF_UNIX; |
25261
89be69860eeb
(main): Move the dynamic allocation of
Karl Heuer <kwzh@gnu.org>
parents:
24652
diff
changeset
|
419 |
493 | 420 { |
47659
473041262ca1
(main): Always use /tmp and non-qualified hostname.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47647
diff
changeset
|
421 char *dot; |
24084
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
422 system_name_length = 32; |
493 | 423 |
24084
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
424 while (1) |
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
425 { |
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
426 system_name = (char *) xmalloc (system_name_length + 1); |
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
427 |
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
428 /* system_name must be null-terminated string. */ |
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
429 system_name[system_name_length] = '\0'; |
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
430 |
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
431 if (gethostname (system_name, system_name_length) == 0) |
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
432 break; |
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
433 |
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
434 free (system_name); |
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
435 system_name_length *= 2; |
c0b0893dd5a6
(main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents:
23412
diff
changeset
|
436 } |
47659
473041262ca1
(main): Always use /tmp and non-qualified hostname.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47647
diff
changeset
|
437 |
473041262ca1
(main): Always use /tmp and non-qualified hostname.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47647
diff
changeset
|
438 /* We always use the non-dotted host name, for simplicity. */ |
473041262ca1
(main): Always use /tmp and non-qualified hostname.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47647
diff
changeset
|
439 dot = index (system_name, '.'); |
473041262ca1
(main): Always use /tmp and non-qualified hostname.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47647
diff
changeset
|
440 if (dot) |
473041262ca1
(main): Always use /tmp and non-qualified hostname.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47647
diff
changeset
|
441 *dot = '\0'; |
25261
89be69860eeb
(main): Move the dynamic allocation of
Karl Heuer <kwzh@gnu.org>
parents:
24652
diff
changeset
|
442 } |
89be69860eeb
(main): Move the dynamic allocation of
Karl Heuer <kwzh@gnu.org>
parents:
24652
diff
changeset
|
443 |
89be69860eeb
(main): Move the dynamic allocation of
Karl Heuer <kwzh@gnu.org>
parents:
24652
diff
changeset
|
444 { |
27474
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
445 int sock_status = 0; |
53646
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
446 int default_sock = !socket_name; |
83010 | 447 int saved_errno = 0; |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
448 |
53646
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
449 if (default_sock) |
52479
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
450 { |
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
451 socket_name = alloca (system_name_length + 100); |
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
452 sprintf (socket_name, "/tmp/emacs%d-%s/server", |
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
453 (int) geteuid (), system_name); |
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
454 } |
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
455 |
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
456 if (strlen (socket_name) < sizeof (server.sun_path)) |
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
457 strcpy (server.sun_path, socket_name); |
bc2610a13fbf
(socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
458 else |
53646
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
459 { |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
460 fprintf (stderr, "%s: socket-name %s too long", |
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
461 argv[0], socket_name); |
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
462 fail (); |
53646
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
463 } |
412 | 464 |
27474
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
465 /* See if the socket exists, and if it's owned by us. */ |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
466 sock_status = socket_status (server.sun_path); |
53543
fec82b542db2
(main): Save errno from socket_status.
Andreas Schwab <schwab@suse.de>
parents:
53497
diff
changeset
|
467 saved_errno = errno; |
53646
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
468 if (sock_status && default_sock) |
493 | 469 { |
27474
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
470 /* Failing that, see if LOGNAME or USER exist and differ from |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
471 our euid. If so, look for a socket based on the UID |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
472 associated with the name. This is reminiscent of the logic |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
473 that init_editfns uses to set the global Vuser_full_name. */ |
42176
1f5dbeefa536
Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents:
39723
diff
changeset
|
474 |
27474
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
475 char *user_name = (char *) getenv ("LOGNAME"); |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
476 if (!user_name) |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
477 user_name = (char *) getenv ("USER"); |
42176
1f5dbeefa536
Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents:
39723
diff
changeset
|
478 |
27474
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
479 if (user_name) |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
480 { |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
481 struct passwd *pw = getpwnam (user_name); |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
482 if (pw && (pw->pw_uid != geteuid ())) |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
483 { |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
484 /* We're running under su, apparently. */ |
53646
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
485 sprintf (socket_name, "/tmp/emacs%d-%s/server", |
37225 | 486 (int) pw->pw_uid, system_name); |
53646
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
487 |
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
488 if (strlen (socket_name) < sizeof (server.sun_path)) |
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
489 strcpy (server.sun_path, socket_name); |
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
490 else |
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
491 { |
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
492 fprintf (stderr, "%s: socket-name %s too long", |
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
493 argv[0], socket_name); |
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
494 exit (1); |
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
495 } |
8c55b1b400d5
(main): Stop if socket name too long.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
53543
diff
changeset
|
496 |
27474
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
497 sock_status = socket_status (server.sun_path); |
83010 | 498 saved_errno = errno; |
27474
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
499 } |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
500 } |
493 | 501 } |
42176
1f5dbeefa536
Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents:
39723
diff
changeset
|
502 |
27474
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
503 switch (sock_status) |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
504 { |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
505 case 1: |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
506 /* There's a socket, but it isn't owned by us. This is OK if |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
507 we are root. */ |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
508 if (0 != geteuid ()) |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
509 { |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
510 fprintf (stderr, "%s: Invalid socket owner\n", argv[0]); |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
511 fail (); |
27474
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
512 } |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
513 break; |
42176
1f5dbeefa536
Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents:
39723
diff
changeset
|
514 |
27474
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
515 case 2: |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
516 /* `stat' failed */ |
53543
fec82b542db2
(main): Save errno from socket_status.
Andreas Schwab <schwab@suse.de>
parents:
53497
diff
changeset
|
517 if (saved_errno == ENOENT) |
27474
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
518 fprintf (stderr, |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
519 "%s: Can't find socket; have you started the server?\n\ |
48627
c91408365d35
(main): Tell user how to start server within Emacs if socket could not
Stephen Eglen <stephen@gnu.org>
parents:
48617
diff
changeset
|
520 To start the server in Emacs, type \"M-x server-start\".\n", |
27474
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
521 argv[0]); |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
522 else |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
523 fprintf (stderr, "%s: Can't stat %s: %s\n", |
53543
fec82b542db2
(main): Save errno from socket_status.
Andreas Schwab <schwab@suse.de>
parents:
53497
diff
changeset
|
524 argv[0], server.sun_path, strerror (saved_errno)); |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
525 fail (); |
27474
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
526 break; |
ed3668c0295a
(socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27305
diff
changeset
|
527 } |
493 | 528 } |
412 | 529 |
3595
e10f7473d2e3
* emacsserver.c (main): When we're passing a `struct sockaddr_un'
Jim Blandy <jimb@redhat.com>
parents:
1031
diff
changeset
|
530 if (connect (s, (struct sockaddr *) &server, strlen (server.sun_path) + 2) |
e10f7473d2e3
* emacsserver.c (main): When we're passing a `struct sockaddr_un'
Jim Blandy <jimb@redhat.com>
parents:
1031
diff
changeset
|
531 < 0) |
412 | 532 { |
533 fprintf (stderr, "%s: ", argv[0]); | |
534 perror ("connect"); | |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
535 fail (); |
412 | 536 } |
15758
7e712d42d371
(main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents:
14610
diff
changeset
|
537 |
7e712d42d371
(main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents:
14610
diff
changeset
|
538 /* We use the stream OUT to send our command to the server. */ |
412 | 539 if ((out = fdopen (s, "r+")) == NULL) |
540 { | |
541 fprintf (stderr, "%s: ", argv[0]); | |
542 perror ("fdopen"); | |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
543 fail (); |
412 | 544 } |
545 | |
15758
7e712d42d371
(main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents:
14610
diff
changeset
|
546 /* We use the stream IN to read the response. |
7e712d42d371
(main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents:
14610
diff
changeset
|
547 We used to use just one stream for both output and input |
7e712d42d371
(main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents:
14610
diff
changeset
|
548 on the socket, but reversing direction works nonportably: |
7e712d42d371
(main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents:
14610
diff
changeset
|
549 on some systems, the output appears as the first input; |
7e712d42d371
(main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents:
14610
diff
changeset
|
550 on other systems it does not. */ |
7e712d42d371
(main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents:
14610
diff
changeset
|
551 if ((in = fdopen (s, "r+")) == NULL) |
7e712d42d371
(main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents:
14610
diff
changeset
|
552 { |
7e712d42d371
(main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents:
14610
diff
changeset
|
553 fprintf (stderr, "%s: ", argv[0]); |
7e712d42d371
(main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents:
14610
diff
changeset
|
554 perror ("fdopen"); |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
555 fail (); |
15758
7e712d42d371
(main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents:
14610
diff
changeset
|
556 } |
7e712d42d371
(main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents:
14610
diff
changeset
|
557 |
48617
802b2a15e451
(main): Test HAVE_GETCWD rather than BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
47717
diff
changeset
|
558 #ifdef HAVE_GETCWD |
802b2a15e451
(main): Test HAVE_GETCWD rather than BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
47717
diff
changeset
|
559 cwd = getcwd (string, sizeof string); |
802b2a15e451
(main): Test HAVE_GETCWD rather than BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
47717
diff
changeset
|
560 #else |
412 | 561 cwd = getwd (string); |
11030
3345f6426f49
Use BSD sockets whenever available, even if HAVE_SYSVIPC.
Richard M. Stallman <rms@gnu.org>
parents:
10124
diff
changeset
|
562 #endif |
412 | 563 if (cwd == 0) |
564 { | |
565 /* getwd puts message in STRING if it fails. */ | |
52069
76d453ac3c4f
(main): Fix having macros in a printf statement.
Juanma Barranquero <lekktu@gmail.com>
parents:
50566
diff
changeset
|
566 |
48617
802b2a15e451
(main): Test HAVE_GETCWD rather than BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
47717
diff
changeset
|
567 #ifdef HAVE_GETCWD |
52069
76d453ac3c4f
(main): Fix having macros in a printf statement.
Juanma Barranquero <lekktu@gmail.com>
parents:
50566
diff
changeset
|
568 fprintf (stderr, "%s: %s (%s)\n", argv[0], |
76d453ac3c4f
(main): Fix having macros in a printf statement.
Juanma Barranquero <lekktu@gmail.com>
parents:
50566
diff
changeset
|
569 "Cannot get current working directory", strerror (errno)); |
48617
802b2a15e451
(main): Test HAVE_GETCWD rather than BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
47717
diff
changeset
|
570 #else |
52069
76d453ac3c4f
(main): Fix having macros in a printf statement.
Juanma Barranquero <lekktu@gmail.com>
parents:
50566
diff
changeset
|
571 fprintf (stderr, "%s: %s (%s)\n", argv[0], string, strerror (errno)); |
19582
1289a4779e68
[HAVE_SYSVIPC]: Include errno.h, as in the other case.
Richard M. Stallman <rms@gnu.org>
parents:
18701
diff
changeset
|
572 #endif |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
573 fail (); |
412 | 574 } |
575 | |
16061
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
576 if (nowait) |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
577 fprintf (out, "-nowait "); |
a1290c4159b5
(quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16030
diff
changeset
|
578 |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
579 if (eval) |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
580 fprintf (out, "-eval "); |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
581 |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
582 if (display) |
412 | 583 { |
52635
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
584 fprintf (out, "-display "); |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
585 quote_file_name (display, out); |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
586 fprintf (out, " "); |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
587 } |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
588 |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
53342
diff
changeset
|
589 if (frame) |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
590 { |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
591 char *tty_name = ttyname (fileno (stdin)); |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
592 if (! tty_name) |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
593 fail (); |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
594 |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
595 init_signals (); |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
596 |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
597 fprintf (out, "-tty "); |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
598 quote_file_name (tty_name, out); |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
599 fprintf (out, " "); |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
600 quote_file_name (getenv("TERM"), out); |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
601 fprintf (out, " "); |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
602 } |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
603 |
52635
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
604 if ((argc - optind > 0)) |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
605 { |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
606 for (i = optind; i < argc; i++) |
412 | 607 { |
52635
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
608 if (eval) |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
609 ; /* Don't prepend any cwd or anything like that. */ |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
610 else if (*argv[i] == '+') |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
611 { |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
612 char *p = argv[i] + 1; |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
613 while (isdigit ((unsigned char) *p) || *p == ':') p++; |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
614 if (*p != 0) |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
615 { |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
616 quote_file_name (cwd, out); |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
617 fprintf (out, "/"); |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
618 } |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
619 } |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
620 else if (*argv[i] != '/') |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
621 { |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
622 quote_file_name (cwd, out); |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
623 fprintf (out, "/"); |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
624 } |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
625 |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
626 quote_file_name (argv[i], out); |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
627 fprintf (out, " "); |
412 | 628 } |
629 } | |
52635
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
630 else |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
631 { |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
53342
diff
changeset
|
632 if (!frame) |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
633 { |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
634 while ((str = fgets (string, BUFSIZ, stdin))) |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
635 { |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
636 quote_file_name (str, out); |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
637 } |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
638 fprintf (out, " "); |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
639 } |
52635
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
640 } |
9963e9da5850
(quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents:
52532
diff
changeset
|
641 |
412 | 642 fprintf (out, "\n"); |
643 fflush (out); | |
644 | |
15995
7284f973fc42
(both versions): Handle -nowait and --nowait by sending data to the server.
Richard M. Stallman <rms@gnu.org>
parents:
15758
diff
changeset
|
645 /* Maybe wait for an answer. */ |
7284f973fc42
(both versions): Handle -nowait and --nowait by sending data to the server.
Richard M. Stallman <rms@gnu.org>
parents:
15758
diff
changeset
|
646 if (nowait) |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
647 { |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
648 return 0; |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
52848
diff
changeset
|
649 } |
15995
7284f973fc42
(both versions): Handle -nowait and --nowait by sending data to the server.
Richard M. Stallman <rms@gnu.org>
parents:
15758
diff
changeset
|
650 |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
651 if (!eval && !frame) |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
652 { |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
653 printf ("Waiting for Emacs..."); |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
654 needlf = 2; |
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
655 } |
412 | 656 fflush (stdout); |
657 | |
47515
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
658 /* Now, wait for an answer and print any messages. */ |
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
659 while ((str = fgets (string, BUFSIZ, in))) |
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
660 { |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
661 if (frame) |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
662 { |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
663 if (strprefix ("emacs-pid ", str)) |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
664 { |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
665 emacs_pid = strtol (string + strlen ("emacs-pid"), NULL, 10); |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
666 } |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
667 } |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
668 else |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
669 { |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
670 if (needlf == 2) |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
671 printf ("\n"); |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
672 printf ("%s", str); |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
673 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n'; |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82994
diff
changeset
|
674 } |
47515
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
675 } |
42176
1f5dbeefa536
Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents:
39723
diff
changeset
|
676 |
47515
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
677 if (needlf) |
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
678 printf ("\n"); |
6ee937dcfe16
(quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42412
diff
changeset
|
679 fflush (stdout); |
412 | 680 |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
8360
diff
changeset
|
681 return 0; |
412 | 682 } |
683 | |
47647
5498210ad40d
Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47515
diff
changeset
|
684 #endif /* HAVE_SOCKETS */ |
5527
51451a050975
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5522
diff
changeset
|
685 |
51451a050975
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5522
diff
changeset
|
686 #ifndef HAVE_STRERROR |
51451a050975
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5522
diff
changeset
|
687 char * |
51451a050975
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5522
diff
changeset
|
688 strerror (errnum) |
51451a050975
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5522
diff
changeset
|
689 int errnum; |
51451a050975
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5522
diff
changeset
|
690 { |
51451a050975
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5522
diff
changeset
|
691 extern char *sys_errlist[]; |
51451a050975
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5522
diff
changeset
|
692 extern int sys_nerr; |
51451a050975
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5522
diff
changeset
|
693 |
51451a050975
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5522
diff
changeset
|
694 if (errnum >= 0 && errnum < sys_nerr) |
51451a050975
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5522
diff
changeset
|
695 return sys_errlist[errnum]; |
51451a050975
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5522
diff
changeset
|
696 return (char *) "Unknown error"; |
51451a050975
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5522
diff
changeset
|
697 } |
51451a050975
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5522
diff
changeset
|
698 |
51451a050975
[! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents:
5522
diff
changeset
|
699 #endif /* ! HAVE_STRERROR */ |
52401 | 700 |
701 /* arch-tag: f39bb9c4-73eb-477e-896d-50832e2ca9a7 | |
702 (do not change this comment) */ |