Merge branch 'master' into lua-scripting
[screen-lua.git] / src / screen.h
blob0a27d0c45a64613edd0a898dbc9a6dcb7b55f06b
1 /* Copyright (c) 1993-2002
2 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
3 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
4 * Copyright (c) 1987 Oliver Laumann
6 * This program 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 2, or (at your option)
9 * any later version.
11 * This program 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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program (see the file COPYING); if not, write to the
18 * Free Software Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 ****************************************************************
22 * $Id$ FAU
25 #include "os.h"
27 #if defined(__STDC__)
28 # ifndef __P
29 # define __P(a) a
30 # endif
31 #else
32 # ifndef __P
33 # define __P(a) ()
34 # endif
35 # define const
36 #endif
38 #include "osdef.h"
40 #include "ansi.h"
41 #include "sched.h"
42 #include "acls.h"
43 #include "comm.h"
44 #include "layer.h"
45 #include "term.h"
46 #include "script.h"
49 #ifdef DEBUG
50 # define STATIC /* a function that the debugger should see */
51 #else
52 # define STATIC static
53 #endif
55 #ifdef DEBUG
56 # define DEBUGDIR "/tmp/debug"
57 # define debugf(a) do {if(dfp){fprintf a;fflush(dfp);}} while (0)
58 # define debug(x) debugf((dfp,x))
59 # define debug1(x,a) debugf((dfp,x,a))
60 # define debug2(x,a,b) debugf((dfp,x,a,b))
61 # define debug3(x,a,b,c) debugf((dfp,x,a,b,c))
62 extern FILE *dfp;
63 #else
64 # define debugf(a) do {} while (0)
65 # define debug(x) debugf(x)
66 # define debug1(x,a) debugf(x)
67 # define debug2(x,a,b) debugf(x)
68 # define debug3(x,a,b,c) debugf(x)
69 #endif
71 #ifndef DEBUG
72 # define NOASSERT
73 #endif
75 #ifndef NOASSERT
76 # if defined(__STDC__)
77 # define ASSERT(lousy_cpp) do {if (!(lousy_cpp)) {if (!dfp) opendebug(0, 1);debug2("ASSERT("#lousy_cpp") failed file %s line %d\n", __FILE__, __LINE__);abort();}} while (0)
78 # else
79 # define ASSERT(lousy_cpp) do {if (!(lousy_cpp)) {if (!dfp) opendebug(0, 1);debug2("ASSERT(lousy_cpp) failed file %s line %d\n", __FILE__, __LINE__);abort();}} while (0)
80 # endif
81 #else
82 # define ASSERT(lousy_cpp) do {} while (0)
83 #endif
85 /* here comes my own Free: jw. */
86 #define Free(a) {if ((a) == 0) abort(); else free((void *)(a)); (a)=0;}
88 #define Ctrl(c) ((c)&037)
90 #define MAXSTR 512
91 #define MAXARGS 64
92 #define MSGWAIT 5
93 #define MSGMINWAIT 1
94 #define SILENCEWAIT 30
97 * if a nasty user really wants to try a history of 3000 lines on all 10
98 * windows, he will allocate 8 MegaBytes of memory, which is quite enough.
100 #define MAXHISTHEIGHT 3000
101 #define DEFAULTHISTHEIGHT 100
102 #if defined(NAME_MAX) && NAME_MAX < 16
103 # define DEFAULT_BUFFERFILE "/tmp/screen-xchg"
104 #else
105 # define DEFAULT_BUFFERFILE "/tmp/screen-exchange"
106 #endif
109 #if defined(hpux) && !(defined(VSUSP) && defined(VDSUSP) && defined(VWERASE) && defined(VLNEXT))
110 # define HPUX_LTCHARS_HACK
111 #endif
113 struct mode
115 #ifdef POSIX
116 struct termios tio;
117 # ifdef HPUX_LTCHARS_HACK
118 struct ltchars m_ltchars;
119 # endif /* HPUX_LTCHARS_HACK */
120 #else /* POSIX */
121 # ifdef TERMIO
122 struct termio tio;
123 # ifdef CYTERMIO
124 int m_mapkey;
125 int m_mapscreen;
126 int m_backspace;
127 # endif
128 # else /* TERMIO */
129 struct sgttyb m_ttyb;
130 struct tchars m_tchars;
131 struct ltchars m_ltchars;
132 int m_ldisc;
133 int m_lmode;
134 # endif /* TERMIO */
135 #endif /* POSIX */
136 #if defined(KANJI) && defined(TIOCKSET)
137 struct jtchars m_jtchars;
138 int m_knjmode;
139 #endif
143 /* #include "logfile.h" */ /* (requires stat.h) struct logfile */
144 #include "image.h"
145 #include "display.h"
146 #include "window.h"
149 * Parameters for the Detach() routine
151 #define D_DETACH 0
152 #define D_STOP 1
153 #define D_REMOTE 2
154 #define D_POWER 3
155 #define D_REMOTE_POWER 4
156 #define D_LOCK 5
157 #define D_HANGUP 6
160 * Here are the messages the attacher sends to the backend
162 #define MSG_CREATE 0
163 #define MSG_ERROR 1
164 #define MSG_ATTACH 2
165 #define MSG_CONT 3
166 #define MSG_DETACH 4
167 #define MSG_POW_DETACH 5
168 #define MSG_WINCH 6
169 #define MSG_HANGUP 7
170 #define MSG_COMMAND 8
173 * versions of struct msg:
174 * 0: screen version 3.6.6 (version count introduced)
175 * 1: screen version 4.1.0
177 #define MSG_VERSION 1
178 #define MSG_REVISION (('m'<<24) | ('s'<<16) | ('g'<<8) | MSG_VERSION)
179 struct msg
181 int protocol_revision; /* reduce harm done by incompatible messages */
182 int type;
183 char m_tty[MAXPATHLEN]; /* ttyname */
184 union
186 struct
188 int lflag;
189 int aflag;
190 int flowflag;
191 int hheight; /* size of scrollback buffer */
192 int nargs;
193 char line[MAXPATHLEN];
194 char dir[MAXPATHLEN];
195 char screenterm[20]; /* is screen really "screen" ? */
197 create;
198 struct
200 char auser[20 + 1]; /* username */
201 int apid; /* pid of frontend */
202 int adaptflag; /* adapt window size? */
203 int lines, columns; /* display size */
204 char preselect[20];
205 int esc; /* his new escape character unless -1 */
206 int meta_esc; /* his new meta esc character unless -1 */
207 char envterm[20 + 1]; /* terminal type */
208 int encoding; /* encoding of display */
209 int detachfirst; /* whether to detach remote sessions first */
211 attach;
212 struct
214 char duser[20 + 1]; /* username */
215 int dpid; /* pid of frontend */
217 detach;
218 struct
220 char auser[20 + 1]; /* username */
221 int nargs;
222 char cmd[MAXPATHLEN]; /* command */
223 int apid; /* pid of frontend */
224 char preselect[20];
226 command;
227 char message[MAXPATHLEN * 2];
228 } m;
232 * And the signals the attacher receives from the backend
234 #define SIG_BYE SIGHUP
235 #define SIG_POWER_BYE SIGUSR1
236 #define SIG_LOCK SIGUSR2
237 #define SIG_STOP SIGTSTP
238 #ifdef SIGIO
239 #define SIG_NODEBUG SIGIO /* triggerd by command 'debug off' */
240 #endif
243 #define BELL (Ctrl('g'))
244 #define VBELLWAIT 1 /* No. of seconds a vbell will be displayed */
246 #define BELL_ON 0 /* No bell has occurred in the window */
247 #define BELL_FOUND 1 /* A bell has occurred, but user not yet notified */
248 #define BELL_DONE 2 /* A bell has occured, user has been notified */
250 #define BELL_VISUAL 3 /* A bell has occured in fore win, notify him visually */
252 #define MON_OFF 0 /* Monitoring is off in the window */
253 #define MON_ON 1 /* No activity has occurred in the window */
254 #define MON_FOUND 2 /* Activity has occured, but user not yet notified */
255 #define MON_DONE 3 /* Activity has occured, user has been notified */
257 #define DUMP_TERMCAP 0 /* WriteFile() options */
258 #define DUMP_HARDCOPY 1
259 #define DUMP_EXCHANGE 2
260 #define DUMP_SCROLLBACK 3
262 #define SILENCE_OFF 0
263 #define SILENCE_ON 1
265 extern char strnomem[];
268 * line modes used by Input()
270 #define INP_COOKED 0
271 #define INP_NOECHO 1
272 #define INP_RAW 2
273 #define INP_EVERY 4
276 #ifdef MULTIUSER
277 struct acl
279 struct acl *next;
280 char *name;
282 #endif
284 /* register list */
285 #define MAX_PLOP_DEFS 256
287 struct baud_values
289 int idx; /* the index in the bsd-is padding lookup table */
290 int bps; /* bits per seconds */
291 int sym; /* symbol defined in ttydev.h */
295 * windowlist orders
297 #define WLIST_NUM 0
298 #define WLIST_MRU 1
299 #define WLIST_NESTED 2