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