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