xref: /csrg-svn/usr.bin/telnet/externs.h (revision 40245)
133685Sbostic /*
233685Sbostic  * Copyright (c) 1988 Regents of the University of California.
333685Sbostic  * All rights reserved.
433685Sbostic  *
533685Sbostic  * Redistribution and use in source and binary forms are permitted
634898Sbostic  * provided that the above copyright notice and this paragraph are
734898Sbostic  * duplicated in all such forms and that any documentation,
834898Sbostic  * advertising materials, and other materials related to such
934898Sbostic  * distribution and use acknowledge that the software was developed
1034898Sbostic  * by the University of California, Berkeley.  The name of the
1134898Sbostic  * University may not be used to endorse or promote products derived
1234898Sbostic  * from this software without specific prior written permission.
1334898Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1434898Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1534898Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1633685Sbostic  *
17*40245Sborman  *	@(#)externs.h	1.21 (Berkeley) 03/01/90
1833685Sbostic  */
1933685Sbostic 
2039529Sborman #ifndef	BSD
2139529Sborman # define BSD 43
2238689Sborman #endif
2338689Sborman 
2439529Sborman #if (BSD > 43 || defined(SYSV_TERMIO)) && !defined(USE_TERMIO)
2539529Sborman # define USE_TERMIO
2639529Sborman #endif
2739529Sborman 
2832141Sminshall #include <stdio.h>
2932141Sminshall #include <setjmp.h>
3038689Sborman #include <sys/ioctl.h>
3138689Sborman #ifdef	USE_TERMIO
3239529Sborman # ifndef	VINTR
3339529Sborman #  ifdef SYSV_TERMIO
3439529Sborman #   include <sys/termio.h>
3539529Sborman #  else
3639529Sborman #   include <sys/termios.h>
3739529Sborman #   define termio termios
3839529Sborman #  endif
3939529Sborman # endif
40*40245Sborman #else
41*40245Sborman typedef char cc_t;
4238689Sborman #endif
4332141Sminshall 
4438689Sborman #define	SUBBUFSIZE	256
4532141Sminshall 
4632141Sminshall extern int errno;		/* outside this world */
4732141Sminshall 
4833802Sminshall extern char
4933802Sminshall     *strcat(),
5033802Sminshall     *strcpy();			/* outside this world */
5133802Sminshall 
5232141Sminshall extern int
5333802Sminshall     flushout,		/* flush output */
5433802Sminshall     connected,		/* Are we connected to the other side? */
5533802Sminshall     globalmode,		/* Mode tty should be in */
5633802Sminshall     In3270,			/* Are we in 3270 mode? */
5733802Sminshall     telnetport,		/* Are we connected to the telnet port? */
5837219Sminshall     localflow,		/* Flow control handled locally */
5933802Sminshall     localchars,		/* we recognize interrupt/quit */
6033802Sminshall     donelclchars,		/* the user has set "localchars" */
6133802Sminshall     showoptions,
6236274Sminshall     net,		/* Network file descriptor */
6336274Sminshall     tin,		/* Terminal input file descriptor */
6433802Sminshall     tout,		/* Terminal output file descriptor */
6533802Sminshall     crlf,		/* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
6633802Sminshall     autoflush,		/* flush output when interrupting? */
6733802Sminshall     autosynch,		/* send interrupt characters with SYNCH? */
6833802Sminshall     SYNCHing,		/* Is the stream in telnet SYNCH mode? */
6933802Sminshall     donebinarytoggle,	/* the user has put us in binary */
7033802Sminshall     dontlecho,		/* do we suppress local echoing right now? */
7133802Sminshall     crmod,
7233802Sminshall     netdata,		/* Print out network data flow */
7338689Sborman     prettydump,		/* Print "netdata" output in user readable format */
7438208Sminshall #if	defined(unix)
7538208Sminshall #if	defined(TN3270)
7638208Sminshall     cursesdata,		/* Print out curses data flow */
7738920Sminshall     apitrace,		/* Trace API transactions */
7838208Sminshall #endif	/* defined(TN3270) */
7938208Sminshall     termdata,		/* Print out terminal data flow */
8038208Sminshall #endif	/* defined(unix) */
8133802Sminshall     debug;			/* Debug level */
8232141Sminshall 
83*40245Sborman extern cc_t
84*40245Sborman     echoc,		/* Toggle local echoing */
85*40245Sborman     escape;		/* Escape to command mode */
86*40245Sborman 
8739529Sborman extern unsigned char
8839529Sborman     *prompt;		/* Prompt for command. */
8939529Sborman 
9032141Sminshall extern char
9133802Sminshall     doopt[],
9233802Sminshall     dont[],
9333802Sminshall     will[],
9433802Sminshall     wont[],
9537226Sminshall     options[],		/* All the little options */
9639529Sborman     *hostname;		/* Who are we connected to? */
9732141Sminshall 
9837226Sminshall /*
9937226Sminshall  * We keep track of each side of the option negotiation.
10037226Sminshall  */
10137226Sminshall 
10238689Sborman #define	MY_STATE_WILL		0x01
10338689Sborman #define	MY_WANT_STATE_WILL	0x02
10438689Sborman #define	MY_STATE_DO		0x04
10538689Sborman #define	MY_WANT_STATE_DO	0x08
10637226Sminshall 
10737226Sminshall /*
10838689Sborman  * Macros to check the current state of things
10937226Sminshall  */
11037226Sminshall 
11138689Sborman #define	my_state_is_do(opt)		(options[opt]&MY_STATE_DO)
11238689Sborman #define	my_state_is_will(opt)		(options[opt]&MY_STATE_WILL)
11338689Sborman #define my_want_state_is_do(opt)	(options[opt]&MY_WANT_STATE_DO)
11438689Sborman #define my_want_state_is_will(opt)	(options[opt]&MY_WANT_STATE_WILL)
11537226Sminshall 
11638689Sborman #define	my_state_is_dont(opt)		(!my_state_is_do(opt))
11738689Sborman #define	my_state_is_wont(opt)		(!my_state_is_will(opt))
11838689Sborman #define my_want_state_is_dont(opt)	(!my_want_state_is_do(opt))
11938689Sborman #define my_want_state_is_wont(opt)	(!my_want_state_is_will(opt))
12037226Sminshall 
12138689Sborman #define	set_my_state_do(opt)		{options[opt] |= MY_STATE_DO;}
12238689Sborman #define	set_my_state_will(opt)		{options[opt] |= MY_STATE_WILL;}
12338689Sborman #define	set_my_want_state_do(opt)	{options[opt] |= MY_WANT_STATE_DO;}
12438689Sborman #define	set_my_want_state_will(opt)	{options[opt] |= MY_WANT_STATE_WILL;}
12538689Sborman 
12638689Sborman #define	set_my_state_dont(opt)		{options[opt] &= ~MY_STATE_DO;}
12738689Sborman #define	set_my_state_wont(opt)		{options[opt] &= ~MY_STATE_WILL;}
12838689Sborman #define	set_my_want_state_dont(opt)	{options[opt] &= ~MY_WANT_STATE_DO;}
12938689Sborman #define	set_my_want_state_wont(opt)	{options[opt] &= ~MY_WANT_STATE_WILL;}
13038689Sborman 
13138689Sborman /*
13238689Sborman  * Make everything symetrical
13338689Sborman  */
13438689Sborman 
13538689Sborman #define	HIS_STATE_WILL			MY_STATE_DO
13638689Sborman #define	HIS_WANT_STATE_WILL		MY_WANT_STATE_DO
13738689Sborman #define HIS_STATE_DO			MY_STATE_WILL
13838689Sborman #define HIS_WANT_STATE_DO		MY_WANT_STATE_WILL
13938689Sborman 
14038689Sborman #define	his_state_is_do			my_state_is_will
14138689Sborman #define	his_state_is_will		my_state_is_do
14238689Sborman #define his_want_state_is_do		my_want_state_is_will
14338689Sborman #define his_want_state_is_will		my_want_state_is_do
14438689Sborman 
14538689Sborman #define	his_state_is_dont		my_state_is_wont
14638689Sborman #define	his_state_is_wont		my_state_is_dont
14738689Sborman #define his_want_state_is_dont		my_want_state_is_wont
14838689Sborman #define his_want_state_is_wont		my_want_state_is_dont
14938689Sborman 
15038689Sborman #define	set_his_state_do		set_my_state_will
15138689Sborman #define	set_his_state_will		set_my_state_do
15238689Sborman #define	set_his_want_state_do		set_my_want_state_will
15338689Sborman #define	set_his_want_state_will		set_my_want_state_do
15438689Sborman 
15538689Sborman #define	set_his_state_dont		set_my_state_wont
15638689Sborman #define	set_his_state_wont		set_my_state_dont
15738689Sborman #define	set_his_want_state_dont		set_my_want_state_wont
15838689Sborman #define	set_his_want_state_wont		set_my_want_state_dont
15938689Sborman 
16038689Sborman 
16132141Sminshall extern FILE
16233802Sminshall     *NetTrace;		/* Where debugging output goes */
16339529Sborman extern unsigned char
16438689Sborman     NetTraceFile[];	/* Name of file where debugging output goes */
16538689Sborman extern void
16638689Sborman     SetNetTrace();	/* Function to change where debugging goes */
16732141Sminshall 
16832141Sminshall extern jmp_buf
16933802Sminshall     peerdied,
17033802Sminshall     toplevel;		/* For error conditions. */
17132141Sminshall 
17232141Sminshall extern void
17334848Sminshall     command(),
17434313Sminshall #if	!defined(NOT43)
17533802Sminshall     dosynch(),
17634313Sminshall #endif	/* !defined(NOT43) */
17738908Sborman     get_status(),
17834848Sminshall     Dump(),
17934848Sminshall     init_3270(),
18034848Sminshall     printoption(),
18134848Sminshall     printsub(),
18237219Sminshall     sendnaws(),
18333802Sminshall     setconnmode(),
18434848Sminshall     setcommandmode(),
18534848Sminshall     setneturg(),
18634848Sminshall     sys_telnet_init(),
18734848Sminshall     telnet(),
18834848Sminshall     TerminalFlushOutput(),
18934848Sminshall     TerminalNewMode(),
19034848Sminshall     TerminalRestoreState(),
19134848Sminshall     TerminalSaveState(),
19234848Sminshall     tninit(),
19334848Sminshall     upcase(),
19434848Sminshall     willoption(),
19534848Sminshall     wontoption();
19632141Sminshall 
19734313Sminshall #if	defined(NOT43)
19834313Sminshall extern int
19934313Sminshall     dosynch();
20034313Sminshall #endif	/* defined(NOT43) */
20134313Sminshall 
20239529Sborman #ifndef	USE_TERMIO
20338689Sborman 
20438689Sborman extern struct	tchars ntc;
20538689Sborman extern struct	ltchars nltc;
20638689Sborman extern struct	sgttyb nttyb;
20738689Sborman 
20839529Sborman # define termEofChar		ntc.t_eofc
20939529Sborman # define termEraseChar		nttyb.sg_erase
21039529Sborman # define termFlushChar		nltc.t_flushc
21139529Sborman # define termIntChar		ntc.t_intrc
21239529Sborman # define termKillChar		nttyb.sg_kill
21339529Sborman # define termLiteralNextChar	nltc.t_lnextc
21439529Sborman # define termQuitChar		ntc.t_quitc
21539529Sborman # define termSuspChar		nltc.t_suspc
21639529Sborman # define termRprntChar		nltc.t_rprntc
21739529Sborman # define termWerasChar		nltc.t_werasc
21839529Sborman # define termStartChar		ntc.t_startc
21939529Sborman # define termStopChar		ntc.t_stopc
220*40245Sborman # define termForw1Char		ntc.t_brkc
221*40245Sborman extern char termForw2Char;
22238689Sborman 
223*40245Sborman # define termEofCharp		(cc_t *)&ntc.t_eofc
224*40245Sborman # define termEraseCharp		(cc_t *)&nttyb.sg_erase
225*40245Sborman # define termFlushCharp		(cc_t *)&nltc.t_flushc
226*40245Sborman # define termIntCharp		(cc_t *)&ntc.t_intrc
227*40245Sborman # define termKillCharp		(cc_t *)&nttyb.sg_kill
228*40245Sborman # define termLiteralNextCharp	(cc_t *)&nltc.t_lnextc
229*40245Sborman # define termQuitCharp		(cc_t *)&ntc.t_quitc
230*40245Sborman # define termSuspCharp		(cc_t *)&nltc.t_suspc
231*40245Sborman # define termRprntCharp		(cc_t *)&nltc.t_rprntc
232*40245Sborman # define termWerasCharp		(cc_t *)&nltc.t_werasc
233*40245Sborman # define termStartCharp		(cc_t *)&ntc.t_startc
234*40245Sborman # define termStopCharp		(cc_t *)&ntc.t_stopc
235*40245Sborman # define termForw1Charp		(cc_t *)&ntc.t_brkc
236*40245Sborman # define termForw2Charp		(cc_t *)&termForw2Char
23738689Sborman 
23838689Sborman # else
23938689Sborman 
24038689Sborman extern struct	termio new_tc;
24138689Sborman 
24239529Sborman # define termEofChar		new_tc.c_cc[VEOF]
24339529Sborman # define termEraseChar		new_tc.c_cc[VERASE]
24439529Sborman # define termIntChar		new_tc.c_cc[VINTR]
24539529Sborman # define termKillChar		new_tc.c_cc[VKILL]
24639529Sborman # define termQuitChar		new_tc.c_cc[VQUIT]
24738689Sborman 
24839529Sborman # ifndef	VSUSP
24939529Sborman extern char termSuspChar;
25039529Sborman # else
25139529Sborman #  define termSuspChar		new_tc.c_cc[VSUSP]
25239529Sborman # endif
25339529Sborman # ifndef	VFLUSHO
25439529Sborman extern char termFlushChar;
25539529Sborman # else
25639529Sborman #  define termFlushChar		new_tc.c_cc[VFLUSHO]
25739529Sborman # endif
25839529Sborman # ifndef VWERASE
25939529Sborman extern char termWerasChar;
26039529Sborman # else
26139529Sborman #  define termWerasChar		new_tc.c_cc[VWERASE]
26239529Sborman # endif
26339529Sborman # ifndef	VREPRINT
26439529Sborman extern char termRprntChar;
26539529Sborman # else
26639529Sborman #  define termRprntChar		new_tc.c_cc[VREPRINT]
26739529Sborman # endif
26839529Sborman # ifndef	VLNEXT
26939529Sborman extern char termLiteralNextChar;
27039529Sborman # else
27139529Sborman #  define termLiteralNextChar	new_tc.c_cc[VLNEXT]
27239529Sborman # endif
27339529Sborman # ifndef	VSTART
27439529Sborman extern char termStartChar;
27539529Sborman # else
27639529Sborman #  define termStartChar		new_tc.c_cc[VSTART]
27739529Sborman # endif
27839529Sborman # ifndef	VSTOP
27939529Sborman extern char termStopChar;
28039529Sborman # else
28139529Sborman #  define termStopChar		new_tc.c_cc[VSTOP]
28239529Sborman # endif
283*40245Sborman # ifndef	VEOL
284*40245Sborman extern char termForw1Char;
285*40245Sborman # else
286*40245Sborman #  define termForw1Char		new_tc.c_cc[VEOL]
287*40245Sborman # endif
288*40245Sborman # ifndef	VEOL2
289*40245Sborman extern char termForw2Char;
290*40245Sborman # else
291*40245Sborman #  define termForw2Char		new_tc.c_cc[VEOL]
292*40245Sborman # endif
29338689Sborman 
29438689Sborman # ifndef CRAY
29539529Sborman #  define termEofCharp		&termEofChar
29639529Sborman #  define termEraseCharp	&termEraseChar
29739529Sborman #  define termIntCharp		&termIntChar
29839529Sborman #  define termKillCharp		&termKillChar
29939529Sborman #  define termQuitCharp		&termQuitChar
30039529Sborman #  define termSuspCharp		&termSuspChar
30139529Sborman #  define termFlushCharp	&termFlushChar
30239529Sborman #  define termWerasCharp	&termWerasChar
30339529Sborman #  define termRprntCharp	&termRprntChar
30439529Sborman #  define termLiteralNextCharp	&termLiteralNextChar
30539529Sborman #  define termStartCharp	&termStartChar
30639529Sborman #  define termStopCharp		&termStopChar
307*40245Sborman #  define termForw1Charp	&termForw1Char
308*40245Sborman #  define termForw2Charp	&termForw2Char
30938689Sborman # else
31038689Sborman 	/* Work around a compiler bug */
31138689Sborman #  define termEofCharp		0
31238689Sborman #  define termEraseCharp	0
31338689Sborman #  define termIntCharp		0
31438689Sborman #  define termKillCharp		0
31538689Sborman #  define termQuitCharp		0
31639529Sborman #  define termSuspCharp		0
31739529Sborman #  define termFlushCharp	0
31839529Sborman #  define termWerasCharp	0
31939529Sborman #  define termRprntCharp	0
32039529Sborman #  define termLiteralNextCharp	0
32139529Sborman #  define termStartCharp	0
32239529Sborman #  define termStopCharp		0
323*40245Sborman #  define termForw1Charp	0
324*40245Sborman #  define termForw2Charp	0
32538689Sborman # endif
32638689Sborman #endif
32738689Sborman 
32838689Sborman 
32932381Sminshall /* Ring buffer structures which are shared */
33032381Sminshall 
33132381Sminshall extern Ring
33233802Sminshall     netoring,
33333802Sminshall     netiring,
33433802Sminshall     ttyoring,
33533802Sminshall     ttyiring;
33633802Sminshall 
33733802Sminshall /* Tn3270 section */
33833802Sminshall #if	defined(TN3270)
33933802Sminshall 
34033802Sminshall extern int
34133802Sminshall     HaveInput,		/* Whether an asynchronous I/O indication came in */
34236241Sminshall     noasynchtty,	/* Don't do signals on I/O (SIGURG, SIGIO) */
34336241Sminshall     noasynchnet,	/* Don't do signals on I/O (SIGURG, SIGIO) */
34436241Sminshall     sigiocount,		/* Count of SIGIO receptions */
34533802Sminshall     shell_active;	/* Subshell is active */
34633802Sminshall 
34733802Sminshall extern char
34833802Sminshall     *Ibackp,		/* Oldest byte of 3270 data */
34933802Sminshall     Ibuf[],		/* 3270 buffer */
35033802Sminshall     *Ifrontp,		/* Where next 3270 byte goes */
35133802Sminshall     tline[],
35233802Sminshall     *transcom;		/* Transparent command */
35333802Sminshall 
35433802Sminshall extern int
35533802Sminshall     settranscom();
35633802Sminshall 
35733802Sminshall extern void
35833802Sminshall     inputAvailable();
35933802Sminshall #endif	/* defined(TN3270) */
360