annotate src/console-tty.c @ 210:49f55ca3ba57

Added tag r20-4b3 for changeset 41ff10fd062f
author cvs
date Mon, 13 Aug 2007 10:05:01 +0200
parents e45d5e7c476e
children 084402c475ba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* TTY console functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 Copyright (C) 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 /* Authors: Ben Wing and Chuck Thompson. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #include "console-tty.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include "console-stream.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include "events.h" /* for Vcontrolling_terminal */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include "faces.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include "frame.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include "lstream.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #include "redisplay.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include "sysdep.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 #ifdef MULE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 #include "mule-coding.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 #endif
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 195
diff changeset
41 #ifdef HAVE_GPM
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 195
diff changeset
42 #include "gpmevent.h"
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 195
diff changeset
43 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 DEFINE_CONSOLE_TYPE (tty);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 Lisp_Object Qterminal_type;
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
48 Lisp_Object Qcontrolling_process;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
50 extern Lisp_Object Vstdio_str; /* in console-stream.c */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 allocate_tty_console_struct (struct console *con)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 163
diff changeset
55 /* zero out all slots except the lisp ones ... */
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 163
diff changeset
56 con->console_data = xnew_and_zero (struct tty_console);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 CONSOLE_TTY_DATA (con)->terminal_type = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 CONSOLE_TTY_DATA (con)->instream = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 CONSOLE_TTY_DATA (con)->outstream = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 tty_init_console (struct console *con, Lisp_Object props)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 {
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
65 Lisp_Object tty = CONSOLE_CONNECTION (con);
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
66 Lisp_Object terminal_type = Qnil, controlling_process = Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 int infd, outfd;
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
68 struct gcpro gcpro1, gcpro2;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
70 GCPRO2 (terminal_type, controlling_process);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 terminal_type = Fplist_get (props, Qterminal_type, Qnil);
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
73 controlling_process = Fplist_get(props, Qcontrolling_process, Qnil);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 163
diff changeset
74
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 /* Determine the terminal type */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 if (!NILP (terminal_type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 CHECK_STRING (terminal_type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 char *temp_type = (char *) getenv ("TERM");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 if (!temp_type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 error ("Cannot determine terminal type");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 terminal_type = build_string (temp_type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
91 /* Determine the controlling process */
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
92 if (!NILP (controlling_process))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
93 CHECK_INT (controlling_process);
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
94
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 /* Open the specified console */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 allocate_tty_console_struct (con);
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
98 if (internal_equal (tty, Vstdio_str, 0))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 infd = fileno (stdin);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 outfd = fileno (stdout);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 CONSOLE_TTY_DATA (con)->is_stdio = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 {
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
106 infd = outfd = open ((char *) XSTRING_DATA (tty), O_RDWR);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 if (infd < 0)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
108 error ("Unable to open tty %s", XSTRING_DATA (tty));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 CONSOLE_TTY_DATA (con)->is_stdio = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 163
diff changeset
111
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 CONSOLE_TTY_DATA (con)->infd = infd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 CONSOLE_TTY_DATA (con)->outfd = outfd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 CONSOLE_TTY_DATA (con)->instream = make_filedesc_input_stream (infd, 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 -1, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 CONSOLE_TTY_DATA (con)->outstream = make_filedesc_output_stream (outfd, 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 -1, 0);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
118 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
119 CONSOLE_TTY_DATA (con)->instream =
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
120 make_decoding_input_stream (XLSTREAM (CONSOLE_TTY_DATA (con)->instream),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
121 Fget_coding_system (Vkeyboard_coding_system));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
122 Lstream_set_character_mode (XLSTREAM (CONSOLE_TTY_DATA (con)->instream));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
123 CONSOLE_TTY_DATA (con)->outstream =
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
124 make_encoding_output_stream (XLSTREAM (CONSOLE_TTY_DATA (con)->outstream),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
125 Fget_coding_system (Vterminal_coding_system));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
126 #endif /* MULE */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 CONSOLE_TTY_DATA (con)->terminal_type = terminal_type;
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
128 CONSOLE_TTY_DATA (con)->controlling_process = controlling_process;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 108
diff changeset
129
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 108
diff changeset
130 #ifdef HAVE_GPM
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 108
diff changeset
131 connect_to_gpm(con);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 108
diff changeset
132 #endif
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 108
diff changeset
133
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 if (NILP (CONSOLE_NAME (con)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 CONSOLE_NAME (con) = Ffile_name_nondirectory (tty);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 int tty_pg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 int controlling_tty_pg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 int cfd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 /* OK, the only sure-fire way I can think of to determine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 whether a particular TTY is our controlling TTY is to check
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 if it has the same foreground process group as our controlling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 TTY. This is OK because a process group can never simultaneously
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 be the foreground process group of two TTY's (in that case it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 would have two controlling TTY's, which is not allowed). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 EMACS_GET_TTY_PROCESS_GROUP (infd, &tty_pg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 cfd = open ("/dev/tty", O_RDWR, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 EMACS_GET_TTY_PROCESS_GROUP (cfd, &controlling_tty_pg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 close (cfd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 if (tty_pg == controlling_tty_pg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 CONSOLE_TTY_DATA (con)->controlling_terminal = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 XSETCONSOLE (Vcontrolling_terminal, con);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 munge_tty_process_group ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 CONSOLE_TTY_DATA (con)->controlling_terminal = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 tty_mark_console (struct console *con, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ((markobj) (CONSOLE_TTY_DATA (con)->terminal_type));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ((markobj) (CONSOLE_TTY_DATA (con)->instream));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ((markobj) (CONSOLE_TTY_DATA (con)->outstream));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 tty_initially_selected_for_input (struct console *con)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 free_tty_console_struct (struct console *con)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 struct tty_console *tcon = (struct tty_console *) con->console_data;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 if (tcon && tcon->term_entry_buffer) /* allocated in term_init () */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 xfree (tcon->term_entry_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 if (tcon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 xfree (tcon);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 tty_delete_console (struct console *con)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 Lstream_close (XLSTREAM (CONSOLE_TTY_DATA (con)->instream));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 Lstream_close (XLSTREAM (CONSOLE_TTY_DATA (con)->outstream));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 if (!CONSOLE_TTY_DATA (con)->is_stdio)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 close (CONSOLE_TTY_DATA (con)->infd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 if (CONSOLE_TTY_DATA (con)->controlling_terminal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 Vcontrolling_terminal = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 unmunge_tty_process_group ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 free_tty_console_struct (con);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 static struct console *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 decode_tty_console (Lisp_Object console)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 XSETCONSOLE (console, decode_console (console));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 CHECK_TTY_CONSOLE (console);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 return XCONSOLE (console);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
213 DEFUN ("console-tty-terminal-type", Fconsole_tty_terminal_type, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 Return the terminal type of TTY console CONSOLE.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
215 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
216 (console))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 return CONSOLE_TTY_DATA (decode_tty_console (console))->terminal_type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
221 DEFUN ("console-tty-controlling-process", Fconsole_tty_controlling_process, 0, 1, 0, /*
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
222 Return the controlling process of TTY console CONSOLE.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
223 */
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
224 (console))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
225 {
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
226 return CONSOLE_TTY_DATA (decode_tty_console (console))->controlling_process;
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
227 }
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
228
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 tty_semi_canonicalize_console_connection (Lisp_Object connection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 {
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
233 return stream_semi_canonicalize_console_connection (connection, errb);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 tty_canonicalize_console_connection (Lisp_Object connection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 {
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
240 return stream_canonicalize_console_connection (connection, errb);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 tty_semi_canonicalize_device_connection (Lisp_Object connection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 {
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
247 return stream_semi_canonicalize_console_connection (connection, errb);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 tty_canonicalize_device_connection (Lisp_Object connection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 {
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
254 return stream_canonicalize_console_connection (connection, errb);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 /* initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 syms_of_console_tty (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 {
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
265 DEFSUBR (Fconsole_tty_terminal_type);
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
266 DEFSUBR (Fconsole_tty_controlling_process);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 defsymbol (&Qterminal_type, "terminal-type");
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 80
diff changeset
268 defsymbol (&Qcontrolling_process, "controlling-process");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 console_type_create_tty (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 INITIALIZE_CONSOLE_TYPE (tty, "tty", "console-tty-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 /* console methods */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 CONSOLE_HAS_METHOD (tty, init_console);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 CONSOLE_HAS_METHOD (tty, mark_console);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 CONSOLE_HAS_METHOD (tty, initially_selected_for_input);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 CONSOLE_HAS_METHOD (tty, delete_console);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 CONSOLE_HAS_METHOD (tty, canonicalize_console_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 CONSOLE_HAS_METHOD (tty, canonicalize_device_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 CONSOLE_HAS_METHOD (tty, semi_canonicalize_console_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 CONSOLE_HAS_METHOD (tty, semi_canonicalize_device_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 vars_of_console_tty (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 Fprovide (Qtty);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 }