Several items:
[unix-history] / usr / src / usr.bin / telnet / externs.h
CommitLineData
897ce52e
KB
1/*
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
b36fc510
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
897ce52e 16 *
87b60187 17 * @(#)externs.h 1.21 (Berkeley) %G%
897ce52e
KB
18 */
19
7daa10bf
PB
20#ifndef BSD
21# define BSD 43
22#endif
23
24#if (BSD > 43 || defined(SYSV_TERMIO)) && !defined(USE_TERMIO)
25# define USE_TERMIO
6055a9f6
PB
26#endif
27
ad54d2e3
GM
28#include <stdio.h>
29#include <setjmp.h>
6055a9f6
PB
30#include <sys/ioctl.h>
31#ifdef USE_TERMIO
7daa10bf
PB
32# ifndef VINTR
33# ifdef SYSV_TERMIO
34# include <sys/termio.h>
35# else
36# include <sys/termios.h>
37# define termio termios
38# endif
39# endif
87b60187
PB
40#else
41typedef char cc_t;
6055a9f6 42#endif
ad54d2e3 43
6055a9f6 44#define SUBBUFSIZE 256
ad54d2e3
GM
45
46extern int errno; /* outside this world */
47
2e48960f
GM
48extern char
49 *strcat(),
50 *strcpy(); /* outside this world */
51
ad54d2e3 52extern int
2e48960f
GM
53 flushout, /* flush output */
54 connected, /* Are we connected to the other side? */
55 globalmode, /* Mode tty should be in */
56 In3270, /* Are we in 3270 mode? */
57 telnetport, /* Are we connected to the telnet port? */
445e62ba 58 localflow, /* Flow control handled locally */
2e48960f
GM
59 localchars, /* we recognize interrupt/quit */
60 donelclchars, /* the user has set "localchars" */
61 showoptions,
344def17
GM
62 net, /* Network file descriptor */
63 tin, /* Terminal input file descriptor */
2e48960f
GM
64 tout, /* Terminal output file descriptor */
65 crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
66 autoflush, /* flush output when interrupting? */
67 autosynch, /* send interrupt characters with SYNCH? */
68 SYNCHing, /* Is the stream in telnet SYNCH mode? */
69 donebinarytoggle, /* the user has put us in binary */
70 dontlecho, /* do we suppress local echoing right now? */
71 crmod,
72 netdata, /* Print out network data flow */
6055a9f6 73 prettydump, /* Print "netdata" output in user readable format */
40cc3fc2
GM
74#if defined(unix)
75#if defined(TN3270)
76 cursesdata, /* Print out curses data flow */
a0b02dfa 77 apitrace, /* Trace API transactions */
40cc3fc2
GM
78#endif /* defined(TN3270) */
79 termdata, /* Print out terminal data flow */
80#endif /* defined(unix) */
2e48960f 81 debug; /* Debug level */
ad54d2e3 82
87b60187 83extern cc_t
7daa10bf 84 echoc, /* Toggle local echoing */
87b60187
PB
85 escape; /* Escape to command mode */
86
87extern unsigned char
7daa10bf
PB
88 *prompt; /* Prompt for command. */
89
ad54d2e3 90extern char
2e48960f
GM
91 doopt[],
92 dont[],
93 will[],
94 wont[],
32d22a68 95 options[], /* All the little options */
7daa10bf 96 *hostname; /* Who are we connected to? */
ad54d2e3 97
32d22a68
GM
98/*
99 * We keep track of each side of the option negotiation.
100 */
101
6055a9f6
PB
102#define MY_STATE_WILL 0x01
103#define MY_WANT_STATE_WILL 0x02
104#define MY_STATE_DO 0x04
105#define MY_WANT_STATE_DO 0x08
106
107/*
108 * Macros to check the current state of things
109 */
110
111#define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
112#define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
113#define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
114#define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
115
116#define my_state_is_dont(opt) (!my_state_is_do(opt))
117#define my_state_is_wont(opt) (!my_state_is_will(opt))
118#define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
119#define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
120
121#define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;}
122#define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;}
123#define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;}
124#define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;}
125
126#define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;}
127#define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;}
128#define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;}
129#define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;}
32d22a68
GM
130
131/*
6055a9f6 132 * Make everything symetrical
32d22a68
GM
133 */
134
6055a9f6
PB
135#define HIS_STATE_WILL MY_STATE_DO
136#define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
137#define HIS_STATE_DO MY_STATE_WILL
138#define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
139
140#define his_state_is_do my_state_is_will
141#define his_state_is_will my_state_is_do
142#define his_want_state_is_do my_want_state_is_will
143#define his_want_state_is_will my_want_state_is_do
144
145#define his_state_is_dont my_state_is_wont
146#define his_state_is_wont my_state_is_dont
147#define his_want_state_is_dont my_want_state_is_wont
148#define his_want_state_is_wont my_want_state_is_dont
149
150#define set_his_state_do set_my_state_will
151#define set_his_state_will set_my_state_do
152#define set_his_want_state_do set_my_want_state_will
153#define set_his_want_state_will set_my_want_state_do
154
155#define set_his_state_dont set_my_state_wont
156#define set_his_state_wont set_my_state_dont
157#define set_his_want_state_dont set_my_want_state_wont
158#define set_his_want_state_wont set_my_want_state_dont
32d22a68 159
32d22a68 160
ad54d2e3 161extern FILE
2e48960f 162 *NetTrace; /* Where debugging output goes */
7daa10bf 163extern unsigned char
6055a9f6
PB
164 NetTraceFile[]; /* Name of file where debugging output goes */
165extern void
166 SetNetTrace(); /* Function to change where debugging goes */
ad54d2e3
GM
167
168extern jmp_buf
2e48960f
GM
169 peerdied,
170 toplevel; /* For error conditions. */
ad54d2e3
GM
171
172extern void
80a47e22 173 command(),
746dd3e1 174#if !defined(NOT43)
2e48960f 175 dosynch(),
746dd3e1 176#endif /* !defined(NOT43) */
6570c863 177 get_status(),
80a47e22
GM
178 Dump(),
179 init_3270(),
180 printoption(),
181 printsub(),
445e62ba 182 sendnaws(),
2e48960f 183 setconnmode(),
80a47e22
GM
184 setcommandmode(),
185 setneturg(),
186 sys_telnet_init(),
187 telnet(),
188 TerminalFlushOutput(),
189 TerminalNewMode(),
190 TerminalRestoreState(),
191 TerminalSaveState(),
192 tninit(),
193 upcase(),
194 willoption(),
195 wontoption();
ad54d2e3 196
746dd3e1
GM
197#if defined(NOT43)
198extern int
199 dosynch();
200#endif /* defined(NOT43) */
201
7daa10bf 202#ifndef USE_TERMIO
6055a9f6
PB
203
204extern struct tchars ntc;
205extern struct ltchars nltc;
206extern struct sgttyb nttyb;
207
7daa10bf
PB
208# define termEofChar ntc.t_eofc
209# define termEraseChar nttyb.sg_erase
210# define termFlushChar nltc.t_flushc
211# define termIntChar ntc.t_intrc
212# define termKillChar nttyb.sg_kill
213# define termLiteralNextChar nltc.t_lnextc
214# define termQuitChar ntc.t_quitc
215# define termSuspChar nltc.t_suspc
216# define termRprntChar nltc.t_rprntc
217# define termWerasChar nltc.t_werasc
218# define termStartChar ntc.t_startc
219# define termStopChar ntc.t_stopc
87b60187
PB
220# define termForw1Char ntc.t_brkc
221extern char termForw2Char;
222
223# define termEofCharp (cc_t *)&ntc.t_eofc
224# define termEraseCharp (cc_t *)&nttyb.sg_erase
225# define termFlushCharp (cc_t *)&nltc.t_flushc
226# define termIntCharp (cc_t *)&ntc.t_intrc
227# define termKillCharp (cc_t *)&nttyb.sg_kill
228# define termLiteralNextCharp (cc_t *)&nltc.t_lnextc
229# define termQuitCharp (cc_t *)&ntc.t_quitc
230# define termSuspCharp (cc_t *)&nltc.t_suspc
231# define termRprntCharp (cc_t *)&nltc.t_rprntc
232# define termWerasCharp (cc_t *)&nltc.t_werasc
233# define termStartCharp (cc_t *)&ntc.t_startc
234# define termStopCharp (cc_t *)&ntc.t_stopc
235# define termForw1Charp (cc_t *)&ntc.t_brkc
236# define termForw2Charp (cc_t *)&termForw2Char
6055a9f6
PB
237
238# else
239
240extern struct termio new_tc;
241
7daa10bf
PB
242# define termEofChar new_tc.c_cc[VEOF]
243# define termEraseChar new_tc.c_cc[VERASE]
244# define termIntChar new_tc.c_cc[VINTR]
245# define termKillChar new_tc.c_cc[VKILL]
246# define termQuitChar new_tc.c_cc[VQUIT]
6055a9f6 247
7daa10bf
PB
248# ifndef VSUSP
249extern char termSuspChar;
6055a9f6 250# else
7daa10bf
PB
251# define termSuspChar new_tc.c_cc[VSUSP]
252# endif
253# ifndef VFLUSHO
254extern char termFlushChar;
255# else
256# define termFlushChar new_tc.c_cc[VFLUSHO]
257# endif
258# ifndef VWERASE
259extern char termWerasChar;
260# else
261# define termWerasChar new_tc.c_cc[VWERASE]
6055a9f6 262# endif
7daa10bf
PB
263# ifndef VREPRINT
264extern char termRprntChar;
265# else
266# define termRprntChar new_tc.c_cc[VREPRINT]
267# endif
268# ifndef VLNEXT
269extern char termLiteralNextChar;
270# else
271# define termLiteralNextChar new_tc.c_cc[VLNEXT]
272# endif
273# ifndef VSTART
274extern char termStartChar;
275# else
276# define termStartChar new_tc.c_cc[VSTART]
277# endif
278# ifndef VSTOP
279extern char termStopChar;
280# else
281# define termStopChar new_tc.c_cc[VSTOP]
282# endif
87b60187
PB
283# ifndef VEOL
284extern char termForw1Char;
285# else
286# define termForw1Char new_tc.c_cc[VEOL]
287# endif
288# ifndef VEOL2
289extern char termForw2Char;
290# else
291# define termForw2Char new_tc.c_cc[VEOL]
292# endif
7daa10bf
PB
293
294# ifndef CRAY
295# define termEofCharp &termEofChar
296# define termEraseCharp &termEraseChar
297# define termIntCharp &termIntChar
298# define termKillCharp &termKillChar
299# define termQuitCharp &termQuitChar
6055a9f6
PB
300# define termSuspCharp &termSuspChar
301# define termFlushCharp &termFlushChar
302# define termWerasCharp &termWerasChar
303# define termRprntCharp &termRprntChar
304# define termLiteralNextCharp &termLiteralNextChar
305# define termStartCharp &termStartChar
306# define termStopCharp &termStopChar
87b60187
PB
307# define termForw1Charp &termForw1Char
308# define termForw2Charp &termForw2Char
7daa10bf
PB
309# else
310 /* Work around a compiler bug */
311# define termEofCharp 0
312# define termEraseCharp 0
313# define termIntCharp 0
314# define termKillCharp 0
315# define termQuitCharp 0
316# define termSuspCharp 0
317# define termFlushCharp 0
318# define termWerasCharp 0
319# define termRprntCharp 0
320# define termLiteralNextCharp 0
321# define termStartCharp 0
322# define termStopCharp 0
87b60187
PB
323# define termForw1Charp 0
324# define termForw2Charp 0
6055a9f6 325# endif
6055a9f6
PB
326#endif
327
115a5494
GM
328
329/* Ring buffer structures which are shared */
330
331extern Ring
2e48960f
GM
332 netoring,
333 netiring,
334 ttyoring,
335 ttyiring;
336
337/* Tn3270 section */
338#if defined(TN3270)
339
340extern int
341 HaveInput, /* Whether an asynchronous I/O indication came in */
4ad36dea
GM
342 noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */
343 noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */
344 sigiocount, /* Count of SIGIO receptions */
2e48960f
GM
345 shell_active; /* Subshell is active */
346
347extern char
348 *Ibackp, /* Oldest byte of 3270 data */
349 Ibuf[], /* 3270 buffer */
350 *Ifrontp, /* Where next 3270 byte goes */
351 tline[],
352 *transcom; /* Transparent command */
353
354extern int
355 settranscom();
356
357extern void
358 inputAvailable();
359#endif /* defined(TN3270) */