xref: /csrg-svn/usr.bin/telnet/externs.h (revision 46808)
133685Sbostic /*
245230Sborman  * Copyright (c) 1988, 1990 Regents of the University of California.
333685Sbostic  * All rights reserved.
433685Sbostic  *
542770Sbostic  * %sccs.include.redist.c%
633685Sbostic  *
7*46808Sdab  *	@(#)externs.h	5.2 (Berkeley) 03/01/91
833685Sbostic  */
933685Sbostic 
1039529Sborman #ifndef	BSD
1139529Sborman # define BSD 43
1238689Sborman #endif
1338689Sborman 
1439529Sborman #if (BSD > 43 || defined(SYSV_TERMIO)) && !defined(USE_TERMIO)
1539529Sborman # define USE_TERMIO
1639529Sborman #endif
1739529Sborman 
1832141Sminshall #include <stdio.h>
1932141Sminshall #include <setjmp.h>
2044360Sborman #ifndef	FILIO_H
2138689Sborman #include <sys/ioctl.h>
2244360Sborman #else
2344360Sborman #include <sys/filio.h>
2444360Sborman #endif
2538689Sborman #ifdef	USE_TERMIO
2639529Sborman # ifndef	VINTR
2739529Sborman #  ifdef SYSV_TERMIO
2839529Sborman #   include <sys/termio.h>
2939529Sborman #  else
3039529Sborman #   include <sys/termios.h>
3139529Sborman #   define termio termios
3239529Sborman #  endif
3339529Sborman # endif
3444360Sborman #endif
3544360Sborman #if defined(NO_CC_T) || !defined(USE_TERMIO)
3644360Sborman # if !defined(USE_TERMIO)
3740245Sborman typedef char cc_t;
3844360Sborman # else
3944360Sborman typedef unsigned char cc_t;
4044360Sborman # endif
4138689Sborman #endif
4232141Sminshall 
43*46808Sdab #ifndef	NO_STRING_H
44*46808Sdab #include <string.h>
45*46808Sdab #endif
46*46808Sdab #include <strings.h>
47*46808Sdab 
4845230Sborman #ifndef	_POSIX_VDISABLE
4945230Sborman # ifdef sun
5045230Sborman #  include <sys/param.h>	/* pick up VDISABLE definition, mayby */
5145230Sborman # endif
5245230Sborman # ifdef VDISABLE
5345230Sborman #  define _POSIX_VDISABLE VDISABLE
5445230Sborman # else
55*46808Sdab #  define _POSIX_VDISABLE ((cc_t)'\377')
5645230Sborman # endif
5745230Sborman #endif
5845230Sborman 
5938689Sborman #define	SUBBUFSIZE	256
6032141Sminshall 
6132141Sminshall extern int errno;		/* outside this world */
6232141Sminshall 
63*46808Sdab #if	!defined(P)
64*46808Sdab # ifdef	__STDC__
65*46808Sdab #  define	P(x)	x
66*46808Sdab # else
67*46808Sdab #  define	P(x)	()
68*46808Sdab # endif
69*46808Sdab #endif
7033802Sminshall 
7132141Sminshall extern int
72*46808Sdab     autologin,		/* Autologin enabled */
73*46808Sdab     eight,		/* use eight bit mode (binary in and/or out */
7433802Sminshall     flushout,		/* flush output */
7533802Sminshall     connected,		/* Are we connected to the other side? */
7633802Sminshall     globalmode,		/* Mode tty should be in */
7733802Sminshall     In3270,			/* Are we in 3270 mode? */
7833802Sminshall     telnetport,		/* Are we connected to the telnet port? */
7937219Sminshall     localflow,		/* Flow control handled locally */
8033802Sminshall     localchars,		/* we recognize interrupt/quit */
8133802Sminshall     donelclchars,		/* the user has set "localchars" */
8233802Sminshall     showoptions,
8336274Sminshall     net,		/* Network file descriptor */
8436274Sminshall     tin,		/* Terminal input file descriptor */
8533802Sminshall     tout,		/* Terminal output file descriptor */
8633802Sminshall     crlf,		/* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
8733802Sminshall     autoflush,		/* flush output when interrupting? */
8833802Sminshall     autosynch,		/* send interrupt characters with SYNCH? */
8933802Sminshall     SYNCHing,		/* Is the stream in telnet SYNCH mode? */
9033802Sminshall     donebinarytoggle,	/* the user has put us in binary */
9133802Sminshall     dontlecho,		/* do we suppress local echoing right now? */
9233802Sminshall     crmod,
9333802Sminshall     netdata,		/* Print out network data flow */
9438689Sborman     prettydump,		/* Print "netdata" output in user readable format */
9538208Sminshall #if	defined(unix)
9638208Sminshall #if	defined(TN3270)
9738208Sminshall     cursesdata,		/* Print out curses data flow */
9838920Sminshall     apitrace,		/* Trace API transactions */
9938208Sminshall #endif	/* defined(TN3270) */
10038208Sminshall     termdata,		/* Print out terminal data flow */
10138208Sminshall #endif	/* defined(unix) */
10233802Sminshall     debug;			/* Debug level */
10332141Sminshall 
10444360Sborman extern cc_t escape;	/* Escape to command mode */
105*46808Sdab extern cc_t rlogin;	/* Rlogin mode escape character */
10644360Sborman #ifdef	KLUDGELINEMODE
10744360Sborman extern cc_t echoc;	/* Toggle local echoing */
10844360Sborman #endif
10940245Sborman 
11044360Sborman extern char
11139529Sborman     *prompt;		/* Prompt for command. */
11239529Sborman 
11332141Sminshall extern char
11433802Sminshall     doopt[],
11533802Sminshall     dont[],
11633802Sminshall     will[],
11733802Sminshall     wont[],
11837226Sminshall     options[],		/* All the little options */
11939529Sborman     *hostname;		/* Who are we connected to? */
120*46808Sdab #if	defined(ENCRYPT)
121*46808Sdab extern void (*encrypt_output) P((unsigned char *, int));
122*46808Sdab extern int (*decrypt_input) P((int));
123*46808Sdab #endif
12432141Sminshall 
12537226Sminshall /*
12637226Sminshall  * We keep track of each side of the option negotiation.
12737226Sminshall  */
12837226Sminshall 
12938689Sborman #define	MY_STATE_WILL		0x01
13038689Sborman #define	MY_WANT_STATE_WILL	0x02
13138689Sborman #define	MY_STATE_DO		0x04
13238689Sborman #define	MY_WANT_STATE_DO	0x08
13337226Sminshall 
13437226Sminshall /*
13538689Sborman  * Macros to check the current state of things
13637226Sminshall  */
13737226Sminshall 
13838689Sborman #define	my_state_is_do(opt)		(options[opt]&MY_STATE_DO)
13938689Sborman #define	my_state_is_will(opt)		(options[opt]&MY_STATE_WILL)
14038689Sborman #define my_want_state_is_do(opt)	(options[opt]&MY_WANT_STATE_DO)
14138689Sborman #define my_want_state_is_will(opt)	(options[opt]&MY_WANT_STATE_WILL)
14237226Sminshall 
14338689Sborman #define	my_state_is_dont(opt)		(!my_state_is_do(opt))
14438689Sborman #define	my_state_is_wont(opt)		(!my_state_is_will(opt))
14538689Sborman #define my_want_state_is_dont(opt)	(!my_want_state_is_do(opt))
14638689Sborman #define my_want_state_is_wont(opt)	(!my_want_state_is_will(opt))
14737226Sminshall 
14838689Sborman #define	set_my_state_do(opt)		{options[opt] |= MY_STATE_DO;}
14938689Sborman #define	set_my_state_will(opt)		{options[opt] |= MY_STATE_WILL;}
15038689Sborman #define	set_my_want_state_do(opt)	{options[opt] |= MY_WANT_STATE_DO;}
15138689Sborman #define	set_my_want_state_will(opt)	{options[opt] |= MY_WANT_STATE_WILL;}
15238689Sborman 
15338689Sborman #define	set_my_state_dont(opt)		{options[opt] &= ~MY_STATE_DO;}
15438689Sborman #define	set_my_state_wont(opt)		{options[opt] &= ~MY_STATE_WILL;}
15538689Sborman #define	set_my_want_state_dont(opt)	{options[opt] &= ~MY_WANT_STATE_DO;}
15638689Sborman #define	set_my_want_state_wont(opt)	{options[opt] &= ~MY_WANT_STATE_WILL;}
15738689Sborman 
15838689Sborman /*
15938689Sborman  * Make everything symetrical
16038689Sborman  */
16138689Sborman 
16238689Sborman #define	HIS_STATE_WILL			MY_STATE_DO
16338689Sborman #define	HIS_WANT_STATE_WILL		MY_WANT_STATE_DO
16438689Sborman #define HIS_STATE_DO			MY_STATE_WILL
16538689Sborman #define HIS_WANT_STATE_DO		MY_WANT_STATE_WILL
16638689Sborman 
16738689Sborman #define	his_state_is_do			my_state_is_will
16838689Sborman #define	his_state_is_will		my_state_is_do
16938689Sborman #define his_want_state_is_do		my_want_state_is_will
17038689Sborman #define his_want_state_is_will		my_want_state_is_do
17138689Sborman 
17238689Sborman #define	his_state_is_dont		my_state_is_wont
17338689Sborman #define	his_state_is_wont		my_state_is_dont
17438689Sborman #define his_want_state_is_dont		my_want_state_is_wont
17538689Sborman #define his_want_state_is_wont		my_want_state_is_dont
17638689Sborman 
17738689Sborman #define	set_his_state_do		set_my_state_will
17838689Sborman #define	set_his_state_will		set_my_state_do
17938689Sborman #define	set_his_want_state_do		set_my_want_state_will
18038689Sborman #define	set_his_want_state_will		set_my_want_state_do
18138689Sborman 
18238689Sborman #define	set_his_state_dont		set_my_state_wont
18338689Sborman #define	set_his_state_wont		set_my_state_dont
18438689Sborman #define	set_his_want_state_dont		set_my_want_state_wont
18538689Sborman #define	set_his_want_state_wont		set_my_want_state_dont
18638689Sborman 
18738689Sborman 
18832141Sminshall extern FILE
18933802Sminshall     *NetTrace;		/* Where debugging output goes */
19039529Sborman extern unsigned char
19138689Sborman     NetTraceFile[];	/* Name of file where debugging output goes */
19238689Sborman extern void
193*46808Sdab     SetNetTrace P((char *));	/* Function to change where debugging goes */
19432141Sminshall 
19532141Sminshall extern jmp_buf
19633802Sminshall     peerdied,
19733802Sminshall     toplevel;		/* For error conditions. */
19832141Sminshall 
19932141Sminshall extern void
200*46808Sdab     command P((int, char *, int)),
201*46808Sdab     Dump P((int, unsigned char *, int)),
202*46808Sdab     init_3270 P((void)),
203*46808Sdab     printoption P((char *, int, int)),
204*46808Sdab     printsub P((int, unsigned char *, int)),
205*46808Sdab     sendnaws P((void)),
206*46808Sdab     setconnmode P((int)),
207*46808Sdab     setcommandmode P((void)),
208*46808Sdab     setneturg P((void)),
209*46808Sdab     sys_telnet_init P((void)),
210*46808Sdab     telnet P((char *)),
211*46808Sdab     tel_enter_binary P((int)),
212*46808Sdab     TerminalFlushOutput P((void)),
213*46808Sdab     TerminalNewMode P((int)),
214*46808Sdab     TerminalRestoreState P((void)),
215*46808Sdab     TerminalSaveState P((void)),
216*46808Sdab     tninit P((void)),
217*46808Sdab     upcase P((char *)),
218*46808Sdab     willoption P((int)),
219*46808Sdab     wontoption P((int));
22032141Sminshall 
221*46808Sdab extern void
222*46808Sdab     lm_will P((unsigned char *, int)),
223*46808Sdab     lm_wont P((unsigned char *, int)),
224*46808Sdab     lm_do P((unsigned char *, int)),
225*46808Sdab     lm_dont P((unsigned char *, int)),
226*46808Sdab     lm_mode P((unsigned char *, int, int));
227*46808Sdab 
228*46808Sdab extern void
229*46808Sdab     slc_init P((void)),
230*46808Sdab     slcstate P((void)),
231*46808Sdab     slc_mode_export P((void)),
232*46808Sdab     slc_mode_import P((int)),
233*46808Sdab     slc_import P((int)),
234*46808Sdab     slc_export P((void)),
235*46808Sdab     slc P((unsigned char *, int)),
236*46808Sdab     slc_check P((void)),
237*46808Sdab     slc_start_reply P((void)),
238*46808Sdab     slc_add_reply P((int, int, int)),
239*46808Sdab     slc_end_reply P((void));
24034313Sminshall extern int
241*46808Sdab     slc_update P((void));
24234313Sminshall 
243*46808Sdab extern void
244*46808Sdab     env_opt P((unsigned char *, int)),
245*46808Sdab     env_opt_start P((void)),
246*46808Sdab     env_opt_start_info P((void)),
247*46808Sdab     env_opt_add P((unsigned char *)),
248*46808Sdab     env_opt_end P((int));
249*46808Sdab 
250*46808Sdab extern unsigned char
251*46808Sdab     *env_default P((int)),
252*46808Sdab     *env_getvalue P((unsigned char *));
253*46808Sdab 
254*46808Sdab extern int
255*46808Sdab     get_status P((void)),
256*46808Sdab     dosynch P((void));
257*46808Sdab 
258*46808Sdab extern cc_t
259*46808Sdab     *tcval P((int));
260*46808Sdab 
26139529Sborman #ifndef	USE_TERMIO
26238689Sborman 
26338689Sborman extern struct	tchars ntc;
26438689Sborman extern struct	ltchars nltc;
26538689Sborman extern struct	sgttyb nttyb;
26638689Sborman 
26739529Sborman # define termEofChar		ntc.t_eofc
26839529Sborman # define termEraseChar		nttyb.sg_erase
26939529Sborman # define termFlushChar		nltc.t_flushc
27039529Sborman # define termIntChar		ntc.t_intrc
27139529Sborman # define termKillChar		nttyb.sg_kill
27239529Sborman # define termLiteralNextChar	nltc.t_lnextc
27339529Sborman # define termQuitChar		ntc.t_quitc
27439529Sborman # define termSuspChar		nltc.t_suspc
27539529Sborman # define termRprntChar		nltc.t_rprntc
27639529Sborman # define termWerasChar		nltc.t_werasc
27739529Sborman # define termStartChar		ntc.t_startc
27839529Sborman # define termStopChar		ntc.t_stopc
27940245Sborman # define termForw1Char		ntc.t_brkc
28044360Sborman extern cc_t termForw2Char;
28145230Sborman extern cc_t termAytChar;
28238689Sborman 
28340245Sborman # define termEofCharp		(cc_t *)&ntc.t_eofc
28440245Sborman # define termEraseCharp		(cc_t *)&nttyb.sg_erase
28540245Sborman # define termFlushCharp		(cc_t *)&nltc.t_flushc
28640245Sborman # define termIntCharp		(cc_t *)&ntc.t_intrc
28740245Sborman # define termKillCharp		(cc_t *)&nttyb.sg_kill
28840245Sborman # define termLiteralNextCharp	(cc_t *)&nltc.t_lnextc
28940245Sborman # define termQuitCharp		(cc_t *)&ntc.t_quitc
29040245Sborman # define termSuspCharp		(cc_t *)&nltc.t_suspc
29140245Sborman # define termRprntCharp		(cc_t *)&nltc.t_rprntc
29240245Sborman # define termWerasCharp		(cc_t *)&nltc.t_werasc
29340245Sborman # define termStartCharp		(cc_t *)&ntc.t_startc
29440245Sborman # define termStopCharp		(cc_t *)&ntc.t_stopc
29540245Sborman # define termForw1Charp		(cc_t *)&ntc.t_brkc
29640245Sborman # define termForw2Charp		(cc_t *)&termForw2Char
29745230Sborman # define termAytCharp		(cc_t *)&termAytChar
29838689Sborman 
29938689Sborman # else
30038689Sborman 
30138689Sborman extern struct	termio new_tc;
30238689Sborman 
30339529Sborman # define termEofChar		new_tc.c_cc[VEOF]
30439529Sborman # define termEraseChar		new_tc.c_cc[VERASE]
30539529Sborman # define termIntChar		new_tc.c_cc[VINTR]
30639529Sborman # define termKillChar		new_tc.c_cc[VKILL]
30739529Sborman # define termQuitChar		new_tc.c_cc[VQUIT]
30838689Sborman 
30939529Sborman # ifndef	VSUSP
31044360Sborman extern cc_t termSuspChar;
31139529Sborman # else
31239529Sborman #  define termSuspChar		new_tc.c_cc[VSUSP]
31339529Sborman # endif
31445230Sborman # if	defined(VFLUSHO) && !defined(VDISCARD)
31545230Sborman #  define VDISCARD VFLUSHO
31644360Sborman # endif
31745230Sborman # ifndef	VDISCARD
31844360Sborman extern cc_t termFlushChar;
31939529Sborman # else
32045230Sborman #  define termFlushChar		new_tc.c_cc[VDISCARD]
32139529Sborman # endif
32239529Sborman # ifndef VWERASE
32344360Sborman extern cc_t termWerasChar;
32439529Sborman # else
32539529Sborman #  define termWerasChar		new_tc.c_cc[VWERASE]
32639529Sborman # endif
32739529Sborman # ifndef	VREPRINT
32844360Sborman extern cc_t termRprntChar;
32939529Sborman # else
33039529Sborman #  define termRprntChar		new_tc.c_cc[VREPRINT]
33139529Sborman # endif
33239529Sborman # ifndef	VLNEXT
33344360Sborman extern cc_t termLiteralNextChar;
33439529Sborman # else
33539529Sborman #  define termLiteralNextChar	new_tc.c_cc[VLNEXT]
33639529Sborman # endif
33739529Sborman # ifndef	VSTART
33844360Sborman extern cc_t termStartChar;
33939529Sborman # else
34039529Sborman #  define termStartChar		new_tc.c_cc[VSTART]
34139529Sborman # endif
34239529Sborman # ifndef	VSTOP
34344360Sborman extern cc_t termStopChar;
34439529Sborman # else
34539529Sborman #  define termStopChar		new_tc.c_cc[VSTOP]
34639529Sborman # endif
34740245Sborman # ifndef	VEOL
34844360Sborman extern cc_t termForw1Char;
34940245Sborman # else
35040245Sborman #  define termForw1Char		new_tc.c_cc[VEOL]
35140245Sborman # endif
35240245Sborman # ifndef	VEOL2
35344360Sborman extern cc_t termForw2Char;
35440245Sborman # else
35540245Sborman #  define termForw2Char		new_tc.c_cc[VEOL]
35640245Sborman # endif
35745230Sborman # ifndef	VSTATUS
35845230Sborman extern cc_t termAytChar;
35945230Sborman #else
36045230Sborman #  define termAytChar		new_tc.c_cc[VSTATUS]
36145230Sborman #endif
36238689Sborman 
36345230Sborman # if !defined(CRAY) || defined(__STDC__)
36439529Sborman #  define termEofCharp		&termEofChar
36539529Sborman #  define termEraseCharp	&termEraseChar
36639529Sborman #  define termIntCharp		&termIntChar
36739529Sborman #  define termKillCharp		&termKillChar
36839529Sborman #  define termQuitCharp		&termQuitChar
36939529Sborman #  define termSuspCharp		&termSuspChar
37039529Sborman #  define termFlushCharp	&termFlushChar
37139529Sborman #  define termWerasCharp	&termWerasChar
37239529Sborman #  define termRprntCharp	&termRprntChar
37339529Sborman #  define termLiteralNextCharp	&termLiteralNextChar
37439529Sborman #  define termStartCharp	&termStartChar
37539529Sborman #  define termStopCharp		&termStopChar
37640245Sborman #  define termForw1Charp	&termForw1Char
37740245Sborman #  define termForw2Charp	&termForw2Char
37845230Sborman #  define termAytCharp		&termAytChar
37938689Sborman # else
38038689Sborman 	/* Work around a compiler bug */
38138689Sborman #  define termEofCharp		0
38238689Sborman #  define termEraseCharp	0
38338689Sborman #  define termIntCharp		0
38438689Sborman #  define termKillCharp		0
38538689Sborman #  define termQuitCharp		0
38639529Sborman #  define termSuspCharp		0
38739529Sborman #  define termFlushCharp	0
38839529Sborman #  define termWerasCharp	0
38939529Sborman #  define termRprntCharp	0
39039529Sborman #  define termLiteralNextCharp	0
39139529Sborman #  define termStartCharp	0
39239529Sborman #  define termStopCharp		0
39340245Sborman #  define termForw1Charp	0
39440245Sborman #  define termForw2Charp	0
39545230Sborman #  define termAytCharp		0
39638689Sborman # endif
39738689Sborman #endif
39838689Sborman 
39938689Sborman 
40032381Sminshall /* Ring buffer structures which are shared */
40132381Sminshall 
40232381Sminshall extern Ring
40333802Sminshall     netoring,
40433802Sminshall     netiring,
40533802Sminshall     ttyoring,
40633802Sminshall     ttyiring;
40733802Sminshall 
40833802Sminshall /* Tn3270 section */
40933802Sminshall #if	defined(TN3270)
41033802Sminshall 
41133802Sminshall extern int
41233802Sminshall     HaveInput,		/* Whether an asynchronous I/O indication came in */
41336241Sminshall     noasynchtty,	/* Don't do signals on I/O (SIGURG, SIGIO) */
41436241Sminshall     noasynchnet,	/* Don't do signals on I/O (SIGURG, SIGIO) */
41536241Sminshall     sigiocount,		/* Count of SIGIO receptions */
41633802Sminshall     shell_active;	/* Subshell is active */
41733802Sminshall 
41833802Sminshall extern char
41933802Sminshall     *Ibackp,		/* Oldest byte of 3270 data */
42033802Sminshall     Ibuf[],		/* 3270 buffer */
42133802Sminshall     *Ifrontp,		/* Where next 3270 byte goes */
42233802Sminshall     tline[],
42333802Sminshall     *transcom;		/* Transparent command */
42433802Sminshall 
42533802Sminshall extern int
426*46808Sdab     settranscom P((int, char**));
42733802Sminshall 
42833802Sminshall extern void
429*46808Sdab     inputAvailable P((void));
43033802Sminshall #endif	/* defined(TN3270) */
431