tip.h revision 28365
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#else
206void logent __P((char *, char *, char *, char*));
207#endif
208
209/*
210 * Definition of indices into variable table so
211 *  value(DEFINE) turns into a static address.
212 */
213
214/*
215'a,.!awk '{ printf("\%s \%s \%d\n", $1, $2, NR - 1); }'
216*/
217
218#define BEAUTIFY 0
219#define BAUDRATE 1
220#define DIALTIMEOUT 2
221#define EOFREAD 3
222#define EOFWRITE 4
223#define EOL 5
224#define ESCAPE 6
225#define EXCEPTIONS 7
226#define FORCE 8
227#define FRAMESIZE 9
228#define HOST 10
229#define LOG 11
230#define LOGIN 12
231#define LOGOUT 13
232#define PHONES 14
233#define PROMPT 15
234#define RAISE 16
235#define RAISECHAR 17
236#define RECORD 18
237#define REMOTE 19
238#define SCRIPT 20
239#define TABEXPAND 21
240#define VERBOSE 22
241#define SHELL 23
242#define HOME 24
243#define ECHOCHECK 25
244#define DISCONNECT 26
245#define TAND 27
246#define LDELAY 28
247#define CDELAY 29
248#define ETIMEOUT 30
249#define RAWFTP 31
250#define HALFDUPLEX 32
251#define LECHO 33
252#define PARITY 34
253#define NOVAL	((value_t *)NULL)
254#define NOACU	((acu_t *)NULL)
255#define NOSTR	((char *)NULL)
256#define NOFILE	((FILE *)NULL)
257#define NOPWD	((struct passwd *)0)
258
259#if HAVE_TERMIOS
260struct termios otermios;
261struct termios ctermios;
262#else /* HAVE_TERMIOS */
263struct sgttyb	arg;		/* current mode of local terminal */
264struct sgttyb	defarg;		/* initial mode of local terminal */
265struct tchars	tchars;		/* current state of terminal */
266struct tchars	defchars;	/* initial state of terminal */
267struct ltchars	ltchars;	/* current local characters of terminal */
268struct ltchars	deflchars;	/* initial local characters of terminal */
269#endif /* HAVE_TERMIOS */
270
271FILE	*fscript;		/* FILE for scripting */
272
273int	fildes[2];		/* file transfer synchronization channel */
274int	repdes[2];		/* read process sychronization channel */
275int	FD;			/* open file descriptor to remote host */
276int	AC;			/* open file descriptor to dialer (v831 only) */
277int	vflag;			/* print .tiprc initialization sequence */
278int	sfd;			/* for ~< operation */
279int	pid;			/* pid of tipout */
280uid_t	uid, euid;		/* real and effective user id's */
281gid_t	gid, egid;		/* real and effective group id's */
282int	stop;			/* stop transfer session flag */
283int	quit;			/* same; but on other end */
284int	intflag;		/* recognized interrupt */
285int	stoprompt;		/* for interrupting a prompt session */
286int	timedout;		/* ~> transfer timedout */
287int	cumode;			/* simulating the "cu" program */
288
289char	fname[80];		/* file name buffer for ~< */
290char	copyname[80];		/* file name buffer for ~> */
291char	ccc;			/* synchronization character */
292char	ch;			/* for tipout */
293char	*uucplock;		/* name of lock file for uucp's */
294
295int	odisc;				/* initial tty line discipline */
296extern	int disc;			/* current tty discpline */
297
298extern	char *ctrl();
299extern	char *vinterp();
300extern	char *connect();
301extern	int   size __P((char *));
302extern	int   any __P((char, char *));
303extern	void  setscript __P((void));
304extern	void  tipout __P((void));
305extern	void  vinit __P((void));
306extern	void  loginit __P((void));
307extern	int   hunt __P((char *));
308extern	int vstring __P((char *, char *));
309extern	void setparity __P((char *));
310extern	void vlex __P((char *));
311extern	void daemon_uid __P((void));
312extern	void disconnect __P((char *));
313extern	void shell_uid __P((void));
314extern	void unraw __P((void));
315extern	void pwrite __P((int, char *, int));
316extern	int prompt __P((char *, char *));
317extern	void  consh __P((int));
318extern	void tipabort __P((char *));
319
320#define TL_VERBOSE       0x00000001
321#define TL_SIGNAL_TIPOUT 0x00000002
322
323int tiplink (char *cmd, unsigned int flags);
324void raw ();
325
326/* end of tip.h */
327