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*39529Sborman * @(#)externs.h 1.20 (Berkeley) 11/14/89 1833685Sbostic */ 1933685Sbostic 20*39529Sborman #ifndef BSD 21*39529Sborman # define BSD 43 2238689Sborman #endif 2338689Sborman 24*39529Sborman #if (BSD > 43 || defined(SYSV_TERMIO)) && !defined(USE_TERMIO) 25*39529Sborman # define USE_TERMIO 26*39529Sborman #endif 27*39529Sborman 2832141Sminshall #include <stdio.h> 2932141Sminshall #include <setjmp.h> 3038689Sborman #include <sys/ioctl.h> 3138689Sborman #ifdef USE_TERMIO 32*39529Sborman # ifndef VINTR 33*39529Sborman # ifdef SYSV_TERMIO 34*39529Sborman # include <sys/termio.h> 35*39529Sborman # else 36*39529Sborman # include <sys/termios.h> 37*39529Sborman # define termio termios 38*39529Sborman # endif 39*39529Sborman # endif 4038689Sborman #endif 4132141Sminshall 4238689Sborman #define SUBBUFSIZE 256 4332141Sminshall 4432141Sminshall extern int errno; /* outside this world */ 4532141Sminshall 4633802Sminshall extern char 4733802Sminshall *strcat(), 4833802Sminshall *strcpy(); /* outside this world */ 4933802Sminshall 5032141Sminshall extern int 5133802Sminshall flushout, /* flush output */ 5233802Sminshall connected, /* Are we connected to the other side? */ 5333802Sminshall globalmode, /* Mode tty should be in */ 5433802Sminshall In3270, /* Are we in 3270 mode? */ 5533802Sminshall telnetport, /* Are we connected to the telnet port? */ 5637219Sminshall localflow, /* Flow control handled locally */ 5733802Sminshall localchars, /* we recognize interrupt/quit */ 5833802Sminshall donelclchars, /* the user has set "localchars" */ 5933802Sminshall showoptions, 6036274Sminshall net, /* Network file descriptor */ 6136274Sminshall tin, /* Terminal input file descriptor */ 6233802Sminshall tout, /* Terminal output file descriptor */ 6333802Sminshall crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */ 6433802Sminshall autoflush, /* flush output when interrupting? */ 6533802Sminshall autosynch, /* send interrupt characters with SYNCH? */ 6633802Sminshall SYNCHing, /* Is the stream in telnet SYNCH mode? */ 6733802Sminshall donebinarytoggle, /* the user has put us in binary */ 6833802Sminshall dontlecho, /* do we suppress local echoing right now? */ 6933802Sminshall crmod, 7033802Sminshall netdata, /* Print out network data flow */ 7138689Sborman prettydump, /* Print "netdata" output in user readable format */ 7238208Sminshall #if defined(unix) 7338208Sminshall #if defined(TN3270) 7438208Sminshall cursesdata, /* Print out curses data flow */ 7538920Sminshall apitrace, /* Trace API transactions */ 7638208Sminshall #endif /* defined(TN3270) */ 7738208Sminshall termdata, /* Print out terminal data flow */ 7838208Sminshall #endif /* defined(unix) */ 7933802Sminshall debug; /* Debug level */ 8032141Sminshall 81*39529Sborman extern unsigned char 82*39529Sborman echoc, /* Toggle local echoing */ 83*39529Sborman escape, /* Escape to command mode */ 84*39529Sborman *prompt; /* Prompt for command. */ 85*39529Sborman 8632141Sminshall extern char 8733802Sminshall doopt[], 8833802Sminshall dont[], 8933802Sminshall will[], 9033802Sminshall wont[], 9137226Sminshall options[], /* All the little options */ 92*39529Sborman *hostname; /* Who are we connected to? */ 9332141Sminshall 9437226Sminshall /* 9537226Sminshall * We keep track of each side of the option negotiation. 9637226Sminshall */ 9737226Sminshall 9838689Sborman #define MY_STATE_WILL 0x01 9938689Sborman #define MY_WANT_STATE_WILL 0x02 10038689Sborman #define MY_STATE_DO 0x04 10138689Sborman #define MY_WANT_STATE_DO 0x08 10237226Sminshall 10337226Sminshall /* 10438689Sborman * Macros to check the current state of things 10537226Sminshall */ 10637226Sminshall 10738689Sborman #define my_state_is_do(opt) (options[opt]&MY_STATE_DO) 10838689Sborman #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL) 10938689Sborman #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO) 11038689Sborman #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL) 11137226Sminshall 11238689Sborman #define my_state_is_dont(opt) (!my_state_is_do(opt)) 11338689Sborman #define my_state_is_wont(opt) (!my_state_is_will(opt)) 11438689Sborman #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt)) 11538689Sborman #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt)) 11637226Sminshall 11738689Sborman #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;} 11838689Sborman #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;} 11938689Sborman #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;} 12038689Sborman #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;} 12138689Sborman 12238689Sborman #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;} 12338689Sborman #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;} 12438689Sborman #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;} 12538689Sborman #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;} 12638689Sborman 12738689Sborman /* 12838689Sborman * Make everything symetrical 12938689Sborman */ 13038689Sborman 13138689Sborman #define HIS_STATE_WILL MY_STATE_DO 13238689Sborman #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO 13338689Sborman #define HIS_STATE_DO MY_STATE_WILL 13438689Sborman #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL 13538689Sborman 13638689Sborman #define his_state_is_do my_state_is_will 13738689Sborman #define his_state_is_will my_state_is_do 13838689Sborman #define his_want_state_is_do my_want_state_is_will 13938689Sborman #define his_want_state_is_will my_want_state_is_do 14038689Sborman 14138689Sborman #define his_state_is_dont my_state_is_wont 14238689Sborman #define his_state_is_wont my_state_is_dont 14338689Sborman #define his_want_state_is_dont my_want_state_is_wont 14438689Sborman #define his_want_state_is_wont my_want_state_is_dont 14538689Sborman 14638689Sborman #define set_his_state_do set_my_state_will 14738689Sborman #define set_his_state_will set_my_state_do 14838689Sborman #define set_his_want_state_do set_my_want_state_will 14938689Sborman #define set_his_want_state_will set_my_want_state_do 15038689Sborman 15138689Sborman #define set_his_state_dont set_my_state_wont 15238689Sborman #define set_his_state_wont set_my_state_dont 15338689Sborman #define set_his_want_state_dont set_my_want_state_wont 15438689Sborman #define set_his_want_state_wont set_my_want_state_dont 15538689Sborman 15638689Sborman 15732141Sminshall extern FILE 15833802Sminshall *NetTrace; /* Where debugging output goes */ 159*39529Sborman extern unsigned char 16038689Sborman NetTraceFile[]; /* Name of file where debugging output goes */ 16138689Sborman extern void 16238689Sborman SetNetTrace(); /* Function to change where debugging goes */ 16332141Sminshall 16432141Sminshall extern jmp_buf 16533802Sminshall peerdied, 16633802Sminshall toplevel; /* For error conditions. */ 16732141Sminshall 16832141Sminshall extern void 16934848Sminshall command(), 17034313Sminshall #if !defined(NOT43) 17133802Sminshall dosynch(), 17234313Sminshall #endif /* !defined(NOT43) */ 17338908Sborman get_status(), 17434848Sminshall Dump(), 17534848Sminshall init_3270(), 17634848Sminshall printoption(), 17734848Sminshall printsub(), 17837219Sminshall sendnaws(), 17933802Sminshall setconnmode(), 18034848Sminshall setcommandmode(), 18134848Sminshall setneturg(), 18234848Sminshall sys_telnet_init(), 18334848Sminshall telnet(), 18434848Sminshall TerminalFlushOutput(), 18534848Sminshall TerminalNewMode(), 18634848Sminshall TerminalRestoreState(), 18734848Sminshall TerminalSaveState(), 18834848Sminshall tninit(), 18934848Sminshall upcase(), 19034848Sminshall willoption(), 19134848Sminshall wontoption(); 19232141Sminshall 19334313Sminshall #if defined(NOT43) 19434313Sminshall extern int 19534313Sminshall dosynch(); 19634313Sminshall #endif /* defined(NOT43) */ 19734313Sminshall 198*39529Sborman #ifndef USE_TERMIO 19938689Sborman 20038689Sborman extern struct tchars ntc; 20138689Sborman extern struct ltchars nltc; 20238689Sborman extern struct sgttyb nttyb; 20338689Sborman 204*39529Sborman # define termEofChar ntc.t_eofc 205*39529Sborman # define termEraseChar nttyb.sg_erase 206*39529Sborman # define termFlushChar nltc.t_flushc 207*39529Sborman # define termIntChar ntc.t_intrc 208*39529Sborman # define termKillChar nttyb.sg_kill 209*39529Sborman # define termLiteralNextChar nltc.t_lnextc 210*39529Sborman # define termQuitChar ntc.t_quitc 211*39529Sborman # define termSuspChar nltc.t_suspc 212*39529Sborman # define termRprntChar nltc.t_rprntc 213*39529Sborman # define termWerasChar nltc.t_werasc 214*39529Sborman # define termStartChar ntc.t_startc 215*39529Sborman # define termStopChar ntc.t_stopc 21638689Sborman 217*39529Sborman # define termEofCharp (unsigned char *)&ntc.t_eofc 218*39529Sborman # define termEraseCharp (unsigned char *)&nttyb.sg_erase 219*39529Sborman # define termFlushCharp (unsigned char *)&nltc.t_flushc 220*39529Sborman # define termIntCharp (unsigned char *)&ntc.t_intrc 221*39529Sborman # define termKillCharp (unsigned char *)&nttyb.sg_kill 222*39529Sborman # define termLiteralNextCharp (unsigned char *)&nltc.t_lnextc 223*39529Sborman # define termQuitCharp (unsigned char *)&ntc.t_quitc 224*39529Sborman # define termSuspCharp (unsigned char *)&nltc.t_suspc 225*39529Sborman # define termRprntCharp (unsigned char *)&nltc.t_rprntc 226*39529Sborman # define termWerasCharp (unsigned char *)&nltc.t_werasc 227*39529Sborman # define termStartCharp (unsigned char *)&ntc.t_startc 228*39529Sborman # define termStopCharp (unsigned char *)&ntc.t_stopc 22938689Sborman 23038689Sborman # else 23138689Sborman 23238689Sborman extern struct termio new_tc; 23338689Sborman 234*39529Sborman # define termEofChar new_tc.c_cc[VEOF] 235*39529Sborman # define termEraseChar new_tc.c_cc[VERASE] 236*39529Sborman # define termIntChar new_tc.c_cc[VINTR] 237*39529Sborman # define termKillChar new_tc.c_cc[VKILL] 238*39529Sborman # define termQuitChar new_tc.c_cc[VQUIT] 23938689Sborman 240*39529Sborman # ifndef VSUSP 241*39529Sborman extern char termSuspChar; 242*39529Sborman # else 243*39529Sborman # define termSuspChar new_tc.c_cc[VSUSP] 244*39529Sborman # endif 245*39529Sborman # ifndef VFLUSHO 246*39529Sborman extern char termFlushChar; 247*39529Sborman # else 248*39529Sborman # define termFlushChar new_tc.c_cc[VFLUSHO] 249*39529Sborman # endif 250*39529Sborman # ifndef VWERASE 251*39529Sborman extern char termWerasChar; 252*39529Sborman # else 253*39529Sborman # define termWerasChar new_tc.c_cc[VWERASE] 254*39529Sborman # endif 255*39529Sborman # ifndef VREPRINT 256*39529Sborman extern char termRprntChar; 257*39529Sborman # else 258*39529Sborman # define termRprntChar new_tc.c_cc[VREPRINT] 259*39529Sborman # endif 260*39529Sborman # ifndef VLNEXT 261*39529Sborman extern char termLiteralNextChar; 262*39529Sborman # else 263*39529Sborman # define termLiteralNextChar new_tc.c_cc[VLNEXT] 264*39529Sborman # endif 265*39529Sborman # ifndef VSTART 266*39529Sborman extern char termStartChar; 267*39529Sborman # else 268*39529Sborman # define termStartChar new_tc.c_cc[VSTART] 269*39529Sborman # endif 270*39529Sborman # ifndef VSTOP 271*39529Sborman extern char termStopChar; 272*39529Sborman # else 273*39529Sborman # define termStopChar new_tc.c_cc[VSTOP] 274*39529Sborman # endif 27538689Sborman 27638689Sborman # ifndef CRAY 277*39529Sborman # define termEofCharp &termEofChar 278*39529Sborman # define termEraseCharp &termEraseChar 279*39529Sborman # define termIntCharp &termIntChar 280*39529Sborman # define termKillCharp &termKillChar 281*39529Sborman # define termQuitCharp &termQuitChar 282*39529Sborman # define termSuspCharp &termSuspChar 283*39529Sborman # define termFlushCharp &termFlushChar 284*39529Sborman # define termWerasCharp &termWerasChar 285*39529Sborman # define termRprntCharp &termRprntChar 286*39529Sborman # define termLiteralNextCharp &termLiteralNextChar 287*39529Sborman # define termStartCharp &termStartChar 288*39529Sborman # define termStopCharp &termStopChar 28938689Sborman # else 29038689Sborman /* Work around a compiler bug */ 29138689Sborman # define termEofCharp 0 29238689Sborman # define termEraseCharp 0 29338689Sborman # define termIntCharp 0 29438689Sborman # define termKillCharp 0 29538689Sborman # define termQuitCharp 0 296*39529Sborman # define termSuspCharp 0 297*39529Sborman # define termFlushCharp 0 298*39529Sborman # define termWerasCharp 0 299*39529Sborman # define termRprntCharp 0 300*39529Sborman # define termLiteralNextCharp 0 301*39529Sborman # define termStartCharp 0 302*39529Sborman # define termStopCharp 0 30338689Sborman # endif 30438689Sborman #endif 30538689Sborman 30638689Sborman 30732381Sminshall /* Ring buffer structures which are shared */ 30832381Sminshall 30932381Sminshall extern Ring 31033802Sminshall netoring, 31133802Sminshall netiring, 31233802Sminshall ttyoring, 31333802Sminshall ttyiring; 31433802Sminshall 31533802Sminshall /* Tn3270 section */ 31633802Sminshall #if defined(TN3270) 31733802Sminshall 31833802Sminshall extern int 31933802Sminshall HaveInput, /* Whether an asynchronous I/O indication came in */ 32036241Sminshall noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */ 32136241Sminshall noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */ 32236241Sminshall sigiocount, /* Count of SIGIO receptions */ 32333802Sminshall shell_active; /* Subshell is active */ 32433802Sminshall 32533802Sminshall extern char 32633802Sminshall *Ibackp, /* Oldest byte of 3270 data */ 32733802Sminshall Ibuf[], /* 3270 buffer */ 32833802Sminshall *Ifrontp, /* Where next 3270 byte goes */ 32933802Sminshall tline[], 33033802Sminshall *transcom; /* Transparent command */ 33133802Sminshall 33233802Sminshall extern int 33333802Sminshall settranscom(); 33433802Sminshall 33533802Sminshall extern void 33633802Sminshall inputAvailable(); 33733802Sminshall #endif /* defined(TN3270) */ 338