]> git.saurik.com Git - apple/network_cmds.git/blame - telnet.tproj/externs.h
network_cmds-85.tar.gz
[apple/network_cmds.git] / telnet.tproj / externs.h
CommitLineData
b7080c8e
A
1/*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.0 (the 'License'). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
12 * this file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
20 * under the License."
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24/*
25 * Copyright (c) 1988, 1990, 1993
26 * The Regents of the University of California. All rights reserved.
27 *
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions
30 * are met:
31 * 1. Redistributions of source code must retain the above copyright
32 * notice, this list of conditions and the following disclaimer.
33 * 2. Redistributions in binary form must reproduce the above copyright
34 * notice, this list of conditions and the following disclaimer in the
35 * documentation and/or other materials provided with the distribution.
36 * 3. All advertising materials mentioning features or use of this software
37 * must display the following acknowledgement:
38 * This product includes software developed by the University of
39 * California, Berkeley and its contributors.
40 * 4. Neither the name of the University nor the names of its contributors
41 * may be used to endorse or promote products derived from this software
42 * without specific prior written permission.
43 *
44 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
45 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
48 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54 * SUCH DAMAGE.
55 *
56 * @(#)externs.h 8.3 (Berkeley) 5/30/95
57 */
58
59#ifndef BSD
60# define BSD 43
61#endif
62
63/*
64 * ucb stdio.h defines BSD as something wierd
65 */
66#if defined(sun) && defined(__svr4__)
67#define BSD 43
68#endif
69
70#ifndef USE_TERMIO
71# if BSD > 43 || defined(SYSV_TERMIO)
72# define USE_TERMIO
73# endif
74#endif
75
76#include <stdio.h>
77#include <setjmp.h>
78#if defined(CRAY) && !defined(NO_BSD_SETJMP)
79#include <bsdsetjmp.h>
80#endif
81#ifndef FILIO_H
82#include <sys/ioctl.h>
83#else
84#include <sys/filio.h>
85#endif
86#ifdef CRAY
87# include <errno.h>
88#endif /* CRAY */
89#ifdef USE_TERMIO
90# ifndef VINTR
91# ifdef SYSV_TERMIO
92# include <sys/termio.h>
93# else
94# include <sys/termios.h>
95# define termio termios
96# endif
97# endif
98#endif
99#if defined(NO_CC_T) || !defined(USE_TERMIO)
100# if !defined(USE_TERMIO)
101typedef char cc_t;
102# else
103typedef unsigned char cc_t;
104# endif
105#endif
106
107#ifndef NO_STRING_H
108#include <string.h>
109#else
110#include <strings.h>
111#endif
112
113#ifndef _POSIX_VDISABLE
114# ifdef sun
115# include <sys/param.h> /* pick up VDISABLE definition, mayby */
116# endif
117# ifdef VDISABLE
118# define _POSIX_VDISABLE VDISABLE
119# else
120# define _POSIX_VDISABLE ((cc_t)'\377')
121# endif
122#endif
123
124#define SUBBUFSIZE 256
125
126#ifndef CRAY
127extern int errno; /* outside this world */
128#endif /* !CRAY */
129
130#if !defined(P)
131# ifdef __STDC__
132# define P(x) x
133# else
134# define P(x) ()
135# endif
136#endif
137
138extern int
139 autologin, /* Autologin enabled */
140 skiprc, /* Don't process the ~/.telnetrc file */
141 eight, /* use eight bit mode (binary in and/or out */
142 flushout, /* flush output */
143 connected, /* Are we connected to the other side? */
144 globalmode, /* Mode tty should be in */
145 In3270, /* Are we in 3270 mode? */
146 telnetport, /* Are we connected to the telnet port? */
147 localflow, /* Flow control handled locally */
148 restartany, /* If flow control, restart output on any character */
149 localchars, /* we recognize interrupt/quit */
150 donelclchars, /* the user has set "localchars" */
151 showoptions,
152 net, /* Network file descriptor */
153 tin, /* Terminal input file descriptor */
154 tout, /* Terminal output file descriptor */
155 crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
156 autoflush, /* flush output when interrupting? */
157 autosynch, /* send interrupt characters with SYNCH? */
158 SYNCHing, /* Is the stream in telnet SYNCH mode? */
159 donebinarytoggle, /* the user has put us in binary */
160 dontlecho, /* do we suppress local echoing right now? */
161 crmod,
162 netdata, /* Print out network data flow */
163 prettydump, /* Print "netdata" output in user readable format */
164#if defined(unix) || defined(__APPLE__)
165#if defined(TN3270)
166 cursesdata, /* Print out curses data flow */
167 apitrace, /* Trace API transactions */
168#endif /* defined(TN3270) */
169 termdata, /* Print out terminal data flow */
170#endif /* defined(unix) || defined(__APPLE__) */
171 debug; /* Debug level */
172
173extern cc_t escape; /* Escape to command mode */
174extern cc_t rlogin; /* Rlogin mode escape character */
175#ifdef KLUDGELINEMODE
176extern cc_t echoc; /* Toggle local echoing */
177#endif
178
179extern char
180 *prompt; /* Prompt for command. */
181
182extern char
183 doopt[],
184 dont[],
185 will[],
186 wont[],
187 options[], /* All the little options */
188 *hostname; /* Who are we connected to? */
189#ifdef ENCRYPTION
190extern void (*encrypt_output) P((unsigned char *, int));
191extern int (*decrypt_input) P((int));
192#endif /* ENCRYPTION */
193
194/*
195 * We keep track of each side of the option negotiation.
196 */
197
198#define MY_STATE_WILL 0x01
199#define MY_WANT_STATE_WILL 0x02
200#define MY_STATE_DO 0x04
201#define MY_WANT_STATE_DO 0x08
202
203/*
204 * Macros to check the current state of things
205 */
206
207#define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
208#define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
209#define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
210#define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
211
212#define my_state_is_dont(opt) (!my_state_is_do(opt))
213#define my_state_is_wont(opt) (!my_state_is_will(opt))
214#define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
215#define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
216
217#define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;}
218#define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;}
219#define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;}
220#define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;}
221
222#define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;}
223#define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;}
224#define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;}
225#define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;}
226
227/*
228 * Make everything symetrical
229 */
230
231#define HIS_STATE_WILL MY_STATE_DO
232#define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
233#define HIS_STATE_DO MY_STATE_WILL
234#define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
235
236#define his_state_is_do my_state_is_will
237#define his_state_is_will my_state_is_do
238#define his_want_state_is_do my_want_state_is_will
239#define his_want_state_is_will my_want_state_is_do
240
241#define his_state_is_dont my_state_is_wont
242#define his_state_is_wont my_state_is_dont
243#define his_want_state_is_dont my_want_state_is_wont
244#define his_want_state_is_wont my_want_state_is_dont
245
246#define set_his_state_do set_my_state_will
247#define set_his_state_will set_my_state_do
248#define set_his_want_state_do set_my_want_state_will
249#define set_his_want_state_will set_my_want_state_do
250
251#define set_his_state_dont set_my_state_wont
252#define set_his_state_wont set_my_state_dont
253#define set_his_want_state_dont set_my_want_state_wont
254#define set_his_want_state_wont set_my_want_state_dont
255
256
257extern FILE
258 *NetTrace; /* Where debugging output goes */
259extern unsigned char
260 NetTraceFile[]; /* Name of file where debugging output goes */
261extern void
262 SetNetTrace P((char *)); /* Function to change where debugging goes */
263
264extern jmp_buf
265 peerdied,
266 toplevel; /* For error conditions. */
267
268extern void
269 command P((int, char *, int)),
270 Dump P((int, unsigned char *, int)),
271 init_3270 P((void)),
272 printoption P((char *, int, int)),
273 printsub P((int, unsigned char *, int)),
274 sendnaws P((void)),
275 setconnmode P((int)),
276 setcommandmode P((void)),
277 setneturg P((void)),
278 sys_telnet_init P((void)),
279 telnet P((char *)),
280 tel_enter_binary P((int)),
281 TerminalFlushOutput P((void)),
282 TerminalNewMode P((int)),
283 TerminalRestoreState P((void)),
284 TerminalSaveState P((void)),
285 tninit P((void)),
286 upcase P((char *)),
287 willoption P((int)),
288 wontoption P((int));
289
290extern void
291 send_do P((int, int)),
292 send_dont P((int, int)),
293 send_will P((int, int)),
294 send_wont P((int, int));
295
296extern void
297 lm_will P((unsigned char *, int)),
298 lm_wont P((unsigned char *, int)),
299 lm_do P((unsigned char *, int)),
300 lm_dont P((unsigned char *, int)),
301 lm_mode P((unsigned char *, int, int));
302
303extern void
304 slc_init P((void)),
305 slcstate P((void)),
306 slc_mode_export P((void)),
307 slc_mode_import P((int)),
308 slc_import P((int)),
309 slc_export P((void)),
310 slc P((unsigned char *, int)),
311 slc_check P((void)),
312 slc_start_reply P((void)),
313 slc_add_reply P((int, int, int)),
314 slc_end_reply P((void));
315extern int
316 slc_update P((void));
317
318extern void
319 env_opt P((unsigned char *, int)),
320 env_opt_start P((void)),
321 env_opt_start_info P((void)),
322 env_opt_add P((unsigned char *)),
323 env_opt_end P((int));
324
325extern unsigned char
326 *env_default P((int, int)),
327 *env_getvalue P((unsigned char *));
328
329extern int
330 get_status P((void)),
331 dosynch P((void));
332
333extern cc_t
334 *tcval P((int));
335
336#ifndef USE_TERMIO
337
338extern struct tchars ntc;
339extern struct ltchars nltc;
340extern struct sgttyb nttyb;
341
342# define termEofChar ntc.t_eofc
343# define termEraseChar nttyb.sg_erase
344# define termFlushChar nltc.t_flushc
345# define termIntChar ntc.t_intrc
346# define termKillChar nttyb.sg_kill
347# define termLiteralNextChar nltc.t_lnextc
348# define termQuitChar ntc.t_quitc
349# define termSuspChar nltc.t_suspc
350# define termRprntChar nltc.t_rprntc
351# define termWerasChar nltc.t_werasc
352# define termStartChar ntc.t_startc
353# define termStopChar ntc.t_stopc
354# define termForw1Char ntc.t_brkc
355extern cc_t termForw2Char;
356extern cc_t termAytChar;
357
358# define termEofCharp (cc_t *)&ntc.t_eofc
359# define termEraseCharp (cc_t *)&nttyb.sg_erase
360# define termFlushCharp (cc_t *)&nltc.t_flushc
361# define termIntCharp (cc_t *)&ntc.t_intrc
362# define termKillCharp (cc_t *)&nttyb.sg_kill
363# define termLiteralNextCharp (cc_t *)&nltc.t_lnextc
364# define termQuitCharp (cc_t *)&ntc.t_quitc
365# define termSuspCharp (cc_t *)&nltc.t_suspc
366# define termRprntCharp (cc_t *)&nltc.t_rprntc
367# define termWerasCharp (cc_t *)&nltc.t_werasc
368# define termStartCharp (cc_t *)&ntc.t_startc
369# define termStopCharp (cc_t *)&ntc.t_stopc
370# define termForw1Charp (cc_t *)&ntc.t_brkc
371# define termForw2Charp (cc_t *)&termForw2Char
372# define termAytCharp (cc_t *)&termAytChar
373
374# else
375
376extern struct termio new_tc;
377
378# define termEofChar new_tc.c_cc[VEOF]
379# define termEraseChar new_tc.c_cc[VERASE]
380# define termIntChar new_tc.c_cc[VINTR]
381# define termKillChar new_tc.c_cc[VKILL]
382# define termQuitChar new_tc.c_cc[VQUIT]
383
384# ifndef VSUSP
385extern cc_t termSuspChar;
386# else
387# define termSuspChar new_tc.c_cc[VSUSP]
388# endif
389# if defined(VFLUSHO) && !defined(VDISCARD)
390# define VDISCARD VFLUSHO
391# endif
392# ifndef VDISCARD
393extern cc_t termFlushChar;
394# else
395# define termFlushChar new_tc.c_cc[VDISCARD]
396# endif
397# ifndef VWERASE
398extern cc_t termWerasChar;
399# else
400# define termWerasChar new_tc.c_cc[VWERASE]
401# endif
402# ifndef VREPRINT
403extern cc_t termRprntChar;
404# else
405# define termRprntChar new_tc.c_cc[VREPRINT]
406# endif
407# ifndef VLNEXT
408extern cc_t termLiteralNextChar;
409# else
410# define termLiteralNextChar new_tc.c_cc[VLNEXT]
411# endif
412# ifndef VSTART
413extern cc_t termStartChar;
414# else
415# define termStartChar new_tc.c_cc[VSTART]
416# endif
417# ifndef VSTOP
418extern cc_t termStopChar;
419# else
420# define termStopChar new_tc.c_cc[VSTOP]
421# endif
422# ifndef VEOL
423extern cc_t termForw1Char;
424# else
425# define termForw1Char new_tc.c_cc[VEOL]
426# endif
427# ifndef VEOL2
428extern cc_t termForw2Char;
429# else
430# define termForw2Char new_tc.c_cc[VEOL]
431# endif
432# ifndef VSTATUS
433extern cc_t termAytChar;
434#else
435# define termAytChar new_tc.c_cc[VSTATUS]
436#endif
437
438# if !defined(CRAY) || defined(__STDC__)
439# define termEofCharp &termEofChar
440# define termEraseCharp &termEraseChar
441# define termIntCharp &termIntChar
442# define termKillCharp &termKillChar
443# define termQuitCharp &termQuitChar
444# define termSuspCharp &termSuspChar
445# define termFlushCharp &termFlushChar
446# define termWerasCharp &termWerasChar
447# define termRprntCharp &termRprntChar
448# define termLiteralNextCharp &termLiteralNextChar
449# define termStartCharp &termStartChar
450# define termStopCharp &termStopChar
451# define termForw1Charp &termForw1Char
452# define termForw2Charp &termForw2Char
453# define termAytCharp &termAytChar
454# else
455 /* Work around a compiler bug */
456# define termEofCharp 0
457# define termEraseCharp 0
458# define termIntCharp 0
459# define termKillCharp 0
460# define termQuitCharp 0
461# define termSuspCharp 0
462# define termFlushCharp 0
463# define termWerasCharp 0
464# define termRprntCharp 0
465# define termLiteralNextCharp 0
466# define termStartCharp 0
467# define termStopCharp 0
468# define termForw1Charp 0
469# define termForw2Charp 0
470# define termAytCharp 0
471# endif
472#endif
473
474
475/* Ring buffer structures which are shared */
476
477extern Ring
478 netoring,
479 netiring,
480 ttyoring,
481 ttyiring;
482
483/* Tn3270 section */
484#if defined(TN3270)
485
486extern int
487 HaveInput, /* Whether an asynchronous I/O indication came in */
488 noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */
489 noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */
490 sigiocount, /* Count of SIGIO receptions */
491 shell_active; /* Subshell is active */
492
493extern char
494 *Ibackp, /* Oldest byte of 3270 data */
495 Ibuf[], /* 3270 buffer */
496 *Ifrontp, /* Where next 3270 byte goes */
497 tline[],
498 *transcom; /* Transparent command */
499
500extern int
501 settranscom P((int, char**));
502
503extern void
504 inputAvailable P((int));
505#endif /* defined(TN3270) */