tip.h revision 7527
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
37/*
38 * tip - terminal interface program
39 */
40
41#include <sys/types.h>
42#include <machine/endian.h>
43#include <sys/file.h>
44#include <sys/time.h>
45
46#if HAVE_TERMIOS
47#include <sys/ioctl.h>         /* for TIOCHPCL */
48#include <sys/filio.h>    /* for FIONREAD */
49#include <sys/termios.h>
50#else
51#include <sgtty.h>
52#endif
53
54#include <signal.h>
55#include <stdio.h>
56#include <stdlib.h>
57#include <string.h>
58#include <pwd.h>
59#include <ctype.h>
60#include <setjmp.h>
61#include <unistd.h>
62#include <errno.h>
63
64/*
65 * Remote host attributes
66 */
67char	*DV;			/* UNIX device(s) to open */
68char	*EL;			/* chars marking an EOL */
69char	*CM;			/* initial connection message */
70char	*IE;			/* EOT to expect on input */
71char	*OE;			/* EOT to send to complete FT */
72char	*CU;			/* call unit if making a phone call */
73char	*AT;			/* acu type */
74char	*PN;			/* phone number(s) */
75char	*DI;			/* disconnect string */
76char	*PA;			/* parity to be generated */
77
78char	*PH;			/* phone number file */
79char	*RM;			/* remote file name */
80char	*HO;			/* host name */
81
82char	*LI;			/* login script */
83char	*LO;			/* logout script */
84
85long	BR;			/* line speed for conversation */
86long	FS;			/* frame size for transfers */
87
88char	DU;			/* this host is dialed up */
89char	HW;			/* this device is hardwired, see hunt.c */
90char	*ES;			/* escape character */
91char	*EX;			/* exceptions */
92char	*FO;			/* force (literal next) char*/
93char	*RC;			/* raise character */
94char	*RE;			/* script record file */
95char	*PR;			/* remote prompt */
96long	DL;			/* line delay for file transfers to remote */
97long	CL;			/* char delay for file transfers to remote */
98long	ET;			/* echocheck timeout */
99char	HD;			/* this host is half duplex - do local echo */
100
101/*
102 * String value table
103 */
104typedef
105	struct {
106		char	*v_name;	/* whose name is it */
107		char	v_type;		/* for interpreting set's */
108		char	v_access;	/* protection of touchy ones */
109		char	*v_abrev;	/* possible abreviation */
110		char	*v_value;	/* casted to a union later */
111	}
112	value_t;
113
114#define STRING	01		/* string valued */
115#define BOOL	02		/* true-false value */
116#define NUMBER	04		/* numeric value */
117#define CHAR	010		/* character value */
118
119#define WRITE	01		/* write access to variable */
120#define	READ	02		/* read access */
121
122#define CHANGED	01		/* low bit is used to show modification */
123#define PUBLIC	1		/* public access rights */
124#define PRIVATE	03		/* private to definer */
125#define ROOT	05		/* root defined */
126
127#define	TRUE	1
128#define FALSE	0
129
130#define ENVIRON	020		/* initialize out of the environment */
131#define IREMOTE	040		/* initialize out of remote structure */
132#define INIT	0100		/* static data space used for initialization */
133#define TMASK	017
134
135/*
136 * Definition of ACU line description
137 */
138typedef
139	struct {
140		char	*acu_name;
141		int	(*acu_dialer)();
142		void	(*acu_disconnect)();
143		void	(*acu_abort)();
144	}
145	acu_t;
146
147#define	equal(a, b)	(strcmp(a,b)==0)/* A nice function to string compare */
148
149/*
150 * variable manipulation stuff --
151 *   if we defined the value entry in value_t, then we couldn't
152 *   initialize it in vars.c, so we cast it as needed to keep lint
153 *   happy.
154 */
155typedef
156	union {
157		int	zz_number;
158		short	zz_boolean[2];
159		char	zz_character[4];
160		int	*zz_address;
161	}
162	zzhack;
163
164#define value(v)	vtable[v].v_value
165
166#define number(v)	((((zzhack *)(&(v))))->zz_number)
167
168#if BYTE_ORDER == LITTLE_ENDIAN
169#define boolean(v)	((((zzhack *)(&(v))))->zz_boolean[0])
170#define character(v)	((((zzhack *)(&(v))))->zz_character[0])
171#endif
172
173#if BYTE_ORDER == BIG_ENDIAN
174#define boolean(v)	((((zzhack *)(&(v))))->zz_boolean[1])
175#define character(v)	((((zzhack *)(&(v))))->zz_character[3])
176#endif
177
178#define address(v)	((((zzhack *)(&(v))))->zz_address)
179
180/*
181 * Escape command table definitions --
182 *   lookup in this table is performed when ``escapec'' is recognized
183 *   at the begining of a line (as defined by the eolmarks variable).
184*/
185
186typedef
187	struct {
188		char	e_char;		/* char to match on */
189		char	e_flags;	/* experimental, priviledged */
190		char	*e_help;	/* help string */
191		int 	(*e_func)();	/* command */
192	}
193	esctable_t;
194
195#define NORM	00		/* normal protection, execute anyone */
196#define EXP	01		/* experimental, mark it with a `*' on help */
197#define PRIV	02		/* priviledged, root execute only */
198
199extern int	vflag;		/* verbose during reading of .tiprc file */
200extern value_t	vtable[];	/* variable table */
201
202#if !ACULOG
203#define logent(a, b, c, d)
204#define loginit()
205#endif
206
207/*
208 * Definition of indices into variable table so
209 *  value(DEFINE) turns into a static address.
210 */
211
212/*
213'a,.!awk '{ printf("\%s \%s \%d\n", $1, $2, NR - 1); }'
214*/
215
216#define BEAUTIFY 0
217#define BAUDRATE 1
218#define DIALTIMEOUT 2
219#define EOFREAD 3
220#define EOFWRITE 4
221#define EOL 5
222#define ESCAPE 6
223#define EXCEPTIONS 7
224#define FORCE 8
225#define FRAMESIZE 9
226#define HOST 10
227#define LOG 11
228#define LOGIN 12
229#define LOGOUT 13
230#define PHONES 14
231#define PROMPT 15
232#define RAISE 16
233#define RAISECHAR 17
234#define RECORD 18
235#define REMOTE 19
236#define SCRIPT 20
237#define TABEXPAND 21
238#define VERBOSE 22
239#define SHELL 23
240#define HOME 24
241#define ECHOCHECK 25
242#define DISCONNECT 26
243#define TAND 27
244#define LDELAY 28
245#define CDELAY 29
246#define ETIMEOUT 30
247#define RAWFTP 31
248#define HALFDUPLEX 32
249#define LECHO 33
250#define PARITY 34
251#define NOVAL	((value_t *)NULL)
252#define NOACU	((acu_t *)NULL)
253#define NOSTR	((char *)NULL)
254#define NOFILE	((FILE *)NULL)
255#define NOPWD	((struct passwd *)0)
256
257#if HAVE_TERMIOS
258struct termios otermios;
259struct termios ctermios;
260#else /* HAVE_TERMIOS */
261struct sgttyb	arg;		/* current mode of local terminal */
262struct sgttyb	defarg;		/* initial mode of local terminal */
263struct tchars	tchars;		/* current state of terminal */
264struct tchars	defchars;	/* initial state of terminal */
265struct ltchars	ltchars;	/* current local characters of terminal */
266struct ltchars	deflchars;	/* initial local characters of terminal */
267#endif /* HAVE_TERMIOS */
268
269FILE	*fscript;		/* FILE for scripting */
270
271int	fildes[2];		/* file transfer synchronization channel */
272int	repdes[2];		/* read process sychronization channel */
273int	FD;			/* open file descriptor to remote host */
274int	AC;			/* open file descriptor to dialer (v831 only) */
275int	vflag;			/* print .tiprc initialization sequence */
276int	sfd;			/* for ~< operation */
277int	pid;			/* pid of tipout */
278uid_t	uid, euid;		/* real and effective user id's */
279gid_t	gid, egid;		/* real and effective group id's */
280int	stop;			/* stop transfer session flag */
281int	quit;			/* same; but on other end */
282int	intflag;		/* recognized interrupt */
283int	stoprompt;		/* for interrupting a prompt session */
284int	timedout;		/* ~> transfer timedout */
285int	cumode;			/* simulating the "cu" program */
286
287char	fname[80];		/* file name buffer for ~< */
288char	copyname[80];		/* file name buffer for ~> */
289char	ccc;			/* synchronization character */
290char	ch;			/* for tipout */
291char	*uucplock;		/* name of lock file for uucp's */
292
293int	odisc;				/* initial tty line discipline */
294extern	int disc;			/* current tty discpline */
295
296extern	char *ctrl();
297extern	char *vinterp();
298extern	char *connect();
299
300int	tipabort	__P((char *));
301
302#define TL_VERBOSE       0x00000001
303#define TL_SIGNAL_TIPOUT 0x00000002
304
305int tiplink (char *cmd, unsigned int flags);
306void raw ();
307
308/* end of tip.h */
309