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