Home | History | Annotate | Line # | Download | only in telnet
externs.h revision 1.6
      1 /*
      2  * Copyright (c) 1988, 1990, 1993
      3  *	The Regents of the University of California.  All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  * 1. Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  * 2. Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in the
     12  *    documentation and/or other materials provided with the distribution.
     13  * 3. All advertising materials mentioning features or use of this software
     14  *    must display the following acknowledgement:
     15  *	This product includes software developed by the University of
     16  *	California, Berkeley and its contributors.
     17  * 4. Neither the name of the University nor the names of its contributors
     18  *    may be used to endorse or promote products derived from this software
     19  *    without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     31  * SUCH DAMAGE.
     32  *
     33  *	from: @(#)externs.h	8.3 (Berkeley) 5/30/95
     34  *	$NetBSD: externs.h,v 1.6 1996/02/24 01:18:36 jtk Exp $
     35  */
     36 
     37 #ifndef	BSD
     38 # define BSD 43
     39 #endif
     40 
     41 /*
     42  * ucb stdio.h defines BSD as something wierd
     43  */
     44 #if defined(sun) && defined(__svr4__)
     45 #define BSD 43
     46 #endif
     47 
     48 #ifndef	USE_TERMIO
     49 # if BSD > 43 || defined(SYSV_TERMIO)
     50 #  define USE_TERMIO
     51 # endif
     52 #endif
     53 
     54 #include <stdio.h>
     55 #include <stdlib.h>
     56 #include <setjmp.h>
     57 #if defined(CRAY) && !defined(NO_BSD_SETJMP)
     58 #include <bsdsetjmp.h>
     59 #endif
     60 #ifndef	FILIO_H
     61 #include <sys/ioctl.h>
     62 #else
     63 #include <sys/filio.h>
     64 #endif
     65 #ifdef CRAY
     66 # include <errno.h>
     67 #endif /* CRAY */
     68 #ifdef	USE_TERMIO
     69 # ifndef	VINTR
     70 #  ifdef SYSV_TERMIO
     71 #   include <sys/termio.h>
     72 #  else
     73 #   include <sys/termios.h>
     74 #   define termio termios
     75 #  endif
     76 # endif
     77 #endif
     78 #if defined(NO_CC_T) || !defined(USE_TERMIO)
     79 # if !defined(USE_TERMIO)
     80 typedef char cc_t;
     81 # else
     82 typedef unsigned char cc_t;
     83 # endif
     84 #endif
     85 
     86 #ifndef	NO_STRING_H
     87 #include <string.h>
     88 #else
     89 #include <strings.h>
     90 #endif
     91 
     92 #ifndef	_POSIX_VDISABLE
     93 # ifdef sun
     94 #  include <sys/param.h>	/* pick up VDISABLE definition, mayby */
     95 # endif
     96 # ifdef VDISABLE
     97 #  define _POSIX_VDISABLE VDISABLE
     98 # else
     99 #  define _POSIX_VDISABLE ((cc_t)'\377')
    100 # endif
    101 #endif
    102 
    103 #define	SUBBUFSIZE	256
    104 
    105 #ifndef CRAY
    106 extern int errno;		/* outside this world */
    107 #endif /* !CRAY */
    108 
    109 #include <sys/cdefs.h>
    110 #define P __P
    111 
    112 extern int
    113     autologin,		/* Autologin enabled */
    114     skiprc,		/* Don't process the ~/.telnetrc file */
    115     eight,		/* use eight bit mode (binary in and/or out */
    116     flushout,		/* flush output */
    117     connected,		/* Are we connected to the other side? */
    118     globalmode,		/* Mode tty should be in */
    119     In3270,		/* Are we in 3270 mode? */
    120     telnetport,		/* Are we connected to the telnet port? */
    121     localflow,		/* Flow control handled locally */
    122     restartany,		/* If flow control, restart output on any character */
    123     localchars,		/* we recognize interrupt/quit */
    124     donelclchars,	/* the user has set "localchars" */
    125     showoptions,
    126     net,		/* Network file descriptor */
    127     tin,		/* Terminal input file descriptor */
    128     tout,		/* Terminal output file descriptor */
    129     crlf,		/* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
    130     autoflush,		/* flush output when interrupting? */
    131     autosynch,		/* send interrupt characters with SYNCH? */
    132     SYNCHing,		/* Is the stream in telnet SYNCH mode? */
    133     donebinarytoggle,	/* the user has put us in binary */
    134     dontlecho,		/* do we suppress local echoing right now? */
    135     crmod,
    136     netdata,		/* Print out network data flow */
    137     prettydump,		/* Print "netdata" output in user readable format */
    138 #if	defined(unix)
    139 #if	defined(TN3270)
    140     cursesdata,		/* Print out curses data flow */
    141     apitrace,		/* Trace API transactions */
    142 #endif	/* defined(TN3270) */
    143     termdata,		/* Print out terminal data flow */
    144 #endif	/* defined(unix) */
    145     debug;		/* Debug level */
    146 
    147 extern cc_t escape;	/* Escape to command mode */
    148 extern cc_t rlogin;	/* Rlogin mode escape character */
    149 #ifdef	KLUDGELINEMODE
    150 extern cc_t echoc;	/* Toggle local echoing */
    151 #endif
    152 
    153 extern char
    154     *prompt;		/* Prompt for command. */
    155 
    156 extern char
    157     doopt[],
    158     dont[],
    159     will[],
    160     wont[],
    161     options[],		/* All the little options */
    162     *hostname;		/* Who are we connected to? */
    163 
    164 /*
    165  * We keep track of each side of the option negotiation.
    166  */
    167 
    168 #define	MY_STATE_WILL		0x01
    169 #define	MY_WANT_STATE_WILL	0x02
    170 #define	MY_STATE_DO		0x04
    171 #define	MY_WANT_STATE_DO	0x08
    172 
    173 /*
    174  * Macros to check the current state of things
    175  */
    176 
    177 #define	my_state_is_do(opt)		(options[opt]&MY_STATE_DO)
    178 #define	my_state_is_will(opt)		(options[opt]&MY_STATE_WILL)
    179 #define my_want_state_is_do(opt)	(options[opt]&MY_WANT_STATE_DO)
    180 #define my_want_state_is_will(opt)	(options[opt]&MY_WANT_STATE_WILL)
    181 
    182 #define	my_state_is_dont(opt)		(!my_state_is_do(opt))
    183 #define	my_state_is_wont(opt)		(!my_state_is_will(opt))
    184 #define my_want_state_is_dont(opt)	(!my_want_state_is_do(opt))
    185 #define my_want_state_is_wont(opt)	(!my_want_state_is_will(opt))
    186 
    187 #define	set_my_state_do(opt)		{options[opt] |= MY_STATE_DO;}
    188 #define	set_my_state_will(opt)		{options[opt] |= MY_STATE_WILL;}
    189 #define	set_my_want_state_do(opt)	{options[opt] |= MY_WANT_STATE_DO;}
    190 #define	set_my_want_state_will(opt)	{options[opt] |= MY_WANT_STATE_WILL;}
    191 
    192 #define	set_my_state_dont(opt)		{options[opt] &= ~MY_STATE_DO;}
    193 #define	set_my_state_wont(opt)		{options[opt] &= ~MY_STATE_WILL;}
    194 #define	set_my_want_state_dont(opt)	{options[opt] &= ~MY_WANT_STATE_DO;}
    195 #define	set_my_want_state_wont(opt)	{options[opt] &= ~MY_WANT_STATE_WILL;}
    196 
    197 /*
    198  * Make everything symetrical
    199  */
    200 
    201 #define	HIS_STATE_WILL			MY_STATE_DO
    202 #define	HIS_WANT_STATE_WILL		MY_WANT_STATE_DO
    203 #define HIS_STATE_DO			MY_STATE_WILL
    204 #define HIS_WANT_STATE_DO		MY_WANT_STATE_WILL
    205 
    206 #define	his_state_is_do			my_state_is_will
    207 #define	his_state_is_will		my_state_is_do
    208 #define his_want_state_is_do		my_want_state_is_will
    209 #define his_want_state_is_will		my_want_state_is_do
    210 
    211 #define	his_state_is_dont		my_state_is_wont
    212 #define	his_state_is_wont		my_state_is_dont
    213 #define his_want_state_is_dont		my_want_state_is_wont
    214 #define his_want_state_is_wont		my_want_state_is_dont
    215 
    216 #define	set_his_state_do		set_my_state_will
    217 #define	set_his_state_will		set_my_state_do
    218 #define	set_his_want_state_do		set_my_want_state_will
    219 #define	set_his_want_state_will		set_my_want_state_do
    220 
    221 #define	set_his_state_dont		set_my_state_wont
    222 #define	set_his_state_wont		set_my_state_dont
    223 #define	set_his_want_state_dont		set_my_want_state_wont
    224 #define	set_his_want_state_wont		set_my_want_state_dont
    225 
    226 
    227 extern FILE
    228     *NetTrace;		/* Where debugging output goes */
    229 extern unsigned char
    230     NetTraceFile[];	/* Name of file where debugging output goes */
    231 extern void
    232     SetNetTrace P((char *));	/* Function to change where debugging goes */
    233 
    234 extern jmp_buf
    235     peerdied,
    236     toplevel;		/* For error conditions. */
    237 
    238 extern void
    239     command P((int, char *, int)),
    240     Dump P((int, unsigned char *, int)),
    241     init_3270 P((void)),
    242     printoption P((char *, int, int)),
    243     printsub P((int, unsigned char *, int)),
    244     sendnaws P((void)),
    245     setconnmode P((int)),
    246     setcommandmode P((void)),
    247     setneturg P((void)),
    248     sys_telnet_init P((void)),
    249     telnet P((char *)),
    250     tel_enter_binary P((int)),
    251     TerminalFlushOutput P((void)),
    252     TerminalNewMode P((int)),
    253     TerminalRestoreState P((void)),
    254     TerminalSaveState P((void)),
    255     tninit P((void)),
    256     upcase P((char *)),
    257     willoption P((int)),
    258     wontoption P((int));
    259 
    260 extern void
    261     send_do P((int, int)),
    262     send_dont P((int, int)),
    263     send_will P((int, int)),
    264     send_wont P((int, int));
    265 
    266 extern void
    267     lm_will P((unsigned char *, int)),
    268     lm_wont P((unsigned char *, int)),
    269     lm_do P((unsigned char *, int)),
    270     lm_dont P((unsigned char *, int)),
    271     lm_mode P((unsigned char *, int, int));
    272 
    273 extern void
    274     slc_init P((void)),
    275     slcstate P((void)),
    276     slc_mode_export P((void)),
    277     slc_mode_import P((int)),
    278     slc_import P((int)),
    279     slc_export P((void)),
    280     slc P((unsigned char *, int)),
    281     slc_check P((void)),
    282     slc_start_reply P((void)),
    283     slc_add_reply P((int, int, int)),
    284     slc_end_reply P((void));
    285 extern int
    286     slc_update P((void));
    287 
    288 extern void
    289     env_opt P((unsigned char *, int)),
    290     env_opt_start P((void)),
    291     env_opt_start_info P((void)),
    292     env_opt_add P((unsigned char *)),
    293     env_opt_end P((int));
    294 
    295 extern unsigned char
    296     *env_default P((int, int)),
    297     *env_getvalue P((unsigned char *));
    298 
    299 extern int
    300     get_status P((void)),
    301     dosynch P((void));
    302 
    303 extern cc_t
    304     *tcval P((int));
    305 
    306 #ifndef	USE_TERMIO
    307 
    308 extern struct	tchars ntc;
    309 extern struct	ltchars nltc;
    310 extern struct	sgttyb nttyb;
    311 
    312 # define termEofChar		ntc.t_eofc
    313 # define termEraseChar		nttyb.sg_erase
    314 # define termFlushChar		nltc.t_flushc
    315 # define termIntChar		ntc.t_intrc
    316 # define termKillChar		nttyb.sg_kill
    317 # define termLiteralNextChar	nltc.t_lnextc
    318 # define termQuitChar		ntc.t_quitc
    319 # define termSuspChar		nltc.t_suspc
    320 # define termRprntChar		nltc.t_rprntc
    321 # define termWerasChar		nltc.t_werasc
    322 # define termStartChar		ntc.t_startc
    323 # define termStopChar		ntc.t_stopc
    324 # define termForw1Char		ntc.t_brkc
    325 extern cc_t termForw2Char;
    326 extern cc_t termAytChar;
    327 
    328 # define termEofCharp		(cc_t *)&ntc.t_eofc
    329 # define termEraseCharp		(cc_t *)&nttyb.sg_erase
    330 # define termFlushCharp		(cc_t *)&nltc.t_flushc
    331 # define termIntCharp		(cc_t *)&ntc.t_intrc
    332 # define termKillCharp		(cc_t *)&nttyb.sg_kill
    333 # define termLiteralNextCharp	(cc_t *)&nltc.t_lnextc
    334 # define termQuitCharp		(cc_t *)&ntc.t_quitc
    335 # define termSuspCharp		(cc_t *)&nltc.t_suspc
    336 # define termRprntCharp		(cc_t *)&nltc.t_rprntc
    337 # define termWerasCharp		(cc_t *)&nltc.t_werasc
    338 # define termStartCharp		(cc_t *)&ntc.t_startc
    339 # define termStopCharp		(cc_t *)&ntc.t_stopc
    340 # define termForw1Charp		(cc_t *)&ntc.t_brkc
    341 # define termForw2Charp		(cc_t *)&termForw2Char
    342 # define termAytCharp		(cc_t *)&termAytChar
    343 
    344 # else
    345 
    346 extern struct	termio new_tc;
    347 
    348 # define termEofChar		new_tc.c_cc[VEOF]
    349 # define termEraseChar		new_tc.c_cc[VERASE]
    350 # define termIntChar		new_tc.c_cc[VINTR]
    351 # define termKillChar		new_tc.c_cc[VKILL]
    352 # define termQuitChar		new_tc.c_cc[VQUIT]
    353 
    354 # ifndef	VSUSP
    355 extern cc_t termSuspChar;
    356 # else
    357 #  define termSuspChar		new_tc.c_cc[VSUSP]
    358 # endif
    359 # if	defined(VFLUSHO) && !defined(VDISCARD)
    360 #  define VDISCARD VFLUSHO
    361 # endif
    362 # ifndef	VDISCARD
    363 extern cc_t termFlushChar;
    364 # else
    365 #  define termFlushChar		new_tc.c_cc[VDISCARD]
    366 # endif
    367 # ifndef VWERASE
    368 extern cc_t termWerasChar;
    369 # else
    370 #  define termWerasChar		new_tc.c_cc[VWERASE]
    371 # endif
    372 # ifndef	VREPRINT
    373 extern cc_t termRprntChar;
    374 # else
    375 #  define termRprntChar		new_tc.c_cc[VREPRINT]
    376 # endif
    377 # ifndef	VLNEXT
    378 extern cc_t termLiteralNextChar;
    379 # else
    380 #  define termLiteralNextChar	new_tc.c_cc[VLNEXT]
    381 # endif
    382 # ifndef	VSTART
    383 extern cc_t termStartChar;
    384 # else
    385 #  define termStartChar		new_tc.c_cc[VSTART]
    386 # endif
    387 # ifndef	VSTOP
    388 extern cc_t termStopChar;
    389 # else
    390 #  define termStopChar		new_tc.c_cc[VSTOP]
    391 # endif
    392 # ifndef	VEOL
    393 extern cc_t termForw1Char;
    394 # else
    395 #  define termForw1Char		new_tc.c_cc[VEOL]
    396 # endif
    397 # ifndef	VEOL2
    398 extern cc_t termForw2Char;
    399 # else
    400 #  define termForw2Char		new_tc.c_cc[VEOL]
    401 # endif
    402 # ifndef	VSTATUS
    403 extern cc_t termAytChar;
    404 #else
    405 #  define termAytChar		new_tc.c_cc[VSTATUS]
    406 #endif
    407 
    408 # if !defined(CRAY) || defined(__STDC__)
    409 #  define termEofCharp		&termEofChar
    410 #  define termEraseCharp	&termEraseChar
    411 #  define termIntCharp		&termIntChar
    412 #  define termKillCharp		&termKillChar
    413 #  define termQuitCharp		&termQuitChar
    414 #  define termSuspCharp		&termSuspChar
    415 #  define termFlushCharp	&termFlushChar
    416 #  define termWerasCharp	&termWerasChar
    417 #  define termRprntCharp	&termRprntChar
    418 #  define termLiteralNextCharp	&termLiteralNextChar
    419 #  define termStartCharp	&termStartChar
    420 #  define termStopCharp		&termStopChar
    421 #  define termForw1Charp	&termForw1Char
    422 #  define termForw2Charp	&termForw2Char
    423 #  define termAytCharp		&termAytChar
    424 # else
    425 	/* Work around a compiler bug */
    426 #  define termEofCharp		0
    427 #  define termEraseCharp	0
    428 #  define termIntCharp		0
    429 #  define termKillCharp		0
    430 #  define termQuitCharp		0
    431 #  define termSuspCharp		0
    432 #  define termFlushCharp	0
    433 #  define termWerasCharp	0
    434 #  define termRprntCharp	0
    435 #  define termLiteralNextCharp	0
    436 #  define termStartCharp	0
    437 #  define termStopCharp		0
    438 #  define termForw1Charp	0
    439 #  define termForw2Charp	0
    440 #  define termAytCharp		0
    441 # endif
    442 #endif
    443 
    444 
    445 /* Ring buffer structures which are shared */
    446 
    447 extern Ring
    448     netoring,
    449     netiring,
    450     ttyoring,
    451     ttyiring;
    452 
    453 /* Tn3270 section */
    454 #if	defined(TN3270)
    455 
    456 extern int
    457     HaveInput,		/* Whether an asynchronous I/O indication came in */
    458     noasynchtty,	/* Don't do signals on I/O (SIGURG, SIGIO) */
    459     noasynchnet,	/* Don't do signals on I/O (SIGURG, SIGIO) */
    460     sigiocount,		/* Count of SIGIO receptions */
    461     shell_active;	/* Subshell is active */
    462 
    463 extern char
    464     *Ibackp,		/* Oldest byte of 3270 data */
    465     Ibuf[],		/* 3270 buffer */
    466     *Ifrontp,		/* Where next 3270 byte goes */
    467     tline[],
    468     *transcom;		/* Transparent command */
    469 
    470 extern int
    471     settranscom P((int, char**));
    472 
    473 extern void
    474     inputAvailable P((int));
    475 #endif	/* defined(TN3270) */
    476