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