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