xref: /csrg-svn/usr.bin/telnet/externs.h (revision 69785)
133685Sbostic /*
262309Sbostic  * Copyright (c) 1988, 1990, 1993
362309Sbostic  *	The Regents of the University of California.  All rights reserved.
433685Sbostic  *
542770Sbostic  * %sccs.include.redist.c%
633685Sbostic  *
7*69785Sdab  *	@(#)externs.h	8.3 (Berkeley) 05/30/95
833685Sbostic  */
933685Sbostic 
1039529Sborman #ifndef	BSD
1139529Sborman # define BSD 43
1238689Sborman #endif
1338689Sborman 
1457213Sdab /*
1557213Sdab  * ucb stdio.h defines BSD as something wierd
1657213Sdab  */
1757213Sdab #if defined(sun) && defined(__svr4__)
1857213Sdab #define BSD 43
1957213Sdab #endif
2057213Sdab 
2165157Sdab #ifndef	USE_TERMIO
2265157Sdab # if BSD > 43 || defined(SYSV_TERMIO)
2365157Sdab #  define USE_TERMIO
2465157Sdab # endif
2539529Sborman #endif
2639529Sborman 
2732141Sminshall #include <stdio.h>
2832141Sminshall #include <setjmp.h>
2960149Sdab #if defined(CRAY) && !defined(NO_BSD_SETJMP)
3060149Sdab #include <bsdsetjmp.h>
3160149Sdab #endif
3244360Sborman #ifndef	FILIO_H
3338689Sborman #include <sys/ioctl.h>
3444360Sborman #else
3544360Sborman #include <sys/filio.h>
3644360Sborman #endif
3760149Sdab #ifdef CRAY
3860149Sdab # include <errno.h>
3960149Sdab #endif /* CRAY */
4038689Sborman #ifdef	USE_TERMIO
4139529Sborman # ifndef	VINTR
4239529Sborman #  ifdef SYSV_TERMIO
4339529Sborman #   include <sys/termio.h>
4439529Sborman #  else
4539529Sborman #   include <sys/termios.h>
4639529Sborman #   define termio termios
4739529Sborman #  endif
4839529Sborman # endif
4944360Sborman #endif
5044360Sborman #if defined(NO_CC_T) || !defined(USE_TERMIO)
5144360Sborman # if !defined(USE_TERMIO)
5240245Sborman typedef char cc_t;
5344360Sborman # else
5444360Sborman typedef unsigned char cc_t;
5544360Sborman # endif
5638689Sborman #endif
5732141Sminshall 
5846808Sdab #ifndef	NO_STRING_H
5946808Sdab #include <string.h>
60*69785Sdab #else
61*69785Sdab #include <strings.h>
6246808Sdab #endif
6346808Sdab 
6445230Sborman #ifndef	_POSIX_VDISABLE
6545230Sborman # ifdef sun
6645230Sborman #  include <sys/param.h>	/* pick up VDISABLE definition, mayby */
6745230Sborman # endif
6845230Sborman # ifdef VDISABLE
6945230Sborman #  define _POSIX_VDISABLE VDISABLE
7045230Sborman # else
7146808Sdab #  define _POSIX_VDISABLE ((cc_t)'\377')
7245230Sborman # endif
7345230Sborman #endif
7445230Sborman 
7538689Sborman #define	SUBBUFSIZE	256
7632141Sminshall 
7760149Sdab #ifndef CRAY
7832141Sminshall extern int errno;		/* outside this world */
7960149Sdab #endif /* !CRAY */
8032141Sminshall 
8146808Sdab #if	!defined(P)
8246808Sdab # ifdef	__STDC__
8346808Sdab #  define	P(x)	x
8446808Sdab # else
8546808Sdab #  define	P(x)	()
8646808Sdab # endif
8746808Sdab #endif
8833802Sminshall 
8932141Sminshall extern int
9046808Sdab     autologin,		/* Autologin enabled */
9147610Sdab     skiprc,		/* Don't process the ~/.telnetrc file */
9246808Sdab     eight,		/* use eight bit mode (binary in and/or out */
9333802Sminshall     flushout,		/* flush output */
9433802Sminshall     connected,		/* Are we connected to the other side? */
9533802Sminshall     globalmode,		/* Mode tty should be in */
96*69785Sdab     In3270,		/* Are we in 3270 mode? */
9733802Sminshall     telnetport,		/* Are we connected to the telnet port? */
9837219Sminshall     localflow,		/* Flow control handled locally */
9957213Sdab     restartany,		/* If flow control, restart output on any character */
10033802Sminshall     localchars,		/* we recognize interrupt/quit */
101*69785Sdab     donelclchars,	/* the user has set "localchars" */
10233802Sminshall     showoptions,
10336274Sminshall     net,		/* Network file descriptor */
10436274Sminshall     tin,		/* Terminal input file descriptor */
10533802Sminshall     tout,		/* Terminal output file descriptor */
10633802Sminshall     crlf,		/* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
10733802Sminshall     autoflush,		/* flush output when interrupting? */
10833802Sminshall     autosynch,		/* send interrupt characters with SYNCH? */
10933802Sminshall     SYNCHing,		/* Is the stream in telnet SYNCH mode? */
11033802Sminshall     donebinarytoggle,	/* the user has put us in binary */
11133802Sminshall     dontlecho,		/* do we suppress local echoing right now? */
11233802Sminshall     crmod,
11333802Sminshall     netdata,		/* Print out network data flow */
11438689Sborman     prettydump,		/* Print "netdata" output in user readable format */
11538208Sminshall #if	defined(unix)
11638208Sminshall #if	defined(TN3270)
11738208Sminshall     cursesdata,		/* Print out curses data flow */
11838920Sminshall     apitrace,		/* Trace API transactions */
11938208Sminshall #endif	/* defined(TN3270) */
12038208Sminshall     termdata,		/* Print out terminal data flow */
12138208Sminshall #endif	/* defined(unix) */
122*69785Sdab     debug;		/* Debug level */
12332141Sminshall 
12444360Sborman extern cc_t escape;	/* Escape to command mode */
12546808Sdab extern cc_t rlogin;	/* Rlogin mode escape character */
12644360Sborman #ifdef	KLUDGELINEMODE
12744360Sborman extern cc_t echoc;	/* Toggle local echoing */
12844360Sborman #endif
12940245Sborman 
13044360Sborman extern char
13139529Sborman     *prompt;		/* Prompt for command. */
13239529Sborman 
13332141Sminshall extern char
13433802Sminshall     doopt[],
13533802Sminshall     dont[],
13633802Sminshall     will[],
13733802Sminshall     wont[],
13837226Sminshall     options[],		/* All the little options */
13939529Sborman     *hostname;		/* Who are we connected to? */
14060149Sdab #ifdef	ENCRYPTION
14146808Sdab extern void (*encrypt_output) P((unsigned char *, int));
14246808Sdab extern int (*decrypt_input) P((int));
14360149Sdab #endif	/* ENCRYPTION */
14432141Sminshall 
14537226Sminshall /*
14637226Sminshall  * We keep track of each side of the option negotiation.
14737226Sminshall  */
14837226Sminshall 
14938689Sborman #define	MY_STATE_WILL		0x01
15038689Sborman #define	MY_WANT_STATE_WILL	0x02
15138689Sborman #define	MY_STATE_DO		0x04
15238689Sborman #define	MY_WANT_STATE_DO	0x08
15337226Sminshall 
15437226Sminshall /*
15538689Sborman  * Macros to check the current state of things
15637226Sminshall  */
15737226Sminshall 
15838689Sborman #define	my_state_is_do(opt)		(options[opt]&MY_STATE_DO)
15938689Sborman #define	my_state_is_will(opt)		(options[opt]&MY_STATE_WILL)
16038689Sborman #define my_want_state_is_do(opt)	(options[opt]&MY_WANT_STATE_DO)
16138689Sborman #define my_want_state_is_will(opt)	(options[opt]&MY_WANT_STATE_WILL)
16237226Sminshall 
16338689Sborman #define	my_state_is_dont(opt)		(!my_state_is_do(opt))
16438689Sborman #define	my_state_is_wont(opt)		(!my_state_is_will(opt))
16538689Sborman #define my_want_state_is_dont(opt)	(!my_want_state_is_do(opt))
16638689Sborman #define my_want_state_is_wont(opt)	(!my_want_state_is_will(opt))
16737226Sminshall 
16838689Sborman #define	set_my_state_do(opt)		{options[opt] |= MY_STATE_DO;}
16938689Sborman #define	set_my_state_will(opt)		{options[opt] |= MY_STATE_WILL;}
17038689Sborman #define	set_my_want_state_do(opt)	{options[opt] |= MY_WANT_STATE_DO;}
17138689Sborman #define	set_my_want_state_will(opt)	{options[opt] |= MY_WANT_STATE_WILL;}
17238689Sborman 
17338689Sborman #define	set_my_state_dont(opt)		{options[opt] &= ~MY_STATE_DO;}
17438689Sborman #define	set_my_state_wont(opt)		{options[opt] &= ~MY_STATE_WILL;}
17538689Sborman #define	set_my_want_state_dont(opt)	{options[opt] &= ~MY_WANT_STATE_DO;}
17638689Sborman #define	set_my_want_state_wont(opt)	{options[opt] &= ~MY_WANT_STATE_WILL;}
17738689Sborman 
17838689Sborman /*
17938689Sborman  * Make everything symetrical
18038689Sborman  */
18138689Sborman 
18238689Sborman #define	HIS_STATE_WILL			MY_STATE_DO
18338689Sborman #define	HIS_WANT_STATE_WILL		MY_WANT_STATE_DO
18438689Sborman #define HIS_STATE_DO			MY_STATE_WILL
18538689Sborman #define HIS_WANT_STATE_DO		MY_WANT_STATE_WILL
18638689Sborman 
18738689Sborman #define	his_state_is_do			my_state_is_will
18838689Sborman #define	his_state_is_will		my_state_is_do
18938689Sborman #define his_want_state_is_do		my_want_state_is_will
19038689Sborman #define his_want_state_is_will		my_want_state_is_do
19138689Sborman 
19238689Sborman #define	his_state_is_dont		my_state_is_wont
19338689Sborman #define	his_state_is_wont		my_state_is_dont
19438689Sborman #define his_want_state_is_dont		my_want_state_is_wont
19538689Sborman #define his_want_state_is_wont		my_want_state_is_dont
19638689Sborman 
19738689Sborman #define	set_his_state_do		set_my_state_will
19838689Sborman #define	set_his_state_will		set_my_state_do
19938689Sborman #define	set_his_want_state_do		set_my_want_state_will
20038689Sborman #define	set_his_want_state_will		set_my_want_state_do
20138689Sborman 
20238689Sborman #define	set_his_state_dont		set_my_state_wont
20338689Sborman #define	set_his_state_wont		set_my_state_dont
20438689Sborman #define	set_his_want_state_dont		set_my_want_state_wont
20538689Sborman #define	set_his_want_state_wont		set_my_want_state_dont
20638689Sborman 
20738689Sborman 
20832141Sminshall extern FILE
20933802Sminshall     *NetTrace;		/* Where debugging output goes */
21039529Sborman extern unsigned char
21138689Sborman     NetTraceFile[];	/* Name of file where debugging output goes */
21238689Sborman extern void
21346808Sdab     SetNetTrace P((char *));	/* Function to change where debugging goes */
21432141Sminshall 
21532141Sminshall extern jmp_buf
21633802Sminshall     peerdied,
21733802Sminshall     toplevel;		/* For error conditions. */
21832141Sminshall 
21932141Sminshall extern void
22046808Sdab     command P((int, char *, int)),
22146808Sdab     Dump P((int, unsigned char *, int)),
22246808Sdab     init_3270 P((void)),
22346808Sdab     printoption P((char *, int, int)),
22446808Sdab     printsub P((int, unsigned char *, int)),
22546808Sdab     sendnaws P((void)),
22646808Sdab     setconnmode P((int)),
22746808Sdab     setcommandmode P((void)),
22846808Sdab     setneturg P((void)),
22946808Sdab     sys_telnet_init P((void)),
23046808Sdab     telnet P((char *)),
23146808Sdab     tel_enter_binary P((int)),
23246808Sdab     TerminalFlushOutput P((void)),
23346808Sdab     TerminalNewMode P((int)),
23446808Sdab     TerminalRestoreState P((void)),
23546808Sdab     TerminalSaveState P((void)),
23646808Sdab     tninit P((void)),
23746808Sdab     upcase P((char *)),
23846808Sdab     willoption P((int)),
23946808Sdab     wontoption P((int));
24032141Sminshall 
24146808Sdab extern void
24258972Sdab     send_do P((int, int)),
24358972Sdab     send_dont P((int, int)),
24458972Sdab     send_will P((int, int)),
24558972Sdab     send_wont P((int, int));
24658972Sdab 
24758972Sdab extern void
24846808Sdab     lm_will P((unsigned char *, int)),
24946808Sdab     lm_wont P((unsigned char *, int)),
25046808Sdab     lm_do P((unsigned char *, int)),
25146808Sdab     lm_dont P((unsigned char *, int)),
25246808Sdab     lm_mode P((unsigned char *, int, int));
25346808Sdab 
25446808Sdab extern void
25546808Sdab     slc_init P((void)),
25646808Sdab     slcstate P((void)),
25746808Sdab     slc_mode_export P((void)),
25846808Sdab     slc_mode_import P((int)),
25946808Sdab     slc_import P((int)),
26046808Sdab     slc_export P((void)),
26146808Sdab     slc P((unsigned char *, int)),
26246808Sdab     slc_check P((void)),
26346808Sdab     slc_start_reply P((void)),
26446808Sdab     slc_add_reply P((int, int, int)),
26546808Sdab     slc_end_reply P((void));
26634313Sminshall extern int
26746808Sdab     slc_update P((void));
26834313Sminshall 
26946808Sdab extern void
27046808Sdab     env_opt P((unsigned char *, int)),
27146808Sdab     env_opt_start P((void)),
27246808Sdab     env_opt_start_info P((void)),
27346808Sdab     env_opt_add P((unsigned char *)),
27446808Sdab     env_opt_end P((int));
27546808Sdab 
27646808Sdab extern unsigned char
27757213Sdab     *env_default P((int, int)),
27846808Sdab     *env_getvalue P((unsigned char *));
27946808Sdab 
28046808Sdab extern int
28146808Sdab     get_status P((void)),
28246808Sdab     dosynch P((void));
28346808Sdab 
28446808Sdab extern cc_t
28546808Sdab     *tcval P((int));
28646808Sdab 
28739529Sborman #ifndef	USE_TERMIO
28838689Sborman 
28938689Sborman extern struct	tchars ntc;
29038689Sborman extern struct	ltchars nltc;
29138689Sborman extern struct	sgttyb nttyb;
29238689Sborman 
29339529Sborman # define termEofChar		ntc.t_eofc
29439529Sborman # define termEraseChar		nttyb.sg_erase
29539529Sborman # define termFlushChar		nltc.t_flushc
29639529Sborman # define termIntChar		ntc.t_intrc
29739529Sborman # define termKillChar		nttyb.sg_kill
29839529Sborman # define termLiteralNextChar	nltc.t_lnextc
29939529Sborman # define termQuitChar		ntc.t_quitc
30039529Sborman # define termSuspChar		nltc.t_suspc
30139529Sborman # define termRprntChar		nltc.t_rprntc
30239529Sborman # define termWerasChar		nltc.t_werasc
30339529Sborman # define termStartChar		ntc.t_startc
30439529Sborman # define termStopChar		ntc.t_stopc
30540245Sborman # define termForw1Char		ntc.t_brkc
30644360Sborman extern cc_t termForw2Char;
30745230Sborman extern cc_t termAytChar;
30838689Sborman 
30940245Sborman # define termEofCharp		(cc_t *)&ntc.t_eofc
31040245Sborman # define termEraseCharp		(cc_t *)&nttyb.sg_erase
31140245Sborman # define termFlushCharp		(cc_t *)&nltc.t_flushc
31240245Sborman # define termIntCharp		(cc_t *)&ntc.t_intrc
31340245Sborman # define termKillCharp		(cc_t *)&nttyb.sg_kill
31440245Sborman # define termLiteralNextCharp	(cc_t *)&nltc.t_lnextc
31540245Sborman # define termQuitCharp		(cc_t *)&ntc.t_quitc
31640245Sborman # define termSuspCharp		(cc_t *)&nltc.t_suspc
31740245Sborman # define termRprntCharp		(cc_t *)&nltc.t_rprntc
31840245Sborman # define termWerasCharp		(cc_t *)&nltc.t_werasc
31940245Sborman # define termStartCharp		(cc_t *)&ntc.t_startc
32040245Sborman # define termStopCharp		(cc_t *)&ntc.t_stopc
32140245Sborman # define termForw1Charp		(cc_t *)&ntc.t_brkc
32240245Sborman # define termForw2Charp		(cc_t *)&termForw2Char
32345230Sborman # define termAytCharp		(cc_t *)&termAytChar
32438689Sborman 
32538689Sborman # else
32638689Sborman 
32738689Sborman extern struct	termio new_tc;
32838689Sborman 
32939529Sborman # define termEofChar		new_tc.c_cc[VEOF]
33039529Sborman # define termEraseChar		new_tc.c_cc[VERASE]
33139529Sborman # define termIntChar		new_tc.c_cc[VINTR]
33239529Sborman # define termKillChar		new_tc.c_cc[VKILL]
33339529Sborman # define termQuitChar		new_tc.c_cc[VQUIT]
33438689Sborman 
33539529Sborman # ifndef	VSUSP
33644360Sborman extern cc_t termSuspChar;
33739529Sborman # else
33839529Sborman #  define termSuspChar		new_tc.c_cc[VSUSP]
33939529Sborman # endif
34045230Sborman # if	defined(VFLUSHO) && !defined(VDISCARD)
34145230Sborman #  define VDISCARD VFLUSHO
34244360Sborman # endif
34345230Sborman # ifndef	VDISCARD
34444360Sborman extern cc_t termFlushChar;
34539529Sborman # else
34645230Sborman #  define termFlushChar		new_tc.c_cc[VDISCARD]
34739529Sborman # endif
34839529Sborman # ifndef VWERASE
34944360Sborman extern cc_t termWerasChar;
35039529Sborman # else
35139529Sborman #  define termWerasChar		new_tc.c_cc[VWERASE]
35239529Sborman # endif
35339529Sborman # ifndef	VREPRINT
35444360Sborman extern cc_t termRprntChar;
35539529Sborman # else
35639529Sborman #  define termRprntChar		new_tc.c_cc[VREPRINT]
35739529Sborman # endif
35839529Sborman # ifndef	VLNEXT
35944360Sborman extern cc_t termLiteralNextChar;
36039529Sborman # else
36139529Sborman #  define termLiteralNextChar	new_tc.c_cc[VLNEXT]
36239529Sborman # endif
36339529Sborman # ifndef	VSTART
36444360Sborman extern cc_t termStartChar;
36539529Sborman # else
36639529Sborman #  define termStartChar		new_tc.c_cc[VSTART]
36739529Sborman # endif
36839529Sborman # ifndef	VSTOP
36944360Sborman extern cc_t termStopChar;
37039529Sborman # else
37139529Sborman #  define termStopChar		new_tc.c_cc[VSTOP]
37239529Sborman # endif
37340245Sborman # ifndef	VEOL
37444360Sborman extern cc_t termForw1Char;
37540245Sborman # else
37640245Sborman #  define termForw1Char		new_tc.c_cc[VEOL]
37740245Sborman # endif
37840245Sborman # ifndef	VEOL2
37944360Sborman extern cc_t termForw2Char;
38040245Sborman # else
38140245Sborman #  define termForw2Char		new_tc.c_cc[VEOL]
38240245Sborman # endif
38345230Sborman # ifndef	VSTATUS
38445230Sborman extern cc_t termAytChar;
38545230Sborman #else
38645230Sborman #  define termAytChar		new_tc.c_cc[VSTATUS]
38745230Sborman #endif
38838689Sborman 
38945230Sborman # if !defined(CRAY) || defined(__STDC__)
39039529Sborman #  define termEofCharp		&termEofChar
39139529Sborman #  define termEraseCharp	&termEraseChar
39239529Sborman #  define termIntCharp		&termIntChar
39339529Sborman #  define termKillCharp		&termKillChar
39439529Sborman #  define termQuitCharp		&termQuitChar
39539529Sborman #  define termSuspCharp		&termSuspChar
39639529Sborman #  define termFlushCharp	&termFlushChar
39739529Sborman #  define termWerasCharp	&termWerasChar
39839529Sborman #  define termRprntCharp	&termRprntChar
39939529Sborman #  define termLiteralNextCharp	&termLiteralNextChar
40039529Sborman #  define termStartCharp	&termStartChar
40139529Sborman #  define termStopCharp		&termStopChar
40240245Sborman #  define termForw1Charp	&termForw1Char
40340245Sborman #  define termForw2Charp	&termForw2Char
40445230Sborman #  define termAytCharp		&termAytChar
40538689Sborman # else
40638689Sborman 	/* Work around a compiler bug */
40738689Sborman #  define termEofCharp		0
40838689Sborman #  define termEraseCharp	0
40938689Sborman #  define termIntCharp		0
41038689Sborman #  define termKillCharp		0
41138689Sborman #  define termQuitCharp		0
41239529Sborman #  define termSuspCharp		0
41339529Sborman #  define termFlushCharp	0
41439529Sborman #  define termWerasCharp	0
41539529Sborman #  define termRprntCharp	0
41639529Sborman #  define termLiteralNextCharp	0
41739529Sborman #  define termStartCharp	0
41839529Sborman #  define termStopCharp		0
41940245Sborman #  define termForw1Charp	0
42040245Sborman #  define termForw2Charp	0
42145230Sborman #  define termAytCharp		0
42238689Sborman # endif
42338689Sborman #endif
42438689Sborman 
42538689Sborman 
42632381Sminshall /* Ring buffer structures which are shared */
42732381Sminshall 
42832381Sminshall extern Ring
42933802Sminshall     netoring,
43033802Sminshall     netiring,
43133802Sminshall     ttyoring,
43233802Sminshall     ttyiring;
43333802Sminshall 
43433802Sminshall /* Tn3270 section */
43533802Sminshall #if	defined(TN3270)
43633802Sminshall 
43733802Sminshall extern int
43833802Sminshall     HaveInput,		/* Whether an asynchronous I/O indication came in */
43936241Sminshall     noasynchtty,	/* Don't do signals on I/O (SIGURG, SIGIO) */
44036241Sminshall     noasynchnet,	/* Don't do signals on I/O (SIGURG, SIGIO) */
44136241Sminshall     sigiocount,		/* Count of SIGIO receptions */
44233802Sminshall     shell_active;	/* Subshell is active */
44333802Sminshall 
44433802Sminshall extern char
44533802Sminshall     *Ibackp,		/* Oldest byte of 3270 data */
44633802Sminshall     Ibuf[],		/* 3270 buffer */
44733802Sminshall     *Ifrontp,		/* Where next 3270 byte goes */
44833802Sminshall     tline[],
44933802Sminshall     *transcom;		/* Transparent command */
45033802Sminshall 
45160179Sbostic extern int
45246808Sdab     settranscom P((int, char**));
45333802Sminshall 
45433802Sminshall extern void
45559893Sbostic     inputAvailable P((int));
45633802Sminshall #endif	/* defined(TN3270) */
457