annotate lib-src/emacsclient.c @ 53233:fe9b37bee5f7

Fully eliminated global tty state variables. lib-src/emacsclient.c (main.c): Fix error message. lisp/frame.el (make-frame-on-tty): New function. lisp/server.el (server-process-filter): Notify emacsclient if there was on error during evaluation. src/cm.c: Fix remaining cases of direct Wcm references. src/dispextern.h: Updated prototypes. src/dispnew.c (Fredraw_frame): Fix set_terminal_modes call. (init_display): Remove reference to meta_key. src/frame.c (make_terminal_frame): Renamed first parameter to tty_name. Call term_init before creating the frame. (Fmake_terminal_frame): Look up the `tty' and `tty-type' frame parameters from the currently selected terminal before the global default. (Fdelete_frame): Make sure that the new selected frame is live. src/keyboard.c (meta_key): Moved to struct tty_output. (read_avail_input): Fix C syntax. Update references to meta_key. (Fsuspend_emacs): pass current tty to init_sys_modes via record_unwind_protect. (Fset_input_mode): Update references to meta_key. (Fcurrent_input_mode): Ditto. src/sysdep.c (init_sys_modes): Updated old_tty and meta_key references. Don't call set_terminal_modes, it needs termcap strings. (reset_sys_modes): Call tty_reset_terminal_modes instead of reset_terminal_modes. Updated old_tty references. src/term.c: Massive updates throuout the file. (TS_*, TN_*): Moved to struct tty_output. (RPov, delete_in_insert_mode se_is_so, costs_set, insert_mode): Ditto. (standout_mode, specified_window, tty_cursor_hidden): Ditto. (tty_set_terminal_modes, tty_reset_terminal_modes): New functions. (turn_on_insert, turn_off_insert): Added tty parameter. (turn_on_highlight, turn_off_highlight, toggle_highlight): Added tty parameter. (tty_hide_cursor, tty_show_cursor): Ditto. (background_highlight, highlight_if_desired): Ditto. (tty_capable_p): Changed first parameter to tty_output. (term_init): Make sure top_frame is initialized. Don't exit on errors if this would have been a secondary terminal. Call set_terminal_modes on the end. (delete_tty): New function. (delete_tty_1): New function. (print_all_frames): New function, marginally useful for debugging. src/termchar.h (struct tty_output): Changed old_tty to be a pointer. Removed old_tty_valid member. Added tty-specific variables from term.c. src/xfaces.c (Ftty_supports_face_attributes_p): Update for new tty_capable_p. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-9
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 27 Dec 2003 10:00:19 +0000
parents 22aaf1e5fbe6
children d4e6a050c9b1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
493
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
1 /* Client process that communicates with GNU Emacs acting as server.
50101
e5f56d47b52c (print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents: 48627
diff changeset
2 Copyright (C) 1986, 1987, 1994, 1999, 2000, 2001, 2003
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
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 This file is part of GNU Emacs.
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 GNU Emacs is free software; you can redistribute it and/or modify
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 any later version.
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 GNU General Public License for more details.
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
83c1951257f1 Include <config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 42176
diff changeset
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
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
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
44
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 /****************************************/
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 #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
48 #include <signal.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
49
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
50 #ifndef INCLUDED_FCNTL
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
51 #define INCLUDED_FCNTL
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
52 #include <fcntl.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
53 #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
54
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
55 #ifdef HAVE_TERMIOS
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
56 #ifndef NO_TERMIO
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
57 #include <termio.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
58 #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
59 #include <termios.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
60 #endif /* not HAVE_TERMIOS */
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
61
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
62 #ifdef __GNU_LIBRARY__
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
63 #include <sys/ioctl.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
64 #include <termios.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
65 #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
66
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
67 #if (defined (POSIX) || defined (NEED_UNISTD_H)) && defined (HAVE_UNISTD_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
68 #include <unistd.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
69 #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
70
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
71
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
72
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
73 /* Try to establish the correct character to disable terminal functions
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
74 in a system-independent manner. Note that USG (at least) define
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
75 _POSIX_VDISABLE as 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
76
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
77 #ifdef _POSIX_VDISABLE
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 #define CDISABLE _POSIX_VDISABLE
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
79 #else /* not _POSIX_VDISABLE */
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
80 #ifdef CDEL
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
81 #undef CDISABLE
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
82 #define CDISABLE CDEL
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
83 #else /* not CDEL */
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
84 #define CDISABLE 255
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
85 #endif /* not CDEL */
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
86 #endif /* not _POSIX_VDISABLE */
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
87
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
88
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
89
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
90 /****************************************/
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
91
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
92 char *getenv (), *getwd ();
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
93 char *getcwd ();
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
94
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
95 /* This is defined with -D from the compilation command,
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
96 which extracts it from ../lisp/version.el. */
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
97
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
98 #ifndef VERSION
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
99 #define VERSION "unspecified"
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
100 #endif
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
101
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
102 /* Name used to invoke this program. */
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
103 char *progname;
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
104
16146
a649abfefbb1 (longopts): Change nowait to no-wait.
Richard M. Stallman <rms@gnu.org>
parents: 16074
diff changeset
105 /* 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
106 int nowait = 0;
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
107
47647
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
108 /* Nonzero means args are expressions to be evaluated. --eval. */
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
109 int eval = 0;
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
110
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
111 /* The display on which Emacs should work. --display. */
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
112 char *display = NULL;
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
113
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
114 /* Nonzero means open a new Emacs frame on the current terminal. */
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
115 int here = 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
116
47647
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
117 /* 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
118 is not running. --alternate-editor. */
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
119 const char * alternate_editor = NULL;
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
120
52532
cd53bfef4ab1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 52479
diff changeset
121 /* 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
122 char *socket_name = NULL;
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
123
21387
4812cf228971 Include <stdlib.h> and <unistd.h> if available.
Andreas Schwab <schwab@suse.de>
parents: 19582
diff changeset
124 void print_help_and_exit ();
4812cf228971 Include <stdlib.h> and <unistd.h> if available.
Andreas Schwab <schwab@suse.de>
parents: 19582
diff changeset
125
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
126 struct option longopts[] =
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
127 {
16146
a649abfefbb1 (longopts): Change nowait to no-wait.
Richard M. Stallman <rms@gnu.org>
parents: 16074
diff changeset
128 { "no-wait", no_argument, NULL, 'n' },
47647
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
129 { "eval", no_argument, NULL, 'e' },
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
130 { "help", no_argument, NULL, 'H' },
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
131 { "version", no_argument, NULL, 'V' },
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
132 { "here", no_argument, NULL, 'h' },
47515
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
133 { "alternate-editor", required_argument, NULL, 'a' },
52479
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
134 { "socket-name", required_argument, NULL, 's' },
47647
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
135 { "display", required_argument, NULL, 'd' },
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
136 { 0, 0, 0, 0 }
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
137 };
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
138
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
139 /* Decode the options from argv and argc.
16061
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
140 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
141
16061
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
142 void
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
143 decode_options (argc, argv)
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
144 int argc;
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
145 char **argv;
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
146 {
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
147 while (1)
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
148 {
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
149 int opt = getopt_long (argc, argv,
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
150 "VHnea:s:d:h", longopts, 0);
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
151
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
152 if (opt == EOF)
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
153 break;
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
154
27305
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
155 alternate_editor = getenv ("ALTERNATE_EDITOR");
42176
1f5dbeefa536 Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39723
diff changeset
156
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
157 switch (opt)
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
158 {
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
159 case 0:
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
160 /* 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
161 long-named option. We should do nothing. */
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
162 break;
42176
1f5dbeefa536 Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39723
diff changeset
163
27305
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
164 case 'a':
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
165 alternate_editor = optarg;
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
166 break;
42176
1f5dbeefa536 Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39723
diff changeset
167
52479
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
168 case 's':
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
169 socket_name = optarg;
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
170 break;
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
171
47647
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
172 case 'd':
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
173 display = optarg;
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
174 break;
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
175
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
176 case 'n':
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
177 nowait = 1;
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
178 break;
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
179
47647
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
180 case 'e':
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
181 eval = 1;
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
182 break;
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
183
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
184 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
185 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
186 exit (0);
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
187 break;
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
188
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
189 case '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
190 here = 1;
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
191 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
192
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
193 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
194 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
195 break;
e5f56d47b52c (print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents: 48627
diff changeset
196
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
197 default:
50101
e5f56d47b52c (print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents: 48627
diff changeset
198 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
199 exit (1);
e5f56d47b52c (print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents: 48627
diff changeset
200 break;
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
201 }
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
202 }
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
203
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
204 if (here) {
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
205 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
206 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
207 }
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
208
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
209 }
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
210
21387
4812cf228971 Include <stdlib.h> and <unistd.h> if available.
Andreas Schwab <schwab@suse.de>
parents: 19582
diff changeset
211 void
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
212 print_help_and_exit ()
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
213 {
50101
e5f56d47b52c (print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents: 48627
diff changeset
214 printf (
e5f56d47b52c (print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents: 48627
diff changeset
215 "Usage: %s [OPTIONS] FILE...\n\
47647
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
216 Tell the Emacs server to visit the specified files.\n\
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
217 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
218 \n\
47647
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
219 The following OPTIONS are accepted:\n\
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
220 -V, --version Just print a version info and return\n\
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
221 -H, --help Print this usage information message\n\
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
222 -h, --here 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
223 -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
224 -e, --eval Evaluate the FILE arguments as ELisp expressions\n\
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
225 -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
226 -s, --socket-name=FILENAME\n\
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
227 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
228 -a, --alternate-editor=EDITOR\n\
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
229 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
230 \n\
47647
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
231 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
232 exit (0);
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
233 }
16061
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
234
52848
5c74e66d6c36 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 52635
diff changeset
235 /* In NAME, insert a & before each &, each space, each newline, and
5c74e66d6c36 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 52635
diff changeset
236 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
237 return value never contains a space. */
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
238
52635
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
239 void
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
240 quote_file_name (name, stream)
16061
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
241 char *name;
52635
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
242 FILE *stream;
16061
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
243 {
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
244 char *copy = (char *) malloc (strlen (name) * 2 + 1);
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
245 char *p, *q;
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
246
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
247 p = name;
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
248 q = copy;
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
249 while (*p)
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
250 {
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
251 if (*p == ' ')
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
252 {
16074
25cfff7ffced (quote_file_name): Quote with &, not \.
Richard M. Stallman <rms@gnu.org>
parents: 16061
diff changeset
253 *q++ = '&';
16061
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
254 *q++ = '_';
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
255 p++;
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
256 }
47515
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
257 else if (*p == '\n')
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
258 {
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
259 *q++ = '&';
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
260 *q++ = 'n';
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
261 p++;
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
262 }
16061
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
263 else
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
264 {
16074
25cfff7ffced (quote_file_name): Quote with &, not \.
Richard M. Stallman <rms@gnu.org>
parents: 16061
diff changeset
265 if (*p == '&' || (*p == '-' && p == name))
25cfff7ffced (quote_file_name): Quote with &, not \.
Richard M. Stallman <rms@gnu.org>
parents: 16061
diff changeset
266 *q++ = '&';
16061
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
267 *q++ = *p++;
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
268 }
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
269 }
16074
25cfff7ffced (quote_file_name): Quote with &, not \.
Richard M. Stallman <rms@gnu.org>
parents: 16061
diff changeset
270 *q++ = 0;
16061
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
271
52635
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
272 fprintf (stream, copy);
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
273
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
274 free (copy);
16061
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
275 }
18701
9c7e0c926ed5 [C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16218
diff changeset
276
9c7e0c926ed5 [C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16218
diff changeset
277 /* 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
278
24169
fbd8d10e80bd (xmalloc): Declare to return long.
Richard M. Stallman <rms@gnu.org>
parents: 24084
diff changeset
279 long *
18701
9c7e0c926ed5 [C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16218
diff changeset
280 xmalloc (size)
9c7e0c926ed5 [C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16218
diff changeset
281 unsigned int size;
9c7e0c926ed5 [C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16218
diff changeset
282 {
24180
bc45833cd3c7 (xmalloc): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 24169
diff changeset
283 long *result = (long *) malloc (size);
18701
9c7e0c926ed5 [C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16218
diff changeset
284 if (result == NULL)
9c7e0c926ed5 [C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16218
diff changeset
285 {
9c7e0c926ed5 [C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16218
diff changeset
286 perror ("malloc");
9c7e0c926ed5 [C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16218
diff changeset
287 exit (1);
9c7e0c926ed5 [C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16218
diff changeset
288 }
9c7e0c926ed5 [C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16218
diff changeset
289 return result;
9c7e0c926ed5 [C_ALLOCA] (xmalloc): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16218
diff changeset
290 }
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
291
27305
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
292 /*
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
293 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
294 defined-- exit with an errorcode.
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
295 */
37165
32679fe3e196 (fail, main): Don't use implicit int return type.
Gerd Moellmann <gerd@gnu.org>
parents: 34953
diff changeset
296 void
27305
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
297 fail (argc, argv)
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
298 int argc;
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
299 char **argv;
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
300 {
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
301 if (alternate_editor)
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
302 {
47515
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
303 int i = optind - 1;
27305
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
304 execvp (alternate_editor, argv + i);
37225
ab2a21b7b7ed (fail): Don't return a value.
Dave Love <fx@gnu.org>
parents: 37165
diff changeset
305 return;
27305
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
306 }
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
307 else
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
308 {
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
309 exit (1);
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
310 }
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
311 }
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
312
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
313
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
314 #ifdef HAVE_TERMIOS
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
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
316 /* Adapted from emacs_get_tty() in sysdep.c. */
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
317 int
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
318 ec_get_tty (int fd, struct termios *settings)
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
319 {
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
320 bzero (settings, sizeof (struct termios));
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
321 if (tcgetattr (fd, settings) < 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
322 return -1;
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
323 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
324 }
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
325
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
326 /* Adapted from emacs_set_tty() in sysdep.c. */
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
327 int
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
328 ec_set_tty (int fd, struct termios *settings, int flushp)
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
329 {
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
330 /* Set the primary parameters - baud rate, character size, etcetera. */
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
331
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
332 int i;
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
333 /* We have those nifty POSIX tcmumbleattr functions.
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
334 William J. Smith <wjs@wiis.wang.com> writes:
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
335 "POSIX 1003.1 defines tcsetattr to return success if it was
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
336 able to perform any of the requested actions, even if some
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
337 of the requested actions could not be performed.
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
338 We must read settings back to ensure tty setup properly.
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
339 AIX requires this to keep tty from hanging occasionally." */
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
340 /* This make sure that we don't loop indefinitely in here. */
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
341 for (i = 0 ; i < 10 ; i++)
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
342 if (tcsetattr (fd, flushp ? TCSAFLUSH : TCSADRAIN, settings) < 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
343 {
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
344 if (errno == EINTR)
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
345 continue;
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
346 else
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
347 return -1;
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
348 }
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
349 else
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
350 {
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
351 struct termios new;
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
352
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
353 bzero (&new, sizeof (new));
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
354 /* Get the current settings, and see if they're what we asked for. */
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
355 tcgetattr (fd, &new);
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
356 /* We cannot use memcmp on the whole structure here because under
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
357 * aix386 the termios structure has some reserved field that may
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
358 * not be filled in.
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
359 */
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
360 if ( new.c_iflag == settings->c_iflag
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
361 && new.c_oflag == settings->c_oflag
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
362 && new.c_cflag == settings->c_cflag
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
363 && new.c_lflag == settings->c_lflag
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
364 && memcmp (new.c_cc, settings->c_cc, NCCS) == 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
365 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
366 else
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
367 continue;
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
368 }
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
369 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
370 }
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
371
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
372 int master;
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
373 char *pty_name;
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
374
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
375 struct termios old_tty;
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
376 struct termios tty;
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
377 int old_tty_valid;
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
378
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
379 int tty_erase_char;
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
380 int flow_control = 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
381 int meta_key = 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
382 char _sobuf[BUFSIZ];
53232
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
383 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
384
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
385 /* Adapted from init_sys_modes() in sysdep.c. */
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
386 int
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
387 init_tty ()
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
388 {
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
389 if (! isatty (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
390 {
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
391 fprintf (stderr, "%s: Input is not a terminal", "init_tty");
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
392 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
393 }
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
394
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
395 ec_get_tty (0, &old_tty);
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
396 old_tty_valid = 1;
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
397 tty = old_tty;
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
398
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
399 tty_erase_char = old_tty.c_cc[VERASE];
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
400
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
401 tty.c_iflag |= (IGNBRK); /* Ignore break condition */
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
402 tty.c_iflag &= ~ICRNL; /* Disable map of CR to NL on input */
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
403 #ifdef INLCR
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
404 tty.c_iflag &= ~INLCR; /* Disable map of NL to CR on input */
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
405 #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
406 #ifdef ISTRIP
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
407 tty.c_iflag &= ~ISTRIP; /* don't strip 8th bit on input */
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
408 #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
409 tty.c_lflag &= ~ECHO; /* Disable echo */
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
410 tty.c_lflag &= ~ICANON; /* Disable erase/kill processing */
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
411 #ifdef IEXTEN
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
412 tty.c_lflag &= ~IEXTEN; /* Disable other editing characters. */
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
413 #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
414 tty.c_lflag |= ISIG; /* Enable signals */
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
415 if (flow_control)
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
416 {
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
417 tty.c_iflag |= IXON; /* Enable start/stop output control */
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
418 #ifdef IXANY
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
419 tty.c_iflag &= ~IXANY;
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
420 #endif /* IXANY */
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
421 }
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
422 else
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
423 tty.c_iflag &= ~IXON; /* Disable start/stop output control */
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
424 tty.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL
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
425 on output */
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
426 tty.c_oflag &= ~TAB3; /* Disable tab expansion */
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
427 #ifdef CS8
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
428 if (meta_key)
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
429 {
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
430 tty.c_cflag |= CS8; /* allow 8th bit on input */
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
431 tty.c_cflag &= ~PARENB; /* Don't check parity */
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
432 }
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
433 #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
434 tty.c_cc[VINTR] = CDISABLE;
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
435 tty.c_cc[VQUIT] = CDISABLE;
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
436 tty.c_cc[VMIN] = 1; /* Input should wait for at least 1 char */
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
437 tty.c_cc[VTIME] = 0; /* no matter how long that takes. */
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
438 #ifdef VSWTCH
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
439 tty.c_cc[VSWTCH] = CDISABLE; /* Turn off shell layering use of C-z */
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
440 #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
441
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
442 #ifdef VSUSP
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
443 tty.c_cc[VSUSP] = CDISABLE; /* Turn off mips handling of C-z. */
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
444 #endif /* VSUSP */
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
445 #ifdef V_DSUSP
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
446 tty.c_cc[V_DSUSP] = CDISABLE; /* Turn off mips handling of C-y. */
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
447 #endif /* V_DSUSP */
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
448 #ifdef VDSUSP /* Some systems have VDSUSP, some have V_DSUSP. */
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
449 tty.c_cc[VDSUSP] = CDISABLE;
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
450 #endif /* VDSUSP */
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
451 #ifdef VLNEXT
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
452 tty.c_cc[VLNEXT] = CDISABLE;
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
453 #endif /* VLNEXT */
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
454 #ifdef VREPRINT
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
455 tty.c_cc[VREPRINT] = CDISABLE;
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
456 #endif /* VREPRINT */
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
457 #ifdef VWERASE
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
458 tty.c_cc[VWERASE] = CDISABLE;
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
459 #endif /* VWERASE */
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
460 #ifdef VDISCARD
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
461 tty.c_cc[VDISCARD] = CDISABLE;
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
462 #endif /* VDISCARD */
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
463
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
464 if (flow_control)
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
465 {
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
466 #ifdef VSTART
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
467 tty.c_cc[VSTART] = '\021';
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
468 #endif /* VSTART */
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
469 #ifdef VSTOP
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
470 tty.c_cc[VSTOP] = '\023';
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
471 #endif /* VSTOP */
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
472 }
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
473 else
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
474 {
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
475 #ifdef VSTART
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
476 tty.c_cc[VSTART] = CDISABLE;
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
477 #endif /* VSTART */
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
478 #ifdef VSTOP
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
479 tty.c_cc[VSTOP] = CDISABLE;
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
480 #endif /* VSTOP */
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
481 }
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
482
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
483 #ifdef SET_LINE_DISCIPLINE
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
484 /* Need to explicitly request TERMIODISC line discipline or
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
485 Ultrix's termios does not work correctly. */
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
486 tty.c_line = SET_LINE_DISCIPLINE;
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
487 #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
488
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
489 #ifdef AIX
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
490 #ifndef IBMR2AIX
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
491 /* AIX enhanced edit loses NULs, so disable it. */
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
492 tty.c_line = 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
493 tty.c_iflag &= ~ASCEDIT;
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
494 #else
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
495 tty.c_cc[VSTRT] = 255;
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
496 tty.c_cc[VSTOP] = 255;
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
497 tty.c_cc[VSUSP] = 255;
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
498 tty.c_cc[VDSUSP] = 255;
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
499 #endif /* IBMR2AIX */
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
500 if (flow_control)
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
501 {
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
502 #ifdef VSTART
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
503 tty.c_cc[VSTART] = '\021';
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
504 #endif /* VSTART */
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
505 #ifdef VSTOP
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
506 tty.c_cc[VSTOP] = '\023';
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
507 #endif /* VSTOP */
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
508 }
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
509 /* Also, PTY overloads NUL and 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
510 don't ignore break, but don't signal either, so it looks like NUL.
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
511 This really serves a purpose only if running in an XTERM window
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
512 or via TELNET or the like, but does no harm elsewhere. */
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
513 tty.c_iflag &= ~IGNBRK;
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
514 tty.c_iflag &= ~BRKINT;
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
515 #endif /* AIX */
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
516
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
517 ec_set_tty (0, &tty, 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
518
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
519 /* This code added to insure that, if flow-control is not to be used,
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
520 we have an unlocked terminal at the start. */
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
521
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
522 #ifdef TCXONC
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
523 if (!flow_control) ioctl (0, TCXONC, 1);
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
524 #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
525 #ifndef APOLLO
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
526 #ifdef TIOCSTART
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
527 if (!flow_control) ioctl (0, TIOCSTART, 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
528 #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
529 #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
530
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
531 #if defined (HAVE_TERMIOS) || defined (HPUX9)
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
532 #ifdef TCOON
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
533 if (!flow_control) tcflow (0, TCOON);
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
534 #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
535 #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
536
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
537 #ifdef _IOFBF
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
538 /* This symbol is defined on recent USG systems.
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
539 Someone says without this call USG won't really buffer the file
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
540 even with a call to setbuf. */
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
541 setvbuf (stdout, (char *) _sobuf, _IOFBF, sizeof _sobuf);
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
542 #else
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
543 setbuf (stdout, (char *) _sobuf);
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
544 #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
545
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
546 return 1;
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
547 }
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
548
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
549 void
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
550 window_change ()
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
551 {
53232
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
552 int width = 0, height = 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
553
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
554 #ifdef TIOCGWINSZ
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
555 {
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
556 /* BSD-style. */
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
557 struct winsize size;
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
558
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
559 if (ioctl (0, TIOCGWINSZ, &size) == -1)
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
560 width = height = 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
561 else
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
562 {
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
563 width = size.ws_col;
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
564 height = size.ws_row;
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
565 }
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
566 }
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
567 #else
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
568 #ifdef TIOCGSIZE
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
569 {
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
570 /* SunOS - style. */
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
571 struct ttysize size;
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
572
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
573 if (ioctl (0, TIOCGSIZE, &size) == -1)
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
574 width = height = 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
575 else
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
576 {
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
577 width = size.ts_cols;
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
578 height = size.ts_lines;
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
579 }
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
580 }
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
581 #endif /* not SunOS-style */
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
582 #endif /* not BSD-style */
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
583
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
584 #ifdef TIOCSWINSZ
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
585 {
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
586 /* BSD-style. */
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
587 struct winsize size;
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
588 size.ws_row = height;
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
589 size.ws_col = width;
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
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
591 ioctl (master, TIOCSWINSZ, &size);
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
592 }
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
593 #else
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 #ifdef TIOCSSIZE
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
595 {
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 /* SunOS - style. */
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
597 struct ttysize size;
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
598 size.ts_lines = height;
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 size.ts_cols = width;
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
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 ioctl (master, TIOCGSIZE, &size);
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 #endif /* not SunOS-style */
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
604 #endif /* not BSD-style */
53232
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
605
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
606 if (width != 0 && height != 0)
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
607 kill (emacs_pid, SIGWINCH);
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
608 }
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
609
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
610 int in_conversation = 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
611 int quit_conversation = 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
612
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
613 SIGTYPE
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
614 hang_up_signal (int signalnum)
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
615 {
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
616 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
617
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
618 if (! in_conversation)
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
619 return;
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
620
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
621 quit_conversation = 1;
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
622
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
623 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
624 }
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
625
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
626 SIGTYPE
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
627 window_change_signal (int signalnum)
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
628 {
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
629 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
630
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
631 if (! in_conversation)
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
632 goto end;
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 window_change();
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 end:
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 signal (SIGWINCH, window_change_signal);
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 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
639 }
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
640
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
641 int
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
642 init_signals ()
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
643 {
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
644 /* Set up signal handlers. */
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
645 signal (SIGWINCH, window_change_signal);
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
646 signal (SIGHUP, hang_up_signal);
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 1;
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 }
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
650
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
651
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
652
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
653 /* Adapted from reset_sys_modes in sysdep.c. */
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
654 int
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
655 reset_tty ()
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
656 {
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
657 fflush (stdout);
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
658 #ifdef BSD_SYSTEM
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
659 #ifndef BSD4_1
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
660 /* Avoid possible loss of output when changing terminal modes. */
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
661 fsync (fileno (stdout));
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
662 #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
663 #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
664
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
665 #ifdef F_SETFL
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
666 #ifdef O_NDELAY
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
667 fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NDELAY);
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
668 #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
669 #endif /* F_SETFL */
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
670
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
671 if (old_tty_valid)
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
672 while (ec_set_tty (0, &old_tty, 0) < 0 && errno == EINTR)
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
673 ;
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
674
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
675 return 1;
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
676 }
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
677
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
678
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
679 int
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
680 init_pty ()
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
681 {
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
682 master = getpt ();
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
683 if (master < 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
684 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
685
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
686 if (grantpt (master) < 0 || unlockpt (master) < 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
687 goto close_master;
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
688 pty_name = strdup (ptsname (master));
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
689 if (! pty_name)
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
690 goto close_master;
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
691
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
692 /* Propagate window size. */
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
693 window_change ();
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
694
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
695 return 1;
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
696
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
697 close_master:
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
698 close (master);
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
699 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
700 }
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
701
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
702 int
53232
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
703 copy_from_to (int in, int out, int sigio)
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
704 {
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
705 static char buf[BUFSIZ];
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
706 int nread = read (in, &buf, BUFSIZ);
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
707 if (nread == 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
708 return 1; /* EOF */
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
709 else if (nread < 0 && errno != EAGAIN)
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
710 return 0; /* Error */
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
711 else if (nread > 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
712 {
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
713 int r = 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
714 int written = 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
715
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
716 do {
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
717 r = write (out, &buf, nread);
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
718 } while ((r < 0 && errno == EAGAIN)
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
719 || (r > 0 && (written += r) && written != nread));
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
720
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
721 if (r < 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
722 return 0; /* Error */
53232
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
723
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
724 if (sigio)
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
725 {
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
726 kill (emacs_pid, SIGIO);
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
727 }
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
728 }
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
729 return 1;
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
730 }
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
731
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
732 int
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
733 pty_conversation ()
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
734 {
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
735 fd_set set;
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
736
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
737 in_conversation = 1;
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
738
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
739 while (! quit_conversation) {
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
740 int res;
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
741
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
742 FD_ZERO (&set);
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
743 FD_SET (master, &set);
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
744 FD_SET (1, &set);
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
745 res = select (FD_SETSIZE, &set, NULL, NULL, NULL);
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
746 if (res < 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
747 {
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
748 if (errno != EINTR)
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
749 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
750 }
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
751 else if (res > 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
752 {
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
753 if (FD_ISSET (master, &set))
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
754 {
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
755 /* Copy Emacs output to stdout. */
53232
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
756 if (! copy_from_to (master, 0, 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
757 return 1;
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
758 }
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
759 if (FD_ISSET (1, &set))
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
760 {
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
761 /* Forward user input to Emacs. */
53232
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
762 if (! copy_from_to (1, master, 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
763 return 1;
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
764 }
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
765 }
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
766 }
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
767 return 1;
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
768 }
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
769
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
770 #endif /* HAVE_TERMIOS */
27305
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
771
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
772
47647
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
773 #if !defined (HAVE_SOCKETS) || defined (NO_SOCKETS_IN_FILE_SYSTEM)
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774
37165
32679fe3e196 (fail, main): Don't use implicit int return type.
Gerd Moellmann <gerd@gnu.org>
parents: 34953
diff changeset
775 int
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 main (argc, argv)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 int argc;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 char **argv;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780 fprintf (stderr, "%s: Sorry, the Emacs server is supported only\n",
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 argv[0]);
47647
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
782 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
783
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
784 fail (argc, argv);
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786
47647
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
787 #else /* HAVE_SOCKETS */
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 #include <sys/types.h>
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 #include <sys/socket.h>
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 #include <sys/un.h>
493
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
792 #include <sys/stat.h>
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 #include <errno.h>
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794
5522
64a936b21f74 Don't declare sys_errlist; declare strerror instead.
Roland McGrath <roland@gnu.org>
parents: 4696
diff changeset
795 extern char *strerror ();
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796 extern int errno;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797
27474
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
798 /* Three possibilities:
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
799 2 - can't be `stat'ed (sets errno)
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
800 1 - isn't owned by us
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
801 0 - success: none of the above */
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
802
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
803 static int
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
804 socket_status (socket_name)
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
805 char *socket_name;
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
806 {
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
807 struct stat statbfr;
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
808
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
809 if (stat (socket_name, &statbfr) == -1)
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
810 return 2;
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
811
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
812 if (statbfr.st_uid != geteuid ())
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
813 return 1;
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
814
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
815 return 0;
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
816 }
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
817
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 8360
diff changeset
818 int
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 main (argc, argv)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 int argc;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 char **argv;
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 {
24084
c0b0893dd5a6 (main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents: 23412
diff changeset
823 char *system_name;
c0b0893dd5a6 (main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents: 23412
diff changeset
824 int system_name_length;
47515
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
825 int s, i, needlf = 0;
15758
7e712d42d371 (main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents: 14610
diff changeset
826 FILE *out, *in;
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 struct sockaddr_un server;
34953
71ff4d0af84f (main): Remove unused local variable statbfr.
Eli Zaretskii <eliz@gnu.org>
parents: 27474
diff changeset
828 char *cwd, *str;
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 char string[BUFSIZ];
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
831 progname = argv[0];
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
832
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
833 /* Process options. */
16061
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
834 decode_options (argc, argv);
16030
fb38057473c8 (decode_options): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15995
diff changeset
835
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
836 if ((argc - optind < 1) && !eval && !here)
50101
e5f56d47b52c (print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents: 48627
diff changeset
837 {
e5f56d47b52c (print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents: 48627
diff changeset
838 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
839 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
840 exit (1);
e5f56d47b52c (print_help_and_exit): Print to stdout. Exit successfully. Added some blank
Juanma Barranquero <lekktu@gmail.com>
parents: 48627
diff changeset
841 }
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842
42176
1f5dbeefa536 Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39723
diff changeset
843 /*
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 * Open up an AF_UNIX socket in this person's home directory
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 */
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 fprintf (stderr, "%s: ", argv[0]);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 perror ("socket");
27305
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
851 fail (argc, argv);
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 }
42176
1f5dbeefa536 Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39723
diff changeset
853
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 server.sun_family = AF_UNIX;
25261
89be69860eeb (main): Move the dynamic allocation of
Karl Heuer <kwzh@gnu.org>
parents: 24652
diff changeset
855
493
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
856 {
47659
473041262ca1 (main): Always use /tmp and non-qualified hostname.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47647
diff changeset
857 char *dot;
24084
c0b0893dd5a6 (main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents: 23412
diff changeset
858 system_name_length = 32;
493
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
859
24084
c0b0893dd5a6 (main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents: 23412
diff changeset
860 while (1)
c0b0893dd5a6 (main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents: 23412
diff changeset
861 {
c0b0893dd5a6 (main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents: 23412
diff changeset
862 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
863
c0b0893dd5a6 (main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents: 23412
diff changeset
864 /* 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
865 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
866
c0b0893dd5a6 (main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents: 23412
diff changeset
867 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
868 break;
c0b0893dd5a6 (main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents: 23412
diff changeset
869
c0b0893dd5a6 (main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents: 23412
diff changeset
870 free (system_name);
c0b0893dd5a6 (main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents: 23412
diff changeset
871 system_name_length *= 2;
c0b0893dd5a6 (main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents: 23412
diff changeset
872 }
47659
473041262ca1 (main): Always use /tmp and non-qualified hostname.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47647
diff changeset
873
473041262ca1 (main): Always use /tmp and non-qualified hostname.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47647
diff changeset
874 /* 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
875 dot = index (system_name, '.');
473041262ca1 (main): Always use /tmp and non-qualified hostname.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47647
diff changeset
876 if (dot)
473041262ca1 (main): Always use /tmp and non-qualified hostname.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47647
diff changeset
877 *dot = '\0';
25261
89be69860eeb (main): Move the dynamic allocation of
Karl Heuer <kwzh@gnu.org>
parents: 24652
diff changeset
878 }
89be69860eeb (main): Move the dynamic allocation of
Karl Heuer <kwzh@gnu.org>
parents: 24652
diff changeset
879
89be69860eeb (main): Move the dynamic allocation of
Karl Heuer <kwzh@gnu.org>
parents: 24652
diff changeset
880 {
27474
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
881 int sock_status = 0;
24084
c0b0893dd5a6 (main): Eliminate arbitrary limit on length of system_name.
Richard M. Stallman <rms@gnu.org>
parents: 23412
diff changeset
882
52479
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
883 if (! socket_name)
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
884 {
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
885 socket_name = alloca (system_name_length + 100);
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
886 sprintf (socket_name, "/tmp/emacs%d-%s/server",
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
887 (int) geteuid (), system_name);
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
888 }
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
889
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
890 if (strlen (socket_name) < sizeof (server.sun_path))
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
891 strcpy (server.sun_path, socket_name);
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
892 else
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
893 fprintf (stderr, "%s: socket-name %s too long",
bc2610a13fbf (socket_name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
894 argv[0], socket_name);
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895
27474
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
896 /* 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
897 sock_status = socket_status (server.sun_path);
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
898 if (sock_status)
493
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
899 {
27474
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
900 /* 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
901 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
902 associated with the name. This is reminiscent of the logic
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
903 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
904
27474
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
905 char *user_name = (char *) getenv ("LOGNAME");
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
906 if (!user_name)
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
907 user_name = (char *) getenv ("USER");
42176
1f5dbeefa536 Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39723
diff changeset
908
27474
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
909 if (user_name)
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
910 {
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
911 struct passwd *pw = getpwnam (user_name);
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
912 if (pw && (pw->pw_uid != geteuid ()))
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
913 {
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
914 /* We're running under su, apparently. */
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
915 sprintf (server.sun_path, "/tmp/esrv%d-%s",
37225
ab2a21b7b7ed (fail): Don't return a value.
Dave Love <fx@gnu.org>
parents: 37165
diff changeset
916 (int) pw->pw_uid, system_name);
27474
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
917 sock_status = socket_status (server.sun_path);
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
918 }
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
919 }
493
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
920 }
42176
1f5dbeefa536 Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39723
diff changeset
921
27474
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
922 switch (sock_status)
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
923 {
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
924 case 1:
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
925 /* 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
926 we are root. */
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
927 if (0 != geteuid ())
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
928 {
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
929 fprintf (stderr, "%s: Invalid socket owner\n", argv[0]);
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
930 fail (argc, argv);
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
931 }
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
932 break;
42176
1f5dbeefa536 Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39723
diff changeset
933
27474
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
934 case 2:
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
935 /* `stat' failed */
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
936 if (errno == ENOENT)
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
937 fprintf (stderr,
48627
c91408365d35 (main): Tell user how to start server within Emacs if socket could not
Stephen Eglen <stephen@gnu.org>
parents: 48617
diff changeset
938 "%s: can't find socket; have you started the server?\n\
c91408365d35 (main): Tell user how to start server within Emacs if socket could not
Stephen Eglen <stephen@gnu.org>
parents: 48617
diff changeset
939 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
940 argv[0]);
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
941 else
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
942 fprintf (stderr, "%s: can't stat %s: %s\n",
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
943 argv[0], server.sun_path, strerror (errno));
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
944 fail (argc, argv);
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
945 break;
ed3668c0295a (socket_status): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 27305
diff changeset
946 }
493
8b101799ff37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 478
diff changeset
947 }
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948
3595
e10f7473d2e3 * emacsserver.c (main): When we're passing a `struct sockaddr_un'
Jim Blandy <jimb@redhat.com>
parents: 1031
diff changeset
949 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
950 < 0)
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 fprintf (stderr, "%s: ", argv[0]);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 perror ("connect");
27305
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
954 fail (argc, argv);
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 }
15758
7e712d42d371 (main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents: 14610
diff changeset
956
7e712d42d371 (main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents: 14610
diff changeset
957 /* We use the stream OUT to send our command to the server. */
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 if ((out = fdopen (s, "r+")) == NULL)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 fprintf (stderr, "%s: ", argv[0]);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961 perror ("fdopen");
27305
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
962 fail (argc, argv);
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964
15758
7e712d42d371 (main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents: 14610
diff changeset
965 /* 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
966 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
967 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
968 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
969 on other systems it does not. */
7e712d42d371 (main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents: 14610
diff changeset
970 if ((in = fdopen (s, "r+")) == NULL)
7e712d42d371 (main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents: 14610
diff changeset
971 {
7e712d42d371 (main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents: 14610
diff changeset
972 fprintf (stderr, "%s: ", argv[0]);
7e712d42d371 (main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents: 14610
diff changeset
973 perror ("fdopen");
27305
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
974 fail (argc, argv);
15758
7e712d42d371 (main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents: 14610
diff changeset
975 }
7e712d42d371 (main) [HAVE_SOCKETS]: Use two separate stdio
Richard M. Stallman <rms@gnu.org>
parents: 14610
diff changeset
976
48617
802b2a15e451 (main): Test HAVE_GETCWD rather than BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents: 47717
diff changeset
977 #ifdef HAVE_GETCWD
802b2a15e451 (main): Test HAVE_GETCWD rather than BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents: 47717
diff changeset
978 cwd = getcwd (string, sizeof string);
802b2a15e451 (main): Test HAVE_GETCWD rather than BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents: 47717
diff changeset
979 #else
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
980 cwd = getwd (string);
11030
3345f6426f49 Use BSD sockets whenever available, even if HAVE_SYSVIPC.
Richard M. Stallman <rms@gnu.org>
parents: 10124
diff changeset
981 #endif
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
982 if (cwd == 0)
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
983 {
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
984 /* 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
985
48617
802b2a15e451 (main): Test HAVE_GETCWD rather than BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents: 47717
diff changeset
986 #ifdef HAVE_GETCWD
52069
76d453ac3c4f (main): Fix having macros in a printf statement.
Juanma Barranquero <lekktu@gmail.com>
parents: 50566
diff changeset
987 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
988 "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
989 #else
52069
76d453ac3c4f (main): Fix having macros in a printf statement.
Juanma Barranquero <lekktu@gmail.com>
parents: 50566
diff changeset
990 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
991 #endif
27305
4161adef5fd3 Add option -a EDITOR and environment variable
Gerd Moellmann <gerd@gnu.org>
parents: 26083
diff changeset
992 fail (argc, argv);
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
993 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
994
16061
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
995 if (nowait)
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
996 fprintf (out, "-nowait ");
a1290c4159b5 (quote_file_name): New function.
Richard M. Stallman <rms@gnu.org>
parents: 16030
diff changeset
997
47647
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
998 if (eval)
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
999 fprintf (out, "-eval ");
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
1000
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
1001 if (display)
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1002 {
52635
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1003 fprintf (out, "-display ");
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1004 quote_file_name (display, out);
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1005 fprintf (out, " ");
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1006 }
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1007
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
1008 if (here)
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
1009 {
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
1010 if (! init_signals ())
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
1011 {
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
1012 fprintf (stderr, "%s: ", argv[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
1013 perror ("fdopen");
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
1014 fail (argc, argv);
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
1015 }
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
1016
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
1017 if (! init_tty ())
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
1018 {
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
1019 reset_tty ();
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
1020 fprintf (stderr, "%s: ", argv[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
1021 perror ("fdopen");
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
1022 fail (argc, argv);
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
1023 }
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
1024
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
1025 if (! init_pty ())
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
1026 {
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
1027 reset_tty ();
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
1028 fprintf (stderr, "%s: ", argv[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
1029 perror ("fdopen");
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
1030 fail (argc, argv);
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
1031 }
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
1032
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
1033 fprintf (out, "-pty ");
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
1034 quote_file_name (pty_name, 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
1035 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
1036 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
1037 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
1038 }
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
1039
52635
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1040 if ((argc - optind > 0))
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1041 {
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1042 for (i = optind; i < argc; i++)
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1043 {
52635
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1044 if (eval)
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1045 ; /* 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
1046 else if (*argv[i] == '+')
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1047 {
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1048 char *p = argv[i] + 1;
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1049 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
1050 if (*p != 0)
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1051 {
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1052 quote_file_name (cwd, out);
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1053 fprintf (out, "/");
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1054 }
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1055 }
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1056 else if (*argv[i] != '/')
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1057 {
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1058 quote_file_name (cwd, out);
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1059 fprintf (out, "/");
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1060 }
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1061
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1062 quote_file_name (argv[i], out);
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1063 fprintf (out, " ");
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065 }
52635
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1066 else
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1067 {
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
1068 if (!here)
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
1069 {
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
1070 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
1071 {
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
1072 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
1073 }
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
1074 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
1075 }
52635
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1076 }
9963e9da5850 (quote_file_name): Print the result instead of
Eli Zaretskii <eliz@gnu.org>
parents: 52532
diff changeset
1077
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1078 fprintf (out, "\n");
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1079 fflush (out);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080
15995
7284f973fc42 (both versions): Handle -nowait and --nowait by sending data to the server.
Richard M. Stallman <rms@gnu.org>
parents: 15758
diff changeset
1081 /* 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
1082 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
1083 {
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
1084 reset_tty ();
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
1085 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
1086 }
15995
7284f973fc42 (both versions): Handle -nowait and --nowait by sending data to the server.
Richard M. Stallman <rms@gnu.org>
parents: 15758
diff changeset
1087
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
1088 if (here)
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
1089 {
53232
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
1090 /* First of all, get the pid of the Emacs process.
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
1091 XXX Is there is some nifty libc/kernel feature for doing this?
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
1092 */
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
1093 str = fgets (string, BUFSIZ, in);
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
1094 emacs_pid = atoi (str);
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
1095 if (emacs_pid == 0)
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
1096 {
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
1097 reset_tty ();
53233
fe9b37bee5f7 Fully eliminated global tty state variables.
Karoly Lorentey <lorentey@elte.hu>
parents: 53232
diff changeset
1098 fprintf (stderr, "%s: %s\n", argv[0], str);
53232
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
1099 fail (argc, argv);
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
1100 }
22aaf1e5fbe6 Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents: 53229
diff changeset
1101
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
1102 if (! pty_conversation ())
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
1103 {
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
1104 reset_tty ();
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
1105 fprintf (stderr, "%s: ", argv[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
1106 perror ("fdopen");
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
1107 fail (argc, argv);
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
1108 }
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
1109 close (master);
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
1110 reset_tty ();
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
1111 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
1112 }
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
1113
47647
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
1114 if (!eval)
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
1115 {
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
1116 printf ("Waiting for Emacs...");
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
1117 needlf = 2;
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
1118 }
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1119 fflush (stdout);
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1120
47515
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
1121 /* 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
1122 while ((str = fgets (string, BUFSIZ, in)))
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
1123 {
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
1124 if (needlf == 2)
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
1125 printf ("\n");
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
1126 printf ("%s", str);
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
1127 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
1128 }
42176
1f5dbeefa536 Include "config.h", not <../src/config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 39723
diff changeset
1129
47515
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
1130 if (needlf)
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
1131 printf ("\n");
6ee937dcfe16 (quote_file_name): Quote \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 42412
diff changeset
1132 fflush (stdout);
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1133
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
1134 reset_tty ();
9491
dd3b83e4ceb0 Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents: 8360
diff changeset
1135 return 0;
412
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1136 }
3cc2c5136064 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1137
47647
5498210ad40d Remove SYSV support.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47515
diff changeset
1138 #endif /* HAVE_SOCKETS */
5527
51451a050975 [! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents: 5522
diff changeset
1139
51451a050975 [! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents: 5522
diff changeset
1140 #ifndef HAVE_STRERROR
51451a050975 [! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents: 5522
diff changeset
1141 char *
51451a050975 [! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents: 5522
diff changeset
1142 strerror (errnum)
51451a050975 [! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents: 5522
diff changeset
1143 int errnum;
51451a050975 [! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents: 5522
diff changeset
1144 {
51451a050975 [! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents: 5522
diff changeset
1145 extern char *sys_errlist[];
51451a050975 [! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents: 5522
diff changeset
1146 extern int sys_nerr;
51451a050975 [! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents: 5522
diff changeset
1147
51451a050975 [! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents: 5522
diff changeset
1148 if (errnum >= 0 && errnum < sys_nerr)
51451a050975 [! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents: 5522
diff changeset
1149 return sys_errlist[errnum];
51451a050975 [! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents: 5522
diff changeset
1150 return (char *) "Unknown error";
51451a050975 [! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents: 5522
diff changeset
1151 }
51451a050975 [! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents: 5522
diff changeset
1152
51451a050975 [! HAVE_STRERROR] (strerror): Define the function.
Roland McGrath <roland@gnu.org>
parents: 5522
diff changeset
1153 #endif /* ! HAVE_STRERROR */
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 52069
diff changeset
1154
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 52069
diff changeset
1155 /* arch-tag: f39bb9c4-73eb-477e-896d-50832e2ca9a7
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 52069
diff changeset
1156 (do not change this comment) */