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