133685Sbostic /* 245230Sborman * Copyright (c) 1988, 1990 Regents of the University of California. 333685Sbostic * All rights reserved. 433685Sbostic * 542770Sbostic * %sccs.include.redist.c% 633685Sbostic * 7*59893Sbostic * @(#)externs.h 5.6 (Berkeley) 05/11/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> 2744360Sborman #ifndef FILIO_H 2838689Sborman #include <sys/ioctl.h> 2944360Sborman #else 3044360Sborman #include <sys/filio.h> 3144360Sborman #endif 3238689Sborman #ifdef USE_TERMIO 3339529Sborman # ifndef VINTR 3439529Sborman # ifdef SYSV_TERMIO 3539529Sborman # include <sys/termio.h> 3639529Sborman # else 3739529Sborman # include <sys/termios.h> 3839529Sborman # define termio termios 3939529Sborman # endif 4039529Sborman # endif 4144360Sborman #endif 4244360Sborman #if defined(NO_CC_T) || !defined(USE_TERMIO) 4344360Sborman # if !defined(USE_TERMIO) 4440245Sborman typedef char cc_t; 4544360Sborman # else 4644360Sborman typedef unsigned char cc_t; 4744360Sborman # endif 4838689Sborman #endif 4932141Sminshall 5046808Sdab #ifndef NO_STRING_H 5146808Sdab #include <string.h> 5246808Sdab #endif 5346808Sdab #include <strings.h> 5446808Sdab 5545230Sborman #ifndef _POSIX_VDISABLE 5645230Sborman # ifdef sun 5745230Sborman # include <sys/param.h> /* pick up VDISABLE definition, mayby */ 5845230Sborman # endif 5945230Sborman # ifdef VDISABLE 6045230Sborman # define _POSIX_VDISABLE VDISABLE 6145230Sborman # else 6246808Sdab # define _POSIX_VDISABLE ((cc_t)'\377') 6345230Sborman # endif 6445230Sborman #endif 6545230Sborman 6638689Sborman #define SUBBUFSIZE 256 6732141Sminshall 6832141Sminshall extern int errno; /* outside this world */ 6932141Sminshall 7046808Sdab #if !defined(P) 7146808Sdab # ifdef __STDC__ 7246808Sdab # define P(x) x 7346808Sdab # else 7446808Sdab # define P(x) () 7546808Sdab # endif 7646808Sdab #endif 7733802Sminshall 7832141Sminshall extern int 7946808Sdab autologin, /* Autologin enabled */ 8047610Sdab skiprc, /* Don't process the ~/.telnetrc file */ 8146808Sdab eight, /* use eight bit mode (binary in and/or out */ 8233802Sminshall flushout, /* flush output */ 8333802Sminshall connected, /* Are we connected to the other side? */ 8433802Sminshall globalmode, /* Mode tty should be in */ 8533802Sminshall In3270, /* Are we in 3270 mode? */ 8633802Sminshall telnetport, /* Are we connected to the telnet port? */ 8737219Sminshall localflow, /* Flow control handled locally */ 8857213Sdab restartany, /* If flow control, restart output on any character */ 8933802Sminshall localchars, /* we recognize interrupt/quit */ 9033802Sminshall donelclchars, /* the user has set "localchars" */ 9133802Sminshall showoptions, 9236274Sminshall net, /* Network file descriptor */ 9336274Sminshall tin, /* Terminal input file descriptor */ 9433802Sminshall tout, /* Terminal output file descriptor */ 9533802Sminshall crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */ 9633802Sminshall autoflush, /* flush output when interrupting? */ 9733802Sminshall autosynch, /* send interrupt characters with SYNCH? */ 9833802Sminshall SYNCHing, /* Is the stream in telnet SYNCH mode? */ 9933802Sminshall donebinarytoggle, /* the user has put us in binary */ 10033802Sminshall dontlecho, /* do we suppress local echoing right now? */ 10133802Sminshall crmod, 10233802Sminshall netdata, /* Print out network data flow */ 10338689Sborman prettydump, /* Print "netdata" output in user readable format */ 10438208Sminshall #if defined(unix) 10538208Sminshall #if defined(TN3270) 10638208Sminshall cursesdata, /* Print out curses data flow */ 10738920Sminshall apitrace, /* Trace API transactions */ 10838208Sminshall #endif /* defined(TN3270) */ 10938208Sminshall termdata, /* Print out terminal data flow */ 11038208Sminshall #endif /* defined(unix) */ 11133802Sminshall debug; /* Debug level */ 11232141Sminshall 11344360Sborman extern cc_t escape; /* Escape to command mode */ 11446808Sdab extern cc_t rlogin; /* Rlogin mode escape character */ 11544360Sborman #ifdef KLUDGELINEMODE 11644360Sborman extern cc_t echoc; /* Toggle local echoing */ 11744360Sborman #endif 11840245Sborman 11944360Sborman extern char 12039529Sborman *prompt; /* Prompt for command. */ 12139529Sborman 12232141Sminshall extern char 12333802Sminshall doopt[], 12433802Sminshall dont[], 12533802Sminshall will[], 12633802Sminshall wont[], 12737226Sminshall options[], /* All the little options */ 12839529Sborman *hostname; /* Who are we connected to? */ 12957213Sdab #if defined(ENCRYPTION) 13046808Sdab extern void (*encrypt_output) P((unsigned char *, int)); 13146808Sdab extern int (*decrypt_input) P((int)); 13246808Sdab #endif 13332141Sminshall 13437226Sminshall /* 13537226Sminshall * We keep track of each side of the option negotiation. 13637226Sminshall */ 13737226Sminshall 13838689Sborman #define MY_STATE_WILL 0x01 13938689Sborman #define MY_WANT_STATE_WILL 0x02 14038689Sborman #define MY_STATE_DO 0x04 14138689Sborman #define MY_WANT_STATE_DO 0x08 14237226Sminshall 14337226Sminshall /* 14438689Sborman * Macros to check the current state of things 14537226Sminshall */ 14637226Sminshall 14738689Sborman #define my_state_is_do(opt) (options[opt]&MY_STATE_DO) 14838689Sborman #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL) 14938689Sborman #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO) 15038689Sborman #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL) 15137226Sminshall 15238689Sborman #define my_state_is_dont(opt) (!my_state_is_do(opt)) 15338689Sborman #define my_state_is_wont(opt) (!my_state_is_will(opt)) 15438689Sborman #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt)) 15538689Sborman #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt)) 15637226Sminshall 15738689Sborman #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;} 15838689Sborman #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;} 15938689Sborman #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;} 16038689Sborman #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;} 16138689Sborman 16238689Sborman #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;} 16338689Sborman #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;} 16438689Sborman #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;} 16538689Sborman #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;} 16638689Sborman 16738689Sborman /* 16838689Sborman * Make everything symetrical 16938689Sborman */ 17038689Sborman 17138689Sborman #define HIS_STATE_WILL MY_STATE_DO 17238689Sborman #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO 17338689Sborman #define HIS_STATE_DO MY_STATE_WILL 17438689Sborman #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL 17538689Sborman 17638689Sborman #define his_state_is_do my_state_is_will 17738689Sborman #define his_state_is_will my_state_is_do 17838689Sborman #define his_want_state_is_do my_want_state_is_will 17938689Sborman #define his_want_state_is_will my_want_state_is_do 18038689Sborman 18138689Sborman #define his_state_is_dont my_state_is_wont 18238689Sborman #define his_state_is_wont my_state_is_dont 18338689Sborman #define his_want_state_is_dont my_want_state_is_wont 18438689Sborman #define his_want_state_is_wont my_want_state_is_dont 18538689Sborman 18638689Sborman #define set_his_state_do set_my_state_will 18738689Sborman #define set_his_state_will set_my_state_do 18838689Sborman #define set_his_want_state_do set_my_want_state_will 18938689Sborman #define set_his_want_state_will set_my_want_state_do 19038689Sborman 19138689Sborman #define set_his_state_dont set_my_state_wont 19238689Sborman #define set_his_state_wont set_my_state_dont 19338689Sborman #define set_his_want_state_dont set_my_want_state_wont 19438689Sborman #define set_his_want_state_wont set_my_want_state_dont 19538689Sborman 19638689Sborman 19732141Sminshall extern FILE 19833802Sminshall *NetTrace; /* Where debugging output goes */ 19939529Sborman extern unsigned char 20038689Sborman NetTraceFile[]; /* Name of file where debugging output goes */ 20138689Sborman extern void 20246808Sdab SetNetTrace P((char *)); /* Function to change where debugging goes */ 20332141Sminshall 20432141Sminshall extern jmp_buf 20533802Sminshall peerdied, 20633802Sminshall toplevel; /* For error conditions. */ 20732141Sminshall 20832141Sminshall extern void 20946808Sdab command P((int, char *, int)), 21046808Sdab Dump P((int, unsigned char *, int)), 21146808Sdab init_3270 P((void)), 21246808Sdab printoption P((char *, int, int)), 21346808Sdab printsub P((int, unsigned char *, int)), 21446808Sdab sendnaws P((void)), 21546808Sdab setconnmode P((int)), 21646808Sdab setcommandmode P((void)), 21746808Sdab setneturg P((void)), 21846808Sdab sys_telnet_init P((void)), 21946808Sdab telnet P((char *)), 22046808Sdab tel_enter_binary P((int)), 22146808Sdab TerminalFlushOutput P((void)), 22246808Sdab TerminalNewMode P((int)), 22346808Sdab TerminalRestoreState P((void)), 22446808Sdab TerminalSaveState P((void)), 22546808Sdab tninit P((void)), 22646808Sdab upcase P((char *)), 22746808Sdab willoption P((int)), 22846808Sdab wontoption P((int)); 22932141Sminshall 23046808Sdab extern void 23158972Sdab send_do P((int, int)), 23258972Sdab send_dont P((int, int)), 23358972Sdab send_will P((int, int)), 23458972Sdab send_wont P((int, int)); 23558972Sdab 23658972Sdab extern void 23746808Sdab lm_will P((unsigned char *, int)), 23846808Sdab lm_wont P((unsigned char *, int)), 23946808Sdab lm_do P((unsigned char *, int)), 24046808Sdab lm_dont P((unsigned char *, int)), 24146808Sdab lm_mode P((unsigned char *, int, int)); 24246808Sdab 24346808Sdab extern void 24446808Sdab slc_init P((void)), 24546808Sdab slcstate P((void)), 24646808Sdab slc_mode_export P((void)), 24746808Sdab slc_mode_import P((int)), 24846808Sdab slc_import P((int)), 24946808Sdab slc_export P((void)), 25046808Sdab slc P((unsigned char *, int)), 25146808Sdab slc_check P((void)), 25246808Sdab slc_start_reply P((void)), 25346808Sdab slc_add_reply P((int, int, int)), 25446808Sdab slc_end_reply P((void)); 25534313Sminshall extern int 25646808Sdab slc_update P((void)); 25734313Sminshall 25846808Sdab extern void 25946808Sdab env_opt P((unsigned char *, int)), 26046808Sdab env_opt_start P((void)), 26146808Sdab env_opt_start_info P((void)), 26246808Sdab env_opt_add P((unsigned char *)), 26346808Sdab env_opt_end P((int)); 26446808Sdab 26546808Sdab extern unsigned char 26657213Sdab *env_default P((int, int)), 26746808Sdab *env_getvalue P((unsigned char *)); 26846808Sdab 26946808Sdab extern int 27046808Sdab get_status P((void)), 27146808Sdab dosynch P((void)); 27246808Sdab 27346808Sdab extern cc_t 27446808Sdab *tcval P((int)); 27546808Sdab 27639529Sborman #ifndef USE_TERMIO 27738689Sborman 27838689Sborman extern struct tchars ntc; 27938689Sborman extern struct ltchars nltc; 28038689Sborman extern struct sgttyb nttyb; 28138689Sborman 28239529Sborman # define termEofChar ntc.t_eofc 28339529Sborman # define termEraseChar nttyb.sg_erase 28439529Sborman # define termFlushChar nltc.t_flushc 28539529Sborman # define termIntChar ntc.t_intrc 28639529Sborman # define termKillChar nttyb.sg_kill 28739529Sborman # define termLiteralNextChar nltc.t_lnextc 28839529Sborman # define termQuitChar ntc.t_quitc 28939529Sborman # define termSuspChar nltc.t_suspc 29039529Sborman # define termRprntChar nltc.t_rprntc 29139529Sborman # define termWerasChar nltc.t_werasc 29239529Sborman # define termStartChar ntc.t_startc 29339529Sborman # define termStopChar ntc.t_stopc 29440245Sborman # define termForw1Char ntc.t_brkc 29544360Sborman extern cc_t termForw2Char; 29645230Sborman extern cc_t termAytChar; 29738689Sborman 29840245Sborman # define termEofCharp (cc_t *)&ntc.t_eofc 29940245Sborman # define termEraseCharp (cc_t *)&nttyb.sg_erase 30040245Sborman # define termFlushCharp (cc_t *)&nltc.t_flushc 30140245Sborman # define termIntCharp (cc_t *)&ntc.t_intrc 30240245Sborman # define termKillCharp (cc_t *)&nttyb.sg_kill 30340245Sborman # define termLiteralNextCharp (cc_t *)&nltc.t_lnextc 30440245Sborman # define termQuitCharp (cc_t *)&ntc.t_quitc 30540245Sborman # define termSuspCharp (cc_t *)&nltc.t_suspc 30640245Sborman # define termRprntCharp (cc_t *)&nltc.t_rprntc 30740245Sborman # define termWerasCharp (cc_t *)&nltc.t_werasc 30840245Sborman # define termStartCharp (cc_t *)&ntc.t_startc 30940245Sborman # define termStopCharp (cc_t *)&ntc.t_stopc 31040245Sborman # define termForw1Charp (cc_t *)&ntc.t_brkc 31140245Sborman # define termForw2Charp (cc_t *)&termForw2Char 31245230Sborman # define termAytCharp (cc_t *)&termAytChar 31338689Sborman 31438689Sborman # else 31538689Sborman 31638689Sborman extern struct termio new_tc; 31738689Sborman 31839529Sborman # define termEofChar new_tc.c_cc[VEOF] 31939529Sborman # define termEraseChar new_tc.c_cc[VERASE] 32039529Sborman # define termIntChar new_tc.c_cc[VINTR] 32139529Sborman # define termKillChar new_tc.c_cc[VKILL] 32239529Sborman # define termQuitChar new_tc.c_cc[VQUIT] 32338689Sborman 32439529Sborman # ifndef VSUSP 32544360Sborman extern cc_t termSuspChar; 32639529Sborman # else 32739529Sborman # define termSuspChar new_tc.c_cc[VSUSP] 32839529Sborman # endif 32945230Sborman # if defined(VFLUSHO) && !defined(VDISCARD) 33045230Sborman # define VDISCARD VFLUSHO 33144360Sborman # endif 33245230Sborman # ifndef VDISCARD 33344360Sborman extern cc_t termFlushChar; 33439529Sborman # else 33545230Sborman # define termFlushChar new_tc.c_cc[VDISCARD] 33639529Sborman # endif 33739529Sborman # ifndef VWERASE 33844360Sborman extern cc_t termWerasChar; 33939529Sborman # else 34039529Sborman # define termWerasChar new_tc.c_cc[VWERASE] 34139529Sborman # endif 34239529Sborman # ifndef VREPRINT 34344360Sborman extern cc_t termRprntChar; 34439529Sborman # else 34539529Sborman # define termRprntChar new_tc.c_cc[VREPRINT] 34639529Sborman # endif 34739529Sborman # ifndef VLNEXT 34844360Sborman extern cc_t termLiteralNextChar; 34939529Sborman # else 35039529Sborman # define termLiteralNextChar new_tc.c_cc[VLNEXT] 35139529Sborman # endif 35239529Sborman # ifndef VSTART 35344360Sborman extern cc_t termStartChar; 35439529Sborman # else 35539529Sborman # define termStartChar new_tc.c_cc[VSTART] 35639529Sborman # endif 35739529Sborman # ifndef VSTOP 35844360Sborman extern cc_t termStopChar; 35939529Sborman # else 36039529Sborman # define termStopChar new_tc.c_cc[VSTOP] 36139529Sborman # endif 36240245Sborman # ifndef VEOL 36344360Sborman extern cc_t termForw1Char; 36440245Sborman # else 36540245Sborman # define termForw1Char new_tc.c_cc[VEOL] 36640245Sborman # endif 36740245Sborman # ifndef VEOL2 36844360Sborman extern cc_t termForw2Char; 36940245Sborman # else 37040245Sborman # define termForw2Char new_tc.c_cc[VEOL] 37140245Sborman # endif 37245230Sborman # ifndef VSTATUS 37345230Sborman extern cc_t termAytChar; 37445230Sborman #else 37545230Sborman # define termAytChar new_tc.c_cc[VSTATUS] 37645230Sborman #endif 37738689Sborman 37845230Sborman # if !defined(CRAY) || defined(__STDC__) 37939529Sborman # define termEofCharp &termEofChar 38039529Sborman # define termEraseCharp &termEraseChar 38139529Sborman # define termIntCharp &termIntChar 38239529Sborman # define termKillCharp &termKillChar 38339529Sborman # define termQuitCharp &termQuitChar 38439529Sborman # define termSuspCharp &termSuspChar 38539529Sborman # define termFlushCharp &termFlushChar 38639529Sborman # define termWerasCharp &termWerasChar 38739529Sborman # define termRprntCharp &termRprntChar 38839529Sborman # define termLiteralNextCharp &termLiteralNextChar 38939529Sborman # define termStartCharp &termStartChar 39039529Sborman # define termStopCharp &termStopChar 39140245Sborman # define termForw1Charp &termForw1Char 39240245Sborman # define termForw2Charp &termForw2Char 39345230Sborman # define termAytCharp &termAytChar 39438689Sborman # else 39538689Sborman /* Work around a compiler bug */ 39638689Sborman # define termEofCharp 0 39738689Sborman # define termEraseCharp 0 39838689Sborman # define termIntCharp 0 39938689Sborman # define termKillCharp 0 40038689Sborman # define termQuitCharp 0 40139529Sborman # define termSuspCharp 0 40239529Sborman # define termFlushCharp 0 40339529Sborman # define termWerasCharp 0 40439529Sborman # define termRprntCharp 0 40539529Sborman # define termLiteralNextCharp 0 40639529Sborman # define termStartCharp 0 40739529Sborman # define termStopCharp 0 40840245Sborman # define termForw1Charp 0 40940245Sborman # define termForw2Charp 0 41045230Sborman # define termAytCharp 0 41138689Sborman # endif 41238689Sborman #endif 41338689Sborman 41438689Sborman 41532381Sminshall /* Ring buffer structures which are shared */ 41632381Sminshall 41732381Sminshall extern Ring 41833802Sminshall netoring, 41933802Sminshall netiring, 42033802Sminshall ttyoring, 42133802Sminshall ttyiring; 42233802Sminshall 42333802Sminshall /* Tn3270 section */ 42433802Sminshall #if defined(TN3270) 42533802Sminshall 42633802Sminshall extern int 42733802Sminshall HaveInput, /* Whether an asynchronous I/O indication came in */ 42836241Sminshall noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */ 42936241Sminshall noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */ 43036241Sminshall sigiocount, /* Count of SIGIO receptions */ 43133802Sminshall shell_active; /* Subshell is active */ 43233802Sminshall 43333802Sminshall extern char 43433802Sminshall *Ibackp, /* Oldest byte of 3270 data */ 43533802Sminshall Ibuf[], /* 3270 buffer */ 43633802Sminshall *Ifrontp, /* Where next 3270 byte goes */ 43733802Sminshall tline[], 43833802Sminshall *transcom; /* Transparent command */ 43933802Sminshall 440*59893Sbostic extern void 44146808Sdab settranscom P((int, char**)); 44233802Sminshall 44333802Sminshall extern void 444*59893Sbostic inputAvailable P((int)); 44533802Sminshall #endif /* defined(TN3270) */ 446