2 * Copyright (c) 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
33 * @(#)externs.h 8.2 (Berkeley) 12/15/93
41 * ucb stdio.h defines BSD as something wierd
43 #if defined(sun) && defined(__svr4__)
48 # if BSD > 43 || defined(SYSV_TERMIO)
55 #if defined(CRAY) && !defined(NO_BSD_SETJMP)
56 #include <bsdsetjmp.h>
59 #include <sys/ioctl.h>
61 #include <sys/filio.h>
69 # include <sys/termio.h>
71 # include <sys/termios.h>
72 # define termio termios
78 #define termio termios
80 #if defined(NO_CC_T) || !defined(USE_TERMIO)
81 # if !defined(USE_TERMIO)
84 typedef unsigned char cc_t;
94 #define MIN(a,b) (((a)<(b))? (a):(b))
97 #ifndef _POSIX_VDISABLE
99 # include <sys/param.h> /* pick up VDISABLE definition, mayby */
102 # define _POSIX_VDISABLE VDISABLE
104 # define _POSIX_VDISABLE ((cc_t)'\377')
108 #define SUBBUFSIZE 256
111 extern int errno; /* outside this world */
123 autologin, /* Autologin enabled */
124 skiprc, /* Don't process the ~/.telnetrc file */
125 eight, /* use eight bit mode (binary in and/or out */
126 flushout, /* flush output */
127 connected, /* Are we connected to the other side? */
128 globalmode, /* Mode tty should be in */
129 In3270, /* Are we in 3270 mode? */
130 telnetport, /* Are we connected to the telnet port? */
131 localflow, /* Flow control handled locally */
132 restartany, /* If flow control, restart output on any character */
133 localchars, /* we recognize interrupt/quit */
134 donelclchars, /* the user has set "localchars" */
136 net, /* Network file descriptor */
137 tin, /* Terminal input file descriptor */
138 tout, /* Terminal output file descriptor */
139 crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
140 autoflush, /* flush output when interrupting? */
141 autosynch, /* send interrupt characters with SYNCH? */
142 SYNCHing, /* Is the stream in telnet SYNCH mode? */
143 donebinarytoggle, /* the user has put us in binary */
144 dontlecho, /* do we suppress local echoing right now? */
146 netdata, /* Print out network data flow */
147 prettydump, /* Print "netdata" output in user readable format */
150 cursesdata, /* Print out curses data flow */
151 apitrace, /* Trace API transactions */
152 #endif /* defined(TN3270) */
153 termdata, /* Print out terminal data flow */
154 #endif /* defined(unix) */
155 debug, /* Debug level */
156 doaddrlookup, /* do a reverse lookup? */
157 clienteof; /* Client received EOF */
159 extern cc_t escape; /* Escape to command mode */
160 extern cc_t rlogin; /* Rlogin mode escape character */
161 #ifdef KLUDGELINEMODE
162 extern cc_t echoc; /* Toggle local echoing */
166 *prompt; /* Prompt for command. */
173 options[], /* All the little options */
174 *hostname; /* Who are we connected to? */
177 * We keep track of each side of the option negotiation.
180 #define MY_STATE_WILL 0x01
181 #define MY_WANT_STATE_WILL 0x02
182 #define MY_STATE_DO 0x04
183 #define MY_WANT_STATE_DO 0x08
186 * Macros to check the current state of things
189 #define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
190 #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
191 #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
192 #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
194 #define my_state_is_dont(opt) (!my_state_is_do(opt))
195 #define my_state_is_wont(opt) (!my_state_is_will(opt))
196 #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
197 #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
199 #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;}
200 #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;}
201 #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;}
202 #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;}
204 #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;}
205 #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;}
206 #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;}
207 #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;}
210 * Make everything symetrical
213 #define HIS_STATE_WILL MY_STATE_DO
214 #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
215 #define HIS_STATE_DO MY_STATE_WILL
216 #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
218 #define his_state_is_do my_state_is_will
219 #define his_state_is_will my_state_is_do
220 #define his_want_state_is_do my_want_state_is_will
221 #define his_want_state_is_will my_want_state_is_do
223 #define his_state_is_dont my_state_is_wont
224 #define his_state_is_wont my_state_is_dont
225 #define his_want_state_is_dont my_want_state_is_wont
226 #define his_want_state_is_wont my_want_state_is_dont
228 #define set_his_state_do set_my_state_will
229 #define set_his_state_will set_my_state_do
230 #define set_his_want_state_do set_my_want_state_will
231 #define set_his_want_state_will set_my_want_state_do
233 #define set_his_state_dont set_my_state_wont
234 #define set_his_state_wont set_my_state_dont
235 #define set_his_want_state_dont set_my_want_state_wont
236 #define set_his_want_state_wont set_my_want_state_dont
240 *NetTrace; /* Where debugging output goes */
242 NetTraceFile[]; /* Name of file where debugging output goes */
244 SetNetTrace P((char *)); /* Function to change where debugging goes */
248 toplevel; /* For error conditions. */
251 command P((int, char *, int)),
252 Dump P((int, unsigned char *, int)),
254 printoption P((char *, int, int)),
255 printsub P((int, unsigned char *, int)),
257 setconnmode P((int)),
258 setcommandmode P((void)),
260 sys_telnet_init P((void)),
262 tel_enter_binary P((int)),
263 TerminalFlushOutput P((void)),
264 TerminalNewMode P((int)),
265 TerminalRestoreState P((void)),
266 TerminalSaveState P((void)),
273 send_do P((int, int)),
274 send_dont P((int, int)),
275 send_will P((int, int)),
276 send_wont P((int, int));
279 lm_will P((unsigned char *, int)),
280 lm_wont P((unsigned char *, int)),
281 lm_do P((unsigned char *, int)),
282 lm_dont P((unsigned char *, int)),
283 lm_mode P((unsigned char *, int, int));
288 slc_mode_export P((void)),
289 slc_mode_import P((int)),
291 slc_export P((void)),
292 slc P((unsigned char *, int)),
294 slc_start_reply P((void)),
295 slc_add_reply P((int, int, int)),
296 slc_end_reply P((void));
298 slc_update P((void));
301 env_opt P((unsigned char *, int)),
302 env_opt_start P((void)),
303 env_opt_start_info P((void)),
304 env_opt_add P((unsigned char *)),
305 env_opt_end P((int));
308 *env_default P((int, int)),
309 *env_getvalue P((unsigned char *));
312 get_status P((void)),
320 extern struct tchars ntc;
321 extern struct ltchars nltc;
322 extern struct sgttyb nttyb;
324 # define termEofChar ntc.t_eofc
325 # define termEraseChar nttyb.sg_erase
326 # define termFlushChar nltc.t_flushc
327 # define termIntChar ntc.t_intrc
328 # define termKillChar nttyb.sg_kill
329 # define termLiteralNextChar nltc.t_lnextc
330 # define termQuitChar ntc.t_quitc
331 # define termSuspChar nltc.t_suspc
332 # define termRprntChar nltc.t_rprntc
333 # define termWerasChar nltc.t_werasc
334 # define termStartChar ntc.t_startc
335 # define termStopChar ntc.t_stopc
336 # define termForw1Char ntc.t_brkc
337 extern cc_t termForw2Char;
338 extern cc_t termAytChar;
340 # define termEofCharp (cc_t *)&ntc.t_eofc
341 # define termEraseCharp (cc_t *)&nttyb.sg_erase
342 # define termFlushCharp (cc_t *)&nltc.t_flushc
343 # define termIntCharp (cc_t *)&ntc.t_intrc
344 # define termKillCharp (cc_t *)&nttyb.sg_kill
345 # define termLiteralNextCharp (cc_t *)&nltc.t_lnextc
346 # define termQuitCharp (cc_t *)&ntc.t_quitc
347 # define termSuspCharp (cc_t *)&nltc.t_suspc
348 # define termRprntCharp (cc_t *)&nltc.t_rprntc
349 # define termWerasCharp (cc_t *)&nltc.t_werasc
350 # define termStartCharp (cc_t *)&ntc.t_startc
351 # define termStopCharp (cc_t *)&ntc.t_stopc
352 # define termForw1Charp (cc_t *)&ntc.t_brkc
353 # define termForw2Charp (cc_t *)&termForw2Char
354 # define termAytCharp (cc_t *)&termAytChar
358 extern struct termio new_tc;
360 # define termEofChar new_tc.c_cc[VEOF]
361 # define termEraseChar new_tc.c_cc[VERASE]
362 # define termIntChar new_tc.c_cc[VINTR]
363 # define termKillChar new_tc.c_cc[VKILL]
364 # define termQuitChar new_tc.c_cc[VQUIT]
367 extern cc_t termSuspChar;
369 # define termSuspChar new_tc.c_cc[VSUSP]
371 # if defined(VFLUSHO) && !defined(VDISCARD)
372 # define VDISCARD VFLUSHO
375 extern cc_t termFlushChar;
377 # define termFlushChar new_tc.c_cc[VDISCARD]
380 extern cc_t termWerasChar;
382 # define termWerasChar new_tc.c_cc[VWERASE]
385 extern cc_t termRprntChar;
387 # define termRprntChar new_tc.c_cc[VREPRINT]
390 extern cc_t termLiteralNextChar;
392 # define termLiteralNextChar new_tc.c_cc[VLNEXT]
395 extern cc_t termStartChar;
397 # define termStartChar new_tc.c_cc[VSTART]
400 extern cc_t termStopChar;
402 # define termStopChar new_tc.c_cc[VSTOP]
405 extern cc_t termForw1Char;
407 # define termForw1Char new_tc.c_cc[VEOL]
410 extern cc_t termForw2Char;
412 # define termForw2Char new_tc.c_cc[VEOL]
415 extern cc_t termAytChar;
417 # define termAytChar new_tc.c_cc[VSTATUS]
420 # if !defined(CRAY) || defined(__STDC__)
421 # define termEofCharp &termEofChar
422 # define termEraseCharp &termEraseChar
423 # define termIntCharp &termIntChar
424 # define termKillCharp &termKillChar
425 # define termQuitCharp &termQuitChar
426 # define termSuspCharp &termSuspChar
427 # define termFlushCharp &termFlushChar
428 # define termWerasCharp &termWerasChar
429 # define termRprntCharp &termRprntChar
430 # define termLiteralNextCharp &termLiteralNextChar
431 # define termStartCharp &termStartChar
432 # define termStopCharp &termStopChar
433 # define termForw1Charp &termForw1Char
434 # define termForw2Charp &termForw2Char
435 # define termAytCharp &termAytChar
437 /* Work around a compiler bug */
438 # define termEofCharp 0
439 # define termEraseCharp 0
440 # define termIntCharp 0
441 # define termKillCharp 0
442 # define termQuitCharp 0
443 # define termSuspCharp 0
444 # define termFlushCharp 0
445 # define termWerasCharp 0
446 # define termRprntCharp 0
447 # define termLiteralNextCharp 0
448 # define termStartCharp 0
449 # define termStopCharp 0
450 # define termForw1Charp 0
451 # define termForw2Charp 0
452 # define termAytCharp 0
457 /* Ring buffer structures which are shared */
469 HaveInput, /* Whether an asynchronous I/O indication came in */
470 noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */
471 noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */
472 sigiocount, /* Count of SIGIO receptions */
473 shell_active; /* Subshell is active */
476 *Ibackp, /* Oldest byte of 3270 data */
477 Ibuf[], /* 3270 buffer */
478 *Ifrontp, /* Where next 3270 byte goes */
480 *transcom; /* Transparent command */
483 settranscom P((int, char**));
486 inputAvailable P((int));
487 #endif /* defined(TN3270) */