1 /* 2 * Copyright (c) 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)externs.h 1.22 (Berkeley) 06/01/90 8 */ 9 10 #ifndef BSD 11 # define BSD 43 12 #endif 13 14 #if (BSD > 43 || defined(SYSV_TERMIO)) && !defined(USE_TERMIO) 15 # define USE_TERMIO 16 #endif 17 18 #include <stdio.h> 19 #include <setjmp.h> 20 #include <sys/ioctl.h> 21 #ifdef USE_TERMIO 22 # ifndef VINTR 23 # ifdef SYSV_TERMIO 24 # include <sys/termio.h> 25 # else 26 # include <sys/termios.h> 27 # define termio termios 28 # endif 29 # endif 30 #else 31 typedef char cc_t; 32 #endif 33 34 #define SUBBUFSIZE 256 35 36 extern int errno; /* outside this world */ 37 38 extern char 39 *strcat(), 40 *strcpy(); /* outside this world */ 41 42 extern int 43 flushout, /* flush output */ 44 connected, /* Are we connected to the other side? */ 45 globalmode, /* Mode tty should be in */ 46 In3270, /* Are we in 3270 mode? */ 47 telnetport, /* Are we connected to the telnet port? */ 48 localflow, /* Flow control handled locally */ 49 localchars, /* we recognize interrupt/quit */ 50 donelclchars, /* the user has set "localchars" */ 51 showoptions, 52 net, /* Network file descriptor */ 53 tin, /* Terminal input file descriptor */ 54 tout, /* Terminal output file descriptor */ 55 crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */ 56 autoflush, /* flush output when interrupting? */ 57 autosynch, /* send interrupt characters with SYNCH? */ 58 SYNCHing, /* Is the stream in telnet SYNCH mode? */ 59 donebinarytoggle, /* the user has put us in binary */ 60 dontlecho, /* do we suppress local echoing right now? */ 61 crmod, 62 netdata, /* Print out network data flow */ 63 prettydump, /* Print "netdata" output in user readable format */ 64 #if defined(unix) 65 #if defined(TN3270) 66 cursesdata, /* Print out curses data flow */ 67 apitrace, /* Trace API transactions */ 68 #endif /* defined(TN3270) */ 69 termdata, /* Print out terminal data flow */ 70 #endif /* defined(unix) */ 71 debug; /* Debug level */ 72 73 extern cc_t 74 echoc, /* Toggle local echoing */ 75 escape; /* Escape to command mode */ 76 77 extern unsigned char 78 *prompt; /* Prompt for command. */ 79 80 extern char 81 doopt[], 82 dont[], 83 will[], 84 wont[], 85 options[], /* All the little options */ 86 *hostname; /* Who are we connected to? */ 87 88 /* 89 * We keep track of each side of the option negotiation. 90 */ 91 92 #define MY_STATE_WILL 0x01 93 #define MY_WANT_STATE_WILL 0x02 94 #define MY_STATE_DO 0x04 95 #define MY_WANT_STATE_DO 0x08 96 97 /* 98 * Macros to check the current state of things 99 */ 100 101 #define my_state_is_do(opt) (options[opt]&MY_STATE_DO) 102 #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL) 103 #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO) 104 #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL) 105 106 #define my_state_is_dont(opt) (!my_state_is_do(opt)) 107 #define my_state_is_wont(opt) (!my_state_is_will(opt)) 108 #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt)) 109 #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt)) 110 111 #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;} 112 #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;} 113 #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;} 114 #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;} 115 116 #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;} 117 #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;} 118 #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;} 119 #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;} 120 121 /* 122 * Make everything symetrical 123 */ 124 125 #define HIS_STATE_WILL MY_STATE_DO 126 #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO 127 #define HIS_STATE_DO MY_STATE_WILL 128 #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL 129 130 #define his_state_is_do my_state_is_will 131 #define his_state_is_will my_state_is_do 132 #define his_want_state_is_do my_want_state_is_will 133 #define his_want_state_is_will my_want_state_is_do 134 135 #define his_state_is_dont my_state_is_wont 136 #define his_state_is_wont my_state_is_dont 137 #define his_want_state_is_dont my_want_state_is_wont 138 #define his_want_state_is_wont my_want_state_is_dont 139 140 #define set_his_state_do set_my_state_will 141 #define set_his_state_will set_my_state_do 142 #define set_his_want_state_do set_my_want_state_will 143 #define set_his_want_state_will set_my_want_state_do 144 145 #define set_his_state_dont set_my_state_wont 146 #define set_his_state_wont set_my_state_dont 147 #define set_his_want_state_dont set_my_want_state_wont 148 #define set_his_want_state_wont set_my_want_state_dont 149 150 151 extern FILE 152 *NetTrace; /* Where debugging output goes */ 153 extern unsigned char 154 NetTraceFile[]; /* Name of file where debugging output goes */ 155 extern void 156 SetNetTrace(); /* Function to change where debugging goes */ 157 158 extern jmp_buf 159 peerdied, 160 toplevel; /* For error conditions. */ 161 162 extern void 163 command(), 164 #if !defined(NOT43) 165 dosynch(), 166 #endif /* !defined(NOT43) */ 167 get_status(), 168 Dump(), 169 init_3270(), 170 printoption(), 171 printsub(), 172 sendnaws(), 173 setconnmode(), 174 setcommandmode(), 175 setneturg(), 176 sys_telnet_init(), 177 telnet(), 178 TerminalFlushOutput(), 179 TerminalNewMode(), 180 TerminalRestoreState(), 181 TerminalSaveState(), 182 tninit(), 183 upcase(), 184 willoption(), 185 wontoption(); 186 187 #if defined(NOT43) 188 extern int 189 dosynch(); 190 #endif /* defined(NOT43) */ 191 192 #ifndef USE_TERMIO 193 194 extern struct tchars ntc; 195 extern struct ltchars nltc; 196 extern struct sgttyb nttyb; 197 198 # define termEofChar ntc.t_eofc 199 # define termEraseChar nttyb.sg_erase 200 # define termFlushChar nltc.t_flushc 201 # define termIntChar ntc.t_intrc 202 # define termKillChar nttyb.sg_kill 203 # define termLiteralNextChar nltc.t_lnextc 204 # define termQuitChar ntc.t_quitc 205 # define termSuspChar nltc.t_suspc 206 # define termRprntChar nltc.t_rprntc 207 # define termWerasChar nltc.t_werasc 208 # define termStartChar ntc.t_startc 209 # define termStopChar ntc.t_stopc 210 # define termForw1Char ntc.t_brkc 211 extern char termForw2Char; 212 213 # define termEofCharp (cc_t *)&ntc.t_eofc 214 # define termEraseCharp (cc_t *)&nttyb.sg_erase 215 # define termFlushCharp (cc_t *)&nltc.t_flushc 216 # define termIntCharp (cc_t *)&ntc.t_intrc 217 # define termKillCharp (cc_t *)&nttyb.sg_kill 218 # define termLiteralNextCharp (cc_t *)&nltc.t_lnextc 219 # define termQuitCharp (cc_t *)&ntc.t_quitc 220 # define termSuspCharp (cc_t *)&nltc.t_suspc 221 # define termRprntCharp (cc_t *)&nltc.t_rprntc 222 # define termWerasCharp (cc_t *)&nltc.t_werasc 223 # define termStartCharp (cc_t *)&ntc.t_startc 224 # define termStopCharp (cc_t *)&ntc.t_stopc 225 # define termForw1Charp (cc_t *)&ntc.t_brkc 226 # define termForw2Charp (cc_t *)&termForw2Char 227 228 # else 229 230 extern struct termio new_tc; 231 232 # define termEofChar new_tc.c_cc[VEOF] 233 # define termEraseChar new_tc.c_cc[VERASE] 234 # define termIntChar new_tc.c_cc[VINTR] 235 # define termKillChar new_tc.c_cc[VKILL] 236 # define termQuitChar new_tc.c_cc[VQUIT] 237 238 # ifndef VSUSP 239 extern char termSuspChar; 240 # else 241 # define termSuspChar new_tc.c_cc[VSUSP] 242 # endif 243 # ifndef VFLUSHO 244 extern char termFlushChar; 245 # else 246 # define termFlushChar new_tc.c_cc[VFLUSHO] 247 # endif 248 # ifndef VWERASE 249 extern char termWerasChar; 250 # else 251 # define termWerasChar new_tc.c_cc[VWERASE] 252 # endif 253 # ifndef VREPRINT 254 extern char termRprntChar; 255 # else 256 # define termRprntChar new_tc.c_cc[VREPRINT] 257 # endif 258 # ifndef VLNEXT 259 extern char termLiteralNextChar; 260 # else 261 # define termLiteralNextChar new_tc.c_cc[VLNEXT] 262 # endif 263 # ifndef VSTART 264 extern char termStartChar; 265 # else 266 # define termStartChar new_tc.c_cc[VSTART] 267 # endif 268 # ifndef VSTOP 269 extern char termStopChar; 270 # else 271 # define termStopChar new_tc.c_cc[VSTOP] 272 # endif 273 # ifndef VEOL 274 extern char termForw1Char; 275 # else 276 # define termForw1Char new_tc.c_cc[VEOL] 277 # endif 278 # ifndef VEOL2 279 extern char termForw2Char; 280 # else 281 # define termForw2Char new_tc.c_cc[VEOL] 282 # endif 283 284 # ifndef CRAY 285 # define termEofCharp &termEofChar 286 # define termEraseCharp &termEraseChar 287 # define termIntCharp &termIntChar 288 # define termKillCharp &termKillChar 289 # define termQuitCharp &termQuitChar 290 # define termSuspCharp &termSuspChar 291 # define termFlushCharp &termFlushChar 292 # define termWerasCharp &termWerasChar 293 # define termRprntCharp &termRprntChar 294 # define termLiteralNextCharp &termLiteralNextChar 295 # define termStartCharp &termStartChar 296 # define termStopCharp &termStopChar 297 # define termForw1Charp &termForw1Char 298 # define termForw2Charp &termForw2Char 299 # else 300 /* Work around a compiler bug */ 301 # define termEofCharp 0 302 # define termEraseCharp 0 303 # define termIntCharp 0 304 # define termKillCharp 0 305 # define termQuitCharp 0 306 # define termSuspCharp 0 307 # define termFlushCharp 0 308 # define termWerasCharp 0 309 # define termRprntCharp 0 310 # define termLiteralNextCharp 0 311 # define termStartCharp 0 312 # define termStopCharp 0 313 # define termForw1Charp 0 314 # define termForw2Charp 0 315 # endif 316 #endif 317 318 319 /* Ring buffer structures which are shared */ 320 321 extern Ring 322 netoring, 323 netiring, 324 ttyoring, 325 ttyiring; 326 327 /* Tn3270 section */ 328 #if defined(TN3270) 329 330 extern int 331 HaveInput, /* Whether an asynchronous I/O indication came in */ 332 noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */ 333 noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */ 334 sigiocount, /* Count of SIGIO receptions */ 335 shell_active; /* Subshell is active */ 336 337 extern char 338 *Ibackp, /* Oldest byte of 3270 data */ 339 Ibuf[], /* 3270 buffer */ 340 *Ifrontp, /* Where next 3270 byte goes */ 341 tline[], 342 *transcom; /* Transparent command */ 343 344 extern int 345 settranscom(); 346 347 extern void 348 inputAvailable(); 349 #endif /* defined(TN3270) */ 350