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