133685Sbostic /* 262309Sbostic * Copyright (c) 1988, 1990, 1993 362309Sbostic * The Regents of the University of California. All rights reserved. 433685Sbostic * 542770Sbostic * %sccs.include.redist.c% 633685Sbostic * 7*65157Sdab * @(#)externs.h 8.2 (Berkeley) 12/15/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 21*65157Sdab #ifndef USE_TERMIO 22*65157Sdab # if BSD > 43 || defined(SYSV_TERMIO) 23*65157Sdab # define USE_TERMIO 24*65157Sdab # endif 2539529Sborman #endif 2639529Sborman 2732141Sminshall #include <stdio.h> 2832141Sminshall #include <setjmp.h> 2960149Sdab #if defined(CRAY) && !defined(NO_BSD_SETJMP) 3060149Sdab #include <bsdsetjmp.h> 3160149Sdab #endif 3244360Sborman #ifndef FILIO_H 3338689Sborman #include <sys/ioctl.h> 3444360Sborman #else 3544360Sborman #include <sys/filio.h> 3644360Sborman #endif 3760149Sdab #ifdef CRAY 3860149Sdab # include <errno.h> 3960149Sdab #endif /* CRAY */ 4038689Sborman #ifdef USE_TERMIO 4139529Sborman # ifndef VINTR 4239529Sborman # ifdef SYSV_TERMIO 4339529Sborman # include <sys/termio.h> 4439529Sborman # else 4539529Sborman # include <sys/termios.h> 4639529Sborman # define termio termios 4739529Sborman # endif 4839529Sborman # endif 4944360Sborman #endif 5044360Sborman #if defined(NO_CC_T) || !defined(USE_TERMIO) 5144360Sborman # if !defined(USE_TERMIO) 5240245Sborman typedef char cc_t; 5344360Sborman # else 5444360Sborman typedef unsigned char cc_t; 5544360Sborman # endif 5638689Sborman #endif 5732141Sminshall 5846808Sdab #ifndef NO_STRING_H 5946808Sdab #include <string.h> 6046808Sdab #endif 6146808Sdab #include <strings.h> 6246808Sdab 6345230Sborman #ifndef _POSIX_VDISABLE 6445230Sborman # ifdef sun 6545230Sborman # include <sys/param.h> /* pick up VDISABLE definition, mayby */ 6645230Sborman # endif 6745230Sborman # ifdef VDISABLE 6845230Sborman # define _POSIX_VDISABLE VDISABLE 6945230Sborman # else 7046808Sdab # define _POSIX_VDISABLE ((cc_t)'\377') 7145230Sborman # endif 7245230Sborman #endif 7345230Sborman 7438689Sborman #define SUBBUFSIZE 256 7532141Sminshall 7660149Sdab #ifndef CRAY 7732141Sminshall extern int errno; /* outside this world */ 7860149Sdab #endif /* !CRAY */ 7932141Sminshall 8046808Sdab #if !defined(P) 8146808Sdab # ifdef __STDC__ 8246808Sdab # define P(x) x 8346808Sdab # else 8446808Sdab # define P(x) () 8546808Sdab # endif 8646808Sdab #endif 8733802Sminshall 8832141Sminshall extern int 8946808Sdab autologin, /* Autologin enabled */ 9047610Sdab skiprc, /* Don't process the ~/.telnetrc file */ 9146808Sdab eight, /* use eight bit mode (binary in and/or out */ 9233802Sminshall flushout, /* flush output */ 9333802Sminshall connected, /* Are we connected to the other side? */ 9433802Sminshall globalmode, /* Mode tty should be in */ 9533802Sminshall In3270, /* Are we in 3270 mode? */ 9633802Sminshall telnetport, /* Are we connected to the telnet port? */ 9737219Sminshall localflow, /* Flow control handled locally */ 9857213Sdab restartany, /* If flow control, restart output on any character */ 9933802Sminshall localchars, /* we recognize interrupt/quit */ 10033802Sminshall donelclchars, /* the user has set "localchars" */ 10133802Sminshall showoptions, 10236274Sminshall net, /* Network file descriptor */ 10336274Sminshall tin, /* Terminal input file descriptor */ 10433802Sminshall tout, /* Terminal output file descriptor */ 10533802Sminshall crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */ 10633802Sminshall autoflush, /* flush output when interrupting? */ 10733802Sminshall autosynch, /* send interrupt characters with SYNCH? */ 10833802Sminshall SYNCHing, /* Is the stream in telnet SYNCH mode? */ 10933802Sminshall donebinarytoggle, /* the user has put us in binary */ 11033802Sminshall dontlecho, /* do we suppress local echoing right now? */ 11133802Sminshall crmod, 11233802Sminshall netdata, /* Print out network data flow */ 11338689Sborman prettydump, /* Print "netdata" output in user readable format */ 11438208Sminshall #if defined(unix) 11538208Sminshall #if defined(TN3270) 11638208Sminshall cursesdata, /* Print out curses data flow */ 11738920Sminshall apitrace, /* Trace API transactions */ 11838208Sminshall #endif /* defined(TN3270) */ 11938208Sminshall termdata, /* Print out terminal data flow */ 12038208Sminshall #endif /* defined(unix) */ 12133802Sminshall debug; /* Debug level */ 12232141Sminshall 12344360Sborman extern cc_t escape; /* Escape to command mode */ 12446808Sdab extern cc_t rlogin; /* Rlogin mode escape character */ 12544360Sborman #ifdef KLUDGELINEMODE 12644360Sborman extern cc_t echoc; /* Toggle local echoing */ 12744360Sborman #endif 12840245Sborman 12944360Sborman extern char 13039529Sborman *prompt; /* Prompt for command. */ 13139529Sborman 13232141Sminshall extern char 13333802Sminshall doopt[], 13433802Sminshall dont[], 13533802Sminshall will[], 13633802Sminshall wont[], 13737226Sminshall options[], /* All the little options */ 13839529Sborman *hostname; /* Who are we connected to? */ 13960149Sdab #ifdef ENCRYPTION 14046808Sdab extern void (*encrypt_output) P((unsigned char *, int)); 14146808Sdab extern int (*decrypt_input) P((int)); 14260149Sdab #endif /* ENCRYPTION */ 14332141Sminshall 14437226Sminshall /* 14537226Sminshall * We keep track of each side of the option negotiation. 14637226Sminshall */ 14737226Sminshall 14838689Sborman #define MY_STATE_WILL 0x01 14938689Sborman #define MY_WANT_STATE_WILL 0x02 15038689Sborman #define MY_STATE_DO 0x04 15138689Sborman #define MY_WANT_STATE_DO 0x08 15237226Sminshall 15337226Sminshall /* 15438689Sborman * Macros to check the current state of things 15537226Sminshall */ 15637226Sminshall 15738689Sborman #define my_state_is_do(opt) (options[opt]&MY_STATE_DO) 15838689Sborman #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL) 15938689Sborman #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO) 16038689Sborman #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL) 16137226Sminshall 16238689Sborman #define my_state_is_dont(opt) (!my_state_is_do(opt)) 16338689Sborman #define my_state_is_wont(opt) (!my_state_is_will(opt)) 16438689Sborman #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt)) 16538689Sborman #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt)) 16637226Sminshall 16738689Sborman #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;} 16838689Sborman #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;} 16938689Sborman #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;} 17038689Sborman #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;} 17138689Sborman 17238689Sborman #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;} 17338689Sborman #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;} 17438689Sborman #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;} 17538689Sborman #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;} 17638689Sborman 17738689Sborman /* 17838689Sborman * Make everything symetrical 17938689Sborman */ 18038689Sborman 18138689Sborman #define HIS_STATE_WILL MY_STATE_DO 18238689Sborman #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO 18338689Sborman #define HIS_STATE_DO MY_STATE_WILL 18438689Sborman #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL 18538689Sborman 18638689Sborman #define his_state_is_do my_state_is_will 18738689Sborman #define his_state_is_will my_state_is_do 18838689Sborman #define his_want_state_is_do my_want_state_is_will 18938689Sborman #define his_want_state_is_will my_want_state_is_do 19038689Sborman 19138689Sborman #define his_state_is_dont my_state_is_wont 19238689Sborman #define his_state_is_wont my_state_is_dont 19338689Sborman #define his_want_state_is_dont my_want_state_is_wont 19438689Sborman #define his_want_state_is_wont my_want_state_is_dont 19538689Sborman 19638689Sborman #define set_his_state_do set_my_state_will 19738689Sborman #define set_his_state_will set_my_state_do 19838689Sborman #define set_his_want_state_do set_my_want_state_will 19938689Sborman #define set_his_want_state_will set_my_want_state_do 20038689Sborman 20138689Sborman #define set_his_state_dont set_my_state_wont 20238689Sborman #define set_his_state_wont set_my_state_dont 20338689Sborman #define set_his_want_state_dont set_my_want_state_wont 20438689Sborman #define set_his_want_state_wont set_my_want_state_dont 20538689Sborman 20638689Sborman 20732141Sminshall extern FILE 20833802Sminshall *NetTrace; /* Where debugging output goes */ 20939529Sborman extern unsigned char 21038689Sborman NetTraceFile[]; /* Name of file where debugging output goes */ 21138689Sborman extern void 21246808Sdab SetNetTrace P((char *)); /* Function to change where debugging goes */ 21332141Sminshall 21432141Sminshall extern jmp_buf 21533802Sminshall peerdied, 21633802Sminshall toplevel; /* For error conditions. */ 21732141Sminshall 21832141Sminshall extern void 21946808Sdab command P((int, char *, int)), 22046808Sdab Dump P((int, unsigned char *, int)), 22146808Sdab init_3270 P((void)), 22246808Sdab printoption P((char *, int, int)), 22346808Sdab printsub P((int, unsigned char *, int)), 22446808Sdab sendnaws P((void)), 22546808Sdab setconnmode P((int)), 22646808Sdab setcommandmode P((void)), 22746808Sdab setneturg P((void)), 22846808Sdab sys_telnet_init P((void)), 22946808Sdab telnet P((char *)), 23046808Sdab tel_enter_binary P((int)), 23146808Sdab TerminalFlushOutput P((void)), 23246808Sdab TerminalNewMode P((int)), 23346808Sdab TerminalRestoreState P((void)), 23446808Sdab TerminalSaveState P((void)), 23546808Sdab tninit P((void)), 23646808Sdab upcase P((char *)), 23746808Sdab willoption P((int)), 23846808Sdab wontoption P((int)); 23932141Sminshall 24046808Sdab extern void 24158972Sdab send_do P((int, int)), 24258972Sdab send_dont P((int, int)), 24358972Sdab send_will P((int, int)), 24458972Sdab send_wont P((int, int)); 24558972Sdab 24658972Sdab extern void 24746808Sdab lm_will P((unsigned char *, int)), 24846808Sdab lm_wont P((unsigned char *, int)), 24946808Sdab lm_do P((unsigned char *, int)), 25046808Sdab lm_dont P((unsigned char *, int)), 25146808Sdab lm_mode P((unsigned char *, int, int)); 25246808Sdab 25346808Sdab extern void 25446808Sdab slc_init P((void)), 25546808Sdab slcstate P((void)), 25646808Sdab slc_mode_export P((void)), 25746808Sdab slc_mode_import P((int)), 25846808Sdab slc_import P((int)), 25946808Sdab slc_export P((void)), 26046808Sdab slc P((unsigned char *, int)), 26146808Sdab slc_check P((void)), 26246808Sdab slc_start_reply P((void)), 26346808Sdab slc_add_reply P((int, int, int)), 26446808Sdab slc_end_reply P((void)); 26534313Sminshall extern int 26646808Sdab slc_update P((void)); 26734313Sminshall 26846808Sdab extern void 26946808Sdab env_opt P((unsigned char *, int)), 27046808Sdab env_opt_start P((void)), 27146808Sdab env_opt_start_info P((void)), 27246808Sdab env_opt_add P((unsigned char *)), 27346808Sdab env_opt_end P((int)); 27446808Sdab 27546808Sdab extern unsigned char 27657213Sdab *env_default P((int, int)), 27746808Sdab *env_getvalue P((unsigned char *)); 27846808Sdab 27946808Sdab extern int 28046808Sdab get_status P((void)), 28146808Sdab dosynch P((void)); 28246808Sdab 28346808Sdab extern cc_t 28446808Sdab *tcval P((int)); 28546808Sdab 28639529Sborman #ifndef USE_TERMIO 28738689Sborman 28838689Sborman extern struct tchars ntc; 28938689Sborman extern struct ltchars nltc; 29038689Sborman extern struct sgttyb nttyb; 29138689Sborman 29239529Sborman # define termEofChar ntc.t_eofc 29339529Sborman # define termEraseChar nttyb.sg_erase 29439529Sborman # define termFlushChar nltc.t_flushc 29539529Sborman # define termIntChar ntc.t_intrc 29639529Sborman # define termKillChar nttyb.sg_kill 29739529Sborman # define termLiteralNextChar nltc.t_lnextc 29839529Sborman # define termQuitChar ntc.t_quitc 29939529Sborman # define termSuspChar nltc.t_suspc 30039529Sborman # define termRprntChar nltc.t_rprntc 30139529Sborman # define termWerasChar nltc.t_werasc 30239529Sborman # define termStartChar ntc.t_startc 30339529Sborman # define termStopChar ntc.t_stopc 30440245Sborman # define termForw1Char ntc.t_brkc 30544360Sborman extern cc_t termForw2Char; 30645230Sborman extern cc_t termAytChar; 30738689Sborman 30840245Sborman # define termEofCharp (cc_t *)&ntc.t_eofc 30940245Sborman # define termEraseCharp (cc_t *)&nttyb.sg_erase 31040245Sborman # define termFlushCharp (cc_t *)&nltc.t_flushc 31140245Sborman # define termIntCharp (cc_t *)&ntc.t_intrc 31240245Sborman # define termKillCharp (cc_t *)&nttyb.sg_kill 31340245Sborman # define termLiteralNextCharp (cc_t *)&nltc.t_lnextc 31440245Sborman # define termQuitCharp (cc_t *)&ntc.t_quitc 31540245Sborman # define termSuspCharp (cc_t *)&nltc.t_suspc 31640245Sborman # define termRprntCharp (cc_t *)&nltc.t_rprntc 31740245Sborman # define termWerasCharp (cc_t *)&nltc.t_werasc 31840245Sborman # define termStartCharp (cc_t *)&ntc.t_startc 31940245Sborman # define termStopCharp (cc_t *)&ntc.t_stopc 32040245Sborman # define termForw1Charp (cc_t *)&ntc.t_brkc 32140245Sborman # define termForw2Charp (cc_t *)&termForw2Char 32245230Sborman # define termAytCharp (cc_t *)&termAytChar 32338689Sborman 32438689Sborman # else 32538689Sborman 32638689Sborman extern struct termio new_tc; 32738689Sborman 32839529Sborman # define termEofChar new_tc.c_cc[VEOF] 32939529Sborman # define termEraseChar new_tc.c_cc[VERASE] 33039529Sborman # define termIntChar new_tc.c_cc[VINTR] 33139529Sborman # define termKillChar new_tc.c_cc[VKILL] 33239529Sborman # define termQuitChar new_tc.c_cc[VQUIT] 33338689Sborman 33439529Sborman # ifndef VSUSP 33544360Sborman extern cc_t termSuspChar; 33639529Sborman # else 33739529Sborman # define termSuspChar new_tc.c_cc[VSUSP] 33839529Sborman # endif 33945230Sborman # if defined(VFLUSHO) && !defined(VDISCARD) 34045230Sborman # define VDISCARD VFLUSHO 34144360Sborman # endif 34245230Sborman # ifndef VDISCARD 34344360Sborman extern cc_t termFlushChar; 34439529Sborman # else 34545230Sborman # define termFlushChar new_tc.c_cc[VDISCARD] 34639529Sborman # endif 34739529Sborman # ifndef VWERASE 34844360Sborman extern cc_t termWerasChar; 34939529Sborman # else 35039529Sborman # define termWerasChar new_tc.c_cc[VWERASE] 35139529Sborman # endif 35239529Sborman # ifndef VREPRINT 35344360Sborman extern cc_t termRprntChar; 35439529Sborman # else 35539529Sborman # define termRprntChar new_tc.c_cc[VREPRINT] 35639529Sborman # endif 35739529Sborman # ifndef VLNEXT 35844360Sborman extern cc_t termLiteralNextChar; 35939529Sborman # else 36039529Sborman # define termLiteralNextChar new_tc.c_cc[VLNEXT] 36139529Sborman # endif 36239529Sborman # ifndef VSTART 36344360Sborman extern cc_t termStartChar; 36439529Sborman # else 36539529Sborman # define termStartChar new_tc.c_cc[VSTART] 36639529Sborman # endif 36739529Sborman # ifndef VSTOP 36844360Sborman extern cc_t termStopChar; 36939529Sborman # else 37039529Sborman # define termStopChar new_tc.c_cc[VSTOP] 37139529Sborman # endif 37240245Sborman # ifndef VEOL 37344360Sborman extern cc_t termForw1Char; 37440245Sborman # else 37540245Sborman # define termForw1Char new_tc.c_cc[VEOL] 37640245Sborman # endif 37740245Sborman # ifndef VEOL2 37844360Sborman extern cc_t termForw2Char; 37940245Sborman # else 38040245Sborman # define termForw2Char new_tc.c_cc[VEOL] 38140245Sborman # endif 38245230Sborman # ifndef VSTATUS 38345230Sborman extern cc_t termAytChar; 38445230Sborman #else 38545230Sborman # define termAytChar new_tc.c_cc[VSTATUS] 38645230Sborman #endif 38738689Sborman 38845230Sborman # if !defined(CRAY) || defined(__STDC__) 38939529Sborman # define termEofCharp &termEofChar 39039529Sborman # define termEraseCharp &termEraseChar 39139529Sborman # define termIntCharp &termIntChar 39239529Sborman # define termKillCharp &termKillChar 39339529Sborman # define termQuitCharp &termQuitChar 39439529Sborman # define termSuspCharp &termSuspChar 39539529Sborman # define termFlushCharp &termFlushChar 39639529Sborman # define termWerasCharp &termWerasChar 39739529Sborman # define termRprntCharp &termRprntChar 39839529Sborman # define termLiteralNextCharp &termLiteralNextChar 39939529Sborman # define termStartCharp &termStartChar 40039529Sborman # define termStopCharp &termStopChar 40140245Sborman # define termForw1Charp &termForw1Char 40240245Sborman # define termForw2Charp &termForw2Char 40345230Sborman # define termAytCharp &termAytChar 40438689Sborman # else 40538689Sborman /* Work around a compiler bug */ 40638689Sborman # define termEofCharp 0 40738689Sborman # define termEraseCharp 0 40838689Sborman # define termIntCharp 0 40938689Sborman # define termKillCharp 0 41038689Sborman # define termQuitCharp 0 41139529Sborman # define termSuspCharp 0 41239529Sborman # define termFlushCharp 0 41339529Sborman # define termWerasCharp 0 41439529Sborman # define termRprntCharp 0 41539529Sborman # define termLiteralNextCharp 0 41639529Sborman # define termStartCharp 0 41739529Sborman # define termStopCharp 0 41840245Sborman # define termForw1Charp 0 41940245Sborman # define termForw2Charp 0 42045230Sborman # define termAytCharp 0 42138689Sborman # endif 42238689Sborman #endif 42338689Sborman 42438689Sborman 42532381Sminshall /* Ring buffer structures which are shared */ 42632381Sminshall 42732381Sminshall extern Ring 42833802Sminshall netoring, 42933802Sminshall netiring, 43033802Sminshall ttyoring, 43133802Sminshall ttyiring; 43233802Sminshall 43333802Sminshall /* Tn3270 section */ 43433802Sminshall #if defined(TN3270) 43533802Sminshall 43633802Sminshall extern int 43733802Sminshall HaveInput, /* Whether an asynchronous I/O indication came in */ 43836241Sminshall noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */ 43936241Sminshall noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */ 44036241Sminshall sigiocount, /* Count of SIGIO receptions */ 44133802Sminshall shell_active; /* Subshell is active */ 44233802Sminshall 44333802Sminshall extern char 44433802Sminshall *Ibackp, /* Oldest byte of 3270 data */ 44533802Sminshall Ibuf[], /* 3270 buffer */ 44633802Sminshall *Ifrontp, /* Where next 3270 byte goes */ 44733802Sminshall tline[], 44833802Sminshall *transcom; /* Transparent command */ 44933802Sminshall 45060179Sbostic extern int 45146808Sdab settranscom P((int, char**)); 45233802Sminshall 45333802Sminshall extern void 45459893Sbostic inputAvailable P((int)); 45533802Sminshall #endif /* defined(TN3270) */ 456