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