Release v.5.0.0
[screen.git] / src / screen.h
blob308c365bce04a97cbcf09e0ccd46568c35e1fdc8
1 /* Copyright (c) 2008, 2009
2 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
3 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
4 * Micah Cowan (micah@cowan.name)
5 * Sadrul Habib Chowdhury (sadrul@users.sourceforge.net)
6 * Copyright (c) 1993-2002, 2003, 2005, 2006, 2007
7 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
8 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
9 * Copyright (c) 1987 Oliver Laumann
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3, or (at your option)
14 * any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program (see the file COPYING); if not, see
23 * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 ****************************************************************
27 * $Id$ GNU
30 #ifndef SCREEN_SCREEN_H
31 #define SCREEN_SCREEN_H
33 #include "config.h"
35 #include <stdbool.h>
37 #include "os.h"
39 /* here comes my own Free: jw. */
40 #define Free(a) {if ((a) == NULL) abort(); else free((void *)(a)); (a)=NULL;}
42 #define Ctrl(c) ((c)&037)
44 #define MAXSTR 768
45 #define MAXARGS 64
46 #define MSGWAIT 5
47 #define MSGMINWAIT 1
48 #define SILENCEWAIT 30
51 * if a nasty user really wants to try a history of 3000 lines on all 10
52 * windows, he will allocate 8 MegaBytes of memory, which is quite enough.
54 #define MAXHISTHEIGHT 3000
55 #define DEFAULTHISTHEIGHT 100
56 #define DEFAULT_BUFFERFILE "/tmp/screen-exchange"
58 struct mode {
59 struct termios tio;
60 #if defined(TIOCKSET)
61 struct jtchars m_jtchars;
62 int m_knjmode;
63 #endif
67 #include "ansi.h"
68 #include "image.h"
69 #include "layer.h"
70 #include "sched.h"
71 #include "term.h"
72 #include "window.h"
75 * Parameters for the Detach() routine
77 #define D_DETACH 0
78 #define D_STOP 1
79 #define D_REMOTE 2
80 #define D_POWER 3
81 #define D_REMOTE_POWER 4
82 #define D_LOCK 5
83 #define D_HANGUP 6
86 * Here are the messages the attacher sends to the backend
88 #define MSG_CREATE 0
89 #define MSG_ERROR 1
90 #define MSG_ATTACH 2
91 #define MSG_CONT 3
92 #define MSG_DETACH 4
93 #define MSG_POW_DETACH 5
94 #define MSG_WINCH 6
95 #define MSG_HANGUP 7
96 #define MSG_COMMAND 8
97 #define MSG_QUERY 9
100 * versions of struct Message:
101 * 0: screen version 3.6.6 (version count introduced)
102 * 1: screen version 4.1.0devel (revisions e3fc19a upto 8147d08)
103 * A few revisions after 8147d08 incorrectly
104 * carried version 1, but should have carried 2.
105 * 2: screen version 4.1.0devel (revisions 8b46d8a upto YYYYYYY)
106 * 3: screen version 4.2.0 (was incorrectly originally. Patched here)
107 * 4: screen version 4.2.1 (bumped once again due to changed terminal and login length)
109 #define MSG_VERSION 4
111 #define MSG_REVISION (('m'<<24) | ('s'<<16) | ('g'<<8) | MSG_VERSION)
112 typedef struct Message Message;
113 struct Message {
114 int protocol_revision; /* reduce harm done by incompatible messages */
115 int type;
116 char m_tty[MAXPATHLEN]; /* ttyname */
117 union {
118 struct {
119 int lflag;
120 int Lflag;
121 bool aflag;
122 int flowflag;
123 int hheight; /* size of scrollback buffer */
124 int nargs;
125 char line[MAXPATHLEN];
126 char dir[MAXPATHLEN];
127 char screenterm[MAXTERMLEN + 1];/* is screen really "screen" ? */
128 } create;
129 struct {
130 char auser[MAXLOGINLEN + 1]; /* username */
131 pid_t apid; /* pid of frontend */
132 int adaptflag; /* adapt window size? */
133 int lines, columns; /* display size */
134 char preselect[20];
135 int esc; /* his new escape character unless -1 */
136 int meta_esc; /* his new meta esc character unless -1 */
137 char envterm[MAXTERMLEN + 1]; /* terminal type */
138 int encoding; /* encoding of display */
139 int detachfirst; /* whether to detach remote sessions first */
140 } attach;
141 struct {
142 char duser[MAXLOGINLEN + 1]; /* username */
143 pid_t dpid; /* pid of frontend */
144 } detach;
145 struct {
146 char auser[MAXLOGINLEN + 1]; /* username */
147 int nargs;
148 char cmd[MAXPATHLEN + 1]; /* command */
149 pid_t apid; /* pid of frontend */
150 char preselect[20];
151 char writeback[MAXPATHLEN]; /* The socket to write the result.
152 Only used for MSG_QUERY */
153 } command;
154 char message[MAXPATHLEN * 2];
155 } m;
159 * And the signals the attacher receives from the backend
161 #define SIG_BYE SIGHUP
162 #define SIG_POWER_BYE SIGUSR1
163 #define SIG_LOCK SIGUSR2
164 #define SIG_STOP SIGTSTP
166 #define BELL (Ctrl('g'))
167 #define VBELLWAIT 1 /* No. of seconds a vbell will be displayed */
169 #define BELL_ON 0 /* No bell has occurred in the window */
170 #define BELL_FOUND 1 /* A bell has occurred, but user not yet notified */
171 #define BELL_DONE 2 /* A bell has occured, user has been notified */
173 #define BELL_VISUAL 3 /* A bell has occured in fore win, notify him visually */
175 #define MON_OFF 0 /* Monitoring is off in the window */
176 #define MON_ON 1 /* No activity has occurred in the window */
177 #define MON_FOUND 2 /* Activity has occured, but user not yet notified */
178 #define MON_DONE 3 /* Activity has occured, user has been notified */
180 #define DUMP_TERMCAP 0 /* WriteFile() options */
181 #define DUMP_HARDCOPY 1
182 #define DUMP_EXCHANGE 2
183 #define DUMP_SCROLLBACK 3
185 #define SILENCE_OFF 0 /* Not checking for silence */
186 #define SILENCE_ON 1 /* Window being monitored for silence */
187 #define SILENCE_FOUND 2 /* Window is silent */
188 #define SILENCE_DONE 3 /* Window is silent and user is notified */
191 * line modes used by Input()
193 #define INP_COOKED 0
194 #define INP_NOECHO 1
195 #define INP_RAW 2
196 #define INP_EVERY 4
199 struct acl
201 struct acl *next;
202 char *name;
205 /* register list */
206 #define MAX_PLOP_DEFS 256
208 struct baud_values {
209 int bps; /* bits per seconds */
210 int sym; /* symbol defined in bits/termios.h */
214 * windowlist orders
216 #define WLIST_NUM 0
217 #define WLIST_MRU 1
218 #define WLIST_NESTED 2
220 void SigHup (int);
221 void eexit (int) __attribute__((__noreturn__));
222 void Detach (int);
223 void Hangup (void);
224 void Kill (pid_t, int);
225 void Msg (int, const char *, ...) __attribute__((format(printf, 2, 3)));
226 void Panic (int, const char *, ...) __attribute__((format(printf, 2, 3))) __attribute__((__noreturn__));
227 void QueryMsg (int, const char *, ...) __attribute__((format(printf, 2, 3)));
228 void Dummy (int, const char *, ...) __attribute__((format(printf, 2, 3)));
229 void Finit (int) __attribute__((__noreturn__));
230 void MakeNewEnv (void);
231 void PutWinMsg (char *, int, int);
232 void setbacktick (int, int, int, char **);
234 /* global variables */
236 /* Content of the tty symlink when attach_tty_is_in_new_ns == true. */
237 extern char attach_tty_name_in_ns[];
238 extern char strnomem[];
239 extern char HostName[];
240 extern char SocketPath[MAXPATHLEN];
241 extern char *attach_tty;
242 extern char *attach_term;
243 extern char *captionstring;
244 extern char *hardcopydir;
245 extern char *home;
246 extern char *hstatusstring;
247 extern char *logtstamp_string;
248 extern char *multi;
249 extern char *preselect;
250 extern char *screenencodings;
251 extern char *screenlogfile;
252 extern char *wliststr;
253 extern char *wlisttit;
254 extern char *ActivityString;
255 extern char *BellString;
256 extern char *BufferFile;
257 extern char *LoginName;
258 extern char *PowDetachString;
259 extern char *RcFileName;
260 extern char *ShellArgs[];
261 extern char *ShellProg;
262 extern char *SocketMatch;
263 extern char *SocketName;
264 extern char *VisualBellString;
265 extern char **NewEnv;
267 extern bool adaptflag;
268 extern bool auto_detach;
269 extern bool cjkwidth;
270 extern bool default_startup;
271 extern bool do_auth;
272 extern bool hastruecolor;
273 extern bool iflag;
274 extern bool logtstamp_on;
275 extern bool lsflag;
276 extern bool quietflag;
277 extern bool wipeflag;
278 extern bool xflag;
279 /* Indicator whether the current tty exists in another namespace. */
280 extern bool attach_tty_is_in_new_ns;
282 extern int af;
283 extern int attach_fd;
284 extern int dflag;
285 extern int force_vt;
286 extern int log_flush;
287 extern int logtstamp_after;
288 extern uid_t multi_uid;
289 extern int multiattach;
290 extern int nversion;
291 extern uid_t own_uid;
292 extern int queryflag;
293 extern int rflag;
294 extern int tty_mode;
295 extern int tty_oldmode;
296 extern pid_t MasterPid;
297 extern int MsgMinWait;
298 extern int MsgWait;
299 extern int ServerSocket;
300 extern int SilenceWait;
301 extern int VBellWait;
302 extern int ZombieKey_destroy;
303 extern int ZombieKey_onerror;
304 extern int ZombieKey_resurrect;
306 extern Window *console_window;
307 extern Window *fore;
308 extern Window *mru_window;
309 extern Window *first_window;
310 extern Window *last_window;
312 extern Layer *flayer;
314 extern Event logflushev;
315 extern Event serv_read;
317 extern struct mode attach_Mode;
319 extern gid_t eff_gid;
320 extern gid_t real_gid;
322 extern uid_t eff_uid;
323 extern uid_t real_uid;
325 extern struct passwd *ppp;
327 #endif /* SCREEN_SCREEN_H */