133685Sbostic /* 233685Sbostic * Copyright (c) 1988 Regents of the University of California. 333685Sbostic * All rights reserved. 433685Sbostic * 542770Sbostic * %sccs.include.redist.c% 633685Sbostic * 7*44360Sborman * @(#)externs.h 1.25 (Berkeley) 06/28/90 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> 20*44360Sborman #ifndef FILIO_H 2138689Sborman #include <sys/ioctl.h> 22*44360Sborman #else 23*44360Sborman #include <sys/filio.h> 24*44360Sborman #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 34*44360Sborman #endif 35*44360Sborman #if defined(NO_CC_T) || !defined(USE_TERMIO) 36*44360Sborman # if !defined(USE_TERMIO) 3740245Sborman typedef char cc_t; 38*44360Sborman # else 39*44360Sborman typedef unsigned char cc_t; 40*44360Sborman # endif 4138689Sborman #endif 4232141Sminshall 4338689Sborman #define SUBBUFSIZE 256 4432141Sminshall 4532141Sminshall extern int errno; /* outside this world */ 4632141Sminshall 4733802Sminshall extern char 4833802Sminshall *strcat(), 4933802Sminshall *strcpy(); /* outside this world */ 5033802Sminshall 5132141Sminshall extern int 5233802Sminshall flushout, /* flush output */ 5333802Sminshall connected, /* Are we connected to the other side? */ 5433802Sminshall globalmode, /* Mode tty should be in */ 5533802Sminshall In3270, /* Are we in 3270 mode? */ 5633802Sminshall telnetport, /* Are we connected to the telnet port? */ 5737219Sminshall localflow, /* Flow control handled locally */ 5833802Sminshall localchars, /* we recognize interrupt/quit */ 5933802Sminshall donelclchars, /* the user has set "localchars" */ 6033802Sminshall showoptions, 6136274Sminshall net, /* Network file descriptor */ 6236274Sminshall tin, /* Terminal input file descriptor */ 6333802Sminshall tout, /* Terminal output file descriptor */ 6433802Sminshall crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */ 6533802Sminshall autoflush, /* flush output when interrupting? */ 6633802Sminshall autosynch, /* send interrupt characters with SYNCH? */ 6733802Sminshall SYNCHing, /* Is the stream in telnet SYNCH mode? */ 6833802Sminshall donebinarytoggle, /* the user has put us in binary */ 6933802Sminshall dontlecho, /* do we suppress local echoing right now? */ 7033802Sminshall crmod, 7133802Sminshall netdata, /* Print out network data flow */ 7243318Skfall #ifdef KERBEROS 7343318Skfall kerberized, /* Try to use Kerberos */ 7443318Skfall #endif 7538689Sborman prettydump, /* Print "netdata" output in user readable format */ 7638208Sminshall #if defined(unix) 7738208Sminshall #if defined(TN3270) 7838208Sminshall cursesdata, /* Print out curses data flow */ 7938920Sminshall apitrace, /* Trace API transactions */ 8038208Sminshall #endif /* defined(TN3270) */ 8138208Sminshall termdata, /* Print out terminal data flow */ 8238208Sminshall #endif /* defined(unix) */ 8333802Sminshall debug; /* Debug level */ 8432141Sminshall 85*44360Sborman extern cc_t escape; /* Escape to command mode */ 86*44360Sborman #ifdef KLUDGELINEMODE 87*44360Sborman extern cc_t echoc; /* Toggle local echoing */ 88*44360Sborman #endif 8940245Sborman 90*44360Sborman extern char 9139529Sborman *prompt; /* Prompt for command. */ 9239529Sborman 9332141Sminshall extern char 9433802Sminshall doopt[], 9533802Sminshall dont[], 9633802Sminshall will[], 9733802Sminshall wont[], 9837226Sminshall options[], /* All the little options */ 9939529Sborman *hostname; /* Who are we connected to? */ 10032141Sminshall 10137226Sminshall /* 10237226Sminshall * We keep track of each side of the option negotiation. 10337226Sminshall */ 10437226Sminshall 10538689Sborman #define MY_STATE_WILL 0x01 10638689Sborman #define MY_WANT_STATE_WILL 0x02 10738689Sborman #define MY_STATE_DO 0x04 10838689Sborman #define MY_WANT_STATE_DO 0x08 10937226Sminshall 11037226Sminshall /* 11138689Sborman * Macros to check the current state of things 11237226Sminshall */ 11337226Sminshall 11438689Sborman #define my_state_is_do(opt) (options[opt]&MY_STATE_DO) 11538689Sborman #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL) 11638689Sborman #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO) 11738689Sborman #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL) 11837226Sminshall 11938689Sborman #define my_state_is_dont(opt) (!my_state_is_do(opt)) 12038689Sborman #define my_state_is_wont(opt) (!my_state_is_will(opt)) 12138689Sborman #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt)) 12238689Sborman #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt)) 12337226Sminshall 12438689Sborman #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;} 12538689Sborman #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;} 12638689Sborman #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;} 12738689Sborman #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;} 12838689Sborman 12938689Sborman #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;} 13038689Sborman #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;} 13138689Sborman #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;} 13238689Sborman #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;} 13338689Sborman 13438689Sborman /* 13538689Sborman * Make everything symetrical 13638689Sborman */ 13738689Sborman 13838689Sborman #define HIS_STATE_WILL MY_STATE_DO 13938689Sborman #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO 14038689Sborman #define HIS_STATE_DO MY_STATE_WILL 14138689Sborman #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL 14238689Sborman 14338689Sborman #define his_state_is_do my_state_is_will 14438689Sborman #define his_state_is_will my_state_is_do 14538689Sborman #define his_want_state_is_do my_want_state_is_will 14638689Sborman #define his_want_state_is_will my_want_state_is_do 14738689Sborman 14838689Sborman #define his_state_is_dont my_state_is_wont 14938689Sborman #define his_state_is_wont my_state_is_dont 15038689Sborman #define his_want_state_is_dont my_want_state_is_wont 15138689Sborman #define his_want_state_is_wont my_want_state_is_dont 15238689Sborman 15338689Sborman #define set_his_state_do set_my_state_will 15438689Sborman #define set_his_state_will set_my_state_do 15538689Sborman #define set_his_want_state_do set_my_want_state_will 15638689Sborman #define set_his_want_state_will set_my_want_state_do 15738689Sborman 15838689Sborman #define set_his_state_dont set_my_state_wont 15938689Sborman #define set_his_state_wont set_my_state_dont 16038689Sborman #define set_his_want_state_dont set_my_want_state_wont 16138689Sborman #define set_his_want_state_wont set_my_want_state_dont 16238689Sborman 16338689Sborman 16432141Sminshall extern FILE 16533802Sminshall *NetTrace; /* Where debugging output goes */ 16639529Sborman extern unsigned char 16738689Sborman NetTraceFile[]; /* Name of file where debugging output goes */ 16838689Sborman extern void 16938689Sborman SetNetTrace(); /* Function to change where debugging goes */ 17032141Sminshall 17132141Sminshall extern jmp_buf 17233802Sminshall peerdied, 17333802Sminshall toplevel; /* For error conditions. */ 17432141Sminshall 17532141Sminshall extern void 17634848Sminshall command(), 17734313Sminshall #if !defined(NOT43) 17833802Sminshall dosynch(), 17934313Sminshall #endif /* !defined(NOT43) */ 18038908Sborman get_status(), 18134848Sminshall Dump(), 18234848Sminshall init_3270(), 18334848Sminshall printoption(), 18434848Sminshall printsub(), 18537219Sminshall sendnaws(), 18633802Sminshall setconnmode(), 18734848Sminshall setcommandmode(), 18834848Sminshall setneturg(), 18934848Sminshall sys_telnet_init(), 19034848Sminshall telnet(), 19134848Sminshall TerminalFlushOutput(), 19234848Sminshall TerminalNewMode(), 19334848Sminshall TerminalRestoreState(), 19434848Sminshall TerminalSaveState(), 19534848Sminshall tninit(), 19634848Sminshall upcase(), 19734848Sminshall willoption(), 19834848Sminshall wontoption(); 19932141Sminshall 20034313Sminshall #if defined(NOT43) 20134313Sminshall extern int 20234313Sminshall dosynch(); 20334313Sminshall #endif /* defined(NOT43) */ 20434313Sminshall 20539529Sborman #ifndef USE_TERMIO 20638689Sborman 20738689Sborman extern struct tchars ntc; 20838689Sborman extern struct ltchars nltc; 20938689Sborman extern struct sgttyb nttyb; 21038689Sborman 21139529Sborman # define termEofChar ntc.t_eofc 21239529Sborman # define termEraseChar nttyb.sg_erase 21339529Sborman # define termFlushChar nltc.t_flushc 21439529Sborman # define termIntChar ntc.t_intrc 21539529Sborman # define termKillChar nttyb.sg_kill 21639529Sborman # define termLiteralNextChar nltc.t_lnextc 21739529Sborman # define termQuitChar ntc.t_quitc 21839529Sborman # define termSuspChar nltc.t_suspc 21939529Sborman # define termRprntChar nltc.t_rprntc 22039529Sborman # define termWerasChar nltc.t_werasc 22139529Sborman # define termStartChar ntc.t_startc 22239529Sborman # define termStopChar ntc.t_stopc 22340245Sborman # define termForw1Char ntc.t_brkc 224*44360Sborman extern cc_t termForw2Char; 22538689Sborman 22640245Sborman # define termEofCharp (cc_t *)&ntc.t_eofc 22740245Sborman # define termEraseCharp (cc_t *)&nttyb.sg_erase 22840245Sborman # define termFlushCharp (cc_t *)&nltc.t_flushc 22940245Sborman # define termIntCharp (cc_t *)&ntc.t_intrc 23040245Sborman # define termKillCharp (cc_t *)&nttyb.sg_kill 23140245Sborman # define termLiteralNextCharp (cc_t *)&nltc.t_lnextc 23240245Sborman # define termQuitCharp (cc_t *)&ntc.t_quitc 23340245Sborman # define termSuspCharp (cc_t *)&nltc.t_suspc 23440245Sborman # define termRprntCharp (cc_t *)&nltc.t_rprntc 23540245Sborman # define termWerasCharp (cc_t *)&nltc.t_werasc 23640245Sborman # define termStartCharp (cc_t *)&ntc.t_startc 23740245Sborman # define termStopCharp (cc_t *)&ntc.t_stopc 23840245Sborman # define termForw1Charp (cc_t *)&ntc.t_brkc 23940245Sborman # define termForw2Charp (cc_t *)&termForw2Char 24038689Sborman 24138689Sborman # else 24238689Sborman 24338689Sborman extern struct termio new_tc; 24438689Sborman 24539529Sborman # define termEofChar new_tc.c_cc[VEOF] 24639529Sborman # define termEraseChar new_tc.c_cc[VERASE] 24739529Sborman # define termIntChar new_tc.c_cc[VINTR] 24839529Sborman # define termKillChar new_tc.c_cc[VKILL] 24939529Sborman # define termQuitChar new_tc.c_cc[VQUIT] 25038689Sborman 25139529Sborman # ifndef VSUSP 252*44360Sborman extern cc_t termSuspChar; 25339529Sborman # else 25439529Sborman # define termSuspChar new_tc.c_cc[VSUSP] 25539529Sborman # endif 256*44360Sborman # if !defined(VFLUSHO) && defined(VDISCARD) 257*44360Sborman # define VFLUSHO VDISCARD 258*44360Sborman # endif 259*44360Sborman # ifndef VFLUSHO 260*44360Sborman extern cc_t termFlushChar; 26139529Sborman # else 262*44360Sborman # define termFlushChar new_tc.c_cc[VFLUSHO] 26339529Sborman # endif 26439529Sborman # ifndef VWERASE 265*44360Sborman extern cc_t termWerasChar; 26639529Sborman # else 26739529Sborman # define termWerasChar new_tc.c_cc[VWERASE] 26839529Sborman # endif 26939529Sborman # ifndef VREPRINT 270*44360Sborman extern cc_t termRprntChar; 27139529Sborman # else 27239529Sborman # define termRprntChar new_tc.c_cc[VREPRINT] 27339529Sborman # endif 27439529Sborman # ifndef VLNEXT 275*44360Sborman extern cc_t termLiteralNextChar; 27639529Sborman # else 27739529Sborman # define termLiteralNextChar new_tc.c_cc[VLNEXT] 27839529Sborman # endif 27939529Sborman # ifndef VSTART 280*44360Sborman extern cc_t termStartChar; 28139529Sborman # else 28239529Sborman # define termStartChar new_tc.c_cc[VSTART] 28339529Sborman # endif 28439529Sborman # ifndef VSTOP 285*44360Sborman extern cc_t termStopChar; 28639529Sborman # else 28739529Sborman # define termStopChar new_tc.c_cc[VSTOP] 28839529Sborman # endif 28940245Sborman # ifndef VEOL 290*44360Sborman extern cc_t termForw1Char; 29140245Sborman # else 29240245Sborman # define termForw1Char new_tc.c_cc[VEOL] 29340245Sborman # endif 29440245Sborman # ifndef VEOL2 295*44360Sborman extern cc_t termForw2Char; 29640245Sborman # else 29740245Sborman # define termForw2Char new_tc.c_cc[VEOL] 29840245Sborman # endif 29938689Sborman 30038689Sborman # ifndef CRAY 30139529Sborman # define termEofCharp &termEofChar 30239529Sborman # define termEraseCharp &termEraseChar 30339529Sborman # define termIntCharp &termIntChar 30439529Sborman # define termKillCharp &termKillChar 30539529Sborman # define termQuitCharp &termQuitChar 30639529Sborman # define termSuspCharp &termSuspChar 30739529Sborman # define termFlushCharp &termFlushChar 30839529Sborman # define termWerasCharp &termWerasChar 30939529Sborman # define termRprntCharp &termRprntChar 31039529Sborman # define termLiteralNextCharp &termLiteralNextChar 31139529Sborman # define termStartCharp &termStartChar 31239529Sborman # define termStopCharp &termStopChar 31340245Sborman # define termForw1Charp &termForw1Char 31440245Sborman # define termForw2Charp &termForw2Char 31538689Sborman # else 31638689Sborman /* Work around a compiler bug */ 31738689Sborman # define termEofCharp 0 31838689Sborman # define termEraseCharp 0 31938689Sborman # define termIntCharp 0 32038689Sborman # define termKillCharp 0 32138689Sborman # define termQuitCharp 0 32239529Sborman # define termSuspCharp 0 32339529Sborman # define termFlushCharp 0 32439529Sborman # define termWerasCharp 0 32539529Sborman # define termRprntCharp 0 32639529Sborman # define termLiteralNextCharp 0 32739529Sborman # define termStartCharp 0 32839529Sborman # define termStopCharp 0 32940245Sborman # define termForw1Charp 0 33040245Sborman # define termForw2Charp 0 33138689Sborman # endif 33238689Sborman #endif 33338689Sborman 33438689Sborman 33532381Sminshall /* Ring buffer structures which are shared */ 33632381Sminshall 33732381Sminshall extern Ring 33833802Sminshall netoring, 33933802Sminshall netiring, 34033802Sminshall ttyoring, 34133802Sminshall ttyiring; 34233802Sminshall 34333802Sminshall /* Tn3270 section */ 34433802Sminshall #if defined(TN3270) 34533802Sminshall 34633802Sminshall extern int 34733802Sminshall HaveInput, /* Whether an asynchronous I/O indication came in */ 34836241Sminshall noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */ 34936241Sminshall noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */ 35036241Sminshall sigiocount, /* Count of SIGIO receptions */ 35133802Sminshall shell_active; /* Subshell is active */ 35233802Sminshall 35333802Sminshall extern char 35433802Sminshall *Ibackp, /* Oldest byte of 3270 data */ 35533802Sminshall Ibuf[], /* 3270 buffer */ 35633802Sminshall *Ifrontp, /* Where next 3270 byte goes */ 35733802Sminshall tline[], 35833802Sminshall *transcom; /* Transparent command */ 35933802Sminshall 36033802Sminshall extern int 36133802Sminshall settranscom(); 36233802Sminshall 36333802Sminshall extern void 36433802Sminshall inputAvailable(); 36533802Sminshall #endif /* defined(TN3270) */ 366