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