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