Annotation of src/usr.bin/telnet/externs.h, Revision 1.20
1.20 ! guenther 1: /* $OpenBSD: externs.h,v 1.19 2014/07/20 03:00:31 deraadt Exp $ */
1.3 art 2: /* $KTH: externs.h,v 1.16 1997/11/29 02:28:35 joda Exp $ */
1.2 niklas 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.
1.11 millert 16: * 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 17: * may be used to endorse or promote products derived from this software
18: * without specific prior written permission.
19: *
20: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30: * SUCH DAMAGE.
31: *
1.3 art 32: * @(#)externs.h 8.3 (Berkeley) 5/30/95
1.1 deraadt 33: */
34:
35: #define SUBBUFSIZE 256
36:
37: extern int
38: autologin, /* Autologin enabled */
39: skiprc, /* Don't process the ~/.telnetrc file */
40: eight, /* use eight bit mode (binary in and/or out */
1.3 art 41: binary,
1.12 otto 42: family, /* address family of peer */
1.1 deraadt 43: flushout, /* flush output */
44: connected, /* Are we connected to the other side? */
45: globalmode, /* Mode tty should be in */
46: telnetport, /* Are we connected to the telnet port? */
47: localflow, /* Flow control handled locally */
48: restartany, /* If flow control, restart output on any character */
49: localchars, /* we recognize interrupt/quit */
1.2 niklas 50: donelclchars, /* the user has set "localchars" */
1.1 deraadt 51: showoptions,
52: net, /* Network file descriptor */
53: tin, /* Terminal input file descriptor */
54: tout, /* Terminal output file descriptor */
55: crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
56: autoflush, /* flush output when interrupting? */
57: autosynch, /* send interrupt characters with SYNCH? */
58: SYNCHing, /* Is the stream in telnet SYNCH mode? */
59: donebinarytoggle, /* the user has put us in binary */
60: dontlecho, /* do we suppress local echoing right now? */
61: crmod,
62: netdata, /* Print out network data flow */
63: prettydump, /* Print "netdata" output in user readable format */
64: termdata, /* Print out terminal data flow */
1.3 art 65: debug; /* Debug level */
1.9 hin 66:
1.10 hin 67: extern volatile sig_atomic_t intr_happened, intr_waiting; /* for interrupt handling */
1.1 deraadt 68:
69: extern cc_t escape; /* Escape to command mode */
70: extern cc_t rlogin; /* Rlogin mode escape character */
71: #ifdef KLUDGELINEMODE
72: extern cc_t echoc; /* Toggle local echoing */
73: #endif
74:
75: extern char
76: *prompt; /* Prompt for command. */
77:
78: extern char
79: doopt[],
80: dont[],
81: will[],
82: wont[],
83: options[], /* All the little options */
84: *hostname; /* Who are we connected to? */
1.15 claudio 85:
1.17 sthen 86: extern int rtableid; /* routing table to use */
1.1 deraadt 87:
88: /*
89: * We keep track of each side of the option negotiation.
90: */
91:
92: #define MY_STATE_WILL 0x01
93: #define MY_WANT_STATE_WILL 0x02
94: #define MY_STATE_DO 0x04
95: #define MY_WANT_STATE_DO 0x08
96:
97: /*
98: * Macros to check the current state of things
99: */
100:
101: #define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
102: #define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
103: #define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
104: #define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
105:
106: #define my_state_is_dont(opt) (!my_state_is_do(opt))
107: #define my_state_is_wont(opt) (!my_state_is_will(opt))
108: #define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
109: #define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
110:
111: #define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;}
112: #define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;}
113: #define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;}
114: #define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;}
115:
116: #define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;}
117: #define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;}
118: #define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;}
119: #define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;}
120:
121: /*
1.7 pvalchev 122: * Make everything symmetrical
1.1 deraadt 123: */
124:
125: #define HIS_STATE_WILL MY_STATE_DO
126: #define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
127: #define HIS_STATE_DO MY_STATE_WILL
128: #define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
129:
130: #define his_state_is_do my_state_is_will
131: #define his_state_is_will my_state_is_do
132: #define his_want_state_is_do my_want_state_is_will
133: #define his_want_state_is_will my_want_state_is_do
134:
135: #define his_state_is_dont my_state_is_wont
136: #define his_state_is_wont my_state_is_dont
137: #define his_want_state_is_dont my_want_state_is_wont
138: #define his_want_state_is_wont my_want_state_is_dont
139:
140: #define set_his_state_do set_my_state_will
141: #define set_his_state_will set_my_state_do
142: #define set_his_want_state_do set_my_want_state_will
143: #define set_his_want_state_will set_my_want_state_do
144:
145: #define set_his_state_dont set_my_state_wont
146: #define set_his_state_wont set_my_state_dont
147: #define set_his_want_state_dont set_my_want_state_wont
148: #define set_his_want_state_wont set_my_want_state_dont
149:
150:
151: extern FILE
152: *NetTrace; /* Where debugging output goes */
153: extern unsigned char
154: NetTraceFile[]; /* Name of file where debugging output goes */
155: extern void
1.3 art 156: SetNetTrace (char *); /* Function to change where debugging goes */
1.1 deraadt 157:
158: extern jmp_buf
159: peerdied,
160: toplevel; /* For error conditions. */
161:
1.3 art 162: /* commands.c */
163:
164: struct env_lst *env_define (unsigned char *, unsigned char *);
165: struct env_lst *env_find(unsigned char *var);
166: void env_init (void);
167: void env_undefine (unsigned char *);
168: void env_export (unsigned char *);
169: void env_unexport (unsigned char *);
170: void env_send (unsigned char *);
171: void env_list (void);
172: unsigned char * env_default(int init, int welldefined);
1.14 otto 173: unsigned char * env_getvalue(unsigned char *var, int exported_only);
1.3 art 174:
175: void set_escape_char(char *s);
176: unsigned long sourceroute(char *arg, char **cpp, int *lenp);
177:
178: #ifdef SIGINFO
179: void ayt_status(void);
180: #endif
181: int tn(int argc, char **argv);
182: void command(int top, char *tbuf, int cnt);
183:
184: /* main.c */
185:
186: void tninit(void);
187: void usage(void);
188:
189: /* network.c */
190:
191: void init_network(void);
192: int stilloob(void);
193: void setneturg(void);
194: int netflush(void);
195:
196: /* sys_bsd.c */
197:
198: void init_sys(void);
199: int TerminalWrite(char *buf, int n);
200: int TerminalRead(unsigned char *buf, int n);
201: int TerminalAutoFlush(void);
202: int TerminalSpecialChars(int c);
203: void TerminalFlushOutput(void);
204: void TerminalSaveState(void);
205: void TerminalDefaultChars(void);
206: void TerminalNewMode(int f);
207: cc_t *tcval(int func);
208: void TerminalSpeeds(long *input_speed, long *output_speed);
209: int TerminalWindowSize(long *rows, long *cols);
210: int NetClose(int fd);
211: void NetNonblockingIO(int fd, int onoff);
212: int process_rings(int netin, int netout, int netex, int ttyin, int ttyout,
213: int poll);
214:
215: /* telnet.c */
216:
217: void init_telnet(void);
218:
219: void tel_leave_binary(int rw);
220: void tel_enter_binary(int rw);
221: int opt_welldefined(char *ep);
222: int telrcv(void);
223: int rlogin_susp(void);
224: void intp(void);
225: void sendbrk(void);
226: void sendabort(void);
227: void sendsusp(void);
228: void sendeof(void);
229: void sendayt(void);
230:
231: void xmitAO(void);
232: void xmitEL(void);
233: void xmitEC(void);
234:
235:
236: void Dump (char, unsigned char *, int);
237: void printoption (char *, int, int);
238: void sendnaws (void);
239: void setconnmode (int);
240: void setcommandmode (void);
241: void setneturg (void);
242: void sys_telnet_init (void);
243: void telnet (char *);
244: void tel_enter_binary (int);
245: void TerminalFlushOutput (void);
246: void TerminalNewMode (int);
247: void TerminalRestoreState (void);
248: void TerminalSaveState (void);
249: void tninit (void);
250: void willoption (int);
251: void wontoption (int);
252:
253:
254: void send_do (int, int);
255: void send_dont (int, int);
256: void send_will (int, int);
257: void send_wont (int, int);
258:
259: void lm_will (unsigned char *, int);
260: void lm_wont (unsigned char *, int);
261: void lm_do (unsigned char *, int);
262: void lm_dont (unsigned char *, int);
263: void lm_mode (unsigned char *, int, int);
264:
265: void slc_init (void);
266: void slcstate (void);
267: void slc_mode_export (void);
268: void slc_mode_import (int);
269: void slc_import (int);
270: void slc_export (void);
271: void slc (unsigned char *, int);
272: void slc_check (void);
273: void slc_start_reply (void);
274: void slc_add_reply (unsigned char, unsigned char, cc_t);
275: void slc_end_reply (void);
276: int slc_update (void);
277:
278: void env_opt (unsigned char *, int);
279: void env_opt_start (void);
280: void env_opt_start_info (void);
281: void env_opt_add (unsigned char *);
282: void env_opt_end (int);
283:
284: unsigned char *env_default (int, int);
1.14 otto 285: unsigned char *env_getvalue (unsigned char *, int);
1.3 art 286:
287: int get_status (void);
288: int dosynch (void);
289:
290: cc_t *tcval (int);
291:
1.20 ! guenther 292: __dead int quit(void);
1.3 art 293:
1.18 guenther 294: /* genget.c */
295:
296: char **genget(char *name, char **table, int stlen);
297: int isprefix(char *s1, char *s2);
298: int Ambiguous(void *s);
299:
1.3 art 300: /* terminal.c */
301:
302: void init_terminal(void);
303: int ttyflush(int drop);
304: int getconnmode(void);
305:
306: /* utilities.c */
307:
308: void SetNetTrace(char *file);
309: void Dump(char direction, unsigned char *buffer, int length);
310: void printoption(char *direction, int cmd, int option);
311: void optionstatus(void);
1.6 hin 312: void printsub(int direction, unsigned char *pointer, int length);
1.3 art 313: void EmptyTerminal(void);
314: void SetForExit(void);
1.20 ! guenther 315: __dead void Exit(int returnCode);
1.3 art 316: void ExitString(char *string, int returnCode);
1.1 deraadt 317:
1.3 art 318: extern struct termios new_tc;
1.1 deraadt 319:
320: # define termEofChar new_tc.c_cc[VEOF]
321: # define termEraseChar new_tc.c_cc[VERASE]
322: # define termIntChar new_tc.c_cc[VINTR]
323: # define termKillChar new_tc.c_cc[VKILL]
324: # define termQuitChar new_tc.c_cc[VQUIT]
325:
326: # ifndef VSUSP
327: extern cc_t termSuspChar;
328: # else
329: # define termSuspChar new_tc.c_cc[VSUSP]
330: # endif
331: # if defined(VFLUSHO) && !defined(VDISCARD)
332: # define VDISCARD VFLUSHO
333: # endif
334: # ifndef VDISCARD
335: extern cc_t termFlushChar;
336: # else
337: # define termFlushChar new_tc.c_cc[VDISCARD]
338: # endif
339: # ifndef VWERASE
340: extern cc_t termWerasChar;
341: # else
342: # define termWerasChar new_tc.c_cc[VWERASE]
343: # endif
344: # ifndef VREPRINT
345: extern cc_t termRprntChar;
346: # else
347: # define termRprntChar new_tc.c_cc[VREPRINT]
348: # endif
349: # ifndef VLNEXT
350: extern cc_t termLiteralNextChar;
351: # else
352: # define termLiteralNextChar new_tc.c_cc[VLNEXT]
353: # endif
354: # ifndef VSTART
355: extern cc_t termStartChar;
356: # else
357: # define termStartChar new_tc.c_cc[VSTART]
358: # endif
359: # ifndef VSTOP
360: extern cc_t termStopChar;
361: # else
362: # define termStopChar new_tc.c_cc[VSTOP]
363: # endif
364: # ifndef VEOL
365: extern cc_t termForw1Char;
366: # else
367: # define termForw1Char new_tc.c_cc[VEOL]
368: # endif
369: # ifndef VEOL2
370: extern cc_t termForw2Char;
371: # else
372: # define termForw2Char new_tc.c_cc[VEOL]
373: # endif
374: # ifndef VSTATUS
375: extern cc_t termAytChar;
376: #else
377: # define termAytChar new_tc.c_cc[VSTATUS]
378: #endif
379:
380: /* Ring buffer structures which are shared */
381:
382: extern Ring
383: netoring,
384: netiring,
385: ttyoring,
386: ttyiring;