Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
[dragonfly.git] / crypto / telnet / telnet / externs.h
blob9cdbd2d6598efc7f649344ae81b66720a09f726b
1 /*
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
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.
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.
33 * @(#)externs.h 8.3 (Berkeley) 5/30/95
34 * $FreeBSD: src/crypto/telnet/telnet/externs.h,v 1.4.2.2 2002/04/13 10:59:08 markm Exp $
35 * $DragonFly: src/crypto/telnet/telnet/externs.h,v 1.2 2003/06/17 04:24:37 dillon Exp $
38 #ifndef BSD
39 # define BSD 43
40 #endif
43 * ucb stdio.h defines BSD as something weird
45 #if defined(sun) && defined(__svr4__)
46 #define BSD 43
47 #endif
49 #ifndef USE_TERMIO
50 # if BSD > 43 || defined(SYSV_TERMIO)
51 # define USE_TERMIO
52 # endif
53 #endif
55 #include <stdio.h>
56 #include <setjmp.h>
57 #include <sys/ioctl.h>
58 #include <errno.h>
59 #ifdef USE_TERMIO
60 # ifndef VINTR
61 # include <sys/termios.h>
62 # endif
63 # define termio termios
64 #endif
65 #if defined(NO_CC_T) || !defined(USE_TERMIO)
66 # if !defined(USE_TERMIO)
67 typedef char cc_t;
68 # else
69 typedef unsigned char cc_t;
70 # endif
71 #endif
73 #include <string.h>
75 #if defined(IPSEC)
76 #include <netinet6/ipsec.h>
77 #if defined(IPSEC_POLICY_IPSEC)
78 extern char *ipsec_policy_in;
79 extern char *ipsec_policy_out;
80 #endif
81 #endif
83 #ifndef _POSIX_VDISABLE
84 # ifdef sun
85 # include <sys/param.h> /* pick up VDISABLE definition, mayby */
86 # endif
87 # ifdef VDISABLE
88 # define _POSIX_VDISABLE VDISABLE
89 # else
90 # define _POSIX_VDISABLE ((cc_t)'\377')
91 # endif
92 #endif
94 #define SUBBUFSIZE 256
96 #if !defined(P)
97 # ifdef __STDC__
98 # define P(x) x
99 # else
100 # define P(x) ()
101 # endif
102 #endif
104 extern int
105 autologin, /* Autologin enabled */
106 skiprc, /* Don't process the ~/.telnetrc file */
107 eight, /* use eight bit mode (binary in and/or out */
108 family, /* address family of peer */
109 flushout, /* flush output */
110 connected, /* Are we connected to the other side? */
111 globalmode, /* Mode tty should be in */
112 telnetport, /* Are we connected to the telnet port? */
113 localflow, /* Flow control handled locally */
114 restartany, /* If flow control, restart output on any character */
115 localchars, /* we recognize interrupt/quit */
116 donelclchars, /* the user has set "localchars" */
117 showoptions,
118 net, /* Network file descriptor */
119 tin, /* Terminal input file descriptor */
120 tout, /* Terminal output file descriptor */
121 crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
122 autoflush, /* flush output when interrupting? */
123 autosynch, /* send interrupt characters with SYNCH? */
124 SYNCHing, /* Is the stream in telnet SYNCH mode? */
125 donebinarytoggle, /* the user has put us in binary */
126 dontlecho, /* do we suppress local echoing right now? */
127 crmod,
128 netdata, /* Print out network data flow */
129 prettydump, /* Print "netdata" output in user readable format */
130 termdata, /* Print out terminal data flow */
131 debug, /* Debug level */
132 doaddrlookup, /* do a reverse lookup? */
133 clienteof; /* Client received EOF */
135 extern cc_t escape; /* Escape to command mode */
136 extern cc_t rlogin; /* Rlogin mode escape character */
137 #ifdef KLUDGELINEMODE
138 extern cc_t echoc; /* Toggle local echoing */
139 #endif
141 extern char
142 *prompt; /* Prompt for command. */
144 extern char
145 doopt[],
146 dont[],
147 will[],
148 wont[],
149 options[], /* All the little options */
150 *hostname; /* Who are we connected to? */
151 #ifdef ENCRYPTION
152 extern void (*encrypt_output)(unsigned char *, int);
153 extern int (*decrypt_input)(int);
154 #endif /* ENCRYPTION */
157 * We keep track of each side of the option negotiation.
160 #define MY_STATE_WILL 0x01
161 #define MY_WANT_STATE_WILL 0x02
162 #define MY_STATE_DO 0x04
163 #define MY_WANT_STATE_DO 0x08
166 * Macros to check the current state of things
169 #define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
170 #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
171 #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
172 #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
174 #define my_state_is_dont(opt) (!my_state_is_do(opt))
175 #define my_state_is_wont(opt) (!my_state_is_will(opt))
176 #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
177 #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
179 #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;}
180 #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;}
181 #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;}
182 #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;}
184 #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;}
185 #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;}
186 #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;}
187 #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;}
190 * Make everything symetrical
193 #define HIS_STATE_WILL MY_STATE_DO
194 #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
195 #define HIS_STATE_DO MY_STATE_WILL
196 #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
198 #define his_state_is_do my_state_is_will
199 #define his_state_is_will my_state_is_do
200 #define his_want_state_is_do my_want_state_is_will
201 #define his_want_state_is_will my_want_state_is_do
203 #define his_state_is_dont my_state_is_wont
204 #define his_state_is_wont my_state_is_dont
205 #define his_want_state_is_dont my_want_state_is_wont
206 #define his_want_state_is_wont my_want_state_is_dont
208 #define set_his_state_do set_my_state_will
209 #define set_his_state_will set_my_state_do
210 #define set_his_want_state_do set_my_want_state_will
211 #define set_his_want_state_will set_my_want_state_do
213 #define set_his_state_dont set_my_state_wont
214 #define set_his_state_wont set_my_state_dont
215 #define set_his_want_state_dont set_my_want_state_wont
216 #define set_his_want_state_wont set_my_want_state_dont
218 #if defined(USE_TERMIO)
219 #define SIG_FUNC_RET void
220 #else
221 #define SIG_FUNC_RET int
222 #endif
224 #ifdef SIGINFO
225 extern SIG_FUNC_RET
226 ayt_status(void);
227 #endif
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(char *); /* Function to change where debugging goes */
236 extern jmp_buf
237 peerdied,
238 toplevel; /* For error conditions. */
240 extern void
241 command(int, const char *, int),
242 Dump(char, unsigned char *, int),
243 env_init(void),
244 Exit(int),
245 ExitString(const char *, int),
246 init_network(void),
247 init_sys(void),
248 init_telnet(void),
249 init_terminal(void),
250 intp(void),
251 optionstatus(void),
252 printoption(const char *, int, int),
253 printsub(char, unsigned char *, int),
254 quit(void),
255 sendabort(void),
256 sendbrk(void),
257 sendeof(void),
258 sendsusp(void),
259 sendnaws(void),
260 sendayt(void),
261 setconnmode(int),
262 setcommandmode(void),
263 set_escape_char(char *s),
264 setneturg(void),
265 sys_telnet_init(void),
266 telnet(char *),
267 tel_enter_binary(int),
268 tel_leave_binary(int),
269 TerminalFlushOutput(void),
270 TerminalNewMode(int),
271 TerminalRestoreState(void),
272 TerminalSaveState(void),
273 TerminalDefaultChars(void),
274 TerminalSpeeds(long *, long *),
275 tninit(void),
276 upcase(char *),
277 willoption(int),
278 wontoption(int);
280 extern void
281 send_do(int, int),
282 send_dont(int, int),
283 send_will(int, int),
284 send_wont(int, int);
286 extern void
287 lm_will(unsigned char *, int),
288 lm_wont(unsigned char *, int),
289 lm_do(unsigned char *, int),
290 lm_dont(unsigned char *, int),
291 lm_mode(unsigned char *, int, int);
293 extern void
294 slc_init(void),
295 slcstate(void),
296 slc_mode_export(void),
297 slc_mode_import(int),
298 slc_import(int),
299 slc_export(void),
300 slc(unsigned char *, int),
301 slc_check(void),
302 slc_start_reply(void),
303 slc_add_reply(unsigned char, unsigned char, cc_t),
304 slc_end_reply(void);
305 extern int
306 getconnmode(void),
307 opt_welldefined(const char *),
308 NetClose(int),
309 netflush(void),
310 process_rings(int, int, int, int, int, int),
311 rlogin_susp(void),
312 SetSockOpt(int, int, int, int),
313 slc_update(void),
314 stilloob(void),
315 telrcv(void),
316 TerminalRead(char *, int),
317 TerminalWrite(char *, int),
318 TerminalAutoFlush(void),
319 TerminalWindowSize(long *, long *),
320 TerminalSpecialChars(int),
321 tn(int, char **),
322 ttyflush(int);
324 extern void
325 env_opt(unsigned char *, int),
326 env_opt_start(void),
327 env_opt_start_info(void),
328 env_opt_add(unsigned char *),
329 env_opt_end(int);
331 extern unsigned char
332 *env_default(int, int),
333 *env_getvalue(const unsigned char *);
335 extern int
336 get_status(char *),
337 dosynch(char *);
339 extern cc_t
340 *tcval(int);
342 #ifndef USE_TERMIO
344 extern struct tchars ntc;
345 extern struct ltchars nltc;
346 extern struct sgttyb nttyb;
348 # define termEofChar ntc.t_eofc
349 # define termEraseChar nttyb.sg_erase
350 # define termFlushChar nltc.t_flushc
351 # define termIntChar ntc.t_intrc
352 # define termKillChar nttyb.sg_kill
353 # define termLiteralNextChar nltc.t_lnextc
354 # define termQuitChar ntc.t_quitc
355 # define termSuspChar nltc.t_suspc
356 # define termRprntChar nltc.t_rprntc
357 # define termWerasChar nltc.t_werasc
358 # define termStartChar ntc.t_startc
359 # define termStopChar ntc.t_stopc
360 # define termForw1Char ntc.t_brkc
361 extern cc_t termForw2Char;
362 extern cc_t termAytChar;
364 # define termEofCharp (cc_t *)&ntc.t_eofc
365 # define termEraseCharp (cc_t *)&nttyb.sg_erase
366 # define termFlushCharp (cc_t *)&nltc.t_flushc
367 # define termIntCharp (cc_t *)&ntc.t_intrc
368 # define termKillCharp (cc_t *)&nttyb.sg_kill
369 # define termLiteralNextCharp (cc_t *)&nltc.t_lnextc
370 # define termQuitCharp (cc_t *)&ntc.t_quitc
371 # define termSuspCharp (cc_t *)&nltc.t_suspc
372 # define termRprntCharp (cc_t *)&nltc.t_rprntc
373 # define termWerasCharp (cc_t *)&nltc.t_werasc
374 # define termStartCharp (cc_t *)&ntc.t_startc
375 # define termStopCharp (cc_t *)&ntc.t_stopc
376 # define termForw1Charp (cc_t *)&ntc.t_brkc
377 # define termForw2Charp (cc_t *)&termForw2Char
378 # define termAytCharp (cc_t *)&termAytChar
380 # else
382 extern struct termio new_tc;
384 # define termEofChar new_tc.c_cc[VEOF]
385 # define termEraseChar new_tc.c_cc[VERASE]
386 # define termIntChar new_tc.c_cc[VINTR]
387 # define termKillChar new_tc.c_cc[VKILL]
388 # define termQuitChar new_tc.c_cc[VQUIT]
390 # ifndef VSUSP
391 extern cc_t termSuspChar;
392 # else
393 # define termSuspChar new_tc.c_cc[VSUSP]
394 # endif
395 # if defined(VFLUSHO) && !defined(VDISCARD)
396 # define VDISCARD VFLUSHO
397 # endif
398 # ifndef VDISCARD
399 extern cc_t termFlushChar;
400 # else
401 # define termFlushChar new_tc.c_cc[VDISCARD]
402 # endif
403 # ifndef VWERASE
404 extern cc_t termWerasChar;
405 # else
406 # define termWerasChar new_tc.c_cc[VWERASE]
407 # endif
408 # ifndef VREPRINT
409 extern cc_t termRprntChar;
410 # else
411 # define termRprntChar new_tc.c_cc[VREPRINT]
412 # endif
413 # ifndef VLNEXT
414 extern cc_t termLiteralNextChar;
415 # else
416 # define termLiteralNextChar new_tc.c_cc[VLNEXT]
417 # endif
418 # ifndef VSTART
419 extern cc_t termStartChar;
420 # else
421 # define termStartChar new_tc.c_cc[VSTART]
422 # endif
423 # ifndef VSTOP
424 extern cc_t termStopChar;
425 # else
426 # define termStopChar new_tc.c_cc[VSTOP]
427 # endif
428 # ifndef VEOL
429 extern cc_t termForw1Char;
430 # else
431 # define termForw1Char new_tc.c_cc[VEOL]
432 # endif
433 # ifndef VEOL2
434 extern cc_t termForw2Char;
435 # else
436 # define termForw2Char new_tc.c_cc[VEOL]
437 # endif
438 # ifndef VSTATUS
439 extern cc_t termAytChar;
440 #else
441 # define termAytChar new_tc.c_cc[VSTATUS]
442 #endif
444 # if defined(__STDC__)
445 # define termEofCharp &termEofChar
446 # define termEraseCharp &termEraseChar
447 # define termIntCharp &termIntChar
448 # define termKillCharp &termKillChar
449 # define termQuitCharp &termQuitChar
450 # define termSuspCharp &termSuspChar
451 # define termFlushCharp &termFlushChar
452 # define termWerasCharp &termWerasChar
453 # define termRprntCharp &termRprntChar
454 # define termLiteralNextCharp &termLiteralNextChar
455 # define termStartCharp &termStartChar
456 # define termStopCharp &termStopChar
457 # define termForw1Charp &termForw1Char
458 # define termForw2Charp &termForw2Char
459 # define termAytCharp &termAytChar
460 # else
461 /* Work around a compiler bug */
462 # define termEofCharp 0
463 # define termEraseCharp 0
464 # define termIntCharp 0
465 # define termKillCharp 0
466 # define termQuitCharp 0
467 # define termSuspCharp 0
468 # define termFlushCharp 0
469 # define termWerasCharp 0
470 # define termRprntCharp 0
471 # define termLiteralNextCharp 0
472 # define termStartCharp 0
473 # define termStopCharp 0
474 # define termForw1Charp 0
475 # define termForw2Charp 0
476 # define termAytCharp 0
477 # endif
478 #endif
481 /* Ring buffer structures which are shared */
483 extern Ring
484 netoring,
485 netiring,
486 ttyoring,
487 ttyiring;
489 extern void
490 xmitAO(void),
491 xmitEC(void),
492 xmitEL(void);