xref: /csrg-svn/usr.bin/telnet/externs.h (revision 45230)
133685Sbostic /*
2*45230Sborman  * Copyright (c) 1988, 1990 Regents of the University of California.
333685Sbostic  * All rights reserved.
433685Sbostic  *
542770Sbostic  * %sccs.include.redist.c%
633685Sbostic  *
7*45230Sborman  *	@(#)externs.h	5.1 (Berkeley) 09/14/90
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*45230Sborman #ifndef	_POSIX_VDISABLE
44*45230Sborman # ifdef sun
45*45230Sborman #  include <sys/param.h>	/* pick up VDISABLE definition, mayby */
46*45230Sborman # endif
47*45230Sborman # ifdef VDISABLE
48*45230Sborman #  define _POSIX_VDISABLE VDISABLE
49*45230Sborman # else
50*45230Sborman #  define _POSIX_VDISABLE ((unsigned char)'\377')
51*45230Sborman # endif
52*45230Sborman #endif
53*45230Sborman 
5438689Sborman #define	SUBBUFSIZE	256
5532141Sminshall 
5632141Sminshall extern int errno;		/* outside this world */
5732141Sminshall 
5833802Sminshall extern char
5933802Sminshall     *strcat(),
6033802Sminshall     *strcpy();			/* outside this world */
6133802Sminshall 
6232141Sminshall extern int
6333802Sminshall     flushout,		/* flush output */
6433802Sminshall     connected,		/* Are we connected to the other side? */
6533802Sminshall     globalmode,		/* Mode tty should be in */
6633802Sminshall     In3270,			/* Are we in 3270 mode? */
6733802Sminshall     telnetport,		/* Are we connected to the telnet port? */
6837219Sminshall     localflow,		/* Flow control handled locally */
6933802Sminshall     localchars,		/* we recognize interrupt/quit */
7033802Sminshall     donelclchars,		/* the user has set "localchars" */
7133802Sminshall     showoptions,
7236274Sminshall     net,		/* Network file descriptor */
7336274Sminshall     tin,		/* Terminal input file descriptor */
7433802Sminshall     tout,		/* Terminal output file descriptor */
7533802Sminshall     crlf,		/* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
7633802Sminshall     autoflush,		/* flush output when interrupting? */
7733802Sminshall     autosynch,		/* send interrupt characters with SYNCH? */
7833802Sminshall     SYNCHing,		/* Is the stream in telnet SYNCH mode? */
7933802Sminshall     donebinarytoggle,	/* the user has put us in binary */
8033802Sminshall     dontlecho,		/* do we suppress local echoing right now? */
8133802Sminshall     crmod,
8233802Sminshall     netdata,		/* Print out network data flow */
8343318Skfall #ifdef	KERBEROS
8443318Skfall     kerberized,		/* Try to use Kerberos */
8543318Skfall #endif
8638689Sborman     prettydump,		/* Print "netdata" output in user readable format */
8738208Sminshall #if	defined(unix)
8838208Sminshall #if	defined(TN3270)
8938208Sminshall     cursesdata,		/* Print out curses data flow */
9038920Sminshall     apitrace,		/* Trace API transactions */
9138208Sminshall #endif	/* defined(TN3270) */
9238208Sminshall     termdata,		/* Print out terminal data flow */
9338208Sminshall #endif	/* defined(unix) */
9433802Sminshall     debug;			/* Debug level */
9532141Sminshall 
9644360Sborman extern cc_t escape;	/* Escape to command mode */
9744360Sborman #ifdef	KLUDGELINEMODE
9844360Sborman extern cc_t echoc;	/* Toggle local echoing */
9944360Sborman #endif
10040245Sborman 
10144360Sborman extern char
10239529Sborman     *prompt;		/* Prompt for command. */
10339529Sborman 
10432141Sminshall extern char
10533802Sminshall     doopt[],
10633802Sminshall     dont[],
10733802Sminshall     will[],
10833802Sminshall     wont[],
10937226Sminshall     options[],		/* All the little options */
11039529Sborman     *hostname;		/* Who are we connected to? */
11132141Sminshall 
11237226Sminshall /*
11337226Sminshall  * We keep track of each side of the option negotiation.
11437226Sminshall  */
11537226Sminshall 
11638689Sborman #define	MY_STATE_WILL		0x01
11738689Sborman #define	MY_WANT_STATE_WILL	0x02
11838689Sborman #define	MY_STATE_DO		0x04
11938689Sborman #define	MY_WANT_STATE_DO	0x08
12037226Sminshall 
12137226Sminshall /*
12238689Sborman  * Macros to check the current state of things
12337226Sminshall  */
12437226Sminshall 
12538689Sborman #define	my_state_is_do(opt)		(options[opt]&MY_STATE_DO)
12638689Sborman #define	my_state_is_will(opt)		(options[opt]&MY_STATE_WILL)
12738689Sborman #define my_want_state_is_do(opt)	(options[opt]&MY_WANT_STATE_DO)
12838689Sborman #define my_want_state_is_will(opt)	(options[opt]&MY_WANT_STATE_WILL)
12937226Sminshall 
13038689Sborman #define	my_state_is_dont(opt)		(!my_state_is_do(opt))
13138689Sborman #define	my_state_is_wont(opt)		(!my_state_is_will(opt))
13238689Sborman #define my_want_state_is_dont(opt)	(!my_want_state_is_do(opt))
13338689Sborman #define my_want_state_is_wont(opt)	(!my_want_state_is_will(opt))
13437226Sminshall 
13538689Sborman #define	set_my_state_do(opt)		{options[opt] |= MY_STATE_DO;}
13638689Sborman #define	set_my_state_will(opt)		{options[opt] |= MY_STATE_WILL;}
13738689Sborman #define	set_my_want_state_do(opt)	{options[opt] |= MY_WANT_STATE_DO;}
13838689Sborman #define	set_my_want_state_will(opt)	{options[opt] |= MY_WANT_STATE_WILL;}
13938689Sborman 
14038689Sborman #define	set_my_state_dont(opt)		{options[opt] &= ~MY_STATE_DO;}
14138689Sborman #define	set_my_state_wont(opt)		{options[opt] &= ~MY_STATE_WILL;}
14238689Sborman #define	set_my_want_state_dont(opt)	{options[opt] &= ~MY_WANT_STATE_DO;}
14338689Sborman #define	set_my_want_state_wont(opt)	{options[opt] &= ~MY_WANT_STATE_WILL;}
14438689Sborman 
14538689Sborman /*
14638689Sborman  * Make everything symetrical
14738689Sborman  */
14838689Sborman 
14938689Sborman #define	HIS_STATE_WILL			MY_STATE_DO
15038689Sborman #define	HIS_WANT_STATE_WILL		MY_WANT_STATE_DO
15138689Sborman #define HIS_STATE_DO			MY_STATE_WILL
15238689Sborman #define HIS_WANT_STATE_DO		MY_WANT_STATE_WILL
15338689Sborman 
15438689Sborman #define	his_state_is_do			my_state_is_will
15538689Sborman #define	his_state_is_will		my_state_is_do
15638689Sborman #define his_want_state_is_do		my_want_state_is_will
15738689Sborman #define his_want_state_is_will		my_want_state_is_do
15838689Sborman 
15938689Sborman #define	his_state_is_dont		my_state_is_wont
16038689Sborman #define	his_state_is_wont		my_state_is_dont
16138689Sborman #define his_want_state_is_dont		my_want_state_is_wont
16238689Sborman #define his_want_state_is_wont		my_want_state_is_dont
16338689Sborman 
16438689Sborman #define	set_his_state_do		set_my_state_will
16538689Sborman #define	set_his_state_will		set_my_state_do
16638689Sborman #define	set_his_want_state_do		set_my_want_state_will
16738689Sborman #define	set_his_want_state_will		set_my_want_state_do
16838689Sborman 
16938689Sborman #define	set_his_state_dont		set_my_state_wont
17038689Sborman #define	set_his_state_wont		set_my_state_dont
17138689Sborman #define	set_his_want_state_dont		set_my_want_state_wont
17238689Sborman #define	set_his_want_state_wont		set_my_want_state_dont
17338689Sborman 
17438689Sborman 
17532141Sminshall extern FILE
17633802Sminshall     *NetTrace;		/* Where debugging output goes */
17739529Sborman extern unsigned char
17838689Sborman     NetTraceFile[];	/* Name of file where debugging output goes */
17938689Sborman extern void
18038689Sborman     SetNetTrace();	/* Function to change where debugging goes */
18132141Sminshall 
18232141Sminshall extern jmp_buf
18333802Sminshall     peerdied,
18433802Sminshall     toplevel;		/* For error conditions. */
18532141Sminshall 
18632141Sminshall extern void
18734848Sminshall     command(),
18834313Sminshall #if	!defined(NOT43)
18933802Sminshall     dosynch(),
19034313Sminshall #endif	/* !defined(NOT43) */
19138908Sborman     get_status(),
19234848Sminshall     Dump(),
19334848Sminshall     init_3270(),
19434848Sminshall     printoption(),
19534848Sminshall     printsub(),
19637219Sminshall     sendnaws(),
19733802Sminshall     setconnmode(),
19834848Sminshall     setcommandmode(),
19934848Sminshall     setneturg(),
20034848Sminshall     sys_telnet_init(),
20134848Sminshall     telnet(),
20234848Sminshall     TerminalFlushOutput(),
20334848Sminshall     TerminalNewMode(),
20434848Sminshall     TerminalRestoreState(),
20534848Sminshall     TerminalSaveState(),
20634848Sminshall     tninit(),
20734848Sminshall     upcase(),
20834848Sminshall     willoption(),
20934848Sminshall     wontoption();
21032141Sminshall 
21134313Sminshall #if	defined(NOT43)
21234313Sminshall extern int
21334313Sminshall     dosynch();
21434313Sminshall #endif	/* defined(NOT43) */
21534313Sminshall 
21639529Sborman #ifndef	USE_TERMIO
21738689Sborman 
21838689Sborman extern struct	tchars ntc;
21938689Sborman extern struct	ltchars nltc;
22038689Sborman extern struct	sgttyb nttyb;
22138689Sborman 
22239529Sborman # define termEofChar		ntc.t_eofc
22339529Sborman # define termEraseChar		nttyb.sg_erase
22439529Sborman # define termFlushChar		nltc.t_flushc
22539529Sborman # define termIntChar		ntc.t_intrc
22639529Sborman # define termKillChar		nttyb.sg_kill
22739529Sborman # define termLiteralNextChar	nltc.t_lnextc
22839529Sborman # define termQuitChar		ntc.t_quitc
22939529Sborman # define termSuspChar		nltc.t_suspc
23039529Sborman # define termRprntChar		nltc.t_rprntc
23139529Sborman # define termWerasChar		nltc.t_werasc
23239529Sborman # define termStartChar		ntc.t_startc
23339529Sborman # define termStopChar		ntc.t_stopc
23440245Sborman # define termForw1Char		ntc.t_brkc
23544360Sborman extern cc_t termForw2Char;
236*45230Sborman extern cc_t termAytChar;
23738689Sborman 
23840245Sborman # define termEofCharp		(cc_t *)&ntc.t_eofc
23940245Sborman # define termEraseCharp		(cc_t *)&nttyb.sg_erase
24040245Sborman # define termFlushCharp		(cc_t *)&nltc.t_flushc
24140245Sborman # define termIntCharp		(cc_t *)&ntc.t_intrc
24240245Sborman # define termKillCharp		(cc_t *)&nttyb.sg_kill
24340245Sborman # define termLiteralNextCharp	(cc_t *)&nltc.t_lnextc
24440245Sborman # define termQuitCharp		(cc_t *)&ntc.t_quitc
24540245Sborman # define termSuspCharp		(cc_t *)&nltc.t_suspc
24640245Sborman # define termRprntCharp		(cc_t *)&nltc.t_rprntc
24740245Sborman # define termWerasCharp		(cc_t *)&nltc.t_werasc
24840245Sborman # define termStartCharp		(cc_t *)&ntc.t_startc
24940245Sborman # define termStopCharp		(cc_t *)&ntc.t_stopc
25040245Sborman # define termForw1Charp		(cc_t *)&ntc.t_brkc
25140245Sborman # define termForw2Charp		(cc_t *)&termForw2Char
252*45230Sborman # define termAytCharp		(cc_t *)&termAytChar
25338689Sborman 
25438689Sborman # else
25538689Sborman 
25638689Sborman extern struct	termio new_tc;
25738689Sborman 
25839529Sborman # define termEofChar		new_tc.c_cc[VEOF]
25939529Sborman # define termEraseChar		new_tc.c_cc[VERASE]
26039529Sborman # define termIntChar		new_tc.c_cc[VINTR]
26139529Sborman # define termKillChar		new_tc.c_cc[VKILL]
26239529Sborman # define termQuitChar		new_tc.c_cc[VQUIT]
26338689Sborman 
26439529Sborman # ifndef	VSUSP
26544360Sborman extern cc_t termSuspChar;
26639529Sborman # else
26739529Sborman #  define termSuspChar		new_tc.c_cc[VSUSP]
26839529Sborman # endif
269*45230Sborman # if	defined(VFLUSHO) && !defined(VDISCARD)
270*45230Sborman #  define VDISCARD VFLUSHO
27144360Sborman # endif
272*45230Sborman # ifndef	VDISCARD
27344360Sborman extern cc_t termFlushChar;
27439529Sborman # else
275*45230Sborman #  define termFlushChar		new_tc.c_cc[VDISCARD]
27639529Sborman # endif
27739529Sborman # ifndef VWERASE
27844360Sborman extern cc_t termWerasChar;
27939529Sborman # else
28039529Sborman #  define termWerasChar		new_tc.c_cc[VWERASE]
28139529Sborman # endif
28239529Sborman # ifndef	VREPRINT
28344360Sborman extern cc_t termRprntChar;
28439529Sborman # else
28539529Sborman #  define termRprntChar		new_tc.c_cc[VREPRINT]
28639529Sborman # endif
28739529Sborman # ifndef	VLNEXT
28844360Sborman extern cc_t termLiteralNextChar;
28939529Sborman # else
29039529Sborman #  define termLiteralNextChar	new_tc.c_cc[VLNEXT]
29139529Sborman # endif
29239529Sborman # ifndef	VSTART
29344360Sborman extern cc_t termStartChar;
29439529Sborman # else
29539529Sborman #  define termStartChar		new_tc.c_cc[VSTART]
29639529Sborman # endif
29739529Sborman # ifndef	VSTOP
29844360Sborman extern cc_t termStopChar;
29939529Sborman # else
30039529Sborman #  define termStopChar		new_tc.c_cc[VSTOP]
30139529Sborman # endif
30240245Sborman # ifndef	VEOL
30344360Sborman extern cc_t termForw1Char;
30440245Sborman # else
30540245Sborman #  define termForw1Char		new_tc.c_cc[VEOL]
30640245Sborman # endif
30740245Sborman # ifndef	VEOL2
30844360Sborman extern cc_t termForw2Char;
30940245Sborman # else
31040245Sborman #  define termForw2Char		new_tc.c_cc[VEOL]
31140245Sborman # endif
312*45230Sborman # ifndef	VSTATUS
313*45230Sborman extern cc_t termAytChar;
314*45230Sborman #else
315*45230Sborman #  define termAytChar		new_tc.c_cc[VSTATUS]
316*45230Sborman #endif
31738689Sborman 
318*45230Sborman # if !defined(CRAY) || defined(__STDC__)
31939529Sborman #  define termEofCharp		&termEofChar
32039529Sborman #  define termEraseCharp	&termEraseChar
32139529Sborman #  define termIntCharp		&termIntChar
32239529Sborman #  define termKillCharp		&termKillChar
32339529Sborman #  define termQuitCharp		&termQuitChar
32439529Sborman #  define termSuspCharp		&termSuspChar
32539529Sborman #  define termFlushCharp	&termFlushChar
32639529Sborman #  define termWerasCharp	&termWerasChar
32739529Sborman #  define termRprntCharp	&termRprntChar
32839529Sborman #  define termLiteralNextCharp	&termLiteralNextChar
32939529Sborman #  define termStartCharp	&termStartChar
33039529Sborman #  define termStopCharp		&termStopChar
33140245Sborman #  define termForw1Charp	&termForw1Char
33240245Sborman #  define termForw2Charp	&termForw2Char
333*45230Sborman #  define termAytCharp		&termAytChar
33438689Sborman # else
33538689Sborman 	/* Work around a compiler bug */
33638689Sborman #  define termEofCharp		0
33738689Sborman #  define termEraseCharp	0
33838689Sborman #  define termIntCharp		0
33938689Sborman #  define termKillCharp		0
34038689Sborman #  define termQuitCharp		0
34139529Sborman #  define termSuspCharp		0
34239529Sborman #  define termFlushCharp	0
34339529Sborman #  define termWerasCharp	0
34439529Sborman #  define termRprntCharp	0
34539529Sborman #  define termLiteralNextCharp	0
34639529Sborman #  define termStartCharp	0
34739529Sborman #  define termStopCharp		0
34840245Sborman #  define termForw1Charp	0
34940245Sborman #  define termForw2Charp	0
350*45230Sborman #  define termAytCharp		0
35138689Sborman # endif
35238689Sborman #endif
35338689Sborman 
35438689Sborman 
35532381Sminshall /* Ring buffer structures which are shared */
35632381Sminshall 
35732381Sminshall extern Ring
35833802Sminshall     netoring,
35933802Sminshall     netiring,
36033802Sminshall     ttyoring,
36133802Sminshall     ttyiring;
36233802Sminshall 
36333802Sminshall /* Tn3270 section */
36433802Sminshall #if	defined(TN3270)
36533802Sminshall 
36633802Sminshall extern int
36733802Sminshall     HaveInput,		/* Whether an asynchronous I/O indication came in */
36836241Sminshall     noasynchtty,	/* Don't do signals on I/O (SIGURG, SIGIO) */
36936241Sminshall     noasynchnet,	/* Don't do signals on I/O (SIGURG, SIGIO) */
37036241Sminshall     sigiocount,		/* Count of SIGIO receptions */
37133802Sminshall     shell_active;	/* Subshell is active */
37233802Sminshall 
37333802Sminshall extern char
37433802Sminshall     *Ibackp,		/* Oldest byte of 3270 data */
37533802Sminshall     Ibuf[],		/* 3270 buffer */
37633802Sminshall     *Ifrontp,		/* Where next 3270 byte goes */
37733802Sminshall     tline[],
37833802Sminshall     *transcom;		/* Transparent command */
37933802Sminshall 
38033802Sminshall extern int
38133802Sminshall     settranscom();
38233802Sminshall 
38333802Sminshall extern void
38433802Sminshall     inputAvailable();
38533802Sminshall #endif	/* defined(TN3270) */
386