133685Sbostic /* 245230Sborman * Copyright (c) 1988, 1990 Regents of the University of California. 333685Sbostic * All rights reserved. 433685Sbostic * 542770Sbostic * %sccs.include.redist.c% 633685Sbostic * 7*47610Sdab * @(#)externs.h 5.3 (Berkeley) 03/22/91 833685Sbostic */ 933685Sbostic 1039529Sborman #ifndef BSD 1139529Sborman # define BSD 43 1238689Sborman #endif 1338689Sborman 1439529Sborman #if (BSD > 43 || defined(SYSV_TERMIO)) && !defined(USE_TERMIO) 1539529Sborman # define USE_TERMIO 1639529Sborman #endif 1739529Sborman 1832141Sminshall #include <stdio.h> 1932141Sminshall #include <setjmp.h> 2044360Sborman #ifndef FILIO_H 2138689Sborman #include <sys/ioctl.h> 2244360Sborman #else 2344360Sborman #include <sys/filio.h> 2444360Sborman #endif 2538689Sborman #ifdef USE_TERMIO 2639529Sborman # ifndef VINTR 2739529Sborman # ifdef SYSV_TERMIO 2839529Sborman # include <sys/termio.h> 2939529Sborman # else 3039529Sborman # include <sys/termios.h> 3139529Sborman # define termio termios 3239529Sborman # endif 3339529Sborman # endif 3444360Sborman #endif 3544360Sborman #if defined(NO_CC_T) || !defined(USE_TERMIO) 3644360Sborman # if !defined(USE_TERMIO) 3740245Sborman typedef char cc_t; 3844360Sborman # else 3944360Sborman typedef unsigned char cc_t; 4044360Sborman # endif 4138689Sborman #endif 4232141Sminshall 4346808Sdab #ifndef NO_STRING_H 4446808Sdab #include <string.h> 4546808Sdab #endif 4646808Sdab #include <strings.h> 4746808Sdab 4845230Sborman #ifndef _POSIX_VDISABLE 4945230Sborman # ifdef sun 5045230Sborman # include <sys/param.h> /* pick up VDISABLE definition, mayby */ 5145230Sborman # endif 5245230Sborman # ifdef VDISABLE 5345230Sborman # define _POSIX_VDISABLE VDISABLE 5445230Sborman # else 5546808Sdab # define _POSIX_VDISABLE ((cc_t)'\377') 5645230Sborman # endif 5745230Sborman #endif 5845230Sborman 5938689Sborman #define SUBBUFSIZE 256 6032141Sminshall 6132141Sminshall extern int errno; /* outside this world */ 6232141Sminshall 6346808Sdab #if !defined(P) 6446808Sdab # ifdef __STDC__ 6546808Sdab # define P(x) x 6646808Sdab # else 6746808Sdab # define P(x) () 6846808Sdab # endif 6946808Sdab #endif 7033802Sminshall 7132141Sminshall extern int 7246808Sdab autologin, /* Autologin enabled */ 73*47610Sdab skiprc, /* Don't process the ~/.telnetrc file */ 7446808Sdab eight, /* use eight bit mode (binary in and/or out */ 7533802Sminshall flushout, /* flush output */ 7633802Sminshall connected, /* Are we connected to the other side? */ 7733802Sminshall globalmode, /* Mode tty should be in */ 7833802Sminshall In3270, /* Are we in 3270 mode? */ 7933802Sminshall telnetport, /* Are we connected to the telnet port? */ 8037219Sminshall localflow, /* Flow control handled locally */ 8133802Sminshall localchars, /* we recognize interrupt/quit */ 8233802Sminshall donelclchars, /* the user has set "localchars" */ 8333802Sminshall showoptions, 8436274Sminshall net, /* Network file descriptor */ 8536274Sminshall tin, /* Terminal input file descriptor */ 8633802Sminshall tout, /* Terminal output file descriptor */ 8733802Sminshall crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */ 8833802Sminshall autoflush, /* flush output when interrupting? */ 8933802Sminshall autosynch, /* send interrupt characters with SYNCH? */ 9033802Sminshall SYNCHing, /* Is the stream in telnet SYNCH mode? */ 9133802Sminshall donebinarytoggle, /* the user has put us in binary */ 9233802Sminshall dontlecho, /* do we suppress local echoing right now? */ 9333802Sminshall crmod, 9433802Sminshall netdata, /* Print out network data flow */ 9538689Sborman prettydump, /* Print "netdata" output in user readable format */ 9638208Sminshall #if defined(unix) 9738208Sminshall #if defined(TN3270) 9838208Sminshall cursesdata, /* Print out curses data flow */ 9938920Sminshall apitrace, /* Trace API transactions */ 10038208Sminshall #endif /* defined(TN3270) */ 10138208Sminshall termdata, /* Print out terminal data flow */ 10238208Sminshall #endif /* defined(unix) */ 10333802Sminshall debug; /* Debug level */ 10432141Sminshall 10544360Sborman extern cc_t escape; /* Escape to command mode */ 10646808Sdab extern cc_t rlogin; /* Rlogin mode escape character */ 10744360Sborman #ifdef KLUDGELINEMODE 10844360Sborman extern cc_t echoc; /* Toggle local echoing */ 10944360Sborman #endif 11040245Sborman 11144360Sborman extern char 11239529Sborman *prompt; /* Prompt for command. */ 11339529Sborman 11432141Sminshall extern char 11533802Sminshall doopt[], 11633802Sminshall dont[], 11733802Sminshall will[], 11833802Sminshall wont[], 11937226Sminshall options[], /* All the little options */ 12039529Sborman *hostname; /* Who are we connected to? */ 12146808Sdab #if defined(ENCRYPT) 12246808Sdab extern void (*encrypt_output) P((unsigned char *, int)); 12346808Sdab extern int (*decrypt_input) P((int)); 12446808Sdab #endif 12532141Sminshall 12637226Sminshall /* 12737226Sminshall * We keep track of each side of the option negotiation. 12837226Sminshall */ 12937226Sminshall 13038689Sborman #define MY_STATE_WILL 0x01 13138689Sborman #define MY_WANT_STATE_WILL 0x02 13238689Sborman #define MY_STATE_DO 0x04 13338689Sborman #define MY_WANT_STATE_DO 0x08 13437226Sminshall 13537226Sminshall /* 13638689Sborman * Macros to check the current state of things 13737226Sminshall */ 13837226Sminshall 13938689Sborman #define my_state_is_do(opt) (options[opt]&MY_STATE_DO) 14038689Sborman #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL) 14138689Sborman #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO) 14238689Sborman #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL) 14337226Sminshall 14438689Sborman #define my_state_is_dont(opt) (!my_state_is_do(opt)) 14538689Sborman #define my_state_is_wont(opt) (!my_state_is_will(opt)) 14638689Sborman #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt)) 14738689Sborman #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt)) 14837226Sminshall 14938689Sborman #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;} 15038689Sborman #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;} 15138689Sborman #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;} 15238689Sborman #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;} 15338689Sborman 15438689Sborman #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;} 15538689Sborman #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;} 15638689Sborman #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;} 15738689Sborman #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;} 15838689Sborman 15938689Sborman /* 16038689Sborman * Make everything symetrical 16138689Sborman */ 16238689Sborman 16338689Sborman #define HIS_STATE_WILL MY_STATE_DO 16438689Sborman #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO 16538689Sborman #define HIS_STATE_DO MY_STATE_WILL 16638689Sborman #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL 16738689Sborman 16838689Sborman #define his_state_is_do my_state_is_will 16938689Sborman #define his_state_is_will my_state_is_do 17038689Sborman #define his_want_state_is_do my_want_state_is_will 17138689Sborman #define his_want_state_is_will my_want_state_is_do 17238689Sborman 17338689Sborman #define his_state_is_dont my_state_is_wont 17438689Sborman #define his_state_is_wont my_state_is_dont 17538689Sborman #define his_want_state_is_dont my_want_state_is_wont 17638689Sborman #define his_want_state_is_wont my_want_state_is_dont 17738689Sborman 17838689Sborman #define set_his_state_do set_my_state_will 17938689Sborman #define set_his_state_will set_my_state_do 18038689Sborman #define set_his_want_state_do set_my_want_state_will 18138689Sborman #define set_his_want_state_will set_my_want_state_do 18238689Sborman 18338689Sborman #define set_his_state_dont set_my_state_wont 18438689Sborman #define set_his_state_wont set_my_state_dont 18538689Sborman #define set_his_want_state_dont set_my_want_state_wont 18638689Sborman #define set_his_want_state_wont set_my_want_state_dont 18738689Sborman 18838689Sborman 18932141Sminshall extern FILE 19033802Sminshall *NetTrace; /* Where debugging output goes */ 19139529Sborman extern unsigned char 19238689Sborman NetTraceFile[]; /* Name of file where debugging output goes */ 19338689Sborman extern void 19446808Sdab SetNetTrace P((char *)); /* Function to change where debugging goes */ 19532141Sminshall 19632141Sminshall extern jmp_buf 19733802Sminshall peerdied, 19833802Sminshall toplevel; /* For error conditions. */ 19932141Sminshall 20032141Sminshall extern void 20146808Sdab command P((int, char *, int)), 20246808Sdab Dump P((int, unsigned char *, int)), 20346808Sdab init_3270 P((void)), 20446808Sdab printoption P((char *, int, int)), 20546808Sdab printsub P((int, unsigned char *, int)), 20646808Sdab sendnaws P((void)), 20746808Sdab setconnmode P((int)), 20846808Sdab setcommandmode P((void)), 20946808Sdab setneturg P((void)), 21046808Sdab sys_telnet_init P((void)), 21146808Sdab telnet P((char *)), 21246808Sdab tel_enter_binary P((int)), 21346808Sdab TerminalFlushOutput P((void)), 21446808Sdab TerminalNewMode P((int)), 21546808Sdab TerminalRestoreState P((void)), 21646808Sdab TerminalSaveState P((void)), 21746808Sdab tninit P((void)), 21846808Sdab upcase P((char *)), 21946808Sdab willoption P((int)), 22046808Sdab wontoption P((int)); 22132141Sminshall 22246808Sdab extern void 22346808Sdab lm_will P((unsigned char *, int)), 22446808Sdab lm_wont P((unsigned char *, int)), 22546808Sdab lm_do P((unsigned char *, int)), 22646808Sdab lm_dont P((unsigned char *, int)), 22746808Sdab lm_mode P((unsigned char *, int, int)); 22846808Sdab 22946808Sdab extern void 23046808Sdab slc_init P((void)), 23146808Sdab slcstate P((void)), 23246808Sdab slc_mode_export P((void)), 23346808Sdab slc_mode_import P((int)), 23446808Sdab slc_import P((int)), 23546808Sdab slc_export P((void)), 23646808Sdab slc P((unsigned char *, int)), 23746808Sdab slc_check P((void)), 23846808Sdab slc_start_reply P((void)), 23946808Sdab slc_add_reply P((int, int, int)), 24046808Sdab slc_end_reply P((void)); 24134313Sminshall extern int 24246808Sdab slc_update P((void)); 24334313Sminshall 24446808Sdab extern void 24546808Sdab env_opt P((unsigned char *, int)), 24646808Sdab env_opt_start P((void)), 24746808Sdab env_opt_start_info P((void)), 24846808Sdab env_opt_add P((unsigned char *)), 24946808Sdab env_opt_end P((int)); 25046808Sdab 25146808Sdab extern unsigned char 25246808Sdab *env_default P((int)), 25346808Sdab *env_getvalue P((unsigned char *)); 25446808Sdab 25546808Sdab extern int 25646808Sdab get_status P((void)), 25746808Sdab dosynch P((void)); 25846808Sdab 25946808Sdab extern cc_t 26046808Sdab *tcval P((int)); 26146808Sdab 26239529Sborman #ifndef USE_TERMIO 26338689Sborman 26438689Sborman extern struct tchars ntc; 26538689Sborman extern struct ltchars nltc; 26638689Sborman extern struct sgttyb nttyb; 26738689Sborman 26839529Sborman # define termEofChar ntc.t_eofc 26939529Sborman # define termEraseChar nttyb.sg_erase 27039529Sborman # define termFlushChar nltc.t_flushc 27139529Sborman # define termIntChar ntc.t_intrc 27239529Sborman # define termKillChar nttyb.sg_kill 27339529Sborman # define termLiteralNextChar nltc.t_lnextc 27439529Sborman # define termQuitChar ntc.t_quitc 27539529Sborman # define termSuspChar nltc.t_suspc 27639529Sborman # define termRprntChar nltc.t_rprntc 27739529Sborman # define termWerasChar nltc.t_werasc 27839529Sborman # define termStartChar ntc.t_startc 27939529Sborman # define termStopChar ntc.t_stopc 28040245Sborman # define termForw1Char ntc.t_brkc 28144360Sborman extern cc_t termForw2Char; 28245230Sborman extern cc_t termAytChar; 28338689Sborman 28440245Sborman # define termEofCharp (cc_t *)&ntc.t_eofc 28540245Sborman # define termEraseCharp (cc_t *)&nttyb.sg_erase 28640245Sborman # define termFlushCharp (cc_t *)&nltc.t_flushc 28740245Sborman # define termIntCharp (cc_t *)&ntc.t_intrc 28840245Sborman # define termKillCharp (cc_t *)&nttyb.sg_kill 28940245Sborman # define termLiteralNextCharp (cc_t *)&nltc.t_lnextc 29040245Sborman # define termQuitCharp (cc_t *)&ntc.t_quitc 29140245Sborman # define termSuspCharp (cc_t *)&nltc.t_suspc 29240245Sborman # define termRprntCharp (cc_t *)&nltc.t_rprntc 29340245Sborman # define termWerasCharp (cc_t *)&nltc.t_werasc 29440245Sborman # define termStartCharp (cc_t *)&ntc.t_startc 29540245Sborman # define termStopCharp (cc_t *)&ntc.t_stopc 29640245Sborman # define termForw1Charp (cc_t *)&ntc.t_brkc 29740245Sborman # define termForw2Charp (cc_t *)&termForw2Char 29845230Sborman # define termAytCharp (cc_t *)&termAytChar 29938689Sborman 30038689Sborman # else 30138689Sborman 30238689Sborman extern struct termio new_tc; 30338689Sborman 30439529Sborman # define termEofChar new_tc.c_cc[VEOF] 30539529Sborman # define termEraseChar new_tc.c_cc[VERASE] 30639529Sborman # define termIntChar new_tc.c_cc[VINTR] 30739529Sborman # define termKillChar new_tc.c_cc[VKILL] 30839529Sborman # define termQuitChar new_tc.c_cc[VQUIT] 30938689Sborman 31039529Sborman # ifndef VSUSP 31144360Sborman extern cc_t termSuspChar; 31239529Sborman # else 31339529Sborman # define termSuspChar new_tc.c_cc[VSUSP] 31439529Sborman # endif 31545230Sborman # if defined(VFLUSHO) && !defined(VDISCARD) 31645230Sborman # define VDISCARD VFLUSHO 31744360Sborman # endif 31845230Sborman # ifndef VDISCARD 31944360Sborman extern cc_t termFlushChar; 32039529Sborman # else 32145230Sborman # define termFlushChar new_tc.c_cc[VDISCARD] 32239529Sborman # endif 32339529Sborman # ifndef VWERASE 32444360Sborman extern cc_t termWerasChar; 32539529Sborman # else 32639529Sborman # define termWerasChar new_tc.c_cc[VWERASE] 32739529Sborman # endif 32839529Sborman # ifndef VREPRINT 32944360Sborman extern cc_t termRprntChar; 33039529Sborman # else 33139529Sborman # define termRprntChar new_tc.c_cc[VREPRINT] 33239529Sborman # endif 33339529Sborman # ifndef VLNEXT 33444360Sborman extern cc_t termLiteralNextChar; 33539529Sborman # else 33639529Sborman # define termLiteralNextChar new_tc.c_cc[VLNEXT] 33739529Sborman # endif 33839529Sborman # ifndef VSTART 33944360Sborman extern cc_t termStartChar; 34039529Sborman # else 34139529Sborman # define termStartChar new_tc.c_cc[VSTART] 34239529Sborman # endif 34339529Sborman # ifndef VSTOP 34444360Sborman extern cc_t termStopChar; 34539529Sborman # else 34639529Sborman # define termStopChar new_tc.c_cc[VSTOP] 34739529Sborman # endif 34840245Sborman # ifndef VEOL 34944360Sborman extern cc_t termForw1Char; 35040245Sborman # else 35140245Sborman # define termForw1Char new_tc.c_cc[VEOL] 35240245Sborman # endif 35340245Sborman # ifndef VEOL2 35444360Sborman extern cc_t termForw2Char; 35540245Sborman # else 35640245Sborman # define termForw2Char new_tc.c_cc[VEOL] 35740245Sborman # endif 35845230Sborman # ifndef VSTATUS 35945230Sborman extern cc_t termAytChar; 36045230Sborman #else 36145230Sborman # define termAytChar new_tc.c_cc[VSTATUS] 36245230Sborman #endif 36338689Sborman 36445230Sborman # if !defined(CRAY) || defined(__STDC__) 36539529Sborman # define termEofCharp &termEofChar 36639529Sborman # define termEraseCharp &termEraseChar 36739529Sborman # define termIntCharp &termIntChar 36839529Sborman # define termKillCharp &termKillChar 36939529Sborman # define termQuitCharp &termQuitChar 37039529Sborman # define termSuspCharp &termSuspChar 37139529Sborman # define termFlushCharp &termFlushChar 37239529Sborman # define termWerasCharp &termWerasChar 37339529Sborman # define termRprntCharp &termRprntChar 37439529Sborman # define termLiteralNextCharp &termLiteralNextChar 37539529Sborman # define termStartCharp &termStartChar 37639529Sborman # define termStopCharp &termStopChar 37740245Sborman # define termForw1Charp &termForw1Char 37840245Sborman # define termForw2Charp &termForw2Char 37945230Sborman # define termAytCharp &termAytChar 38038689Sborman # else 38138689Sborman /* Work around a compiler bug */ 38238689Sborman # define termEofCharp 0 38338689Sborman # define termEraseCharp 0 38438689Sborman # define termIntCharp 0 38538689Sborman # define termKillCharp 0 38638689Sborman # define termQuitCharp 0 38739529Sborman # define termSuspCharp 0 38839529Sborman # define termFlushCharp 0 38939529Sborman # define termWerasCharp 0 39039529Sborman # define termRprntCharp 0 39139529Sborman # define termLiteralNextCharp 0 39239529Sborman # define termStartCharp 0 39339529Sborman # define termStopCharp 0 39440245Sborman # define termForw1Charp 0 39540245Sborman # define termForw2Charp 0 39645230Sborman # define termAytCharp 0 39738689Sborman # endif 39838689Sborman #endif 39938689Sborman 40038689Sborman 40132381Sminshall /* Ring buffer structures which are shared */ 40232381Sminshall 40332381Sminshall extern Ring 40433802Sminshall netoring, 40533802Sminshall netiring, 40633802Sminshall ttyoring, 40733802Sminshall ttyiring; 40833802Sminshall 40933802Sminshall /* Tn3270 section */ 41033802Sminshall #if defined(TN3270) 41133802Sminshall 41233802Sminshall extern int 41333802Sminshall HaveInput, /* Whether an asynchronous I/O indication came in */ 41436241Sminshall noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */ 41536241Sminshall noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */ 41636241Sminshall sigiocount, /* Count of SIGIO receptions */ 41733802Sminshall shell_active; /* Subshell is active */ 41833802Sminshall 41933802Sminshall extern char 42033802Sminshall *Ibackp, /* Oldest byte of 3270 data */ 42133802Sminshall Ibuf[], /* 3270 buffer */ 42233802Sminshall *Ifrontp, /* Where next 3270 byte goes */ 42333802Sminshall tline[], 42433802Sminshall *transcom; /* Transparent command */ 42533802Sminshall 42633802Sminshall extern int 42746808Sdab settranscom P((int, char**)); 42833802Sminshall 42933802Sminshall extern void 43046808Sdab inputAvailable P((void)); 43133802Sminshall #endif /* defined(TN3270) */ 432