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