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