Annotation of src/usr.bin/telnet/externs.h, Revision 1.2
1.2 ! niklas 1: /* $OpenBSD$ */
! 2: /* $NetBSD: externs.h,v 1.8 1996/02/28 21:03:58 thorpej Exp $ */
! 3:
1.1 deraadt 4: /*
5: * Copyright (c) 1988, 1990, 1993
6: * The Regents of the University of California. All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
16: * 3. All advertising materials mentioning features or use of this software
17: * must display the following acknowledgement:
18: * This product includes software developed by the University of
19: * California, Berkeley and its contributors.
20: * 4. Neither the name of the University nor the names of its contributors
21: * may be used to endorse or promote products derived from this software
22: * without specific prior written permission.
23: *
24: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34: * SUCH DAMAGE.
35: *
1.2 ! niklas 36: * from: @(#)externs.h 8.3 (Berkeley) 5/30/95
1.1 deraadt 37: */
38:
39: #ifndef BSD
40: # define BSD 43
41: #endif
42:
43: /*
44: * ucb stdio.h defines BSD as something wierd
45: */
46: #if defined(sun) && defined(__svr4__)
47: #define BSD 43
48: #endif
49:
50: #ifndef USE_TERMIO
51: # if BSD > 43 || defined(SYSV_TERMIO)
52: # define USE_TERMIO
53: # endif
54: #endif
55:
56: #include <stdio.h>
57: #include <stdlib.h>
58: #include <setjmp.h>
59: #if defined(CRAY) && !defined(NO_BSD_SETJMP)
60: #include <bsdsetjmp.h>
61: #endif
62: #ifndef FILIO_H
63: #include <sys/ioctl.h>
64: #else
65: #include <sys/filio.h>
66: #endif
67: #ifdef CRAY
68: # include <errno.h>
69: #endif /* CRAY */
70: #ifdef USE_TERMIO
71: # ifndef VINTR
72: # ifdef SYSV_TERMIO
73: # include <sys/termio.h>
74: # else
75: # include <sys/termios.h>
76: # define termio termios
77: # endif
78: # endif
79: #endif
80: #if defined(NO_CC_T) || !defined(USE_TERMIO)
81: # if !defined(USE_TERMIO)
82: typedef char cc_t;
83: # else
84: typedef unsigned char cc_t;
85: # endif
86: #endif
87:
88: #ifndef NO_STRING_H
89: #include <string.h>
1.2 ! niklas 90: #else
! 91: #include <strings.h>
1.1 deraadt 92: #endif
93:
94: #ifndef _POSIX_VDISABLE
95: # ifdef sun
96: # include <sys/param.h> /* pick up VDISABLE definition, mayby */
97: # endif
98: # ifdef VDISABLE
99: # define _POSIX_VDISABLE VDISABLE
100: # else
101: # define _POSIX_VDISABLE ((cc_t)'\377')
102: # endif
103: #endif
104:
105: #define SUBBUFSIZE 256
106:
107: #ifndef CRAY
108: extern int errno; /* outside this world */
109: #endif /* !CRAY */
110:
1.2 ! niklas 111: #include <sys/cdefs.h>
! 112: #define P __P
1.1 deraadt 113:
114: extern int
115: autologin, /* Autologin enabled */
116: skiprc, /* Don't process the ~/.telnetrc file */
117: eight, /* use eight bit mode (binary in and/or out */
118: flushout, /* flush output */
119: connected, /* Are we connected to the other side? */
120: globalmode, /* Mode tty should be in */
1.2 ! niklas 121: In3270, /* Are we in 3270 mode? */
1.1 deraadt 122: telnetport, /* Are we connected to the telnet port? */
123: localflow, /* Flow control handled locally */
124: restartany, /* If flow control, restart output on any character */
125: localchars, /* we recognize interrupt/quit */
1.2 ! niklas 126: donelclchars, /* the user has set "localchars" */
1.1 deraadt 127: showoptions,
128: net, /* Network file descriptor */
129: tin, /* Terminal input file descriptor */
130: tout, /* Terminal output file descriptor */
131: crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
132: autoflush, /* flush output when interrupting? */
133: autosynch, /* send interrupt characters with SYNCH? */
134: SYNCHing, /* Is the stream in telnet SYNCH mode? */
135: donebinarytoggle, /* the user has put us in binary */
136: dontlecho, /* do we suppress local echoing right now? */
137: crmod,
138: netdata, /* Print out network data flow */
139: prettydump, /* Print "netdata" output in user readable format */
140: #if defined(unix)
141: #if defined(TN3270)
142: cursesdata, /* Print out curses data flow */
143: apitrace, /* Trace API transactions */
144: #endif /* defined(TN3270) */
145: termdata, /* Print out terminal data flow */
146: #endif /* defined(unix) */
1.2 ! niklas 147: debug, /* Debug level */
1.1 deraadt 148: clienteof; /* Client received EOF */
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) */