428
|
1 /* Processes implementation header
|
|
2 Copyright (C) 1985, 1992, 1993, 1994 Free Software Foundation, Inc.
|
853
|
3 Copyright (C) 2002 Ben Wing.
|
428
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* This file must be only included by the process implementation files:
|
|
23 process-unix.c, process-msw.c etc. The Lisp_Process structure and other
|
|
24 contents of this file is not exported to the rest of the world */
|
|
25
|
440
|
26 #ifndef INCLUDED_procimpl_h_
|
|
27 #define INCLUDED_procimpl_h_
|
428
|
28
|
|
29 /*
|
|
30 * Structure which keeps methods of the process implementation.
|
|
31 * There is only one object of this class exists in a particular
|
|
32 * XEmacs implementation.
|
|
33 */
|
|
34
|
|
35 /* #### Comment me... */
|
|
36
|
|
37 struct process_methods
|
|
38 {
|
440
|
39 void (*mark_process_data) (Lisp_Process *proc);
|
|
40 void (*print_process_data) (Lisp_Process *proc, Lisp_Object printcharfun);
|
|
41 void (*finalize_process_data) (Lisp_Process *proc, int for_disksave);
|
|
42 void (*alloc_process_data) (Lisp_Process *p);
|
|
43 void (*init_process_io_handles) (Lisp_Process *p,
|
853
|
44 void* in, void* out, void *err, int flags);
|
440
|
45 int (*create_process) (Lisp_Process *p,
|
428
|
46 Lisp_Object *argv, int nargv,
|
853
|
47 Lisp_Object program, Lisp_Object cur_dir,
|
|
48 int separate_err);
|
440
|
49 int (*tooltalk_connection_p) (Lisp_Process *p);
|
428
|
50 #ifdef HAVE_SOCKETS
|
|
51 void (*open_network_stream) (Lisp_Object name, Lisp_Object host,
|
|
52 Lisp_Object service, Lisp_Object protocol,
|
|
53 void** vinfd, void** voutfd);
|
|
54 #ifdef HAVE_MULTICAST
|
|
55 void (*open_multicast_group) (Lisp_Object name, Lisp_Object dest,
|
|
56 Lisp_Object port, Lisp_Object ttl,
|
|
57 void** vinfd, void** voutfd);
|
|
58 #endif /* HAVE_MULTICAST */
|
|
59 #endif /* HAVE_SOCKETS */
|
|
60 Lisp_Object (*canonicalize_host_name) (Lisp_Object host);
|
440
|
61 int (*set_window_size) (Lisp_Process* p, int height, int width);
|
428
|
62 void (*send_process) (Lisp_Object proc, struct lstream* lstream);
|
|
63 void (*reap_exited_processes) (void);
|
440
|
64 void (*update_status_if_terminated) (Lisp_Process* p);
|
428
|
65 void (*kill_child_process) (Lisp_Object proc, int signo,
|
|
66 int current_group, int nomsg);
|
|
67 int (*kill_process_by_pid) (int pid, int sigcode);
|
|
68 int (*process_send_eof) (Lisp_Object proc);
|
440
|
69 Lisp_Object (*get_tty_name) (Lisp_Process *p);
|
853
|
70 void (*deactivate_process) (Lisp_Process *p,
|
|
71 USID* in_usid,
|
|
72 USID* err_usid);
|
428
|
73 void (*init_process) (void);
|
|
74 };
|
|
75
|
|
76 extern struct process_methods the_process_methods;
|
|
77
|
|
78 /*
|
|
79 * Accessors for process_methods
|
|
80 */
|
|
81
|
|
82 #define HAS_PROCMETH_P(name) (the_process_methods.name != 0)
|
|
83 #define PROCMETH(name, par) ((the_process_methods.name) par)
|
|
84 #define PROCMETH_OR_GIVEN(name, par, given) (HAS_PROCMETH_P(name) ? PROCMETH(name, par) : (given))
|
|
85 #define MAYBE_PROCMETH(name, par) do { if (HAS_PROCMETH_P(name)) PROCMETH(name, par); } while (0);
|
|
86 #define MAYBE_LISP_PROCMETH(name, par) PROCMETH_OR_GIVEN(name, par, Qnil)
|
|
87 #define MAYBE_INT_PROCMETH(name, par) PROCMETH_OR_GIVEN(name, par, 0)
|
|
88 #define PROCESS_HAS_METHOD(os, name) the_process_methods.name = os##_##name
|
|
89
|
|
90 /*
|
|
91 * Structure records pertinent information about open channels.
|
|
92 * There is one channel associated with each process.
|
|
93 */
|
|
94
|
|
95 struct Lisp_Process
|
|
96 {
|
|
97 struct lcrecord_header header;
|
|
98 /* Name of this process */
|
|
99 Lisp_Object name;
|
|
100 /* List of command arguments that this process was run with */
|
|
101 Lisp_Object command;
|
|
102 /* (funcall FILTER PROC STRING) (if FILTER is non-nil)
|
|
103 to dispose of a bunch of chars from the process all at once */
|
|
104 Lisp_Object filter;
|
853
|
105 /* (funcall FILTER PROC STRING) (if FILTER is non-nil)
|
|
106 to dispose of a bunch of chars from the stderr of process all at once */
|
|
107 Lisp_Object stderr_filter;
|
428
|
108 /* (funcall SENTINEL PROCESS) when process state changes */
|
|
109 Lisp_Object sentinel;
|
853
|
110 /* Buffer that output or stderr output is going to */
|
|
111 Lisp_Object buffer, stderr_buffer;
|
428
|
112 /* Marker set to end of last buffer-inserted output from this process */
|
853
|
113 Lisp_Object mark, stderr_mark;
|
428
|
114 /* Lisp_Int of subprocess' PID, or a cons of
|
|
115 service/host if this is really a network connection */
|
|
116 Lisp_Object pid;
|
|
117
|
|
118 /* Symbol indicating status of process.
|
|
119 This may be a symbol: run, stop, exit, signal */
|
|
120 Lisp_Object status_symbol;
|
|
121
|
|
122 /* Exit code if process has terminated,
|
|
123 signal which stopped/interrupted process
|
|
124 or 0 if process is running */
|
|
125 int exit_code;
|
|
126 /* Non-false if process has exited and "dumped core" on its way down */
|
|
127 char core_dumped;
|
|
128
|
|
129 /* This next field is only actually used #ifdef ENERGIZE */
|
|
130 /* if this flag is not NIL, then filter will do the read on the
|
|
131 channel, rather than having a call to make_string.
|
|
132 This only works if the filter is a subr. */
|
|
133 char filter_does_read;
|
853
|
134 /* Non-zero means kill silently if Emacs is exited. */
|
428
|
135 char kill_without_query;
|
853
|
136 char in_selected, err_selected;
|
428
|
137 /* Event-count of last event in which this process changed status. */
|
|
138 volatile int tick;
|
|
139 /* Event-count of last such event reported. */
|
|
140 int update_tick;
|
853
|
141 /* Non-zero if stderr and stdout are separated. */
|
|
142 char separate_stderr;
|
428
|
143 /* Low level streams used in input and output, connected to child */
|
|
144 Lisp_Object pipe_instream;
|
|
145 Lisp_Object pipe_outstream;
|
853
|
146 Lisp_Object pipe_errstream;
|
428
|
147 /* Data end streams, decoding and encoding pipe_* streams */
|
|
148 Lisp_Object coding_instream;
|
|
149 Lisp_Object coding_outstream;
|
853
|
150 Lisp_Object coding_errstream;
|
428
|
151
|
|
152 /* Implementation dependent data */
|
|
153 void *process_data;
|
|
154 };
|
|
155
|
|
156 /* Macros to refer to data connection streams */
|
|
157 #define DATA_INSTREAM(p) (p)->coding_instream
|
|
158 #define DATA_OUTSTREAM(p) (p)->coding_outstream
|
853
|
159 #define DATA_ERRSTREAM(p) (p)->coding_errstream
|
428
|
160
|
|
161 /* Random externs from process.c */
|
|
162 extern Lisp_Object Qrun, Qstop, Qopen, Qclosed;
|
|
163 extern Lisp_Object Qtcp, Qudp;
|
|
164 extern Lisp_Object Vprocess_connection_type;
|
|
165 extern Lisp_Object Vprocess_list;
|
|
166
|
|
167 extern struct hash_table *usid_to_process;
|
|
168
|
|
169 extern volatile int process_tick;
|
|
170
|
|
171 extern int windowed_process_io;
|
|
172
|
|
173 #ifdef HAVE_MULTICAST
|
|
174 extern Lisp_Object Qmulticast;
|
|
175 #endif
|
|
176
|
|
177 #ifdef PROCESS_IO_BLOCKING
|
|
178 extern Lisp_Object network_stream_blocking_port_list;
|
|
179 #endif /* PROCESS_IO_BLOCKING */
|
|
180
|
|
181 Lisp_Object make_process_internal (Lisp_Object name);
|
440
|
182 void init_process_io_handles (Lisp_Process *p, void* in,
|
853
|
183 void* out, void *err, int flags);
|
428
|
184 void send_process (Lisp_Object proc,
|
|
185 Lisp_Object relocatable,
|
867
|
186 const Ibyte *nonrelocatable,
|
428
|
187 int start, int len);
|
|
188
|
440
|
189 #endif /* INCLUDED_procimpl_h_ */
|