xref: /dragonfly/usr.bin/tip/tip.h (revision aeaecd48)
1 /*
2  * Copyright (c) 1989, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *	This product includes software developed by the University of
17  *	California, Berkeley and its contributors.
18  * 4. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  *      @(#)tip.h	8.1 (Berkeley) 6/6/93
35  *
36  * $FreeBSD: src/usr.bin/tip/tip/tip.h,v 1.5.2.1 2000/07/01 12:24:23 ps Exp $
37  */
38 
39 /*
40  * tip - terminal interface program
41  */
42 
43 #include <sys/types.h>
44 #include <machine/endian.h>
45 #include <sys/file.h>
46 #include <sys/time.h>
47 #include <limits.h>
48 
49 #include <sys/ioctl.h>         /* for TIOCHPCL */
50 #include <sys/filio.h>    /* for FIONREAD */
51 #include <sys/termios.h>
52 
53 #include <signal.h>
54 #include <stdio.h>
55 #include <stdlib.h>
56 #include <string.h>
57 #include <pwd.h>
58 #include <ctype.h>
59 #include <setjmp.h>
60 #include <unistd.h>
61 #include <errno.h>
62 
63 /*
64  * Remote host attributes
65  */
66 char	*DV;			/* UNIX device(s) to open */
67 char	*EL;			/* chars marking an EOL */
68 char	*CM;			/* initial connection message */
69 char	*IE;			/* EOT to expect on input */
70 char	*OE;			/* EOT to send to complete FT */
71 char	*CU;			/* call unit if making a phone call */
72 char	*AT;			/* acu type */
73 char	*PN;			/* phone number(s) */
74 char	*DI;			/* disconnect string */
75 char	*PA;			/* parity to be generated */
76 
77 char	*PH;			/* phone number file */
78 char	*RM;			/* remote file name */
79 char	*HO;			/* host name */
80 
81 char	*LI;			/* login script */
82 char	*LO;			/* logout script */
83 
84 long	BR;			/* line speed for conversation */
85 long	FS;			/* frame size for transfers */
86 
87 char	DU;			/* this host is dialed up */
88 char	HW;			/* this device is hardwired, see hunt.c */
89 char	*ES;			/* escape character */
90 char	*EX;			/* exceptions */
91 char	*FO;			/* force (literal next) char*/
92 char	*RC;			/* raise character */
93 char	*RE;			/* script record file */
94 char	*PR;			/* remote prompt */
95 long	DL;			/* line delay for file transfers to remote */
96 long	CL;			/* char delay for file transfers to remote */
97 long	ET;			/* echocheck timeout */
98 char	HD;			/* this host is half duplex - do local echo */
99 
100 /*
101  * String value table
102  */
103 typedef
104 	struct {
105 		char	*v_name;	/* whose name is it */
106 		char	v_type;		/* for interpreting set's */
107 		char	v_access;	/* protection of touchy ones */
108 		char	*v_abrev;	/* possible abreviation */
109 		char	*v_value;	/* casted to a union later */
110 	}
111 	value_t;
112 
113 #define STRING	01		/* string valued */
114 #define BOOL	02		/* true-false value */
115 #define NUMBER	04		/* numeric value */
116 #define CHAR	010		/* character value */
117 
118 #define WRITE	01		/* write access to variable */
119 #define	READ	02		/* read access */
120 
121 #define CHANGED	01		/* low bit is used to show modification */
122 #define PUBLIC	1		/* public access rights */
123 #define PRIVATE	03		/* private to definer */
124 #define ROOT	05		/* root defined */
125 
126 #define	TRUE	1
127 #define FALSE	0
128 
129 #define ENVIRON	020		/* initialize out of the environment */
130 #define IREMOTE	040		/* initialize out of remote structure */
131 #define INIT	0100		/* static data space used for initialization */
132 #define TMASK	017
133 
134 /*
135  * Definition of ACU line description
136  */
137 typedef
138 	struct {
139 		char	*acu_name;
140 		int	(*acu_dialer)(char *, char *);
141 		void	(*acu_disconnect)(void);
142 		void	(*acu_abort)(void);
143 	}
144 	acu_t;
145 
146 #define	equal(a, b)	(strcmp(a,b)==0)/* A nice function to string compare */
147 
148 /*
149  * variable manipulation stuff --
150  *   if we defined the value entry in value_t, then we couldn't
151  *   initialize it in vars.c, so we cast it as needed to keep lint
152  *   happy.
153  */
154 typedef
155 	union {
156 		int	zz_number;
157 		short	zz_boolean[2];
158 		char	zz_character[4];
159 		int	*zz_address;
160 	}
161 	zzhack;
162 
163 #define value(v)	vtable[v].v_value
164 
165 #define number(v)	((((zzhack *)(&(v))))->zz_number)
166 
167 #if BYTE_ORDER == LITTLE_ENDIAN
168 #define boolean(v)	((((zzhack *)(&(v))))->zz_boolean[0])
169 #define character(v)	((((zzhack *)(&(v))))->zz_character[0])
170 #endif
171 
172 #if BYTE_ORDER == BIG_ENDIAN
173 #define boolean(v)	((((zzhack *)(&(v))))->zz_boolean[1])
174 #define character(v)	((((zzhack *)(&(v))))->zz_character[3])
175 #endif
176 
177 #define address(v)	((((zzhack *)(&(v))))->zz_address)
178 
179 /*
180  * Escape command table definitions --
181  *   lookup in this table is performed when ``escapec'' is recognized
182  *   at the begining of a line (as defined by the eolmarks variable).
183 */
184 
185 typedef
186 	struct {
187 		char	e_char;		/* char to match on */
188 		char	e_flags;	/* experimental, priviledged */
189 		char	*e_help;	/* help string */
190 		void 	(*e_func)(int);	/* command */
191 	}
192 	esctable_t;
193 
194 #define NORM	00		/* normal protection, execute anyone */
195 #define EXP	01		/* experimental, mark it with a `*' on help */
196 #define PRIV	02		/* priviledged, root execute only */
197 
198 extern int	vflag;		/* verbose during reading of .tiprc file */
199 extern value_t	vtable[];	/* variable table */
200 
201 void logent(char *, char *, char *, char*);
202 void  loginit(void);
203 
204 /*
205  * Definition of indices into variable table so
206  *  value(DEFINE) turns into a static address.
207  */
208 
209 /*
210 'a,.!awk '{ printf("\%s \%s \%d\n", $1, $2, NR - 1); }'
211 */
212 
213 #define BEAUTIFY 0
214 #define BAUDRATE 1
215 #define DIALTIMEOUT 2
216 #define EOFREAD 3
217 #define EOFWRITE 4
218 #define EOL 5
219 #define ESCAPE 6
220 #define EXCEPTIONS 7
221 #define FORCE 8
222 #define FRAMESIZE 9
223 #define HOST 10
224 #define LOG 11
225 #define LOGIN 12
226 #define LOGOUT 13
227 #define PHONES 14
228 #define PROMPT 15
229 #define RAISE 16
230 #define RAISECHAR 17
231 #define RECORD 18
232 #define REMOTE 19
233 #define SCRIPT 20
234 #define TABEXPAND 21
235 #define VERBOSE 22
236 #define SHELL 23
237 #define HOME 24
238 #define ECHOCHECK 25
239 #define DISCONNECT 26
240 #define TAND 27
241 #define LDELAY 28
242 #define CDELAY 29
243 #define ETIMEOUT 30
244 #define RAWFTP 31
245 #define HALFDUPLEX 32
246 #define LECHO 33
247 #define PARITY 34
248 
249 /*
250 	Specify default bit rate for connections
251 */
252 #define DEFBR 1200
253 
254 struct termios otermios;
255 struct termios ctermios;
256 
257 FILE	*fscript;		/* FILE for scripting */
258 
259 int	fildes[2];		/* file transfer synchronization channel */
260 int	repdes[2];		/* read process sychronization channel */
261 int	FD;			/* open file descriptor to remote host */
262 int	AC;			/* open file descriptor to dialer (v831 only) */
263 int	vflag;			/* print .tiprc initialization sequence */
264 int	sfd;			/* for ~< operation */
265 int	pid;			/* pid of tipout */
266 uid_t	uid, euid;		/* real and effective user id's */
267 gid_t	gid, egid;		/* real and effective group id's */
268 int	stop;			/* stop transfer session flag */
269 int	quit;			/* same; but on other end */
270 int	intflag;		/* recognized interrupt */
271 int	stoprompt;		/* for interrupting a prompt session */
272 int	timedout;		/* ~> transfer timedout */
273 int	cumode;			/* simulating the "cu" program */
274 
275 char	fname[PATH_MAX];	/* file name buffer for ~< */
276 char	copyname[PATH_MAX];	/* file name buffer for ~> */
277 char	ccc;			/* synchronization character */
278 char	ch;			/* for tipout */
279 char	*uucplock;		/* name of lock file for uucp's */
280 
281 int	odisc;				/* initial tty line discipline */
282 extern	int disc;			/* current tty discpline */
283 
284 char	*ctrl(char);
285 char	*vinterp(char *, char);
286 char	*connect(void);
287 int	size(char *);
288 int	any(char, char *);
289 void	setscript(void);
290 void	tipout(void);
291 void	vinit(void);
292 long	hunt(char *);
293 int	vstring(char *, char *);
294 void	setparity(char *);
295 void	vlex(char *);
296 void	daemon_uid(void);
297 void	disconnect(char *);
298 void	shell_uid(void);
299 void	unraw(void);
300 void	user_uid(void);
301 void	xpwrite(int, char *, int);
302 int	prompt(char *, char *, size_t);
303 void	tipabort(char *);
304 void	cumain(int, char **);
305 char	*getremote(char *);
306 char	*interp(char *);
307 
308 void	chdirectory(int);
309 void	cleanup(int);
310 void	consh(int);
311 void	cu_put(int);
312 void	cu_take(int);
313 void	dollar(int);
314 char	*expand(char *);
315 void	finish(int);
316 void	genbrk(int);
317 void	getfl(int);
318 void	help(int);
319 void	pipefile(int);
320 void	pipeout(int);
321 void	sendfile(int);
322 void	shell(int);
323 int	speed(int);
324 void	suspend(int);
325 void	timeoutfunc(int);
326 void	ttysetup(int);
327 void	variable(int);
328 
329 void	biz22_abort(void);
330 int	biz22f_dialer(char *, char *);
331 int	biz22w_dialer(char *, char *);
332 void	biz22_disconnect(void);
333 
334 void	cour_abort(void);
335 int	cour_dialer(char *, char *);
336 void	cour_disconnect(void);
337 
338 void	df_abort(void);
339 int	df02_dialer(char *, char *);
340 int	df03_dialer(char *, char *);
341 void	df_disconnect(void);
342 
343 void	dn_abort(void);
344 int	dn_dialer(char *, char *);
345 void	dn_disconnect(void);
346 
347 void	hay_abort(void);
348 int	hay_dialer(char *, char *);
349 void	hay_disconnect(void);
350 
351 void	multitech_abort(void);
352 int	multitech_dialer(char *, char *);
353 void	multitech_disconnect(void);
354 
355 void	t3000_abort(void);
356 int	t3000_dialer(char *, char *);
357 void	t3000_disconnect(void);
358 
359 acu_t	*unidialer_getmodem(const char *);
360 
361 void	v3451_abort(void);
362 int	v3451_dialer(char *, char *);
363 void	v3451_disconnect(void);
364 
365 void	v831_abort(void);
366 int	v831_dialer(char *, char *);
367 void	v831_disconnect(void);
368 
369 void	ven_abort(void);
370 int	ven_dialer(char *, char *);
371 void	ven_disconnect(void);
372 
373 #define TL_VERBOSE       0x00000001
374 #define TL_SIGNAL_TIPOUT 0x00000002
375 
376 int tiplink(char *cmd, unsigned int flags);
377 void raw(void);
378 
379 /* end of tip.h */
380