xref: /csrg-svn/usr.bin/tip/tip.h (revision 3697)
1*3697Sroot /*	tip.h	4.1	81/05/09	*/
2*3697Sroot /*
3*3697Sroot  * tip - terminal interface program
4*3697Sroot  *
5*3697Sroot  * Samuel J. Leffler
6*3697Sroot  */
7*3697Sroot 
8*3697Sroot #include <sgtty.h>
9*3697Sroot #include <signal.h>
10*3697Sroot #include <stdio.h>
11*3697Sroot #include <pwd.h>
12*3697Sroot #include <sys/types.h>
13*3697Sroot 
14*3697Sroot /*
15*3697Sroot  * Remote host attributes
16*3697Sroot  */
17*3697Sroot char	*DV;			/* UNIX device(s) to open */
18*3697Sroot char	*EL;			/* chars marking an EOL */
19*3697Sroot char	*CM;			/* initial connection message */
20*3697Sroot char	*IE;			/* EOT to expect on input */
21*3697Sroot char	*OE;			/* EOT to send to complete FT */
22*3697Sroot char	*CU;			/* call unit if making a phone call */
23*3697Sroot char	*AT;			/* acu type */
24*3697Sroot char	*PN;			/* phone number(s) */
25*3697Sroot 
26*3697Sroot char	*PH;			/* phone number file */
27*3697Sroot char	*RM;			/* remote file name */
28*3697Sroot char	*HO;			/* host name */
29*3697Sroot 
30*3697Sroot int	BR;			/* line speed for conversation */
31*3697Sroot int	FS;			/* frame size for transfers */
32*3697Sroot 
33*3697Sroot char	DU;			/* this host is dialed up */
34*3697Sroot 
35*3697Sroot /*
36*3697Sroot  * String value table
37*3697Sroot  */
38*3697Sroot typedef
39*3697Sroot 	struct {
40*3697Sroot 		char	*v_name;	/* whose name is it */
41*3697Sroot 		char	v_type;		/* for interpreting set's */
42*3697Sroot 		char	v_access;	/* protection of touchy ones */
43*3697Sroot 		char	*v_abrev;	/* possible abreviation */
44*3697Sroot 		char	*v_value;	/* casted to a union later */
45*3697Sroot 	}
46*3697Sroot 	value_t;
47*3697Sroot 
48*3697Sroot #define STRING	01		/* string valued */
49*3697Sroot #define BOOL	02		/* true-false value */
50*3697Sroot #define NUMBER	04		/* numeric value */
51*3697Sroot #define CHAR	010		/* character value */
52*3697Sroot 
53*3697Sroot #define WRITE	01		/* write access to variable */
54*3697Sroot #define	READ	02		/* read access */
55*3697Sroot 
56*3697Sroot #define CHANGED	01		/* low bit is used to show modification */
57*3697Sroot #define PUBLIC	1		/* public access rights */
58*3697Sroot #define PRIVATE	03		/* private to definer */
59*3697Sroot #define ROOT	05		/* root defined */
60*3697Sroot 
61*3697Sroot #define	TRUE	1
62*3697Sroot #define FALSE	0
63*3697Sroot 
64*3697Sroot #define ENVIRON	020		/* initialize out of the environment */
65*3697Sroot #define IREMOTE	040		/* initialize out of remote structure */
66*3697Sroot #define INIT	0100		/* static data space used for initialization */
67*3697Sroot #define TMASK	017
68*3697Sroot 
69*3697Sroot /*
70*3697Sroot  * Definition of ACU line description
71*3697Sroot  */
72*3697Sroot typedef
73*3697Sroot 	struct {
74*3697Sroot 		char	*acu_name;
75*3697Sroot 		int	(*acu_dialer)();
76*3697Sroot 		int	(*acu_disconnect)();
77*3697Sroot 		int	(*acu_abort)();
78*3697Sroot 	}
79*3697Sroot 	acu_t;
80*3697Sroot 
81*3697Sroot #define	equal(a, b)	(strcmp(a,b)==0)/* A nice function to string compare */
82*3697Sroot #define islower(c)	((c)>='a'&&(c)<='z')
83*3697Sroot #define toupper(c)	(c)-=('a'-'A')
84*3697Sroot #define isnum(c)	((c)>='0'&&(c)<= '9')
85*3697Sroot #define CTRL(c)		('c'&037)
86*3697Sroot 
87*3697Sroot /*
88*3697Sroot  * variable manipulation stuff --
89*3697Sroot  *   if we defined the value entry in value_t, then we couldn't
90*3697Sroot  *   initialize it in vars.c, so we cast it as needed to keep lint
91*3697Sroot  *   happy.
92*3697Sroot  */
93*3697Sroot typedef
94*3697Sroot 	union {
95*3697Sroot 		int	zz_number;
96*3697Sroot 		short	zz_boolean;
97*3697Sroot 		char	zz_character;
98*3697Sroot 		int	*zz_address;
99*3697Sroot 	}
100*3697Sroot 	zzhack;
101*3697Sroot 
102*3697Sroot #define value(v)	vtable[v].v_value
103*3697Sroot 
104*3697Sroot #define boolean(v)	((((zzhack *)(&(v))))->zz_boolean)
105*3697Sroot #define number(v)	((((zzhack *)(&(v))))->zz_number)
106*3697Sroot #define character(v)	((((zzhack *)(&(v))))->zz_character)
107*3697Sroot #define address(v)	((((zzhack *)(&(v))))->zz_address)
108*3697Sroot 
109*3697Sroot /*
110*3697Sroot  * Escape command table definitions --
111*3697Sroot  *   lookup in this table is performed when ``escapec'' is recognized
112*3697Sroot  *   at the begining of a line (as defined by the eolmarks variable).
113*3697Sroot */
114*3697Sroot 
115*3697Sroot typedef
116*3697Sroot 	struct {
117*3697Sroot 		char	e_char;		/* char to match on */
118*3697Sroot 		char	e_flags;	/* experimental, priviledged */
119*3697Sroot 		char	*e_help;	/* help string */
120*3697Sroot 		int 	(*e_func)();	/* command */
121*3697Sroot 	}
122*3697Sroot 	esctable_t;
123*3697Sroot 
124*3697Sroot #define NORM	00		/* normal protection, execute anyone */
125*3697Sroot #define EXP	01		/* experimental, mark it with a `*' on help */
126*3697Sroot #define PRIV	02		/* priviledged, root execute only */
127*3697Sroot 
128*3697Sroot extern int	vflag;		/* verbose during reading of .tiprc file */
129*3697Sroot extern value_t	vtable[];	/* variable table */
130*3697Sroot 
131*3697Sroot #ifndef ACULOG
132*3697Sroot #define logent(a, b, c, d)
133*3697Sroot #define loginit()
134*3697Sroot #endif
135*3697Sroot 
136*3697Sroot /*
137*3697Sroot  * Definition of indices into variable table so
138*3697Sroot  *  value(DEFINE) turns into a static address.
139*3697Sroot  */
140*3697Sroot 
141*3697Sroot #define BEAUTIFY	0
142*3697Sroot #define BAUDRATE	1
143*3697Sroot #define DIALTIMEOUT	2
144*3697Sroot #define EOFREAD		3
145*3697Sroot #define EOFWRITE	4
146*3697Sroot #define EOL		5
147*3697Sroot #define ESCAPE		6
148*3697Sroot #define EXCEPTIONS	7
149*3697Sroot #define FORCE		8
150*3697Sroot #define FRAMESIZE	9
151*3697Sroot #define HOST		10
152*3697Sroot #if ACULOG
153*3697Sroot #define LOCK		11
154*3697Sroot #define LOG		12
155*3697Sroot #define PHONES		13
156*3697Sroot #define PROMPT		14
157*3697Sroot #define RAISE		15
158*3697Sroot #define RAISECHAR	16
159*3697Sroot #define RECORD		17
160*3697Sroot #define REMOTE		18
161*3697Sroot #define SCRIPT		19
162*3697Sroot #define TABEXPAND	20
163*3697Sroot #define VERBOSE		21
164*3697Sroot #define SHELL		22
165*3697Sroot #define HOME		23
166*3697Sroot #else
167*3697Sroot #define PHONES		11
168*3697Sroot #define PROMPT		12
169*3697Sroot #define RAISE		13
170*3697Sroot #define RAISECHAR	14
171*3697Sroot #define RECORD		15
172*3697Sroot #define REMOTE		16
173*3697Sroot #define SCRIPT		17
174*3697Sroot #define TABEXPAND	18
175*3697Sroot #define VERBOSE		19
176*3697Sroot #define SHELL		20
177*3697Sroot #define HOME		21
178*3697Sroot #endif
179*3697Sroot 
180*3697Sroot #define NOVAL	((value_t *)NULL)
181*3697Sroot #define NOACU	((acu_t *)NULL)
182*3697Sroot #define NOSTR	((char *)NULL)
183*3697Sroot #define NOFILE	((FILE *)NULL)
184*3697Sroot #define NOPWD	((struct passwd *)0)
185*3697Sroot 
186*3697Sroot struct sgttyb	arg;		/* current mode of local terminal */
187*3697Sroot struct sgttyb	defarg;		/* initial mode of local terminal */
188*3697Sroot struct tchars	tchars;		/* current state of terminal */
189*3697Sroot struct tchars	defchars;	/* initial state of terminal */
190*3697Sroot 
191*3697Sroot FILE	*fscript;		/* FILE for scripting */
192*3697Sroot 
193*3697Sroot int	fildes[2];		/* file transfer synchronization channel */
194*3697Sroot int	repdes[2];		/* read process sychronization channel */
195*3697Sroot int	FD;			/* open file descriptor to remote host */
196*3697Sroot int	vflag;			/* print .tiprc initialization sequence */
197*3697Sroot int	sfd;			/* for ~< operation */
198*3697Sroot int	pid;			/* pid of tipout */
199*3697Sroot int	stop;			/* stop transfer session flag */
200*3697Sroot int	quit;			/* same; but on other end */
201*3697Sroot int	intflag;		/* recognized interrupt */
202*3697Sroot int	stoprompt;		/* for interrupting a prompt session */
203*3697Sroot int	timedout;		/* ~> transfer timedout */
204*3697Sroot 
205*3697Sroot char	fname[80];		/* file name buffer for ~< */
206*3697Sroot char	copyname[80];		/* file name buffer for ~> */
207*3697Sroot char	ccc;			/* synchronization character */
208*3697Sroot char	ch;			/* for tipout */
209*3697Sroot char	*uucplock;		/* name of lock file for uucp's */
210*3697Sroot 
211*3697Sroot /*
212*3697Sroot  * From <sys/tty.h> (PDP-11 V7) ... it's put in here to avoid lots
213*3697Sroot  *  of naming conflicts with stuff we have to pull in to use tty.h
214*3697Sroot  */
215*3697Sroot #ifndef TIOCFLUSH
216*3697Sroot #	define TIOCFLUSH	(('t'<<8)|16)
217*3697Sroot #endif
218*3697Sroot 
219*3697Sroot /*
220*3697Sroot  * On PDP-11 V7 systems with Rand's capacity call use this
221*3697Sroot  *  stuff, otherwise <assuming it's a VM system> use FIONREAD
222*3697Sroot  */
223*3697Sroot #ifndef FIONREAD
224*3697Sroot #define	FIOCAPACITY	(('f'<<8)|3)
225*3697Sroot 
226*3697Sroot struct capacity {
227*3697Sroot 	off_t	cp_nbytes;
228*3697Sroot 	char	cp_eof;
229*3697Sroot };
230*3697Sroot #endif
231*3697Sroot 
232*3697Sroot #ifdef VMUNIX
233*3697Sroot int	odisc;				/* initial tty line discipline */
234*3697Sroot #endif
235*3697Sroot 
236*3697Sroot extern char		*ctrl();
237*3697Sroot extern char		*ctime();
238*3697Sroot extern long		time();
239*3697Sroot extern struct passwd 	*getpwuid();
240*3697Sroot extern char		*getlogin();
241*3697Sroot extern char		*vinterp();
242*3697Sroot extern char		*getenv();
243*3697Sroot extern char		*rindex();
244*3697Sroot extern char		*index();
245*3697Sroot extern char		*malloc();
246*3697Sroot extern char		*connect();
247