Start converting to GPL v3+ (ref: ticket #23900)
[screen-lua.git] / src / screen.h
blob96a345d7caca6c201d5bf7b12a1e26c2fee0db2e
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 3, 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, see
18 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 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"
48 #ifdef DEBUG
49 # define STATIC /* a function that the debugger should see */
50 #else
51 # define STATIC static
52 #endif
54 #ifdef DEBUG
55 # define DEBUGDIR "/tmp/debug"
56 # define debugf(a) do {if(dfp){fprintf a;fflush(dfp);}} while (0)
57 # define debug(x) debugf((dfp,x))
58 # define debug1(x,a) debugf((dfp,x,a))
59 # define debug2(x,a,b) debugf((dfp,x,a,b))
60 # define debug3(x,a,b,c) debugf((dfp,x,a,b,c))
61 extern FILE *dfp;
62 #else
63 # define debugf(a) do {} while (0)
64 # define debug(x) debugf(x)
65 # define debug1(x,a) debugf(x)
66 # define debug2(x,a,b) debugf(x)
67 # define debug3(x,a,b,c) debugf(x)
68 #endif
70 #ifndef DEBUG
71 # define NOASSERT
72 #endif
74 #ifndef NOASSERT
75 # if defined(__STDC__)
76 # 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)
77 # else
78 # 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)
79 # endif
80 #else
81 # define ASSERT(lousy_cpp) do {} while (0)
82 #endif
84 /* here comes my own Free: jw. */
85 #define Free(a) {if ((a) == 0) abort(); else free((void *)(a)); (a)=0;}
87 #define Ctrl(c) ((c)&037)
89 #define MAXSTR 512
90 #define MAXARGS 64
91 #define MSGWAIT 5
92 #define MSGMINWAIT 1
93 #define SILENCEWAIT 30
96 * if a nasty user really wants to try a history of 3000 lines on all 10
97 * windows, he will allocate 8 MegaBytes of memory, which is quite enough.
99 #define MAXHISTHEIGHT 3000
100 #define DEFAULTHISTHEIGHT 100
101 #if defined(NAME_MAX) && NAME_MAX < 16
102 # define DEFAULT_BUFFERFILE "/tmp/screen-xchg"
103 #else
104 # define DEFAULT_BUFFERFILE "/tmp/screen-exchange"
105 #endif
108 #if defined(hpux) && !(defined(VSUSP) && defined(VDSUSP) && defined(VWERASE) && defined(VLNEXT))
109 # define HPUX_LTCHARS_HACK
110 #endif
112 struct mode
114 #ifdef POSIX
115 struct termios tio;
116 # ifdef HPUX_LTCHARS_HACK
117 struct ltchars m_ltchars;
118 # endif /* HPUX_LTCHARS_HACK */
119 #else /* POSIX */
120 # ifdef TERMIO
121 struct termio tio;
122 # ifdef CYTERMIO
123 int m_mapkey;
124 int m_mapscreen;
125 int m_backspace;
126 # endif
127 # else /* TERMIO */
128 struct sgttyb m_ttyb;
129 struct tchars m_tchars;
130 struct ltchars m_ltchars;
131 int m_ldisc;
132 int m_lmode;
133 # endif /* TERMIO */
134 #endif /* POSIX */
135 #if defined(KANJI) && defined(TIOCKSET)
136 struct jtchars m_jtchars;
137 int m_knjmode;
138 #endif
142 /* #include "logfile.h" */ /* (requires stat.h) struct logfile */
143 #include "image.h"
144 #include "display.h"
145 #include "window.h"
148 * Parameters for the Detach() routine
150 #define D_DETACH 0
151 #define D_STOP 1
152 #define D_REMOTE 2
153 #define D_POWER 3
154 #define D_REMOTE_POWER 4
155 #define D_LOCK 5
156 #define D_HANGUP 6
159 * Here are the messages the attacher sends to the backend
161 #define MSG_CREATE 0
162 #define MSG_ERROR 1
163 #define MSG_ATTACH 2
164 #define MSG_CONT 3
165 #define MSG_DETACH 4
166 #define MSG_POW_DETACH 5
167 #define MSG_WINCH 6
168 #define MSG_HANGUP 7
169 #define MSG_COMMAND 8
172 * versions of struct msg:
173 * 0: screen version 3.6.6 (version count introduced)
174 * 1: screen version 4.1.0
176 #define MSG_VERSION 1
177 #define MSG_REVISION (('m'<<24) | ('s'<<16) | ('g'<<8) | MSG_VERSION)
178 struct msg
180 int protocol_revision; /* reduce harm done by incompatible messages */
181 int type;
182 char m_tty[MAXPATHLEN]; /* ttyname */
183 union
185 struct
187 int lflag;
188 int aflag;
189 int flowflag;
190 int hheight; /* size of scrollback buffer */
191 int nargs;
192 char line[MAXPATHLEN];
193 char dir[MAXPATHLEN];
194 char screenterm[20]; /* is screen really "screen" ? */
196 create;
197 struct
199 char auser[20 + 1]; /* username */
200 int apid; /* pid of frontend */
201 int adaptflag; /* adapt window size? */
202 int lines, columns; /* display size */
203 char preselect[20];
204 int esc; /* his new escape character unless -1 */
205 int meta_esc; /* his new meta esc character unless -1 */
206 char envterm[20 + 1]; /* terminal type */
207 int encoding; /* encoding of display */
208 int detachfirst; /* whether to detach remote sessions first */
210 attach;
211 struct
213 char duser[20 + 1]; /* username */
214 int dpid; /* pid of frontend */
216 detach;
217 struct
219 char auser[20 + 1]; /* username */
220 int nargs;
221 char cmd[MAXPATHLEN]; /* command */
222 int apid; /* pid of frontend */
223 char preselect[20];
225 command;
226 char message[MAXPATHLEN * 2];
227 } m;
231 * And the signals the attacher receives from the backend
233 #define SIG_BYE SIGHUP
234 #define SIG_POWER_BYE SIGUSR1
235 #define SIG_LOCK SIGUSR2
236 #define SIG_STOP SIGTSTP
237 #ifdef SIGIO
238 #define SIG_NODEBUG SIGIO /* triggerd by command 'debug off' */
239 #endif
242 #define BELL (Ctrl('g'))
243 #define VBELLWAIT 1 /* No. of seconds a vbell will be displayed */
245 #define BELL_ON 0 /* No bell has occurred in the window */
246 #define BELL_FOUND 1 /* A bell has occurred, but user not yet notified */
247 #define BELL_DONE 2 /* A bell has occured, user has been notified */
249 #define BELL_VISUAL 3 /* A bell has occured in fore win, notify him visually */
251 #define MON_OFF 0 /* Monitoring is off in the window */
252 #define MON_ON 1 /* No activity has occurred in the window */
253 #define MON_FOUND 2 /* Activity has occured, but user not yet notified */
254 #define MON_DONE 3 /* Activity has occured, user has been notified */
256 #define DUMP_TERMCAP 0 /* WriteFile() options */
257 #define DUMP_HARDCOPY 1
258 #define DUMP_EXCHANGE 2
259 #define DUMP_SCROLLBACK 3
261 #define SILENCE_OFF 0
262 #define SILENCE_ON 1
264 extern char strnomem[];
267 * line modes used by Input()
269 #define INP_COOKED 0
270 #define INP_NOECHO 1
271 #define INP_RAW 2
272 #define INP_EVERY 4
275 #ifdef MULTIUSER
276 struct acl
278 struct acl *next;
279 char *name;
281 #endif
283 /* register list */
284 #define MAX_PLOP_DEFS 256
286 struct baud_values
288 int idx; /* the index in the bsd-is padding lookup table */
289 int bps; /* bits per seconds */
290 int sym; /* symbol defined in ttydev.h */
294 * windowlist orders
296 #define WLIST_NUM 0
297 #define WLIST_MRU 1
298 #define WLIST_NESTED 2