xref: /dragonfly/usr.bin/tip/tip.h (revision 97edc4fd)
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. Neither the name of the University nor the names of its contributors
15  *    may be used to endorse or promote products derived from this software
16  *    without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  *      @(#)tip.h	8.1 (Berkeley) 6/6/93
31  *
32  * $FreeBSD: src/usr.bin/tip/tip/tip.h,v 1.5.2.1 2000/07/01 12:24:23 ps Exp $
33  */
34 
35 /*
36  * tip - terminal interface program
37  */
38 
39 #include <sys/types.h>
40 #include <machine/endian.h>
41 #include <sys/time.h>
42 #include <limits.h>
43 
44 #include <sys/ioctl.h>         /* for TIOCHPCL */
45 #include <sys/filio.h>    /* for FIONREAD */
46 
47 #include <fcntl.h>
48 #include <signal.h>
49 #include <stdio.h>
50 #include <stdlib.h>
51 #include <string.h>
52 #include <pwd.h>
53 #include <ctype.h>
54 #include <setjmp.h>
55 #include <termios.h>
56 #include <unistd.h>
57 #include <errno.h>
58 
59 #ifndef EXTERN
60 #define	EXTERN	extern
61 #endif
62 
63 /*
64  * Remote host attributes
65  */
66 EXTERN char	*DV;		/* UNIX device(s) to open */
67 EXTERN char	*EL;		/* chars marking an EOL */
68 EXTERN char	*CM;		/* initial connection message */
69 EXTERN char	*IE;		/* EOT to expect on input */
70 EXTERN char	*OE;		/* EOT to send to complete FT */
71 EXTERN char	*CU;		/* call unit if making a phone call */
72 EXTERN char	*AT;		/* acu type */
73 EXTERN char	*PN;		/* phone number(s) */
74 EXTERN char	*DI;		/* disconnect string */
75 EXTERN char	*PA;		/* parity to be generated */
76 
77 EXTERN char	*PH;		/* phone number file */
78 EXTERN char	*RM;		/* remote file name */
79 EXTERN char	*HO;		/* host name */
80 
81 EXTERN char	*LI;		/* login script */
82 EXTERN char	*LO;		/* logout script */
83 
84 EXTERN long	BR;		/* line speed for conversation */
85 EXTERN long	FS;		/* frame size for transfers */
86 
87 EXTERN char	DU;		/* this host is dialed up */
88 EXTERN char	HW;		/* this device is hardwired, see hunt.c */
89 EXTERN char	*ES;		/* escape character */
90 EXTERN char	*EX;		/* exceptions */
91 EXTERN char	*FO;		/* force (literal next) char*/
92 EXTERN char	*RC;		/* raise character */
93 EXTERN char	*RE;		/* script record file */
94 EXTERN char	*PR;		/* remote prompt */
95 EXTERN long	DL;		/* line delay for file transfers to remote */
96 EXTERN long	CL;		/* char delay for file transfers to remote */
97 EXTERN long	ET;		/* echocheck timeout */
98 EXTERN 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 value_t	vtable[];	/* variable table */
199 
200 void logent(char *, char *, char *, char*);
201 void  loginit(void);
202 
203 /*
204  * Definition of indices into variable table so
205  *  value(DEFINE) turns into a static address.
206  */
207 
208 /*
209 'a,.!awk '{ printf("\%s \%s \%d\n", $1, $2, NR - 1); }'
210 */
211 
212 #define BEAUTIFY 0
213 #define BAUDRATE 1
214 #define DIALTIMEOUT 2
215 #define EOFREAD 3
216 #define EOFWRITE 4
217 #define EOL 5
218 #define ESCAPE 6
219 #define EXCEPTIONS 7
220 #define FORCE 8
221 #define FRAMESIZE 9
222 #define HOST 10
223 #define LOG 11
224 #define LOGIN 12
225 #define LOGOUT 13
226 #define PHONES 14
227 #define PROMPT 15
228 #define RAISE 16
229 #define RAISECHAR 17
230 #define RECORD 18
231 #define REMOTE 19
232 #define SCRIPT 20
233 #define TABEXPAND 21
234 #define VERBOSE 22
235 #define SHELL 23
236 #define HOME 24
237 #define ECHOCHECK 25
238 #define DISCONNECT 26
239 #define TAND 27
240 #define LDELAY 28
241 #define CDELAY 29
242 #define ETIMEOUT 30
243 #define RAWFTP 31
244 #define HALFDUPLEX 32
245 #define LECHO 33
246 #define PARITY 34
247 
248 /*
249 	Specify default bit rate for connections
250 */
251 #define DEFBR 1200
252 
253 EXTERN struct termios otermios;
254 EXTERN struct termios ctermios;
255 
256 EXTERN FILE	*fscript;	/* FILE for scripting */
257 
258 EXTERN int	fildes[2];	/* file transfer synchronization channel */
259 EXTERN int	repdes[2];	/* read process sychronization channel */
260 EXTERN int	FD;		/* open file descriptor to remote host */
261 EXTERN int	AC;		/* open file descriptor to dialer (v831 only) */
262 EXTERN int	vflag;		/* print .tiprc initialization sequence */
263 EXTERN int	sfd;		/* for ~< operation */
264 EXTERN int	pid;		/* pid of tipout */
265 EXTERN uid_t	uid, euid;	/* real and effective user id's */
266 EXTERN gid_t	gid, egid;	/* real and effective group id's */
267 EXTERN int	stop;		/* stop transfer session flag */
268 EXTERN int	quit;		/* same; but on other end */
269 EXTERN int	intflag;	/* recognized interrupt */
270 EXTERN int	stoprompt;	/* for interrupting a prompt session */
271 EXTERN int	timedout;	/* ~> transfer timedout */
272 EXTERN int	cumode;		/* simulating the "cu" program */
273 
274 EXTERN char	fname[PATH_MAX]; /* file name buffer for ~< */
275 EXTERN char	copyname[PATH_MAX]; /* file name buffer for ~> */
276 EXTERN char	ccc;		/* synchronization character */
277 EXTERN char	ch;		/* for tipout */
278 EXTERN char	*uucplock;	/* name of lock file for uucp's */
279 
280 EXTERN int	odisc;			/* initial tty line discipline */
281 extern	int disc;			/* current tty discpline */
282 
283 char	*ctrl(char);
284 char	*vinterp(char *, char);
285 char	*connect(void);
286 int	size(char *);
287 int	any(char, char *);
288 void	setscript(void);
289 void	tipout(void) __dead2;
290 void	vinit(void);
291 long	hunt(char *);
292 int	vstring(char *, char *);
293 void	setparity(char *);
294 void	vlex(char *);
295 void	daemon_uid(void);
296 void	disconnect(char *);
297 void	shell_uid(void);
298 void	unraw(void);
299 void	user_uid(void);
300 void	xpwrite(int, char *, int);
301 int	prompt(char *, char *, size_t);
302 void	tipabort(char *) __dead2;
303 void	cumain(int, char **) __dead2;
304 char	*getremote(char *);
305 char	*interp(char *);
306 
307 void	chdirectory(int);
308 void	cleanup(int) __dead2;
309 void	consh(int);
310 void	cu_put(int);
311 void	cu_take(int);
312 void	dollar(int);
313 char	*expand(char *);
314 void	finish(int) __dead2;
315 void	genbrk(int);
316 void	getfl(int);
317 void	help(int);
318 void	pipefile(int);
319 void	pipeout(int);
320 void	sendfile(int);
321 void	shell(int);
322 int	speed(int);
323 void	suspend(int);
324 void	timeoutfunc(int);
325 void	ttysetup(int);
326 void	variable(int);
327 
328 void	biz22_abort(void);
329 int	biz22f_dialer(char *, char *);
330 int	biz22w_dialer(char *, char *);
331 void	biz22_disconnect(void);
332 
333 void	cour_abort(void);
334 int	cour_dialer(char *, char *);
335 void	cour_disconnect(void);
336 
337 void	df_abort(void);
338 int	df02_dialer(char *, char *);
339 int	df03_dialer(char *, char *);
340 void	df_disconnect(void);
341 
342 void	dn_abort(void);
343 int	dn_dialer(char *, char *);
344 void	dn_disconnect(void);
345 
346 void	hay_abort(void);
347 int	hay_dialer(char *, char *);
348 void	hay_disconnect(void);
349 
350 void	multitech_abort(void);
351 int	multitech_dialer(char *, char *);
352 void	multitech_disconnect(void);
353 
354 void	t3000_abort(void);
355 int	t3000_dialer(char *, char *);
356 void	t3000_disconnect(void);
357 
358 acu_t	*unidialer_getmodem(const char *);
359 
360 void	v3451_abort(void);
361 int	v3451_dialer(char *, char *);
362 void	v3451_disconnect(void);
363 
364 void	v831_abort(void);
365 int	v831_dialer(char *, char *);
366 void	v831_disconnect(void);
367 
368 void	ven_abort(void);
369 int	ven_dialer(char *, char *);
370 void	ven_disconnect(void);
371 
372 #define TL_VERBOSE       0x00000001
373 #define TL_SIGNAL_TIPOUT 0x00000002
374 
375 int tiplink(char *cmd, unsigned int flags);
376 void raw(void);
377 
378 /* end of tip.h */
379