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