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