externs.h revision 1.8 1 /* $NetBSD: externs.h,v 1.8 1996/02/28 21:03:58 thorpej 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 extern void
234 SetNetTrace P((char *)); /* Function to change where debugging goes */
235
236 extern jmp_buf
237 peerdied,
238 toplevel; /* For error conditions. */
239
240 extern void
241 command P((int, char *, int)),
242 Dump P((int, unsigned char *, int)),
243 init_3270 P((void)),
244 printoption P((char *, int, int)),
245 printsub P((int, unsigned char *, int)),
246 sendnaws P((void)),
247 setconnmode P((int)),
248 setcommandmode P((void)),
249 setneturg P((void)),
250 sys_telnet_init P((void)),
251 telnet P((char *)),
252 tel_enter_binary P((int)),
253 TerminalFlushOutput P((void)),
254 TerminalNewMode P((int)),
255 TerminalRestoreState P((void)),
256 TerminalSaveState P((void)),
257 tninit P((void)),
258 upcase P((char *)),
259 willoption P((int)),
260 wontoption P((int));
261
262 extern void
263 send_do P((int, int)),
264 send_dont P((int, int)),
265 send_will P((int, int)),
266 send_wont P((int, int));
267
268 extern void
269 lm_will P((unsigned char *, int)),
270 lm_wont P((unsigned char *, int)),
271 lm_do P((unsigned char *, int)),
272 lm_dont P((unsigned char *, int)),
273 lm_mode P((unsigned char *, int, int));
274
275 extern void
276 slc_init P((void)),
277 slcstate P((void)),
278 slc_mode_export P((void)),
279 slc_mode_import P((int)),
280 slc_import P((int)),
281 slc_export P((void)),
282 slc P((unsigned char *, int)),
283 slc_check P((void)),
284 slc_start_reply P((void)),
285 slc_add_reply P((int, int, int)),
286 slc_end_reply P((void));
287 extern int
288 slc_update P((void));
289
290 extern void
291 env_opt P((unsigned char *, int)),
292 env_opt_start P((void)),
293 env_opt_start_info P((void)),
294 env_opt_add P((unsigned char *)),
295 env_opt_end P((int));
296
297 extern unsigned char
298 *env_default P((int, int)),
299 *env_getvalue P((unsigned char *));
300
301 extern int
302 get_status P((void)),
303 dosynch P((void));
304
305 extern cc_t
306 *tcval P((int));
307
308 #ifndef USE_TERMIO
309
310 extern struct tchars ntc;
311 extern struct ltchars nltc;
312 extern struct sgttyb nttyb;
313
314 # define termEofChar ntc.t_eofc
315 # define termEraseChar nttyb.sg_erase
316 # define termFlushChar nltc.t_flushc
317 # define termIntChar ntc.t_intrc
318 # define termKillChar nttyb.sg_kill
319 # define termLiteralNextChar nltc.t_lnextc
320 # define termQuitChar ntc.t_quitc
321 # define termSuspChar nltc.t_suspc
322 # define termRprntChar nltc.t_rprntc
323 # define termWerasChar nltc.t_werasc
324 # define termStartChar ntc.t_startc
325 # define termStopChar ntc.t_stopc
326 # define termForw1Char ntc.t_brkc
327 extern cc_t termForw2Char;
328 extern cc_t termAytChar;
329
330 # define termEofCharp (cc_t *)&ntc.t_eofc
331 # define termEraseCharp (cc_t *)&nttyb.sg_erase
332 # define termFlushCharp (cc_t *)&nltc.t_flushc
333 # define termIntCharp (cc_t *)&ntc.t_intrc
334 # define termKillCharp (cc_t *)&nttyb.sg_kill
335 # define termLiteralNextCharp (cc_t *)&nltc.t_lnextc
336 # define termQuitCharp (cc_t *)&ntc.t_quitc
337 # define termSuspCharp (cc_t *)&nltc.t_suspc
338 # define termRprntCharp (cc_t *)&nltc.t_rprntc
339 # define termWerasCharp (cc_t *)&nltc.t_werasc
340 # define termStartCharp (cc_t *)&ntc.t_startc
341 # define termStopCharp (cc_t *)&ntc.t_stopc
342 # define termForw1Charp (cc_t *)&ntc.t_brkc
343 # define termForw2Charp (cc_t *)&termForw2Char
344 # define termAytCharp (cc_t *)&termAytChar
345
346 # else
347
348 extern struct termio new_tc;
349
350 # define termEofChar new_tc.c_cc[VEOF]
351 # define termEraseChar new_tc.c_cc[VERASE]
352 # define termIntChar new_tc.c_cc[VINTR]
353 # define termKillChar new_tc.c_cc[VKILL]
354 # define termQuitChar new_tc.c_cc[VQUIT]
355
356 # ifndef VSUSP
357 extern cc_t termSuspChar;
358 # else
359 # define termSuspChar new_tc.c_cc[VSUSP]
360 # endif
361 # if defined(VFLUSHO) && !defined(VDISCARD)
362 # define VDISCARD VFLUSHO
363 # endif
364 # ifndef VDISCARD
365 extern cc_t termFlushChar;
366 # else
367 # define termFlushChar new_tc.c_cc[VDISCARD]
368 # endif
369 # ifndef VWERASE
370 extern cc_t termWerasChar;
371 # else
372 # define termWerasChar new_tc.c_cc[VWERASE]
373 # endif
374 # ifndef VREPRINT
375 extern cc_t termRprntChar;
376 # else
377 # define termRprntChar new_tc.c_cc[VREPRINT]
378 # endif
379 # ifndef VLNEXT
380 extern cc_t termLiteralNextChar;
381 # else
382 # define termLiteralNextChar new_tc.c_cc[VLNEXT]
383 # endif
384 # ifndef VSTART
385 extern cc_t termStartChar;
386 # else
387 # define termStartChar new_tc.c_cc[VSTART]
388 # endif
389 # ifndef VSTOP
390 extern cc_t termStopChar;
391 # else
392 # define termStopChar new_tc.c_cc[VSTOP]
393 # endif
394 # ifndef VEOL
395 extern cc_t termForw1Char;
396 # else
397 # define termForw1Char new_tc.c_cc[VEOL]
398 # endif
399 # ifndef VEOL2
400 extern cc_t termForw2Char;
401 # else
402 # define termForw2Char new_tc.c_cc[VEOL]
403 # endif
404 # ifndef VSTATUS
405 extern cc_t termAytChar;
406 #else
407 # define termAytChar new_tc.c_cc[VSTATUS]
408 #endif
409
410 # if !defined(CRAY) || defined(__STDC__)
411 # define termEofCharp &termEofChar
412 # define termEraseCharp &termEraseChar
413 # define termIntCharp &termIntChar
414 # define termKillCharp &termKillChar
415 # define termQuitCharp &termQuitChar
416 # define termSuspCharp &termSuspChar
417 # define termFlushCharp &termFlushChar
418 # define termWerasCharp &termWerasChar
419 # define termRprntCharp &termRprntChar
420 # define termLiteralNextCharp &termLiteralNextChar
421 # define termStartCharp &termStartChar
422 # define termStopCharp &termStopChar
423 # define termForw1Charp &termForw1Char
424 # define termForw2Charp &termForw2Char
425 # define termAytCharp &termAytChar
426 # else
427 /* Work around a compiler bug */
428 # define termEofCharp 0
429 # define termEraseCharp 0
430 # define termIntCharp 0
431 # define termKillCharp 0
432 # define termQuitCharp 0
433 # define termSuspCharp 0
434 # define termFlushCharp 0
435 # define termWerasCharp 0
436 # define termRprntCharp 0
437 # define termLiteralNextCharp 0
438 # define termStartCharp 0
439 # define termStopCharp 0
440 # define termForw1Charp 0
441 # define termForw2Charp 0
442 # define termAytCharp 0
443 # endif
444 #endif
445
446
447 /* Ring buffer structures which are shared */
448
449 extern Ring
450 netoring,
451 netiring,
452 ttyoring,
453 ttyiring;
454
455 /* Tn3270 section */
456 #if defined(TN3270)
457
458 extern int
459 HaveInput, /* Whether an asynchronous I/O indication came in */
460 noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */
461 noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */
462 sigiocount, /* Count of SIGIO receptions */
463 shell_active; /* Subshell is active */
464
465 extern char
466 *Ibackp, /* Oldest byte of 3270 data */
467 Ibuf[], /* 3270 buffer */
468 *Ifrontp, /* Where next 3270 byte goes */
469 tline[],
470 *transcom; /* Transparent command */
471
472 extern int
473 settranscom P((int, char**));
474
475 extern void
476 inputAvailable P((int));
477 #endif /* defined(TN3270) */
478