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