xref: /haiku/src/bin/network/telnetd/ext.h (revision bc2428853ff331825f608f1b6cceb96bc006ebae)
1 /*
2  * Copyright (c) 1989, 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. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *	@(#)ext.h	8.2 (Berkeley) 12/15/93
30  * $FreeBSD$
31  */
32 
33 #ifndef EXTERN
34 #define	EXTERN	extern
35 #endif
36 
37 /*
38  * Telnet server variable declarations
39  */
40 EXTERN char	options[256];
41 EXTERN char	do_dont_resp[256];
42 EXTERN char	will_wont_resp[256];
43 EXTERN int	linemode;	/* linemode on/off */
44 #ifdef	LINEMODE
45 EXTERN int	uselinemode;	/* what linemode to use (on/off) */
46 EXTERN int	editmode;	/* edit modes in use */
47 EXTERN int	useeditmode;	/* edit modes to use */
48 EXTERN int	alwayslinemode;	/* command line option */
49 EXTERN int	lmodetype;	/* Client support for linemode */
50 #endif	/* LINEMODE */
51 EXTERN int	flowmode;	/* current flow control state */
52 EXTERN int	restartany;	/* restart output on any character state */
53 #ifdef DIAGNOSTICS
54 EXTERN int	diagnostic;	/* telnet diagnostic capabilities */
55 #endif /* DIAGNOSTICS */
56 #ifdef BFTPDAEMON
57 EXTERN int	bftpd;		/* behave as bftp daemon */
58 #endif /* BFTPDAEMON */
59 #ifdef	AUTHENTICATION
60 EXTERN int	auth_level;
61 #endif
62 
63 EXTERN slcfun	slctab[NSLC + 1];	/* slc mapping table */
64 
65 EXTERN char	*terminaltype;
66 
67 /*
68  * I/O data buffers, pointers, and counters.
69  */
70 EXTERN char	ptyobuf[BUFSIZ+NETSLOP], *pfrontp, *pbackp;
71 
72 EXTERN char	netibuf[BUFSIZ], *netip;
73 
74 EXTERN char	netobuf[BUFSIZ], *nfrontp, *nbackp;
75 EXTERN char	*neturg;		/* one past last bye of urgent data */
76 
77 EXTERN int	pcc, ncc;
78 
79 EXTERN int	pty, net;
80 EXTERN char	line[32];
81 EXTERN int	SYNCHing;		/* we are in TELNET SYNCH mode */
82 
83 EXTERN void
84 	_termstat(void),
85 	add_slc(char, char, cc_t),
86 	check_slc(void),
87 	change_slc(char, char, cc_t),
88 	cleanup(int),
89 	clientstat(int, int, int),
90 	copy_termbuf(char *, size_t),
91 	deferslc(void),
92 	defer_terminit(void),
93 	do_opt_slc(unsigned char *, int),
94 	doeof(void),
95 	dooption(int),
96 	dontoption(int),
97 	edithost(char *, char *),
98 	fatal(int, const char *),
99 	fatalperror(int, const char *),
100 	get_slc_defaults(void),
101 	init_env(void),
102 	init_termbuf(void),
103 	interrupt(void),
104 	localstat(void),
105 	flowstat(void),
106 	netclear(void),
107 	netflush(void),
108 #ifdef DIAGNOSTICS
109 	printoption(const char *, int),
110 	printdata(const char *, char *, int),
111 	printsub(char, unsigned char *, int),
112 #endif
113 	process_slc(unsigned char, unsigned char, cc_t),
114 	ptyflush(void),
115 	putchr(int),
116 	putf(char *, char *),
117 	recv_ayt(void),
118 	send_do(int, int),
119 	send_dont(int, int),
120 	send_slc(void),
121 	send_status(void),
122 	send_will(int, int),
123 	send_wont(int, int),
124 	sendbrk(void),
125 	sendsusp(void),
126 	set_termbuf(void),
127 	start_login(char *, int, char *),
128 	start_slc(int),
129 #ifdef	AUTHENTICATION
130 	start_slave(char *),
131 #else
132 	start_slave(char *, int, char *),
133 #endif
134 	suboption(void),
135 	telrcv(void),
136 	ttloop(void),
137 	tty_binaryin(int),
138 	tty_binaryout(int);
139 
140 EXTERN int
141 	end_slc(unsigned char **),
142 	getnpty(void),
143 #ifndef convex
144 	getpty(int *),
145 #endif
146 	login_tty(int),
147 	spcset(int, cc_t *, cc_t **),
148 	stilloob(int),
149 	terminit(void),
150 	termstat(void),
151 	tty_flowmode(void),
152 	tty_restartany(void),
153 	tty_isbinaryin(void),
154 	tty_isbinaryout(void),
155 	tty_iscrnl(void),
156 	tty_isecho(void),
157 	tty_isediting(void),
158 	tty_islitecho(void),
159 	tty_isnewmap(void),
160 	tty_israw(void),
161 	tty_issofttab(void),
162 	tty_istrapsig(void),
163 	tty_linemode(void);
164 
165 EXTERN void
166 	tty_rspeed(int),
167 	tty_setecho(int),
168 	tty_setedit(int),
169 	tty_setlinemode(int),
170 	tty_setlitecho(int),
171 	tty_setsig(int),
172 	tty_setsofttab(int),
173 	tty_tspeed(int),
174 	willoption(int),
175 	wontoption(int);
176 
177 int	output_data(const char *, ...) __printflike(1, 2);
178 void	output_datalen(const char *, int);
179 void	startslave(char *, int, char *);
180 
181 #ifdef	ENCRYPTION
182 extern void	(*encrypt_output)(unsigned char *, int);
183 extern int	(*decrypt_input)(int);
184 EXTERN char	*nclearto;
185 #endif	/* ENCRYPTION */
186 
187 
188 /*
189  * The following are some clocks used to decide how to interpret
190  * the relationship between various variables.
191  */
192 
193 EXTERN struct {
194     int
195 	system,			/* what the current time is */
196 	echotoggle,		/* last time user entered echo character */
197 	modenegotiated,		/* last time operating mode negotiated */
198 	didnetreceive,		/* last time we read data from network */
199 	ttypesubopt,		/* ttype subopt is received */
200 	tspeedsubopt,		/* tspeed subopt is received */
201 	environsubopt,		/* environ subopt is received */
202 	oenvironsubopt,		/* old environ subopt is received */
203 	xdisplocsubopt,		/* xdisploc subopt is received */
204 	baseline,		/* time started to do timed action */
205 	gotDM;			/* when did we last see a data mark */
206 } clocks;
207 
208 #ifndef	DEFAULT_IM
209 #   ifdef ultrix
210 #    define DEFAULT_IM	"\r\n\r\nULTRIX (%h) (%t)\r\n\r\r\n\r"
211 #   else
212 #    ifdef __FreeBSD__
213 #     define DEFAULT_IM  "\r\n\r\nFreeBSD (%h) (%t)\r\n\r\r\n\r"
214 #    else
215 #     ifdef __HAIKU__
216 #      define DEFAULT_IM	"\r\n\r\nHaiku (%h) (%t)\r\n\r\r\n\r"
217 #     else
218 #      define DEFAULT_IM	"\r\n\r\n4.4 BSD UNIX (%h) (%t)\r\n\r\r\n\r"
219 #     endif
220 #    endif
221 #   endif
222 #endif
223