externs.h revision 1.9 1 /* $NetBSD: externs.h,v 1.9 1998/02/27 10:44:13 christos Exp $ */
2
3 /*
4 * Copyright (c) 1988, 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * from: @(#)externs.h 8.3 (Berkeley) 5/30/95
36 */
37
38 #ifndef BSD
39 # define BSD 43
40 #endif
41
42 /*
43 * ucb stdio.h defines BSD as something wierd
44 */
45 #if defined(sun) && defined(__svr4__)
46 #define BSD 43
47 #endif
48
49 #ifndef USE_TERMIO
50 # if BSD > 43 || defined(SYSV_TERMIO)
51 # define USE_TERMIO
52 # endif
53 #endif
54
55 #include <stdio.h>
56 #include <stdlib.h>
57 #include <setjmp.h>
58 #if defined(CRAY) && !defined(NO_BSD_SETJMP)
59 #include <bsdsetjmp.h>
60 #endif
61 #ifndef FILIO_H
62 #include <sys/ioctl.h>
63 #else
64 #include <sys/filio.h>
65 #endif
66 #ifdef CRAY
67 # include <errno.h>
68 #endif /* CRAY */
69 #ifdef USE_TERMIO
70 # ifndef VINTR
71 # ifdef SYSV_TERMIO
72 # include <sys/termio.h>
73 # else
74 # include <sys/termios.h>
75 # define termio termios
76 # endif
77 # endif
78 #endif
79 #if defined(NO_CC_T) || !defined(USE_TERMIO)
80 # if !defined(USE_TERMIO)
81 typedef char cc_t;
82 # else
83 typedef unsigned char cc_t;
84 # endif
85 #endif
86
87 #ifndef NO_STRING_H
88 #include <string.h>
89 #else
90 #include <strings.h>
91 #endif
92
93 #ifndef _POSIX_VDISABLE
94 # ifdef sun
95 # include <sys/param.h> /* pick up VDISABLE definition, mayby */
96 # endif
97 # ifdef VDISABLE
98 # define _POSIX_VDISABLE VDISABLE
99 # else
100 # define _POSIX_VDISABLE ((cc_t)'\377')
101 # endif
102 #endif
103
104 #define SUBBUFSIZE 256
105
106 #ifndef CRAY
107 extern int errno; /* outside this world */
108 #endif /* !CRAY */
109
110 #include <sys/cdefs.h>
111 #define P __P
112
113 extern int
114 autologin, /* Autologin enabled */
115 skiprc, /* Don't process the ~/.telnetrc file */
116 eight, /* use eight bit mode (binary in and/or out */
117 flushout, /* flush output */
118 connected, /* Are we connected to the other side? */
119 globalmode, /* Mode tty should be in */
120 In3270, /* Are we in 3270 mode? */
121 telnetport, /* Are we connected to the telnet port? */
122 localflow, /* Flow control handled locally */
123 restartany, /* If flow control, restart output on any character */
124 localchars, /* we recognize interrupt/quit */
125 donelclchars, /* the user has set "localchars" */
126 showoptions,
127 net, /* Network file descriptor */
128 tin, /* Terminal input file descriptor */
129 tout, /* Terminal output file descriptor */
130 crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
131 autoflush, /* flush output when interrupting? */
132 autosynch, /* send interrupt characters with SYNCH? */
133 SYNCHing, /* Is the stream in telnet SYNCH mode? */
134 donebinarytoggle, /* the user has put us in binary */
135 dontlecho, /* do we suppress local echoing right now? */
136 crmod,
137 netdata, /* Print out network data flow */
138 prettydump, /* Print "netdata" output in user readable format */
139 #if defined(unix)
140 #if defined(TN3270)
141 cursesdata, /* Print out curses data flow */
142 apitrace, /* Trace API transactions */
143 #endif /* defined(TN3270) */
144 termdata, /* Print out terminal data flow */
145 #endif /* defined(unix) */
146 debug, /* Debug level */
147 clienteof; /* Client received EOF */
148
149 extern cc_t escape; /* Escape to command mode */
150 extern cc_t rlogin; /* Rlogin mode escape character */
151 #ifdef KLUDGELINEMODE
152 extern cc_t echoc; /* Toggle local echoing */
153 #endif
154
155 extern char
156 *prompt; /* Prompt for command. */
157
158 extern char
159 doopt[],
160 dont[],
161 will[],
162 wont[],
163 options[], /* All the little options */
164 *hostname; /* Who are we connected to? */
165
166 /*
167 * We keep track of each side of the option negotiation.
168 */
169
170 #define MY_STATE_WILL 0x01
171 #define MY_WANT_STATE_WILL 0x02
172 #define MY_STATE_DO 0x04
173 #define MY_WANT_STATE_DO 0x08
174
175 /*
176 * Macros to check the current state of things
177 */
178
179 #define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
180 #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
181 #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
182 #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
183
184 #define my_state_is_dont(opt) (!my_state_is_do(opt))
185 #define my_state_is_wont(opt) (!my_state_is_will(opt))
186 #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
187 #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
188
189 #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;}
190 #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;}
191 #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;}
192 #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;}
193
194 #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;}
195 #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;}
196 #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;}
197 #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;}
198
199 /*
200 * Make everything symetrical
201 */
202
203 #define HIS_STATE_WILL MY_STATE_DO
204 #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
205 #define HIS_STATE_DO MY_STATE_WILL
206 #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
207
208 #define his_state_is_do my_state_is_will
209 #define his_state_is_will my_state_is_do
210 #define his_want_state_is_do my_want_state_is_will
211 #define his_want_state_is_will my_want_state_is_do
212
213 #define his_state_is_dont my_state_is_wont
214 #define his_state_is_wont my_state_is_dont
215 #define his_want_state_is_dont my_want_state_is_wont
216 #define his_want_state_is_wont my_want_state_is_dont
217
218 #define set_his_state_do set_my_state_will
219 #define set_his_state_will set_my_state_do
220 #define set_his_want_state_do set_my_want_state_will
221 #define set_his_want_state_will set_my_want_state_do
222
223 #define set_his_state_dont set_my_state_wont
224 #define set_his_state_wont set_my_state_dont
225 #define set_his_want_state_dont set_my_want_state_wont
226 #define set_his_want_state_wont set_my_want_state_dont
227
228
229 extern FILE
230 *NetTrace; /* Where debugging output goes */
231 extern unsigned char
232 NetTraceFile[]; /* Name of file where debugging output goes */
233
234 extern jmp_buf
235 peerdied,
236 toplevel; /* For error conditions. */
237
238
239 /* authenc.c */
240 int net_write P((unsigned char *, int));
241 void net_encrypt P((void));
242 int telnet_spin P((void));
243 char *telnet_getenv P((char *));
244 char *telnet_gets P((char *, char *, int, int));
245
246 /* commands.c */
247 int send_tncmd P((void (*)(int, int), char *, char *));
248 void _setlist_init P((void));
249 void set_escape_char P((char *));
250 int set_mode P((int));
251 int clear_mode P((int));
252 int modehelp P((int));
253 int suspend P((int, char *[]));
254 int shell P((int, char *[]));
255 int quit P((int, char *[]));
256 int logout P((int, char *[]));
257 int env_cmd P((int, char *[]));
258 struct env_lst *env_find P((unsigned char *));
259 void env_init P((void));
260 struct env_lst *env_define P((unsigned char *, unsigned char *));
261 struct env_lst *env_undefine P((unsigned char *, unsigned char *));
262 struct env_lst *env_export P((unsigned char *, unsigned char *));
263 struct env_lst *env_unexport P((unsigned char *, unsigned char *));
264 struct env_lst *env_send P((unsigned char *, unsigned char *));
265 struct env_lst *env_list P((unsigned char *, unsigned char *));
266 unsigned char *env_default P((int, int ));
267 unsigned char *env_getvalue P((unsigned char *));
268 void env_varval P((unsigned char *));
269 int auth_cmd P((int, char *[]));
270 int ayt_status P((void));
271 int tn P((int, char *[]));
272 void command P((int, char *, int));
273 void cmdrc P((char *, char *));
274 unsigned long sourceroute P((char *, char **, unsigned long *));
275
276 /* main.c */
277 void tninit P((void));
278 void usage P((void));
279
280 /* network.c */
281 void init_network P((void));
282 int stilloob P((void));
283 void setneturg P((void));
284 int netflush P((void));
285
286 /* sys_bsd.c */
287 void init_sys P((void));
288 int TerminalWrite P((char *, int));
289 int TerminalRead P((unsigned char *, int));
290 int TerminalAutoFlush P((void));
291 int TerminalSpecialChars P((int));
292 void TerminalFlushOutput P((void));
293 void TerminalSaveState P((void));
294 cc_t *tcval P((int));
295 void TerminalDefaultChars P((void));
296 void TerminalRestoreState P((void));
297 void TerminalNewMode P((int));
298 void TerminalSpeeds P((long *, long *));
299 int TerminalWindowSize P((long *, long *));
300 int NetClose P((int));
301 void NetNonblockingIO P((int, int));
302 void NetSigIO P((int, int));
303 void NetSetPgrp P((int));
304 void sys_telnet_init P((void));
305 int process_rings P((int , int , int , int , int , int));
306
307 /* telnet.c */
308 void init_telnet P((void));
309 void send_do P((int, int ));
310 void send_dont P((int, int ));
311 void send_will P((int, int ));
312 void send_wont P((int, int ));
313 void willoption P((int));
314 void wontoption P((int));
315 char **mklist P((char *, char *));
316 int is_unique P((char *, char **, char **));
317 int setupterm P((char *, int, int *));
318 char *gettermname P((void));
319 void lm_will P((unsigned char *, int));
320 void lm_wont P((unsigned char *, int));
321 void lm_do P((unsigned char *, int));
322 void lm_dont P((unsigned char *, int));
323 void lm_mode P((unsigned char *, int, int ));
324 void slc_init P((void));
325 void slcstate P((void));
326 void slc_mode_export P((int));
327 void slc_mode_import P((int));
328 void slc_import P((int));
329 void slc_export P((void));
330 void slc P((unsigned char *, int));
331 void slc_check P((void));
332 void slc_start_reply P((void));
333 void slc_add_reply P((unsigned int, unsigned int, cc_t));
334 void slc_end_reply P((void));
335 int slc_update P((void));
336 void env_opt P((unsigned char *, int));
337 void env_opt_start P((void));
338 void env_opt_start_info P((void));
339 void env_opt_add P((unsigned char *));
340 int opt_welldefined P((char *));
341 void env_opt_end P((int));
342 int telrcv P((void));
343 int rlogin_susp P((void));
344 int Scheduler P((int));
345 void telnet P((char *));
346 void xmitAO P((void));
347 void xmitEL P((void));
348 void xmitEC P((void));
349 int dosynch P((char *));
350 int get_status P((char *));
351 void intp P((void));
352 void sendbrk P((void));
353 void sendabort P((void));
354 void sendsusp P((void));
355 void sendeof P((void));
356 void sendayt P((void));
357 void sendnaws P((void));
358 void tel_enter_binary P((int));
359 void tel_leave_binary P((int));
360
361 /* terminal.c */
362 void init_terminal P((void));
363 int ttyflush P((int));
364 int getconnmode P((void));
365 void setconnmode P((int));
366 void setcommandmode P((void));
367
368 /* utilities.c */
369 void upcase P((char *));
370 int SetSockOpt P((int, int , int , int ));
371 void SetNetTrace P((char *));
372 void Dump P((int, unsigned char *, int));
373 void printoption P((char *, int, int ));
374 void optionstatus P((void));
375 void printsub P((int, unsigned char *, int));
376 void EmptyTerminal P((void));
377 void SetForExit P((void));
378 void Exit P((int)) __attribute__((__noreturn__));
379 void ExitString P((char *, int)) __attribute__((__noreturn__));
380
381 #ifndef USE_TERMIO
382
383 extern struct tchars ntc;
384 extern struct ltchars nltc;
385 extern struct sgttyb nttyb;
386
387 # define termEofChar ntc.t_eofc
388 # define termEraseChar nttyb.sg_erase
389 # define termFlushChar nltc.t_flushc
390 # define termIntChar ntc.t_intrc
391 # define termKillChar nttyb.sg_kill
392 # define termLiteralNextChar nltc.t_lnextc
393 # define termQuitChar ntc.t_quitc
394 # define termSuspChar nltc.t_suspc
395 # define termRprntChar nltc.t_rprntc
396 # define termWerasChar nltc.t_werasc
397 # define termStartChar ntc.t_startc
398 # define termStopChar ntc.t_stopc
399 # define termForw1Char ntc.t_brkc
400 extern cc_t termForw2Char;
401 extern cc_t termAytChar;
402
403 # define termEofCharp (cc_t *)&ntc.t_eofc
404 # define termEraseCharp (cc_t *)&nttyb.sg_erase
405 # define termFlushCharp (cc_t *)&nltc.t_flushc
406 # define termIntCharp (cc_t *)&ntc.t_intrc
407 # define termKillCharp (cc_t *)&nttyb.sg_kill
408 # define termLiteralNextCharp (cc_t *)&nltc.t_lnextc
409 # define termQuitCharp (cc_t *)&ntc.t_quitc
410 # define termSuspCharp (cc_t *)&nltc.t_suspc
411 # define termRprntCharp (cc_t *)&nltc.t_rprntc
412 # define termWerasCharp (cc_t *)&nltc.t_werasc
413 # define termStartCharp (cc_t *)&ntc.t_startc
414 # define termStopCharp (cc_t *)&ntc.t_stopc
415 # define termForw1Charp (cc_t *)&ntc.t_brkc
416 # define termForw2Charp (cc_t *)&termForw2Char
417 # define termAytCharp (cc_t *)&termAytChar
418
419 # else
420
421 extern struct termio new_tc;
422
423 # define termEofChar new_tc.c_cc[VEOF]
424 # define termEraseChar new_tc.c_cc[VERASE]
425 # define termIntChar new_tc.c_cc[VINTR]
426 # define termKillChar new_tc.c_cc[VKILL]
427 # define termQuitChar new_tc.c_cc[VQUIT]
428
429 # ifndef VSUSP
430 extern cc_t termSuspChar;
431 # else
432 # define termSuspChar new_tc.c_cc[VSUSP]
433 # endif
434 # if defined(VFLUSHO) && !defined(VDISCARD)
435 # define VDISCARD VFLUSHO
436 # endif
437 # ifndef VDISCARD
438 extern cc_t termFlushChar;
439 # else
440 # define termFlushChar new_tc.c_cc[VDISCARD]
441 # endif
442 # ifndef VWERASE
443 extern cc_t termWerasChar;
444 # else
445 # define termWerasChar new_tc.c_cc[VWERASE]
446 # endif
447 # ifndef VREPRINT
448 extern cc_t termRprntChar;
449 # else
450 # define termRprntChar new_tc.c_cc[VREPRINT]
451 # endif
452 # ifndef VLNEXT
453 extern cc_t termLiteralNextChar;
454 # else
455 # define termLiteralNextChar new_tc.c_cc[VLNEXT]
456 # endif
457 # ifndef VSTART
458 extern cc_t termStartChar;
459 # else
460 # define termStartChar new_tc.c_cc[VSTART]
461 # endif
462 # ifndef VSTOP
463 extern cc_t termStopChar;
464 # else
465 # define termStopChar new_tc.c_cc[VSTOP]
466 # endif
467 # ifndef VEOL
468 extern cc_t termForw1Char;
469 # else
470 # define termForw1Char new_tc.c_cc[VEOL]
471 # endif
472 # ifndef VEOL2
473 extern cc_t termForw2Char;
474 # else
475 # define termForw2Char new_tc.c_cc[VEOL]
476 # endif
477 # ifndef VSTATUS
478 extern cc_t termAytChar;
479 #else
480 # define termAytChar new_tc.c_cc[VSTATUS]
481 #endif
482
483 # if !defined(CRAY) || defined(__STDC__)
484 # define termEofCharp &termEofChar
485 # define termEraseCharp &termEraseChar
486 # define termIntCharp &termIntChar
487 # define termKillCharp &termKillChar
488 # define termQuitCharp &termQuitChar
489 # define termSuspCharp &termSuspChar
490 # define termFlushCharp &termFlushChar
491 # define termWerasCharp &termWerasChar
492 # define termRprntCharp &termRprntChar
493 # define termLiteralNextCharp &termLiteralNextChar
494 # define termStartCharp &termStartChar
495 # define termStopCharp &termStopChar
496 # define termForw1Charp &termForw1Char
497 # define termForw2Charp &termForw2Char
498 # define termAytCharp &termAytChar
499 # else
500 /* Work around a compiler bug */
501 # define termEofCharp 0
502 # define termEraseCharp 0
503 # define termIntCharp 0
504 # define termKillCharp 0
505 # define termQuitCharp 0
506 # define termSuspCharp 0
507 # define termFlushCharp 0
508 # define termWerasCharp 0
509 # define termRprntCharp 0
510 # define termLiteralNextCharp 0
511 # define termStartCharp 0
512 # define termStopCharp 0
513 # define termForw1Charp 0
514 # define termForw2Charp 0
515 # define termAytCharp 0
516 # endif
517 #endif
518
519
520 /* Ring buffer structures which are shared */
521
522 extern Ring
523 netoring,
524 netiring,
525 ttyoring,
526 ttyiring;
527
528 /* Tn3270 section */
529 #if defined(TN3270)
530
531 extern int
532 HaveInput, /* Whether an asynchronous I/O indication came in */
533 noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */
534 noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */
535 sigiocount, /* Count of SIGIO receptions */
536 shell_active; /* Subshell is active */
537
538 extern char
539 *Ibackp, /* Oldest byte of 3270 data */
540 Ibuf[], /* 3270 buffer */
541 *Ifrontp, /* Where next 3270 byte goes */
542 tline[],
543 *transcom; /* Transparent command */
544
545 /* tn3270.c */
546 void init_3270 P((void));
547 int DataToNetwork P((char *, int, int));
548 void inputAvailable P((int));
549 void outputPurge P((void));
550 int DataToTerminal P((char *, int));
551 int Push3270 P((void));
552 void Finish3270 P((void));
553 void StringToTerminal P((char *));
554 void _putchar P((int));
555 void SetIn3270 P((void));
556 int tn3270_ttype P((void));
557 int settranscom P((int, char *[]));
558
559 #endif /* defined(TN3270) */
560