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