133685Sbostic /* 233685Sbostic * Copyright (c) 1988 Regents of the University of California. 333685Sbostic * All rights reserved. 433685Sbostic * 533685Sbostic * Redistribution and use in source and binary forms are permitted 634898Sbostic * provided that the above copyright notice and this paragraph are 734898Sbostic * duplicated in all such forms and that any documentation, 834898Sbostic * advertising materials, and other materials related to such 934898Sbostic * distribution and use acknowledge that the software was developed 1034898Sbostic * by the University of California, Berkeley. The name of the 1134898Sbostic * University may not be used to endorse or promote products derived 1234898Sbostic * from this software without specific prior written permission. 1334898Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 1434898Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 1534898Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1633685Sbostic * 17*38689Sborman * @(#)externs.h 1.17 (Berkeley) 08/21/89 1833685Sbostic */ 1933685Sbostic 20*38689Sborman #ifdef CRAY 21*38689Sborman #define USE_TERMIO 22*38689Sborman #endif 23*38689Sborman 2432141Sminshall #include <stdio.h> 2532141Sminshall #include <setjmp.h> 26*38689Sborman #include <sys/ioctl.h> 27*38689Sborman #ifdef USE_TERMIO 28*38689Sborman #ifndef VINTR 29*38689Sborman #include <sys/termio.h> 30*38689Sborman #endif 31*38689Sborman #endif 3232141Sminshall 33*38689Sborman #define SUBBUFSIZE 256 3432141Sminshall 3532141Sminshall extern int errno; /* outside this world */ 3632141Sminshall 3733802Sminshall extern char 3833802Sminshall *strcat(), 3933802Sminshall *strcpy(); /* outside this world */ 4033802Sminshall 4132141Sminshall extern int 4233802Sminshall flushout, /* flush output */ 4333802Sminshall connected, /* Are we connected to the other side? */ 4433802Sminshall globalmode, /* Mode tty should be in */ 4533802Sminshall In3270, /* Are we in 3270 mode? */ 4633802Sminshall telnetport, /* Are we connected to the telnet port? */ 4737219Sminshall localflow, /* Flow control handled locally */ 4833802Sminshall localchars, /* we recognize interrupt/quit */ 4933802Sminshall donelclchars, /* the user has set "localchars" */ 5033802Sminshall showoptions, 5136274Sminshall net, /* Network file descriptor */ 5236274Sminshall tin, /* Terminal input file descriptor */ 5333802Sminshall tout, /* Terminal output file descriptor */ 5433802Sminshall crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */ 5533802Sminshall autoflush, /* flush output when interrupting? */ 5633802Sminshall autosynch, /* send interrupt characters with SYNCH? */ 5733802Sminshall SYNCHing, /* Is the stream in telnet SYNCH mode? */ 5833802Sminshall donebinarytoggle, /* the user has put us in binary */ 5933802Sminshall dontlecho, /* do we suppress local echoing right now? */ 6033802Sminshall crmod, 6133802Sminshall netdata, /* Print out network data flow */ 62*38689Sborman prettydump, /* Print "netdata" output in user readable format */ 6338208Sminshall #if defined(unix) 6438208Sminshall #if defined(TN3270) 6538208Sminshall cursesdata, /* Print out curses data flow */ 6638208Sminshall #endif /* defined(TN3270) */ 6738208Sminshall termdata, /* Print out terminal data flow */ 6838208Sminshall #endif /* defined(unix) */ 6933802Sminshall debug; /* Debug level */ 7032141Sminshall 7132141Sminshall extern char 7233802Sminshall echoc, /* Toggle local echoing */ 7333802Sminshall escape, /* Escape to command mode */ 7433802Sminshall doopt[], 7533802Sminshall dont[], 7633802Sminshall will[], 7733802Sminshall wont[], 7837226Sminshall options[], /* All the little options */ 7933802Sminshall *hostname, /* Who are we connected to? */ 8033802Sminshall *prompt; /* Prompt for command. */ 8132141Sminshall 8237226Sminshall /* 8337226Sminshall * We keep track of each side of the option negotiation. 8437226Sminshall */ 8537226Sminshall 86*38689Sborman #define MY_STATE_WILL 0x01 87*38689Sborman #define MY_WANT_STATE_WILL 0x02 88*38689Sborman #define MY_STATE_DO 0x04 89*38689Sborman #define MY_WANT_STATE_DO 0x08 9037226Sminshall 9137226Sminshall /* 92*38689Sborman * Macros to check the current state of things 9337226Sminshall */ 9437226Sminshall 95*38689Sborman #define my_state_is_do(opt) (options[opt]&MY_STATE_DO) 96*38689Sborman #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL) 97*38689Sborman #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO) 98*38689Sborman #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL) 9937226Sminshall 100*38689Sborman #define my_state_is_dont(opt) (!my_state_is_do(opt)) 101*38689Sborman #define my_state_is_wont(opt) (!my_state_is_will(opt)) 102*38689Sborman #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt)) 103*38689Sborman #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt)) 10437226Sminshall 105*38689Sborman #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;} 106*38689Sborman #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;} 107*38689Sborman #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;} 108*38689Sborman #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;} 109*38689Sborman 110*38689Sborman #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;} 111*38689Sborman #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;} 112*38689Sborman #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;} 113*38689Sborman #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;} 114*38689Sborman 115*38689Sborman /* 116*38689Sborman * Make everything symetrical 117*38689Sborman */ 118*38689Sborman 119*38689Sborman #define HIS_STATE_WILL MY_STATE_DO 120*38689Sborman #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO 121*38689Sborman #define HIS_STATE_DO MY_STATE_WILL 122*38689Sborman #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL 123*38689Sborman 124*38689Sborman #define his_state_is_do my_state_is_will 125*38689Sborman #define his_state_is_will my_state_is_do 126*38689Sborman #define his_want_state_is_do my_want_state_is_will 127*38689Sborman #define his_want_state_is_will my_want_state_is_do 128*38689Sborman 129*38689Sborman #define his_state_is_dont my_state_is_wont 130*38689Sborman #define his_state_is_wont my_state_is_dont 131*38689Sborman #define his_want_state_is_dont my_want_state_is_wont 132*38689Sborman #define his_want_state_is_wont my_want_state_is_dont 133*38689Sborman 134*38689Sborman #define set_his_state_do set_my_state_will 135*38689Sborman #define set_his_state_will set_my_state_do 136*38689Sborman #define set_his_want_state_do set_my_want_state_will 137*38689Sborman #define set_his_want_state_will set_my_want_state_do 138*38689Sborman 139*38689Sborman #define set_his_state_dont set_my_state_wont 140*38689Sborman #define set_his_state_wont set_my_state_dont 141*38689Sborman #define set_his_want_state_dont set_my_want_state_wont 142*38689Sborman #define set_his_want_state_wont set_my_want_state_dont 143*38689Sborman 144*38689Sborman 14532141Sminshall extern FILE 14633802Sminshall *NetTrace; /* Where debugging output goes */ 147*38689Sborman extern char 148*38689Sborman NetTraceFile[]; /* Name of file where debugging output goes */ 149*38689Sborman extern void 150*38689Sborman SetNetTrace(); /* Function to change where debugging goes */ 15132141Sminshall 15232141Sminshall extern jmp_buf 15333802Sminshall peerdied, 15433802Sminshall toplevel; /* For error conditions. */ 15532141Sminshall 15632141Sminshall extern void 15734848Sminshall command(), 15834313Sminshall #if !defined(NOT43) 15933802Sminshall dosynch(), 16034313Sminshall #endif /* !defined(NOT43) */ 16134848Sminshall Dump(), 16234848Sminshall init_3270(), 16334848Sminshall printoption(), 16434848Sminshall printsub(), 16537219Sminshall sendnaws(), 16633802Sminshall setconnmode(), 16734848Sminshall setcommandmode(), 16834848Sminshall setneturg(), 16934848Sminshall sys_telnet_init(), 17034848Sminshall telnet(), 17134848Sminshall TerminalFlushOutput(), 17234848Sminshall TerminalNewMode(), 17334848Sminshall TerminalRestoreState(), 17434848Sminshall TerminalSaveState(), 17534848Sminshall tninit(), 17634848Sminshall upcase(), 17734848Sminshall willoption(), 17834848Sminshall wontoption(); 17932141Sminshall 18034313Sminshall #if defined(NOT43) 18134313Sminshall extern int 18234313Sminshall dosynch(); 18334313Sminshall #endif /* defined(NOT43) */ 18434313Sminshall 185*38689Sborman #if !defined(MSDOS) 186*38689Sborman # ifndef USE_TERMIO 187*38689Sborman 188*38689Sborman extern struct tchars ntc; 189*38689Sborman extern struct ltchars nltc; 190*38689Sborman extern struct sgttyb nttyb; 191*38689Sborman 192*38689Sborman # define termEofChar ntc.t_eofc 193*38689Sborman # define termEraseChar nttyb.sg_erase 194*38689Sborman # define termFlushChar nltc.t_flushc 195*38689Sborman # define termIntChar ntc.t_intrc 196*38689Sborman # define termKillChar nttyb.sg_kill 197*38689Sborman # define termLiteralNextChar nltc.t_lnextc 198*38689Sborman # define termQuitChar ntc.t_quitc 199*38689Sborman # define termSuspChar nltc.t_suspc 200*38689Sborman # define termRprntChar nltc.t_rprntc 201*38689Sborman # define termWerasChar nltc.t_werasc 202*38689Sborman # define termStartChar ntc.t_startc 203*38689Sborman # define termStopChar ntc.t_stopc 204*38689Sborman 205*38689Sborman # define termEofCharp &ntc.t_eofc 206*38689Sborman # define termEraseCharp &nttyb.sg_erase 207*38689Sborman # define termFlushCharp &nltc.t_flushc 208*38689Sborman # define termIntCharp &ntc.t_intrc 209*38689Sborman # define termKillCharp &nttyb.sg_kill 210*38689Sborman # define termLiteralNextCharp &nltc.t_lnextc 211*38689Sborman # define termQuitCharp &ntc.t_quitc 212*38689Sborman # define termSuspCharp &nltc.t_suspc 213*38689Sborman # define termRprntCharp &nltc.t_rprntc 214*38689Sborman # define termWerasCharp &nltc.t_werasc 215*38689Sborman # define termStartCharp &ntc.t_startc 216*38689Sborman # define termStopCharp &ntc.t_stopc 217*38689Sborman 218*38689Sborman # else 219*38689Sborman 220*38689Sborman extern struct termio new_tc; 221*38689Sborman 222*38689Sborman # define termEofChar new_tc.c_cc[VEOF] 223*38689Sborman # define termEraseChar new_tc.c_cc[VERASE] 224*38689Sborman # define termIntChar new_tc.c_cc[VINTR] 225*38689Sborman # define termKillChar new_tc.c_cc[VKILL] 226*38689Sborman # define termQuitChar new_tc.c_cc[VQUIT] 227*38689Sborman 22832141Sminshall extern char 229*38689Sborman termSuspChar, 230*38689Sborman termFlushChar, 231*38689Sborman termWerasChar, 232*38689Sborman termRprntChar, 233*38689Sborman termLiteralNextChar, 234*38689Sborman termStartChar, 235*38689Sborman termStopChar; 236*38689Sborman 237*38689Sborman # ifndef CRAY 238*38689Sborman # define termEofCharp &new_tc.c_cc[VEOF] 239*38689Sborman # define termEraseCharp &new_tc.c_cc[VERASE] 240*38689Sborman # define termIntCharp &new_tc.c_cc[VINTR] 241*38689Sborman # define termKillCharp &new_tc.c_cc[VKILL] 242*38689Sborman # define termQuitCharp &new_tc.c_cc[VQUIT] 243*38689Sborman # else 244*38689Sborman /* Work around a compiler bug */ 245*38689Sborman # define termEofCharp 0 246*38689Sborman # define termEraseCharp 0 247*38689Sborman # define termIntCharp 0 248*38689Sborman # define termKillCharp 0 249*38689Sborman # define termQuitCharp 0 250*38689Sborman # endif 251*38689Sborman # define termSuspCharp &termSuspChar 252*38689Sborman # define termFlushCharp &termFlushChar 253*38689Sborman # define termWerasCharp &termWerasChar 254*38689Sborman # define termRprntCharp &termRprntChar 255*38689Sborman # define termLiteralNextCharp &termLiteralNextChar 256*38689Sborman # define termStartCharp &termStartChar 257*38689Sborman # define termStopCharp &termStopChar 258*38689Sborman # endif 259*38689Sborman 260*38689Sborman #else /* MSDOS */ 261*38689Sborman 262*38689Sborman extern char 26332141Sminshall termEofChar, 26432141Sminshall termEraseChar, 26532141Sminshall termIntChar, 26632141Sminshall termKillChar, 267*38689Sborman termQuitChar, 268*38689Sborman termSuspChar, 269*38689Sborman termFlushChar, 270*38689Sborman termWerasChar, 271*38689Sborman termRprntChar, 27232141Sminshall termLiteralNextChar, 273*38689Sborman termStartChar, 274*38689Sborman termStopChar; 27532381Sminshall 276*38689Sborman #endif 277*38689Sborman 278*38689Sborman 27932381Sminshall /* Ring buffer structures which are shared */ 28032381Sminshall 28132381Sminshall extern Ring 28233802Sminshall netoring, 28333802Sminshall netiring, 28433802Sminshall ttyoring, 28533802Sminshall ttyiring; 28633802Sminshall 28733802Sminshall /* Tn3270 section */ 28833802Sminshall #if defined(TN3270) 28933802Sminshall 29033802Sminshall extern int 29133802Sminshall HaveInput, /* Whether an asynchronous I/O indication came in */ 29236241Sminshall noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */ 29336241Sminshall noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */ 29436241Sminshall sigiocount, /* Count of SIGIO receptions */ 29533802Sminshall shell_active; /* Subshell is active */ 29633802Sminshall 29733802Sminshall extern char 29833802Sminshall *Ibackp, /* Oldest byte of 3270 data */ 29933802Sminshall Ibuf[], /* 3270 buffer */ 30033802Sminshall *Ifrontp, /* Where next 3270 byte goes */ 30133802Sminshall tline[], 30233802Sminshall *transcom; /* Transparent command */ 30333802Sminshall 30433802Sminshall extern int 30533802Sminshall settranscom(); 30633802Sminshall 30733802Sminshall extern void 30833802Sminshall inputAvailable(); 30933802Sminshall #endif /* defined(TN3270) */ 310