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*38920Sminshall * @(#)externs.h 1.19 (Berkeley) 09/02/89 1833685Sbostic */ 1933685Sbostic 2038689Sborman #ifdef CRAY 2138689Sborman #define USE_TERMIO 2238689Sborman #endif 2338689Sborman 2432141Sminshall #include <stdio.h> 2532141Sminshall #include <setjmp.h> 2638689Sborman #include <sys/ioctl.h> 2738689Sborman #ifdef USE_TERMIO 2838689Sborman #ifndef VINTR 2938689Sborman #include <sys/termio.h> 3038689Sborman #endif 3138689Sborman #endif 3232141Sminshall 3338689Sborman #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 */ 6238689Sborman prettydump, /* Print "netdata" output in user readable format */ 6338208Sminshall #if defined(unix) 6438208Sminshall #if defined(TN3270) 6538208Sminshall cursesdata, /* Print out curses data flow */ 66*38920Sminshall apitrace, /* Trace API transactions */ 6738208Sminshall #endif /* defined(TN3270) */ 6838208Sminshall termdata, /* Print out terminal data flow */ 6938208Sminshall #endif /* defined(unix) */ 7033802Sminshall debug; /* Debug level */ 7132141Sminshall 7232141Sminshall extern char 7333802Sminshall echoc, /* Toggle local echoing */ 7433802Sminshall escape, /* Escape to command mode */ 7533802Sminshall doopt[], 7633802Sminshall dont[], 7733802Sminshall will[], 7833802Sminshall wont[], 7937226Sminshall options[], /* All the little options */ 8033802Sminshall *hostname, /* Who are we connected to? */ 8133802Sminshall *prompt; /* Prompt for command. */ 8232141Sminshall 8337226Sminshall /* 8437226Sminshall * We keep track of each side of the option negotiation. 8537226Sminshall */ 8637226Sminshall 8738689Sborman #define MY_STATE_WILL 0x01 8838689Sborman #define MY_WANT_STATE_WILL 0x02 8938689Sborman #define MY_STATE_DO 0x04 9038689Sborman #define MY_WANT_STATE_DO 0x08 9137226Sminshall 9237226Sminshall /* 9338689Sborman * Macros to check the current state of things 9437226Sminshall */ 9537226Sminshall 9638689Sborman #define my_state_is_do(opt) (options[opt]&MY_STATE_DO) 9738689Sborman #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL) 9838689Sborman #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO) 9938689Sborman #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL) 10037226Sminshall 10138689Sborman #define my_state_is_dont(opt) (!my_state_is_do(opt)) 10238689Sborman #define my_state_is_wont(opt) (!my_state_is_will(opt)) 10338689Sborman #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt)) 10438689Sborman #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt)) 10537226Sminshall 10638689Sborman #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;} 10738689Sborman #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;} 10838689Sborman #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;} 10938689Sborman #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;} 11038689Sborman 11138689Sborman #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;} 11238689Sborman #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;} 11338689Sborman #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;} 11438689Sborman #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;} 11538689Sborman 11638689Sborman /* 11738689Sborman * Make everything symetrical 11838689Sborman */ 11938689Sborman 12038689Sborman #define HIS_STATE_WILL MY_STATE_DO 12138689Sborman #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO 12238689Sborman #define HIS_STATE_DO MY_STATE_WILL 12338689Sborman #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL 12438689Sborman 12538689Sborman #define his_state_is_do my_state_is_will 12638689Sborman #define his_state_is_will my_state_is_do 12738689Sborman #define his_want_state_is_do my_want_state_is_will 12838689Sborman #define his_want_state_is_will my_want_state_is_do 12938689Sborman 13038689Sborman #define his_state_is_dont my_state_is_wont 13138689Sborman #define his_state_is_wont my_state_is_dont 13238689Sborman #define his_want_state_is_dont my_want_state_is_wont 13338689Sborman #define his_want_state_is_wont my_want_state_is_dont 13438689Sborman 13538689Sborman #define set_his_state_do set_my_state_will 13638689Sborman #define set_his_state_will set_my_state_do 13738689Sborman #define set_his_want_state_do set_my_want_state_will 13838689Sborman #define set_his_want_state_will set_my_want_state_do 13938689Sborman 14038689Sborman #define set_his_state_dont set_my_state_wont 14138689Sborman #define set_his_state_wont set_my_state_dont 14238689Sborman #define set_his_want_state_dont set_my_want_state_wont 14338689Sborman #define set_his_want_state_wont set_my_want_state_dont 14438689Sborman 14538689Sborman 14632141Sminshall extern FILE 14733802Sminshall *NetTrace; /* Where debugging output goes */ 14838689Sborman extern char 14938689Sborman NetTraceFile[]; /* Name of file where debugging output goes */ 15038689Sborman extern void 15138689Sborman SetNetTrace(); /* Function to change where debugging goes */ 15232141Sminshall 15332141Sminshall extern jmp_buf 15433802Sminshall peerdied, 15533802Sminshall toplevel; /* For error conditions. */ 15632141Sminshall 15732141Sminshall extern void 15834848Sminshall command(), 15934313Sminshall #if !defined(NOT43) 16033802Sminshall dosynch(), 16134313Sminshall #endif /* !defined(NOT43) */ 16238908Sborman get_status(), 16334848Sminshall Dump(), 16434848Sminshall init_3270(), 16534848Sminshall printoption(), 16634848Sminshall printsub(), 16737219Sminshall sendnaws(), 16833802Sminshall setconnmode(), 16934848Sminshall setcommandmode(), 17034848Sminshall setneturg(), 17134848Sminshall sys_telnet_init(), 17234848Sminshall telnet(), 17334848Sminshall TerminalFlushOutput(), 17434848Sminshall TerminalNewMode(), 17534848Sminshall TerminalRestoreState(), 17634848Sminshall TerminalSaveState(), 17734848Sminshall tninit(), 17834848Sminshall upcase(), 17934848Sminshall willoption(), 18034848Sminshall wontoption(); 18132141Sminshall 18234313Sminshall #if defined(NOT43) 18334313Sminshall extern int 18434313Sminshall dosynch(); 18534313Sminshall #endif /* defined(NOT43) */ 18634313Sminshall 18738689Sborman #if !defined(MSDOS) 18838689Sborman # ifndef USE_TERMIO 18938689Sborman 19038689Sborman extern struct tchars ntc; 19138689Sborman extern struct ltchars nltc; 19238689Sborman extern struct sgttyb nttyb; 19338689Sborman 19438689Sborman # define termEofChar ntc.t_eofc 19538689Sborman # define termEraseChar nttyb.sg_erase 19638689Sborman # define termFlushChar nltc.t_flushc 19738689Sborman # define termIntChar ntc.t_intrc 19838689Sborman # define termKillChar nttyb.sg_kill 19938689Sborman # define termLiteralNextChar nltc.t_lnextc 20038689Sborman # define termQuitChar ntc.t_quitc 20138689Sborman # define termSuspChar nltc.t_suspc 20238689Sborman # define termRprntChar nltc.t_rprntc 20338689Sborman # define termWerasChar nltc.t_werasc 20438689Sborman # define termStartChar ntc.t_startc 20538689Sborman # define termStopChar ntc.t_stopc 20638689Sborman 20738689Sborman # define termEofCharp &ntc.t_eofc 20838689Sborman # define termEraseCharp &nttyb.sg_erase 20938689Sborman # define termFlushCharp &nltc.t_flushc 21038689Sborman # define termIntCharp &ntc.t_intrc 21138689Sborman # define termKillCharp &nttyb.sg_kill 21238689Sborman # define termLiteralNextCharp &nltc.t_lnextc 21338689Sborman # define termQuitCharp &ntc.t_quitc 21438689Sborman # define termSuspCharp &nltc.t_suspc 21538689Sborman # define termRprntCharp &nltc.t_rprntc 21638689Sborman # define termWerasCharp &nltc.t_werasc 21738689Sborman # define termStartCharp &ntc.t_startc 21838689Sborman # define termStopCharp &ntc.t_stopc 21938689Sborman 22038689Sborman # else 22138689Sborman 22238689Sborman extern struct termio new_tc; 22338689Sborman 22438689Sborman # define termEofChar new_tc.c_cc[VEOF] 22538689Sborman # define termEraseChar new_tc.c_cc[VERASE] 22638689Sborman # define termIntChar new_tc.c_cc[VINTR] 22738689Sborman # define termKillChar new_tc.c_cc[VKILL] 22838689Sborman # define termQuitChar new_tc.c_cc[VQUIT] 22938689Sborman 23032141Sminshall extern char 23138689Sborman termSuspChar, 23238689Sborman termFlushChar, 23338689Sborman termWerasChar, 23438689Sborman termRprntChar, 23538689Sborman termLiteralNextChar, 23638689Sborman termStartChar, 23738689Sborman termStopChar; 23838689Sborman 23938689Sborman # ifndef CRAY 24038689Sborman # define termEofCharp &new_tc.c_cc[VEOF] 24138689Sborman # define termEraseCharp &new_tc.c_cc[VERASE] 24238689Sborman # define termIntCharp &new_tc.c_cc[VINTR] 24338689Sborman # define termKillCharp &new_tc.c_cc[VKILL] 24438689Sborman # define termQuitCharp &new_tc.c_cc[VQUIT] 24538689Sborman # else 24638689Sborman /* Work around a compiler bug */ 24738689Sborman # define termEofCharp 0 24838689Sborman # define termEraseCharp 0 24938689Sborman # define termIntCharp 0 25038689Sborman # define termKillCharp 0 25138689Sborman # define termQuitCharp 0 25238689Sborman # endif 25338689Sborman # define termSuspCharp &termSuspChar 25438689Sborman # define termFlushCharp &termFlushChar 25538689Sborman # define termWerasCharp &termWerasChar 25638689Sborman # define termRprntCharp &termRprntChar 25738689Sborman # define termLiteralNextCharp &termLiteralNextChar 25838689Sborman # define termStartCharp &termStartChar 25938689Sborman # define termStopCharp &termStopChar 26038689Sborman # endif 26138689Sborman 26238689Sborman #else /* MSDOS */ 26338689Sborman 26438689Sborman extern char 26532141Sminshall termEofChar, 26632141Sminshall termEraseChar, 26732141Sminshall termIntChar, 26832141Sminshall termKillChar, 26938689Sborman termQuitChar, 27038689Sborman termSuspChar, 27138689Sborman termFlushChar, 27238689Sborman termWerasChar, 27338689Sborman termRprntChar, 27432141Sminshall termLiteralNextChar, 27538689Sborman termStartChar, 27638689Sborman termStopChar; 27732381Sminshall 27838689Sborman #endif 27938689Sborman 28038689Sborman 28132381Sminshall /* Ring buffer structures which are shared */ 28232381Sminshall 28332381Sminshall extern Ring 28433802Sminshall netoring, 28533802Sminshall netiring, 28633802Sminshall ttyoring, 28733802Sminshall ttyiring; 28833802Sminshall 28933802Sminshall /* Tn3270 section */ 29033802Sminshall #if defined(TN3270) 29133802Sminshall 29233802Sminshall extern int 29333802Sminshall HaveInput, /* Whether an asynchronous I/O indication came in */ 29436241Sminshall noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */ 29536241Sminshall noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */ 29636241Sminshall sigiocount, /* Count of SIGIO receptions */ 29733802Sminshall shell_active; /* Subshell is active */ 29833802Sminshall 29933802Sminshall extern char 30033802Sminshall *Ibackp, /* Oldest byte of 3270 data */ 30133802Sminshall Ibuf[], /* 3270 buffer */ 30233802Sminshall *Ifrontp, /* Where next 3270 byte goes */ 30333802Sminshall tline[], 30433802Sminshall *transcom; /* Transparent command */ 30533802Sminshall 30633802Sminshall extern int 30733802Sminshall settranscom(); 30833802Sminshall 30933802Sminshall extern void 31033802Sminshall inputAvailable(); 31133802Sminshall #endif /* defined(TN3270) */ 312