xref: /csrg-svn/usr.bin/telnet/externs.h (revision 57213)
133685Sbostic /*
245230Sborman  * Copyright (c) 1988, 1990 Regents of the University of California.
333685Sbostic  * All rights reserved.
433685Sbostic  *
542770Sbostic  * %sccs.include.redist.c%
633685Sbostic  *
7*57213Sdab  *	@(#)externs.h	5.4 (Berkeley) 12/18/92
833685Sbostic  */
933685Sbostic 
1039529Sborman #ifndef	BSD
1139529Sborman # define BSD 43
1238689Sborman #endif
1338689Sborman 
14*57213Sdab /*
15*57213Sdab  * ucb stdio.h defines BSD as something wierd
16*57213Sdab  */
17*57213Sdab #if defined(sun) && defined(__svr4__)
18*57213Sdab #define BSD 43
19*57213Sdab #endif
20*57213Sdab 
2139529Sborman #if (BSD > 43 || defined(SYSV_TERMIO)) && !defined(USE_TERMIO)
2239529Sborman # define USE_TERMIO
2339529Sborman #endif
2439529Sborman 
2532141Sminshall #include <stdio.h>
2632141Sminshall #include <setjmp.h>
2744360Sborman #ifndef	FILIO_H
2838689Sborman #include <sys/ioctl.h>
2944360Sborman #else
3044360Sborman #include <sys/filio.h>
3144360Sborman #endif
3238689Sborman #ifdef	USE_TERMIO
3339529Sborman # ifndef	VINTR
3439529Sborman #  ifdef SYSV_TERMIO
3539529Sborman #   include <sys/termio.h>
3639529Sborman #  else
3739529Sborman #   include <sys/termios.h>
3839529Sborman #   define termio termios
3939529Sborman #  endif
4039529Sborman # endif
4144360Sborman #endif
4244360Sborman #if defined(NO_CC_T) || !defined(USE_TERMIO)
4344360Sborman # if !defined(USE_TERMIO)
4440245Sborman typedef char cc_t;
4544360Sborman # else
4644360Sborman typedef unsigned char cc_t;
4744360Sborman # endif
4838689Sborman #endif
4932141Sminshall 
5046808Sdab #ifndef	NO_STRING_H
5146808Sdab #include <string.h>
5246808Sdab #endif
5346808Sdab #include <strings.h>
5446808Sdab 
5545230Sborman #ifndef	_POSIX_VDISABLE
5645230Sborman # ifdef sun
5745230Sborman #  include <sys/param.h>	/* pick up VDISABLE definition, mayby */
5845230Sborman # endif
5945230Sborman # ifdef VDISABLE
6045230Sborman #  define _POSIX_VDISABLE VDISABLE
6145230Sborman # else
6246808Sdab #  define _POSIX_VDISABLE ((cc_t)'\377')
6345230Sborman # endif
6445230Sborman #endif
6545230Sborman 
6638689Sborman #define	SUBBUFSIZE	256
6732141Sminshall 
6832141Sminshall extern int errno;		/* outside this world */
6932141Sminshall 
7046808Sdab #if	!defined(P)
7146808Sdab # ifdef	__STDC__
7246808Sdab #  define	P(x)	x
7346808Sdab # else
7446808Sdab #  define	P(x)	()
7546808Sdab # endif
7646808Sdab #endif
7733802Sminshall 
7832141Sminshall extern int
7946808Sdab     autologin,		/* Autologin enabled */
8047610Sdab     skiprc,		/* Don't process the ~/.telnetrc file */
8146808Sdab     eight,		/* use eight bit mode (binary in and/or out */
8233802Sminshall     flushout,		/* flush output */
8333802Sminshall     connected,		/* Are we connected to the other side? */
8433802Sminshall     globalmode,		/* Mode tty should be in */
8533802Sminshall     In3270,			/* Are we in 3270 mode? */
8633802Sminshall     telnetport,		/* Are we connected to the telnet port? */
8737219Sminshall     localflow,		/* Flow control handled locally */
88*57213Sdab     restartany,		/* If flow control, restart output on any character */
8933802Sminshall     localchars,		/* we recognize interrupt/quit */
9033802Sminshall     donelclchars,		/* the user has set "localchars" */
9133802Sminshall     showoptions,
9236274Sminshall     net,		/* Network file descriptor */
9336274Sminshall     tin,		/* Terminal input file descriptor */
9433802Sminshall     tout,		/* Terminal output file descriptor */
9533802Sminshall     crlf,		/* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
9633802Sminshall     autoflush,		/* flush output when interrupting? */
9733802Sminshall     autosynch,		/* send interrupt characters with SYNCH? */
9833802Sminshall     SYNCHing,		/* Is the stream in telnet SYNCH mode? */
9933802Sminshall     donebinarytoggle,	/* the user has put us in binary */
10033802Sminshall     dontlecho,		/* do we suppress local echoing right now? */
10133802Sminshall     crmod,
10233802Sminshall     netdata,		/* Print out network data flow */
10338689Sborman     prettydump,		/* Print "netdata" output in user readable format */
10438208Sminshall #if	defined(unix)
10538208Sminshall #if	defined(TN3270)
10638208Sminshall     cursesdata,		/* Print out curses data flow */
10738920Sminshall     apitrace,		/* Trace API transactions */
10838208Sminshall #endif	/* defined(TN3270) */
10938208Sminshall     termdata,		/* Print out terminal data flow */
11038208Sminshall #endif	/* defined(unix) */
11133802Sminshall     debug;			/* Debug level */
11232141Sminshall 
11344360Sborman extern cc_t escape;	/* Escape to command mode */
11446808Sdab extern cc_t rlogin;	/* Rlogin mode escape character */
11544360Sborman #ifdef	KLUDGELINEMODE
11644360Sborman extern cc_t echoc;	/* Toggle local echoing */
11744360Sborman #endif
11840245Sborman 
11944360Sborman extern char
12039529Sborman     *prompt;		/* Prompt for command. */
12139529Sborman 
12232141Sminshall extern char
12333802Sminshall     doopt[],
12433802Sminshall     dont[],
12533802Sminshall     will[],
12633802Sminshall     wont[],
12737226Sminshall     options[],		/* All the little options */
12839529Sborman     *hostname;		/* Who are we connected to? */
129*57213Sdab #if	defined(ENCRYPTION)
13046808Sdab extern void (*encrypt_output) P((unsigned char *, int));
13146808Sdab extern int (*decrypt_input) P((int));
13246808Sdab #endif
13332141Sminshall 
13437226Sminshall /*
13537226Sminshall  * We keep track of each side of the option negotiation.
13637226Sminshall  */
13737226Sminshall 
13838689Sborman #define	MY_STATE_WILL		0x01
13938689Sborman #define	MY_WANT_STATE_WILL	0x02
14038689Sborman #define	MY_STATE_DO		0x04
14138689Sborman #define	MY_WANT_STATE_DO	0x08
14237226Sminshall 
14337226Sminshall /*
14438689Sborman  * Macros to check the current state of things
14537226Sminshall  */
14637226Sminshall 
14738689Sborman #define	my_state_is_do(opt)		(options[opt]&MY_STATE_DO)
14838689Sborman #define	my_state_is_will(opt)		(options[opt]&MY_STATE_WILL)
14938689Sborman #define my_want_state_is_do(opt)	(options[opt]&MY_WANT_STATE_DO)
15038689Sborman #define my_want_state_is_will(opt)	(options[opt]&MY_WANT_STATE_WILL)
15137226Sminshall 
15238689Sborman #define	my_state_is_dont(opt)		(!my_state_is_do(opt))
15338689Sborman #define	my_state_is_wont(opt)		(!my_state_is_will(opt))
15438689Sborman #define my_want_state_is_dont(opt)	(!my_want_state_is_do(opt))
15538689Sborman #define my_want_state_is_wont(opt)	(!my_want_state_is_will(opt))
15637226Sminshall 
15738689Sborman #define	set_my_state_do(opt)		{options[opt] |= MY_STATE_DO;}
15838689Sborman #define	set_my_state_will(opt)		{options[opt] |= MY_STATE_WILL;}
15938689Sborman #define	set_my_want_state_do(opt)	{options[opt] |= MY_WANT_STATE_DO;}
16038689Sborman #define	set_my_want_state_will(opt)	{options[opt] |= MY_WANT_STATE_WILL;}
16138689Sborman 
16238689Sborman #define	set_my_state_dont(opt)		{options[opt] &= ~MY_STATE_DO;}
16338689Sborman #define	set_my_state_wont(opt)		{options[opt] &= ~MY_STATE_WILL;}
16438689Sborman #define	set_my_want_state_dont(opt)	{options[opt] &= ~MY_WANT_STATE_DO;}
16538689Sborman #define	set_my_want_state_wont(opt)	{options[opt] &= ~MY_WANT_STATE_WILL;}
16638689Sborman 
16738689Sborman /*
16838689Sborman  * Make everything symetrical
16938689Sborman  */
17038689Sborman 
17138689Sborman #define	HIS_STATE_WILL			MY_STATE_DO
17238689Sborman #define	HIS_WANT_STATE_WILL		MY_WANT_STATE_DO
17338689Sborman #define HIS_STATE_DO			MY_STATE_WILL
17438689Sborman #define HIS_WANT_STATE_DO		MY_WANT_STATE_WILL
17538689Sborman 
17638689Sborman #define	his_state_is_do			my_state_is_will
17738689Sborman #define	his_state_is_will		my_state_is_do
17838689Sborman #define his_want_state_is_do		my_want_state_is_will
17938689Sborman #define his_want_state_is_will		my_want_state_is_do
18038689Sborman 
18138689Sborman #define	his_state_is_dont		my_state_is_wont
18238689Sborman #define	his_state_is_wont		my_state_is_dont
18338689Sborman #define his_want_state_is_dont		my_want_state_is_wont
18438689Sborman #define his_want_state_is_wont		my_want_state_is_dont
18538689Sborman 
18638689Sborman #define	set_his_state_do		set_my_state_will
18738689Sborman #define	set_his_state_will		set_my_state_do
18838689Sborman #define	set_his_want_state_do		set_my_want_state_will
18938689Sborman #define	set_his_want_state_will		set_my_want_state_do
19038689Sborman 
19138689Sborman #define	set_his_state_dont		set_my_state_wont
19238689Sborman #define	set_his_state_wont		set_my_state_dont
19338689Sborman #define	set_his_want_state_dont		set_my_want_state_wont
19438689Sborman #define	set_his_want_state_wont		set_my_want_state_dont
19538689Sborman 
19638689Sborman 
19732141Sminshall extern FILE
19833802Sminshall     *NetTrace;		/* Where debugging output goes */
19939529Sborman extern unsigned char
20038689Sborman     NetTraceFile[];	/* Name of file where debugging output goes */
20138689Sborman extern void
20246808Sdab     SetNetTrace P((char *));	/* Function to change where debugging goes */
20332141Sminshall 
20432141Sminshall extern jmp_buf
20533802Sminshall     peerdied,
20633802Sminshall     toplevel;		/* For error conditions. */
20732141Sminshall 
20832141Sminshall extern void
20946808Sdab     command P((int, char *, int)),
21046808Sdab     Dump P((int, unsigned char *, int)),
21146808Sdab     init_3270 P((void)),
21246808Sdab     printoption P((char *, int, int)),
21346808Sdab     printsub P((int, unsigned char *, int)),
21446808Sdab     sendnaws P((void)),
21546808Sdab     setconnmode P((int)),
21646808Sdab     setcommandmode P((void)),
21746808Sdab     setneturg P((void)),
21846808Sdab     sys_telnet_init P((void)),
21946808Sdab     telnet P((char *)),
22046808Sdab     tel_enter_binary P((int)),
22146808Sdab     TerminalFlushOutput P((void)),
22246808Sdab     TerminalNewMode P((int)),
22346808Sdab     TerminalRestoreState P((void)),
22446808Sdab     TerminalSaveState P((void)),
22546808Sdab     tninit P((void)),
22646808Sdab     upcase P((char *)),
22746808Sdab     willoption P((int)),
22846808Sdab     wontoption P((int));
22932141Sminshall 
23046808Sdab extern void
23146808Sdab     lm_will P((unsigned char *, int)),
23246808Sdab     lm_wont P((unsigned char *, int)),
23346808Sdab     lm_do P((unsigned char *, int)),
23446808Sdab     lm_dont P((unsigned char *, int)),
23546808Sdab     lm_mode P((unsigned char *, int, int));
23646808Sdab 
23746808Sdab extern void
23846808Sdab     slc_init P((void)),
23946808Sdab     slcstate P((void)),
24046808Sdab     slc_mode_export P((void)),
24146808Sdab     slc_mode_import P((int)),
24246808Sdab     slc_import P((int)),
24346808Sdab     slc_export P((void)),
24446808Sdab     slc P((unsigned char *, int)),
24546808Sdab     slc_check P((void)),
24646808Sdab     slc_start_reply P((void)),
24746808Sdab     slc_add_reply P((int, int, int)),
24846808Sdab     slc_end_reply P((void));
24934313Sminshall extern int
25046808Sdab     slc_update P((void));
25134313Sminshall 
25246808Sdab extern void
25346808Sdab     env_opt P((unsigned char *, int)),
25446808Sdab     env_opt_start P((void)),
25546808Sdab     env_opt_start_info P((void)),
25646808Sdab     env_opt_add P((unsigned char *)),
25746808Sdab     env_opt_end P((int));
25846808Sdab 
25946808Sdab extern unsigned char
260*57213Sdab     *env_default P((int, int)),
26146808Sdab     *env_getvalue P((unsigned char *));
26246808Sdab 
26346808Sdab extern int
26446808Sdab     get_status P((void)),
26546808Sdab     dosynch P((void));
26646808Sdab 
26746808Sdab extern cc_t
26846808Sdab     *tcval P((int));
26946808Sdab 
27039529Sborman #ifndef	USE_TERMIO
27138689Sborman 
27238689Sborman extern struct	tchars ntc;
27338689Sborman extern struct	ltchars nltc;
27438689Sborman extern struct	sgttyb nttyb;
27538689Sborman 
27639529Sborman # define termEofChar		ntc.t_eofc
27739529Sborman # define termEraseChar		nttyb.sg_erase
27839529Sborman # define termFlushChar		nltc.t_flushc
27939529Sborman # define termIntChar		ntc.t_intrc
28039529Sborman # define termKillChar		nttyb.sg_kill
28139529Sborman # define termLiteralNextChar	nltc.t_lnextc
28239529Sborman # define termQuitChar		ntc.t_quitc
28339529Sborman # define termSuspChar		nltc.t_suspc
28439529Sborman # define termRprntChar		nltc.t_rprntc
28539529Sborman # define termWerasChar		nltc.t_werasc
28639529Sborman # define termStartChar		ntc.t_startc
28739529Sborman # define termStopChar		ntc.t_stopc
28840245Sborman # define termForw1Char		ntc.t_brkc
28944360Sborman extern cc_t termForw2Char;
29045230Sborman extern cc_t termAytChar;
29138689Sborman 
29240245Sborman # define termEofCharp		(cc_t *)&ntc.t_eofc
29340245Sborman # define termEraseCharp		(cc_t *)&nttyb.sg_erase
29440245Sborman # define termFlushCharp		(cc_t *)&nltc.t_flushc
29540245Sborman # define termIntCharp		(cc_t *)&ntc.t_intrc
29640245Sborman # define termKillCharp		(cc_t *)&nttyb.sg_kill
29740245Sborman # define termLiteralNextCharp	(cc_t *)&nltc.t_lnextc
29840245Sborman # define termQuitCharp		(cc_t *)&ntc.t_quitc
29940245Sborman # define termSuspCharp		(cc_t *)&nltc.t_suspc
30040245Sborman # define termRprntCharp		(cc_t *)&nltc.t_rprntc
30140245Sborman # define termWerasCharp		(cc_t *)&nltc.t_werasc
30240245Sborman # define termStartCharp		(cc_t *)&ntc.t_startc
30340245Sborman # define termStopCharp		(cc_t *)&ntc.t_stopc
30440245Sborman # define termForw1Charp		(cc_t *)&ntc.t_brkc
30540245Sborman # define termForw2Charp		(cc_t *)&termForw2Char
30645230Sborman # define termAytCharp		(cc_t *)&termAytChar
30738689Sborman 
30838689Sborman # else
30938689Sborman 
31038689Sborman extern struct	termio new_tc;
31138689Sborman 
31239529Sborman # define termEofChar		new_tc.c_cc[VEOF]
31339529Sborman # define termEraseChar		new_tc.c_cc[VERASE]
31439529Sborman # define termIntChar		new_tc.c_cc[VINTR]
31539529Sborman # define termKillChar		new_tc.c_cc[VKILL]
31639529Sborman # define termQuitChar		new_tc.c_cc[VQUIT]
31738689Sborman 
31839529Sborman # ifndef	VSUSP
31944360Sborman extern cc_t termSuspChar;
32039529Sborman # else
32139529Sborman #  define termSuspChar		new_tc.c_cc[VSUSP]
32239529Sborman # endif
32345230Sborman # if	defined(VFLUSHO) && !defined(VDISCARD)
32445230Sborman #  define VDISCARD VFLUSHO
32544360Sborman # endif
32645230Sborman # ifndef	VDISCARD
32744360Sborman extern cc_t termFlushChar;
32839529Sborman # else
32945230Sborman #  define termFlushChar		new_tc.c_cc[VDISCARD]
33039529Sborman # endif
33139529Sborman # ifndef VWERASE
33244360Sborman extern cc_t termWerasChar;
33339529Sborman # else
33439529Sborman #  define termWerasChar		new_tc.c_cc[VWERASE]
33539529Sborman # endif
33639529Sborman # ifndef	VREPRINT
33744360Sborman extern cc_t termRprntChar;
33839529Sborman # else
33939529Sborman #  define termRprntChar		new_tc.c_cc[VREPRINT]
34039529Sborman # endif
34139529Sborman # ifndef	VLNEXT
34244360Sborman extern cc_t termLiteralNextChar;
34339529Sborman # else
34439529Sborman #  define termLiteralNextChar	new_tc.c_cc[VLNEXT]
34539529Sborman # endif
34639529Sborman # ifndef	VSTART
34744360Sborman extern cc_t termStartChar;
34839529Sborman # else
34939529Sborman #  define termStartChar		new_tc.c_cc[VSTART]
35039529Sborman # endif
35139529Sborman # ifndef	VSTOP
35244360Sborman extern cc_t termStopChar;
35339529Sborman # else
35439529Sborman #  define termStopChar		new_tc.c_cc[VSTOP]
35539529Sborman # endif
35640245Sborman # ifndef	VEOL
35744360Sborman extern cc_t termForw1Char;
35840245Sborman # else
35940245Sborman #  define termForw1Char		new_tc.c_cc[VEOL]
36040245Sborman # endif
36140245Sborman # ifndef	VEOL2
36244360Sborman extern cc_t termForw2Char;
36340245Sborman # else
36440245Sborman #  define termForw2Char		new_tc.c_cc[VEOL]
36540245Sborman # endif
36645230Sborman # ifndef	VSTATUS
36745230Sborman extern cc_t termAytChar;
36845230Sborman #else
36945230Sborman #  define termAytChar		new_tc.c_cc[VSTATUS]
37045230Sborman #endif
37138689Sborman 
37245230Sborman # if !defined(CRAY) || defined(__STDC__)
37339529Sborman #  define termEofCharp		&termEofChar
37439529Sborman #  define termEraseCharp	&termEraseChar
37539529Sborman #  define termIntCharp		&termIntChar
37639529Sborman #  define termKillCharp		&termKillChar
37739529Sborman #  define termQuitCharp		&termQuitChar
37839529Sborman #  define termSuspCharp		&termSuspChar
37939529Sborman #  define termFlushCharp	&termFlushChar
38039529Sborman #  define termWerasCharp	&termWerasChar
38139529Sborman #  define termRprntCharp	&termRprntChar
38239529Sborman #  define termLiteralNextCharp	&termLiteralNextChar
38339529Sborman #  define termStartCharp	&termStartChar
38439529Sborman #  define termStopCharp		&termStopChar
38540245Sborman #  define termForw1Charp	&termForw1Char
38640245Sborman #  define termForw2Charp	&termForw2Char
38745230Sborman #  define termAytCharp		&termAytChar
38838689Sborman # else
38938689Sborman 	/* Work around a compiler bug */
39038689Sborman #  define termEofCharp		0
39138689Sborman #  define termEraseCharp	0
39238689Sborman #  define termIntCharp		0
39338689Sborman #  define termKillCharp		0
39438689Sborman #  define termQuitCharp		0
39539529Sborman #  define termSuspCharp		0
39639529Sborman #  define termFlushCharp	0
39739529Sborman #  define termWerasCharp	0
39839529Sborman #  define termRprntCharp	0
39939529Sborman #  define termLiteralNextCharp	0
40039529Sborman #  define termStartCharp	0
40139529Sborman #  define termStopCharp		0
40240245Sborman #  define termForw1Charp	0
40340245Sborman #  define termForw2Charp	0
40445230Sborman #  define termAytCharp		0
40538689Sborman # endif
40638689Sborman #endif
40738689Sborman 
40838689Sborman 
40932381Sminshall /* Ring buffer structures which are shared */
41032381Sminshall 
41132381Sminshall extern Ring
41233802Sminshall     netoring,
41333802Sminshall     netiring,
41433802Sminshall     ttyoring,
41533802Sminshall     ttyiring;
41633802Sminshall 
41733802Sminshall /* Tn3270 section */
41833802Sminshall #if	defined(TN3270)
41933802Sminshall 
42033802Sminshall extern int
42133802Sminshall     HaveInput,		/* Whether an asynchronous I/O indication came in */
42236241Sminshall     noasynchtty,	/* Don't do signals on I/O (SIGURG, SIGIO) */
42336241Sminshall     noasynchnet,	/* Don't do signals on I/O (SIGURG, SIGIO) */
42436241Sminshall     sigiocount,		/* Count of SIGIO receptions */
42533802Sminshall     shell_active;	/* Subshell is active */
42633802Sminshall 
42733802Sminshall extern char
42833802Sminshall     *Ibackp,		/* Oldest byte of 3270 data */
42933802Sminshall     Ibuf[],		/* 3270 buffer */
43033802Sminshall     *Ifrontp,		/* Where next 3270 byte goes */
43133802Sminshall     tline[],
43233802Sminshall     *transcom;		/* Transparent command */
43333802Sminshall 
43433802Sminshall extern int
43546808Sdab     settranscom P((int, char**));
43633802Sminshall 
43733802Sminshall extern void
43846808Sdab     inputAvailable P((void));
43933802Sminshall #endif	/* defined(TN3270) */
440