OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / user / telnet / externs.h
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  *      @(#)externs.h   8.2 (Berkeley) 12/15/93
34  */
35
36 #ifndef BSD
37 # define BSD 43
38 #endif
39
40 /*
41  * ucb stdio.h defines BSD as something wierd
42  */
43 #if defined(sun) && defined(__svr4__)
44 #define BSD 43
45 #endif
46
47 #ifndef USE_TERMIO
48 # if BSD > 43 || defined(SYSV_TERMIO)
49 #  define USE_TERMIO
50 # endif
51 #endif
52
53 #include <stdio.h>
54 #include <setjmp.h>
55 #if defined(CRAY) && !defined(NO_BSD_SETJMP)
56 #include <bsdsetjmp.h>
57 #endif
58 #ifndef FILIO_H
59 #include <sys/ioctl.h>
60 #else
61 #include <sys/filio.h>
62 #endif
63 #ifdef CRAY
64 # include <errno.h>
65 #endif /* CRAY */
66 #ifdef  USE_TERMIO
67 # ifndef        VINTR
68 #  ifdef SYSV_TERMIO
69 #   include <sys/termio.h>
70 #  else
71 #   include <sys/termios.h>
72 #   define termio termios
73 #  endif
74 # endif
75 #endif
76 #ifdef VEOL2
77 #undef termio
78 #define termio termios
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>
90 #endif
91 #include <strings.h>
92
93 #ifndef MIN
94 #define MIN(a,b)        (((a)<(b))? (a):(b))
95 #endif
96
97 #ifndef _POSIX_VDISABLE
98 # ifdef sun
99 #  include <sys/param.h>        /* pick up VDISABLE definition, mayby */
100 # endif
101 # ifdef VDISABLE
102 #  define _POSIX_VDISABLE VDISABLE
103 # else
104 #  define _POSIX_VDISABLE ((cc_t)'\377')
105 # endif
106 #endif
107
108 #define SUBBUFSIZE      256
109
110 #ifndef CRAY
111 extern int errno;               /* outside this world */
112 #endif /* !CRAY */
113
114 #if     !defined(P)
115 # ifdef __STDC__
116 #  define       P(x)    x
117 # else
118 #  define       P(x)    ()
119 # endif
120 #endif
121
122 extern int
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" */
135     showoptions,
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? */
145     crmod,
146     netdata,            /* Print out network data flow */
147     prettydump,         /* Print "netdata" output in user readable format */
148 #if     defined(unix)
149 #if     defined(TN3270)
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 */
158
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 */
163 #endif
164
165 extern char
166     *prompt;            /* Prompt for command. */
167
168 extern char
169     doopt[],
170     dont[],
171     will[],
172     wont[],
173     options[],          /* All the little options */
174     *hostname;          /* Who are we connected to? */
175
176 /*
177  * We keep track of each side of the option negotiation.
178  */
179
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
184
185 /*
186  * Macros to check the current state of things
187  */
188
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)
193
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))
198
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;}
203
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;}
208
209 /*
210  * Make everything symetrical
211  */
212
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
217
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
222
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
227
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
232
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
237
238
239 extern FILE
240     *NetTrace;          /* Where debugging output goes */
241 extern unsigned char
242     NetTraceFile[];     /* Name of file where debugging output goes */
243 extern void
244     SetNetTrace P((char *));    /* Function to change where debugging goes */
245
246 extern jmp_buf
247     peerdied,
248     toplevel;           /* For error conditions. */
249
250 extern void
251     command P((int, char *, int)),
252     Dump P((int, unsigned char *, int)),
253     init_3270 P((void)),
254     printoption P((char *, int, int)),
255     printsub P((int, unsigned char *, int)),
256     sendnaws P((void)),
257     setconnmode P((int)),
258     setcommandmode P((void)),
259     setneturg P((void)),
260     sys_telnet_init P((void)),
261     telnet P((char *)),
262     tel_enter_binary P((int)),
263     TerminalFlushOutput P((void)),
264     TerminalNewMode P((int)),
265     TerminalRestoreState P((void)),
266     TerminalSaveState P((void)),
267     tninit P((void)),
268     upcase P((char *)),
269     willoption P((int)),
270     wontoption P((int));
271
272 extern 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));
277
278 extern void
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));
284
285 extern void
286     slc_init P((void)),
287     slcstate P((void)),
288     slc_mode_export P((void)),
289     slc_mode_import P((int)),
290     slc_import P((int)),
291     slc_export P((void)),
292     slc P((unsigned char *, int)),
293     slc_check P((void)),
294     slc_start_reply P((void)),
295     slc_add_reply P((int, int, int)),
296     slc_end_reply P((void));
297 extern int
298     slc_update P((void));
299
300 extern 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));
306
307 extern unsigned char
308     *env_default P((int, int)),
309     *env_getvalue P((unsigned char *));
310
311 extern int
312     get_status P((void)),
313     dosynch P((void));
314
315 extern cc_t
316     *tcval P((int));
317
318 #ifndef USE_TERMIO
319
320 extern struct   tchars ntc;
321 extern struct   ltchars nltc;
322 extern struct   sgttyb nttyb;
323
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;
339
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
355
356 # else
357
358 extern struct   termio new_tc;
359
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]
365
366 # ifndef        VSUSP
367 extern cc_t termSuspChar;
368 # else
369 #  define termSuspChar          new_tc.c_cc[VSUSP]
370 # endif
371 # if    defined(VFLUSHO) && !defined(VDISCARD)
372 #  define VDISCARD VFLUSHO
373 # endif
374 # ifndef        VDISCARD
375 extern cc_t termFlushChar;
376 # else
377 #  define termFlushChar         new_tc.c_cc[VDISCARD]
378 # endif
379 # ifndef VWERASE
380 extern cc_t termWerasChar;
381 # else
382 #  define termWerasChar         new_tc.c_cc[VWERASE]
383 # endif
384 # ifndef        VREPRINT
385 extern cc_t termRprntChar;
386 # else
387 #  define termRprntChar         new_tc.c_cc[VREPRINT]
388 # endif
389 # ifndef        VLNEXT
390 extern cc_t termLiteralNextChar;
391 # else
392 #  define termLiteralNextChar   new_tc.c_cc[VLNEXT]
393 # endif
394 # ifndef        VSTART
395 extern cc_t termStartChar;
396 # else
397 #  define termStartChar         new_tc.c_cc[VSTART]
398 # endif
399 # ifndef        VSTOP
400 extern cc_t termStopChar;
401 # else
402 #  define termStopChar          new_tc.c_cc[VSTOP]
403 # endif
404 # ifndef        VEOL
405 extern cc_t termForw1Char;
406 # else
407 #  define termForw1Char         new_tc.c_cc[VEOL]
408 # endif
409 # ifndef        VEOL2
410 extern cc_t termForw2Char;
411 # else
412 #  define termForw2Char         new_tc.c_cc[VEOL]
413 # endif
414 # ifndef        VSTATUS
415 extern cc_t termAytChar;
416 #else
417 #  define termAytChar           new_tc.c_cc[VSTATUS]
418 #endif
419
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
436 # else
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
453 # endif
454 #endif
455
456
457 /* Ring buffer structures which are shared */
458
459 extern Ring
460     netoring,
461     netiring,
462     ttyoring,
463     ttyiring;
464
465 /* Tn3270 section */
466 #if     defined(TN3270)
467
468 extern int
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 */
474
475 extern char
476     *Ibackp,            /* Oldest byte of 3270 data */
477     Ibuf[],             /* 3270 buffer */
478     *Ifrontp,           /* Where next 3270 byte goes */
479     tline[],
480     *transcom;          /* Transparent command */
481
482 extern int
483     settranscom P((int, char**));
484
485 extern void
486     inputAvailable P((int));
487 #endif  /* defined(TN3270) */