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