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