xref: /csrg-svn/usr.bin/telnet/externs.h (revision 60149)
133685Sbostic /*
245230Sborman  * Copyright (c) 1988, 1990 Regents of the University of California.
333685Sbostic  * All rights reserved.
433685Sbostic  *
542770Sbostic  * %sccs.include.redist.c%
633685Sbostic  *
7*60149Sdab  *	@(#)externs.h	5.7 (Berkeley) 05/20/93
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 
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>
27*60149Sdab #if defined(CRAY) && !defined(NO_BSD_SETJMP)
28*60149Sdab #include <bsdsetjmp.h>
29*60149Sdab #endif
3044360Sborman #ifndef	FILIO_H
3138689Sborman #include <sys/ioctl.h>
3244360Sborman #else
3344360Sborman #include <sys/filio.h>
3444360Sborman #endif
35*60149Sdab #ifdef CRAY
36*60149Sdab # include <errno.h>
37*60149Sdab #endif /* CRAY */
3838689Sborman #ifdef	USE_TERMIO
3939529Sborman # ifndef	VINTR
4039529Sborman #  ifdef SYSV_TERMIO
4139529Sborman #   include <sys/termio.h>
4239529Sborman #  else
4339529Sborman #   include <sys/termios.h>
4439529Sborman #   define termio termios
4539529Sborman #  endif
4639529Sborman # endif
4744360Sborman #endif
4844360Sborman #if defined(NO_CC_T) || !defined(USE_TERMIO)
4944360Sborman # if !defined(USE_TERMIO)
5040245Sborman typedef char cc_t;
5144360Sborman # else
5244360Sborman typedef unsigned char cc_t;
5344360Sborman # endif
5438689Sborman #endif
5532141Sminshall 
5646808Sdab #ifndef	NO_STRING_H
5746808Sdab #include <string.h>
5846808Sdab #endif
5946808Sdab #include <strings.h>
6046808Sdab 
6145230Sborman #ifndef	_POSIX_VDISABLE
6245230Sborman # ifdef sun
6345230Sborman #  include <sys/param.h>	/* pick up VDISABLE definition, mayby */
6445230Sborman # endif
6545230Sborman # ifdef VDISABLE
6645230Sborman #  define _POSIX_VDISABLE VDISABLE
6745230Sborman # else
6846808Sdab #  define _POSIX_VDISABLE ((cc_t)'\377')
6945230Sborman # endif
7045230Sborman #endif
7145230Sborman 
7238689Sborman #define	SUBBUFSIZE	256
7332141Sminshall 
74*60149Sdab #ifndef CRAY
7532141Sminshall extern int errno;		/* outside this world */
76*60149Sdab #endif /* !CRAY */
7732141Sminshall 
7846808Sdab #if	!defined(P)
7946808Sdab # ifdef	__STDC__
8046808Sdab #  define	P(x)	x
8146808Sdab # else
8246808Sdab #  define	P(x)	()
8346808Sdab # endif
8446808Sdab #endif
8533802Sminshall 
8632141Sminshall extern int
8746808Sdab     autologin,		/* Autologin enabled */
8847610Sdab     skiprc,		/* Don't process the ~/.telnetrc file */
8946808Sdab     eight,		/* use eight bit mode (binary in and/or out */
9033802Sminshall     flushout,		/* flush output */
9133802Sminshall     connected,		/* Are we connected to the other side? */
9233802Sminshall     globalmode,		/* Mode tty should be in */
9333802Sminshall     In3270,			/* Are we in 3270 mode? */
9433802Sminshall     telnetport,		/* Are we connected to the telnet port? */
9537219Sminshall     localflow,		/* Flow control handled locally */
9657213Sdab     restartany,		/* If flow control, restart output on any character */
9733802Sminshall     localchars,		/* we recognize interrupt/quit */
9833802Sminshall     donelclchars,		/* the user has set "localchars" */
9933802Sminshall     showoptions,
10036274Sminshall     net,		/* Network file descriptor */
10136274Sminshall     tin,		/* Terminal input file descriptor */
10233802Sminshall     tout,		/* Terminal output file descriptor */
10333802Sminshall     crlf,		/* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
10433802Sminshall     autoflush,		/* flush output when interrupting? */
10533802Sminshall     autosynch,		/* send interrupt characters with SYNCH? */
10633802Sminshall     SYNCHing,		/* Is the stream in telnet SYNCH mode? */
10733802Sminshall     donebinarytoggle,	/* the user has put us in binary */
10833802Sminshall     dontlecho,		/* do we suppress local echoing right now? */
10933802Sminshall     crmod,
11033802Sminshall     netdata,		/* Print out network data flow */
11138689Sborman     prettydump,		/* Print "netdata" output in user readable format */
11238208Sminshall #if	defined(unix)
11338208Sminshall #if	defined(TN3270)
11438208Sminshall     cursesdata,		/* Print out curses data flow */
11538920Sminshall     apitrace,		/* Trace API transactions */
11638208Sminshall #endif	/* defined(TN3270) */
11738208Sminshall     termdata,		/* Print out terminal data flow */
11838208Sminshall #endif	/* defined(unix) */
11933802Sminshall     debug;			/* Debug level */
12032141Sminshall 
12144360Sborman extern cc_t escape;	/* Escape to command mode */
12246808Sdab extern cc_t rlogin;	/* Rlogin mode escape character */
12344360Sborman #ifdef	KLUDGELINEMODE
12444360Sborman extern cc_t echoc;	/* Toggle local echoing */
12544360Sborman #endif
12640245Sborman 
12744360Sborman extern char
12839529Sborman     *prompt;		/* Prompt for command. */
12939529Sborman 
13032141Sminshall extern char
13133802Sminshall     doopt[],
13233802Sminshall     dont[],
13333802Sminshall     will[],
13433802Sminshall     wont[],
13537226Sminshall     options[],		/* All the little options */
13639529Sborman     *hostname;		/* Who are we connected to? */
137*60149Sdab #ifdef	ENCRYPTION
13846808Sdab extern void (*encrypt_output) P((unsigned char *, int));
13946808Sdab extern int (*decrypt_input) P((int));
140*60149Sdab #endif	/* ENCRYPTION */
14132141Sminshall 
14237226Sminshall /*
14337226Sminshall  * We keep track of each side of the option negotiation.
14437226Sminshall  */
14537226Sminshall 
14638689Sborman #define	MY_STATE_WILL		0x01
14738689Sborman #define	MY_WANT_STATE_WILL	0x02
14838689Sborman #define	MY_STATE_DO		0x04
14938689Sborman #define	MY_WANT_STATE_DO	0x08
15037226Sminshall 
15137226Sminshall /*
15238689Sborman  * Macros to check the current state of things
15337226Sminshall  */
15437226Sminshall 
15538689Sborman #define	my_state_is_do(opt)		(options[opt]&MY_STATE_DO)
15638689Sborman #define	my_state_is_will(opt)		(options[opt]&MY_STATE_WILL)
15738689Sborman #define my_want_state_is_do(opt)	(options[opt]&MY_WANT_STATE_DO)
15838689Sborman #define my_want_state_is_will(opt)	(options[opt]&MY_WANT_STATE_WILL)
15937226Sminshall 
16038689Sborman #define	my_state_is_dont(opt)		(!my_state_is_do(opt))
16138689Sborman #define	my_state_is_wont(opt)		(!my_state_is_will(opt))
16238689Sborman #define my_want_state_is_dont(opt)	(!my_want_state_is_do(opt))
16338689Sborman #define my_want_state_is_wont(opt)	(!my_want_state_is_will(opt))
16437226Sminshall 
16538689Sborman #define	set_my_state_do(opt)		{options[opt] |= MY_STATE_DO;}
16638689Sborman #define	set_my_state_will(opt)		{options[opt] |= MY_STATE_WILL;}
16738689Sborman #define	set_my_want_state_do(opt)	{options[opt] |= MY_WANT_STATE_DO;}
16838689Sborman #define	set_my_want_state_will(opt)	{options[opt] |= MY_WANT_STATE_WILL;}
16938689Sborman 
17038689Sborman #define	set_my_state_dont(opt)		{options[opt] &= ~MY_STATE_DO;}
17138689Sborman #define	set_my_state_wont(opt)		{options[opt] &= ~MY_STATE_WILL;}
17238689Sborman #define	set_my_want_state_dont(opt)	{options[opt] &= ~MY_WANT_STATE_DO;}
17338689Sborman #define	set_my_want_state_wont(opt)	{options[opt] &= ~MY_WANT_STATE_WILL;}
17438689Sborman 
17538689Sborman /*
17638689Sborman  * Make everything symetrical
17738689Sborman  */
17838689Sborman 
17938689Sborman #define	HIS_STATE_WILL			MY_STATE_DO
18038689Sborman #define	HIS_WANT_STATE_WILL		MY_WANT_STATE_DO
18138689Sborman #define HIS_STATE_DO			MY_STATE_WILL
18238689Sborman #define HIS_WANT_STATE_DO		MY_WANT_STATE_WILL
18338689Sborman 
18438689Sborman #define	his_state_is_do			my_state_is_will
18538689Sborman #define	his_state_is_will		my_state_is_do
18638689Sborman #define his_want_state_is_do		my_want_state_is_will
18738689Sborman #define his_want_state_is_will		my_want_state_is_do
18838689Sborman 
18938689Sborman #define	his_state_is_dont		my_state_is_wont
19038689Sborman #define	his_state_is_wont		my_state_is_dont
19138689Sborman #define his_want_state_is_dont		my_want_state_is_wont
19238689Sborman #define his_want_state_is_wont		my_want_state_is_dont
19338689Sborman 
19438689Sborman #define	set_his_state_do		set_my_state_will
19538689Sborman #define	set_his_state_will		set_my_state_do
19638689Sborman #define	set_his_want_state_do		set_my_want_state_will
19738689Sborman #define	set_his_want_state_will		set_my_want_state_do
19838689Sborman 
19938689Sborman #define	set_his_state_dont		set_my_state_wont
20038689Sborman #define	set_his_state_wont		set_my_state_dont
20138689Sborman #define	set_his_want_state_dont		set_my_want_state_wont
20238689Sborman #define	set_his_want_state_wont		set_my_want_state_dont
20338689Sborman 
20438689Sborman 
20532141Sminshall extern FILE
20633802Sminshall     *NetTrace;		/* Where debugging output goes */
20739529Sborman extern unsigned char
20838689Sborman     NetTraceFile[];	/* Name of file where debugging output goes */
20938689Sborman extern void
21046808Sdab     SetNetTrace P((char *));	/* Function to change where debugging goes */
21132141Sminshall 
21232141Sminshall extern jmp_buf
21333802Sminshall     peerdied,
21433802Sminshall     toplevel;		/* For error conditions. */
21532141Sminshall 
21632141Sminshall extern void
21746808Sdab     command P((int, char *, int)),
21846808Sdab     Dump P((int, unsigned char *, int)),
21946808Sdab     init_3270 P((void)),
22046808Sdab     printoption P((char *, int, int)),
22146808Sdab     printsub P((int, unsigned char *, int)),
22246808Sdab     sendnaws P((void)),
22346808Sdab     setconnmode P((int)),
22446808Sdab     setcommandmode P((void)),
22546808Sdab     setneturg P((void)),
22646808Sdab     sys_telnet_init P((void)),
22746808Sdab     telnet P((char *)),
22846808Sdab     tel_enter_binary P((int)),
22946808Sdab     TerminalFlushOutput P((void)),
23046808Sdab     TerminalNewMode P((int)),
23146808Sdab     TerminalRestoreState P((void)),
23246808Sdab     TerminalSaveState P((void)),
23346808Sdab     tninit P((void)),
23446808Sdab     upcase P((char *)),
23546808Sdab     willoption P((int)),
23646808Sdab     wontoption P((int));
23732141Sminshall 
23846808Sdab extern void
23958972Sdab     send_do P((int, int)),
24058972Sdab     send_dont P((int, int)),
24158972Sdab     send_will P((int, int)),
24258972Sdab     send_wont P((int, int));
24358972Sdab 
24458972Sdab extern void
24546808Sdab     lm_will P((unsigned char *, int)),
24646808Sdab     lm_wont P((unsigned char *, int)),
24746808Sdab     lm_do P((unsigned char *, int)),
24846808Sdab     lm_dont P((unsigned char *, int)),
24946808Sdab     lm_mode P((unsigned char *, int, int));
25046808Sdab 
25146808Sdab extern void
25246808Sdab     slc_init P((void)),
25346808Sdab     slcstate P((void)),
25446808Sdab     slc_mode_export P((void)),
25546808Sdab     slc_mode_import P((int)),
25646808Sdab     slc_import P((int)),
25746808Sdab     slc_export P((void)),
25846808Sdab     slc P((unsigned char *, int)),
25946808Sdab     slc_check P((void)),
26046808Sdab     slc_start_reply P((void)),
26146808Sdab     slc_add_reply P((int, int, int)),
26246808Sdab     slc_end_reply P((void));
26334313Sminshall extern int
26446808Sdab     slc_update P((void));
26534313Sminshall 
26646808Sdab extern void
26746808Sdab     env_opt P((unsigned char *, int)),
26846808Sdab     env_opt_start P((void)),
26946808Sdab     env_opt_start_info P((void)),
27046808Sdab     env_opt_add P((unsigned char *)),
27146808Sdab     env_opt_end P((int));
27246808Sdab 
27346808Sdab extern unsigned char
27457213Sdab     *env_default P((int, int)),
27546808Sdab     *env_getvalue P((unsigned char *));
27646808Sdab 
27746808Sdab extern int
27846808Sdab     get_status P((void)),
27946808Sdab     dosynch P((void));
28046808Sdab 
28146808Sdab extern cc_t
28246808Sdab     *tcval P((int));
28346808Sdab 
28439529Sborman #ifndef	USE_TERMIO
28538689Sborman 
28638689Sborman extern struct	tchars ntc;
28738689Sborman extern struct	ltchars nltc;
28838689Sborman extern struct	sgttyb nttyb;
28938689Sborman 
29039529Sborman # define termEofChar		ntc.t_eofc
29139529Sborman # define termEraseChar		nttyb.sg_erase
29239529Sborman # define termFlushChar		nltc.t_flushc
29339529Sborman # define termIntChar		ntc.t_intrc
29439529Sborman # define termKillChar		nttyb.sg_kill
29539529Sborman # define termLiteralNextChar	nltc.t_lnextc
29639529Sborman # define termQuitChar		ntc.t_quitc
29739529Sborman # define termSuspChar		nltc.t_suspc
29839529Sborman # define termRprntChar		nltc.t_rprntc
29939529Sborman # define termWerasChar		nltc.t_werasc
30039529Sborman # define termStartChar		ntc.t_startc
30139529Sborman # define termStopChar		ntc.t_stopc
30240245Sborman # define termForw1Char		ntc.t_brkc
30344360Sborman extern cc_t termForw2Char;
30445230Sborman extern cc_t termAytChar;
30538689Sborman 
30640245Sborman # define termEofCharp		(cc_t *)&ntc.t_eofc
30740245Sborman # define termEraseCharp		(cc_t *)&nttyb.sg_erase
30840245Sborman # define termFlushCharp		(cc_t *)&nltc.t_flushc
30940245Sborman # define termIntCharp		(cc_t *)&ntc.t_intrc
31040245Sborman # define termKillCharp		(cc_t *)&nttyb.sg_kill
31140245Sborman # define termLiteralNextCharp	(cc_t *)&nltc.t_lnextc
31240245Sborman # define termQuitCharp		(cc_t *)&ntc.t_quitc
31340245Sborman # define termSuspCharp		(cc_t *)&nltc.t_suspc
31440245Sborman # define termRprntCharp		(cc_t *)&nltc.t_rprntc
31540245Sborman # define termWerasCharp		(cc_t *)&nltc.t_werasc
31640245Sborman # define termStartCharp		(cc_t *)&ntc.t_startc
31740245Sborman # define termStopCharp		(cc_t *)&ntc.t_stopc
31840245Sborman # define termForw1Charp		(cc_t *)&ntc.t_brkc
31940245Sborman # define termForw2Charp		(cc_t *)&termForw2Char
32045230Sborman # define termAytCharp		(cc_t *)&termAytChar
32138689Sborman 
32238689Sborman # else
32338689Sborman 
32438689Sborman extern struct	termio new_tc;
32538689Sborman 
32639529Sborman # define termEofChar		new_tc.c_cc[VEOF]
32739529Sborman # define termEraseChar		new_tc.c_cc[VERASE]
32839529Sborman # define termIntChar		new_tc.c_cc[VINTR]
32939529Sborman # define termKillChar		new_tc.c_cc[VKILL]
33039529Sborman # define termQuitChar		new_tc.c_cc[VQUIT]
33138689Sborman 
33239529Sborman # ifndef	VSUSP
33344360Sborman extern cc_t termSuspChar;
33439529Sborman # else
33539529Sborman #  define termSuspChar		new_tc.c_cc[VSUSP]
33639529Sborman # endif
33745230Sborman # if	defined(VFLUSHO) && !defined(VDISCARD)
33845230Sborman #  define VDISCARD VFLUSHO
33944360Sborman # endif
34045230Sborman # ifndef	VDISCARD
34144360Sborman extern cc_t termFlushChar;
34239529Sborman # else
34345230Sborman #  define termFlushChar		new_tc.c_cc[VDISCARD]
34439529Sborman # endif
34539529Sborman # ifndef VWERASE
34644360Sborman extern cc_t termWerasChar;
34739529Sborman # else
34839529Sborman #  define termWerasChar		new_tc.c_cc[VWERASE]
34939529Sborman # endif
35039529Sborman # ifndef	VREPRINT
35144360Sborman extern cc_t termRprntChar;
35239529Sborman # else
35339529Sborman #  define termRprntChar		new_tc.c_cc[VREPRINT]
35439529Sborman # endif
35539529Sborman # ifndef	VLNEXT
35644360Sborman extern cc_t termLiteralNextChar;
35739529Sborman # else
35839529Sborman #  define termLiteralNextChar	new_tc.c_cc[VLNEXT]
35939529Sborman # endif
36039529Sborman # ifndef	VSTART
36144360Sborman extern cc_t termStartChar;
36239529Sborman # else
36339529Sborman #  define termStartChar		new_tc.c_cc[VSTART]
36439529Sborman # endif
36539529Sborman # ifndef	VSTOP
36644360Sborman extern cc_t termStopChar;
36739529Sborman # else
36839529Sborman #  define termStopChar		new_tc.c_cc[VSTOP]
36939529Sborman # endif
37040245Sborman # ifndef	VEOL
37144360Sborman extern cc_t termForw1Char;
37240245Sborman # else
37340245Sborman #  define termForw1Char		new_tc.c_cc[VEOL]
37440245Sborman # endif
37540245Sborman # ifndef	VEOL2
37644360Sborman extern cc_t termForw2Char;
37740245Sborman # else
37840245Sborman #  define termForw2Char		new_tc.c_cc[VEOL]
37940245Sborman # endif
38045230Sborman # ifndef	VSTATUS
38145230Sborman extern cc_t termAytChar;
38245230Sborman #else
38345230Sborman #  define termAytChar		new_tc.c_cc[VSTATUS]
38445230Sborman #endif
38538689Sborman 
38645230Sborman # if !defined(CRAY) || defined(__STDC__)
38739529Sborman #  define termEofCharp		&termEofChar
38839529Sborman #  define termEraseCharp	&termEraseChar
38939529Sborman #  define termIntCharp		&termIntChar
39039529Sborman #  define termKillCharp		&termKillChar
39139529Sborman #  define termQuitCharp		&termQuitChar
39239529Sborman #  define termSuspCharp		&termSuspChar
39339529Sborman #  define termFlushCharp	&termFlushChar
39439529Sborman #  define termWerasCharp	&termWerasChar
39539529Sborman #  define termRprntCharp	&termRprntChar
39639529Sborman #  define termLiteralNextCharp	&termLiteralNextChar
39739529Sborman #  define termStartCharp	&termStartChar
39839529Sborman #  define termStopCharp		&termStopChar
39940245Sborman #  define termForw1Charp	&termForw1Char
40040245Sborman #  define termForw2Charp	&termForw2Char
40145230Sborman #  define termAytCharp		&termAytChar
40238689Sborman # else
40338689Sborman 	/* Work around a compiler bug */
40438689Sborman #  define termEofCharp		0
40538689Sborman #  define termEraseCharp	0
40638689Sborman #  define termIntCharp		0
40738689Sborman #  define termKillCharp		0
40838689Sborman #  define termQuitCharp		0
40939529Sborman #  define termSuspCharp		0
41039529Sborman #  define termFlushCharp	0
41139529Sborman #  define termWerasCharp	0
41239529Sborman #  define termRprntCharp	0
41339529Sborman #  define termLiteralNextCharp	0
41439529Sborman #  define termStartCharp	0
41539529Sborman #  define termStopCharp		0
41640245Sborman #  define termForw1Charp	0
41740245Sborman #  define termForw2Charp	0
41845230Sborman #  define termAytCharp		0
41938689Sborman # endif
42038689Sborman #endif
42138689Sborman 
42238689Sborman 
42332381Sminshall /* Ring buffer structures which are shared */
42432381Sminshall 
42532381Sminshall extern Ring
42633802Sminshall     netoring,
42733802Sminshall     netiring,
42833802Sminshall     ttyoring,
42933802Sminshall     ttyiring;
43033802Sminshall 
43133802Sminshall /* Tn3270 section */
43233802Sminshall #if	defined(TN3270)
43333802Sminshall 
43433802Sminshall extern int
43533802Sminshall     HaveInput,		/* Whether an asynchronous I/O indication came in */
43636241Sminshall     noasynchtty,	/* Don't do signals on I/O (SIGURG, SIGIO) */
43736241Sminshall     noasynchnet,	/* Don't do signals on I/O (SIGURG, SIGIO) */
43836241Sminshall     sigiocount,		/* Count of SIGIO receptions */
43933802Sminshall     shell_active;	/* Subshell is active */
44033802Sminshall 
44133802Sminshall extern char
44233802Sminshall     *Ibackp,		/* Oldest byte of 3270 data */
44333802Sminshall     Ibuf[],		/* 3270 buffer */
44433802Sminshall     *Ifrontp,		/* Where next 3270 byte goes */
44533802Sminshall     tline[],
44633802Sminshall     *transcom;		/* Transparent command */
44733802Sminshall 
44859893Sbostic extern void
44946808Sdab     settranscom P((int, char**));
45033802Sminshall 
45133802Sminshall extern void
45259893Sbostic     inputAvailable P((int));
45333802Sminshall #endif	/* defined(TN3270) */
454