xref: /csrg-svn/usr.bin/telnet/externs.h (revision 42770)
133685Sbostic /*
233685Sbostic  * Copyright (c) 1988 Regents of the University of California.
333685Sbostic  * All rights reserved.
433685Sbostic  *
5*42770Sbostic  * %sccs.include.redist.c%
633685Sbostic  *
7*42770Sbostic  *	@(#)externs.h	1.22 (Berkeley) 06/01/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>
2038689Sborman #include <sys/ioctl.h>
2138689Sborman #ifdef	USE_TERMIO
2239529Sborman # ifndef	VINTR
2339529Sborman #  ifdef SYSV_TERMIO
2439529Sborman #   include <sys/termio.h>
2539529Sborman #  else
2639529Sborman #   include <sys/termios.h>
2739529Sborman #   define termio termios
2839529Sborman #  endif
2939529Sborman # endif
3040245Sborman #else
3140245Sborman typedef char cc_t;
3238689Sborman #endif
3332141Sminshall 
3438689Sborman #define	SUBBUFSIZE	256
3532141Sminshall 
3632141Sminshall extern int errno;		/* outside this world */
3732141Sminshall 
3833802Sminshall extern char
3933802Sminshall     *strcat(),
4033802Sminshall     *strcpy();			/* outside this world */
4133802Sminshall 
4232141Sminshall extern int
4333802Sminshall     flushout,		/* flush output */
4433802Sminshall     connected,		/* Are we connected to the other side? */
4533802Sminshall     globalmode,		/* Mode tty should be in */
4633802Sminshall     In3270,			/* Are we in 3270 mode? */
4733802Sminshall     telnetport,		/* Are we connected to the telnet port? */
4837219Sminshall     localflow,		/* Flow control handled locally */
4933802Sminshall     localchars,		/* we recognize interrupt/quit */
5033802Sminshall     donelclchars,		/* the user has set "localchars" */
5133802Sminshall     showoptions,
5236274Sminshall     net,		/* Network file descriptor */
5336274Sminshall     tin,		/* Terminal input file descriptor */
5433802Sminshall     tout,		/* Terminal output file descriptor */
5533802Sminshall     crlf,		/* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
5633802Sminshall     autoflush,		/* flush output when interrupting? */
5733802Sminshall     autosynch,		/* send interrupt characters with SYNCH? */
5833802Sminshall     SYNCHing,		/* Is the stream in telnet SYNCH mode? */
5933802Sminshall     donebinarytoggle,	/* the user has put us in binary */
6033802Sminshall     dontlecho,		/* do we suppress local echoing right now? */
6133802Sminshall     crmod,
6233802Sminshall     netdata,		/* Print out network data flow */
6338689Sborman     prettydump,		/* Print "netdata" output in user readable format */
6438208Sminshall #if	defined(unix)
6538208Sminshall #if	defined(TN3270)
6638208Sminshall     cursesdata,		/* Print out curses data flow */
6738920Sminshall     apitrace,		/* Trace API transactions */
6838208Sminshall #endif	/* defined(TN3270) */
6938208Sminshall     termdata,		/* Print out terminal data flow */
7038208Sminshall #endif	/* defined(unix) */
7133802Sminshall     debug;			/* Debug level */
7232141Sminshall 
7340245Sborman extern cc_t
7440245Sborman     echoc,		/* Toggle local echoing */
7540245Sborman     escape;		/* Escape to command mode */
7640245Sborman 
7739529Sborman extern unsigned char
7839529Sborman     *prompt;		/* Prompt for command. */
7939529Sborman 
8032141Sminshall extern char
8133802Sminshall     doopt[],
8233802Sminshall     dont[],
8333802Sminshall     will[],
8433802Sminshall     wont[],
8537226Sminshall     options[],		/* All the little options */
8639529Sborman     *hostname;		/* Who are we connected to? */
8732141Sminshall 
8837226Sminshall /*
8937226Sminshall  * We keep track of each side of the option negotiation.
9037226Sminshall  */
9137226Sminshall 
9238689Sborman #define	MY_STATE_WILL		0x01
9338689Sborman #define	MY_WANT_STATE_WILL	0x02
9438689Sborman #define	MY_STATE_DO		0x04
9538689Sborman #define	MY_WANT_STATE_DO	0x08
9637226Sminshall 
9737226Sminshall /*
9838689Sborman  * Macros to check the current state of things
9937226Sminshall  */
10037226Sminshall 
10138689Sborman #define	my_state_is_do(opt)		(options[opt]&MY_STATE_DO)
10238689Sborman #define	my_state_is_will(opt)		(options[opt]&MY_STATE_WILL)
10338689Sborman #define my_want_state_is_do(opt)	(options[opt]&MY_WANT_STATE_DO)
10438689Sborman #define my_want_state_is_will(opt)	(options[opt]&MY_WANT_STATE_WILL)
10537226Sminshall 
10638689Sborman #define	my_state_is_dont(opt)		(!my_state_is_do(opt))
10738689Sborman #define	my_state_is_wont(opt)		(!my_state_is_will(opt))
10838689Sborman #define my_want_state_is_dont(opt)	(!my_want_state_is_do(opt))
10938689Sborman #define my_want_state_is_wont(opt)	(!my_want_state_is_will(opt))
11037226Sminshall 
11138689Sborman #define	set_my_state_do(opt)		{options[opt] |= MY_STATE_DO;}
11238689Sborman #define	set_my_state_will(opt)		{options[opt] |= MY_STATE_WILL;}
11338689Sborman #define	set_my_want_state_do(opt)	{options[opt] |= MY_WANT_STATE_DO;}
11438689Sborman #define	set_my_want_state_will(opt)	{options[opt] |= MY_WANT_STATE_WILL;}
11538689Sborman 
11638689Sborman #define	set_my_state_dont(opt)		{options[opt] &= ~MY_STATE_DO;}
11738689Sborman #define	set_my_state_wont(opt)		{options[opt] &= ~MY_STATE_WILL;}
11838689Sborman #define	set_my_want_state_dont(opt)	{options[opt] &= ~MY_WANT_STATE_DO;}
11938689Sborman #define	set_my_want_state_wont(opt)	{options[opt] &= ~MY_WANT_STATE_WILL;}
12038689Sborman 
12138689Sborman /*
12238689Sborman  * Make everything symetrical
12338689Sborman  */
12438689Sborman 
12538689Sborman #define	HIS_STATE_WILL			MY_STATE_DO
12638689Sborman #define	HIS_WANT_STATE_WILL		MY_WANT_STATE_DO
12738689Sborman #define HIS_STATE_DO			MY_STATE_WILL
12838689Sborman #define HIS_WANT_STATE_DO		MY_WANT_STATE_WILL
12938689Sborman 
13038689Sborman #define	his_state_is_do			my_state_is_will
13138689Sborman #define	his_state_is_will		my_state_is_do
13238689Sborman #define his_want_state_is_do		my_want_state_is_will
13338689Sborman #define his_want_state_is_will		my_want_state_is_do
13438689Sborman 
13538689Sborman #define	his_state_is_dont		my_state_is_wont
13638689Sborman #define	his_state_is_wont		my_state_is_dont
13738689Sborman #define his_want_state_is_dont		my_want_state_is_wont
13838689Sborman #define his_want_state_is_wont		my_want_state_is_dont
13938689Sborman 
14038689Sborman #define	set_his_state_do		set_my_state_will
14138689Sborman #define	set_his_state_will		set_my_state_do
14238689Sborman #define	set_his_want_state_do		set_my_want_state_will
14338689Sborman #define	set_his_want_state_will		set_my_want_state_do
14438689Sborman 
14538689Sborman #define	set_his_state_dont		set_my_state_wont
14638689Sborman #define	set_his_state_wont		set_my_state_dont
14738689Sborman #define	set_his_want_state_dont		set_my_want_state_wont
14838689Sborman #define	set_his_want_state_wont		set_my_want_state_dont
14938689Sborman 
15038689Sborman 
15132141Sminshall extern FILE
15233802Sminshall     *NetTrace;		/* Where debugging output goes */
15339529Sborman extern unsigned char
15438689Sborman     NetTraceFile[];	/* Name of file where debugging output goes */
15538689Sborman extern void
15638689Sborman     SetNetTrace();	/* Function to change where debugging goes */
15732141Sminshall 
15832141Sminshall extern jmp_buf
15933802Sminshall     peerdied,
16033802Sminshall     toplevel;		/* For error conditions. */
16132141Sminshall 
16232141Sminshall extern void
16334848Sminshall     command(),
16434313Sminshall #if	!defined(NOT43)
16533802Sminshall     dosynch(),
16634313Sminshall #endif	/* !defined(NOT43) */
16738908Sborman     get_status(),
16834848Sminshall     Dump(),
16934848Sminshall     init_3270(),
17034848Sminshall     printoption(),
17134848Sminshall     printsub(),
17237219Sminshall     sendnaws(),
17333802Sminshall     setconnmode(),
17434848Sminshall     setcommandmode(),
17534848Sminshall     setneturg(),
17634848Sminshall     sys_telnet_init(),
17734848Sminshall     telnet(),
17834848Sminshall     TerminalFlushOutput(),
17934848Sminshall     TerminalNewMode(),
18034848Sminshall     TerminalRestoreState(),
18134848Sminshall     TerminalSaveState(),
18234848Sminshall     tninit(),
18334848Sminshall     upcase(),
18434848Sminshall     willoption(),
18534848Sminshall     wontoption();
18632141Sminshall 
18734313Sminshall #if	defined(NOT43)
18834313Sminshall extern int
18934313Sminshall     dosynch();
19034313Sminshall #endif	/* defined(NOT43) */
19134313Sminshall 
19239529Sborman #ifndef	USE_TERMIO
19338689Sborman 
19438689Sborman extern struct	tchars ntc;
19538689Sborman extern struct	ltchars nltc;
19638689Sborman extern struct	sgttyb nttyb;
19738689Sborman 
19839529Sborman # define termEofChar		ntc.t_eofc
19939529Sborman # define termEraseChar		nttyb.sg_erase
20039529Sborman # define termFlushChar		nltc.t_flushc
20139529Sborman # define termIntChar		ntc.t_intrc
20239529Sborman # define termKillChar		nttyb.sg_kill
20339529Sborman # define termLiteralNextChar	nltc.t_lnextc
20439529Sborman # define termQuitChar		ntc.t_quitc
20539529Sborman # define termSuspChar		nltc.t_suspc
20639529Sborman # define termRprntChar		nltc.t_rprntc
20739529Sborman # define termWerasChar		nltc.t_werasc
20839529Sborman # define termStartChar		ntc.t_startc
20939529Sborman # define termStopChar		ntc.t_stopc
21040245Sborman # define termForw1Char		ntc.t_brkc
21140245Sborman extern char termForw2Char;
21238689Sborman 
21340245Sborman # define termEofCharp		(cc_t *)&ntc.t_eofc
21440245Sborman # define termEraseCharp		(cc_t *)&nttyb.sg_erase
21540245Sborman # define termFlushCharp		(cc_t *)&nltc.t_flushc
21640245Sborman # define termIntCharp		(cc_t *)&ntc.t_intrc
21740245Sborman # define termKillCharp		(cc_t *)&nttyb.sg_kill
21840245Sborman # define termLiteralNextCharp	(cc_t *)&nltc.t_lnextc
21940245Sborman # define termQuitCharp		(cc_t *)&ntc.t_quitc
22040245Sborman # define termSuspCharp		(cc_t *)&nltc.t_suspc
22140245Sborman # define termRprntCharp		(cc_t *)&nltc.t_rprntc
22240245Sborman # define termWerasCharp		(cc_t *)&nltc.t_werasc
22340245Sborman # define termStartCharp		(cc_t *)&ntc.t_startc
22440245Sborman # define termStopCharp		(cc_t *)&ntc.t_stopc
22540245Sborman # define termForw1Charp		(cc_t *)&ntc.t_brkc
22640245Sborman # define termForw2Charp		(cc_t *)&termForw2Char
22738689Sborman 
22838689Sborman # else
22938689Sborman 
23038689Sborman extern struct	termio new_tc;
23138689Sborman 
23239529Sborman # define termEofChar		new_tc.c_cc[VEOF]
23339529Sborman # define termEraseChar		new_tc.c_cc[VERASE]
23439529Sborman # define termIntChar		new_tc.c_cc[VINTR]
23539529Sborman # define termKillChar		new_tc.c_cc[VKILL]
23639529Sborman # define termQuitChar		new_tc.c_cc[VQUIT]
23738689Sborman 
23839529Sborman # ifndef	VSUSP
23939529Sborman extern char termSuspChar;
24039529Sborman # else
24139529Sborman #  define termSuspChar		new_tc.c_cc[VSUSP]
24239529Sborman # endif
24339529Sborman # ifndef	VFLUSHO
24439529Sborman extern char termFlushChar;
24539529Sborman # else
24639529Sborman #  define termFlushChar		new_tc.c_cc[VFLUSHO]
24739529Sborman # endif
24839529Sborman # ifndef VWERASE
24939529Sborman extern char termWerasChar;
25039529Sborman # else
25139529Sborman #  define termWerasChar		new_tc.c_cc[VWERASE]
25239529Sborman # endif
25339529Sborman # ifndef	VREPRINT
25439529Sborman extern char termRprntChar;
25539529Sborman # else
25639529Sborman #  define termRprntChar		new_tc.c_cc[VREPRINT]
25739529Sborman # endif
25839529Sborman # ifndef	VLNEXT
25939529Sborman extern char termLiteralNextChar;
26039529Sborman # else
26139529Sborman #  define termLiteralNextChar	new_tc.c_cc[VLNEXT]
26239529Sborman # endif
26339529Sborman # ifndef	VSTART
26439529Sborman extern char termStartChar;
26539529Sborman # else
26639529Sborman #  define termStartChar		new_tc.c_cc[VSTART]
26739529Sborman # endif
26839529Sborman # ifndef	VSTOP
26939529Sborman extern char termStopChar;
27039529Sborman # else
27139529Sborman #  define termStopChar		new_tc.c_cc[VSTOP]
27239529Sborman # endif
27340245Sborman # ifndef	VEOL
27440245Sborman extern char termForw1Char;
27540245Sborman # else
27640245Sborman #  define termForw1Char		new_tc.c_cc[VEOL]
27740245Sborman # endif
27840245Sborman # ifndef	VEOL2
27940245Sborman extern char termForw2Char;
28040245Sborman # else
28140245Sborman #  define termForw2Char		new_tc.c_cc[VEOL]
28240245Sborman # endif
28338689Sborman 
28438689Sborman # ifndef CRAY
28539529Sborman #  define termEofCharp		&termEofChar
28639529Sborman #  define termEraseCharp	&termEraseChar
28739529Sborman #  define termIntCharp		&termIntChar
28839529Sborman #  define termKillCharp		&termKillChar
28939529Sborman #  define termQuitCharp		&termQuitChar
29039529Sborman #  define termSuspCharp		&termSuspChar
29139529Sborman #  define termFlushCharp	&termFlushChar
29239529Sborman #  define termWerasCharp	&termWerasChar
29339529Sborman #  define termRprntCharp	&termRprntChar
29439529Sborman #  define termLiteralNextCharp	&termLiteralNextChar
29539529Sborman #  define termStartCharp	&termStartChar
29639529Sborman #  define termStopCharp		&termStopChar
29740245Sborman #  define termForw1Charp	&termForw1Char
29840245Sborman #  define termForw2Charp	&termForw2Char
29938689Sborman # else
30038689Sborman 	/* Work around a compiler bug */
30138689Sborman #  define termEofCharp		0
30238689Sborman #  define termEraseCharp	0
30338689Sborman #  define termIntCharp		0
30438689Sborman #  define termKillCharp		0
30538689Sborman #  define termQuitCharp		0
30639529Sborman #  define termSuspCharp		0
30739529Sborman #  define termFlushCharp	0
30839529Sborman #  define termWerasCharp	0
30939529Sborman #  define termRprntCharp	0
31039529Sborman #  define termLiteralNextCharp	0
31139529Sborman #  define termStartCharp	0
31239529Sborman #  define termStopCharp		0
31340245Sborman #  define termForw1Charp	0
31440245Sborman #  define termForw2Charp	0
31538689Sborman # endif
31638689Sborman #endif
31738689Sborman 
31838689Sborman 
31932381Sminshall /* Ring buffer structures which are shared */
32032381Sminshall 
32132381Sminshall extern Ring
32233802Sminshall     netoring,
32333802Sminshall     netiring,
32433802Sminshall     ttyoring,
32533802Sminshall     ttyiring;
32633802Sminshall 
32733802Sminshall /* Tn3270 section */
32833802Sminshall #if	defined(TN3270)
32933802Sminshall 
33033802Sminshall extern int
33133802Sminshall     HaveInput,		/* Whether an asynchronous I/O indication came in */
33236241Sminshall     noasynchtty,	/* Don't do signals on I/O (SIGURG, SIGIO) */
33336241Sminshall     noasynchnet,	/* Don't do signals on I/O (SIGURG, SIGIO) */
33436241Sminshall     sigiocount,		/* Count of SIGIO receptions */
33533802Sminshall     shell_active;	/* Subshell is active */
33633802Sminshall 
33733802Sminshall extern char
33833802Sminshall     *Ibackp,		/* Oldest byte of 3270 data */
33933802Sminshall     Ibuf[],		/* 3270 buffer */
34033802Sminshall     *Ifrontp,		/* Where next 3270 byte goes */
34133802Sminshall     tline[],
34233802Sminshall     *transcom;		/* Transparent command */
34333802Sminshall 
34433802Sminshall extern int
34533802Sminshall     settranscom();
34633802Sminshall 
34733802Sminshall extern void
34833802Sminshall     inputAvailable();
34933802Sminshall #endif	/* defined(TN3270) */
350