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