tip.h revision 1.3 1 1.3 jtc /* $NetBSD: tip.h,v 1.3 1994/12/08 09:31:10 jtc Exp $ */
2 1.3 jtc
3 1.1 cgd /*
4 1.3 jtc * Copyright (c) 1989, 1993
5 1.3 jtc * The Regents of the University of California. All rights reserved.
6 1.3 jtc *
7 1.1 cgd *
8 1.1 cgd * Redistribution and use in source and binary forms, with or without
9 1.1 cgd * modification, are permitted provided that the following conditions
10 1.1 cgd * are met:
11 1.1 cgd * 1. Redistributions of source code must retain the above copyright
12 1.1 cgd * notice, this list of conditions and the following disclaimer.
13 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 cgd * notice, this list of conditions and the following disclaimer in the
15 1.1 cgd * documentation and/or other materials provided with the distribution.
16 1.1 cgd * 3. All advertising materials mentioning features or use of this software
17 1.1 cgd * must display the following acknowledgement:
18 1.1 cgd * This product includes software developed by the University of
19 1.1 cgd * California, Berkeley and its contributors.
20 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
21 1.1 cgd * may be used to endorse or promote products derived from this software
22 1.1 cgd * without specific prior written permission.
23 1.1 cgd *
24 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 1.1 cgd * SUCH DAMAGE.
35 1.1 cgd *
36 1.3 jtc * @(#)tip.h 8.1 (Berkeley) 6/6/93
37 1.1 cgd */
38 1.1 cgd
39 1.1 cgd /*
40 1.1 cgd * tip - terminal interface program
41 1.1 cgd */
42 1.1 cgd
43 1.1 cgd #include <sys/types.h>
44 1.1 cgd #include <machine/endian.h>
45 1.1 cgd #include <sys/file.h>
46 1.1 cgd #include <sys/time.h>
47 1.1 cgd
48 1.1 cgd #include <sgtty.h>
49 1.1 cgd #include <signal.h>
50 1.1 cgd #include <stdio.h>
51 1.1 cgd #include <stdlib.h>
52 1.1 cgd #include <string.h>
53 1.1 cgd #include <pwd.h>
54 1.1 cgd #include <ctype.h>
55 1.1 cgd #include <setjmp.h>
56 1.1 cgd #include <unistd.h>
57 1.1 cgd #include <errno.h>
58 1.1 cgd
59 1.1 cgd /*
60 1.1 cgd * Remote host attributes
61 1.1 cgd */
62 1.1 cgd char *DV; /* UNIX device(s) to open */
63 1.1 cgd char *EL; /* chars marking an EOL */
64 1.1 cgd char *CM; /* initial connection message */
65 1.1 cgd char *IE; /* EOT to expect on input */
66 1.1 cgd char *OE; /* EOT to send to complete FT */
67 1.1 cgd char *CU; /* call unit if making a phone call */
68 1.1 cgd char *AT; /* acu type */
69 1.1 cgd char *PN; /* phone number(s) */
70 1.1 cgd char *DI; /* disconnect string */
71 1.1 cgd char *PA; /* parity to be generated */
72 1.1 cgd
73 1.1 cgd char *PH; /* phone number file */
74 1.1 cgd char *RM; /* remote file name */
75 1.1 cgd char *HO; /* host name */
76 1.1 cgd
77 1.3 jtc long BR; /* line speed for conversation */
78 1.3 jtc long FS; /* frame size for transfers */
79 1.1 cgd
80 1.1 cgd char DU; /* this host is dialed up */
81 1.1 cgd char HW; /* this device is hardwired, see hunt.c */
82 1.1 cgd char *ES; /* escape character */
83 1.1 cgd char *EX; /* exceptions */
84 1.1 cgd char *FO; /* force (literal next) char*/
85 1.1 cgd char *RC; /* raise character */
86 1.1 cgd char *RE; /* script record file */
87 1.1 cgd char *PR; /* remote prompt */
88 1.3 jtc long DL; /* line delay for file transfers to remote */
89 1.3 jtc long CL; /* char delay for file transfers to remote */
90 1.3 jtc long ET; /* echocheck timeout */
91 1.1 cgd char HD; /* this host is half duplex - do local echo */
92 1.1 cgd
93 1.1 cgd /*
94 1.1 cgd * String value table
95 1.1 cgd */
96 1.1 cgd typedef
97 1.1 cgd struct {
98 1.1 cgd char *v_name; /* whose name is it */
99 1.1 cgd char v_type; /* for interpreting set's */
100 1.1 cgd char v_access; /* protection of touchy ones */
101 1.1 cgd char *v_abrev; /* possible abreviation */
102 1.1 cgd char *v_value; /* casted to a union later */
103 1.1 cgd }
104 1.1 cgd value_t;
105 1.1 cgd
106 1.1 cgd #define STRING 01 /* string valued */
107 1.1 cgd #define BOOL 02 /* true-false value */
108 1.1 cgd #define NUMBER 04 /* numeric value */
109 1.1 cgd #define CHAR 010 /* character value */
110 1.1 cgd
111 1.1 cgd #define WRITE 01 /* write access to variable */
112 1.1 cgd #define READ 02 /* read access */
113 1.1 cgd
114 1.1 cgd #define CHANGED 01 /* low bit is used to show modification */
115 1.1 cgd #define PUBLIC 1 /* public access rights */
116 1.1 cgd #define PRIVATE 03 /* private to definer */
117 1.1 cgd #define ROOT 05 /* root defined */
118 1.1 cgd
119 1.1 cgd #define TRUE 1
120 1.1 cgd #define FALSE 0
121 1.1 cgd
122 1.1 cgd #define ENVIRON 020 /* initialize out of the environment */
123 1.1 cgd #define IREMOTE 040 /* initialize out of remote structure */
124 1.1 cgd #define INIT 0100 /* static data space used for initialization */
125 1.1 cgd #define TMASK 017
126 1.1 cgd
127 1.1 cgd /*
128 1.1 cgd * Definition of ACU line description
129 1.1 cgd */
130 1.1 cgd typedef
131 1.1 cgd struct {
132 1.1 cgd char *acu_name;
133 1.1 cgd int (*acu_dialer)();
134 1.1 cgd int (*acu_disconnect)();
135 1.1 cgd int (*acu_abort)();
136 1.1 cgd }
137 1.1 cgd acu_t;
138 1.1 cgd
139 1.1 cgd #define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */
140 1.1 cgd
141 1.1 cgd /*
142 1.1 cgd * variable manipulation stuff --
143 1.1 cgd * if we defined the value entry in value_t, then we couldn't
144 1.1 cgd * initialize it in vars.c, so we cast it as needed to keep lint
145 1.1 cgd * happy.
146 1.1 cgd */
147 1.1 cgd typedef
148 1.1 cgd union {
149 1.1 cgd int zz_number;
150 1.1 cgd short zz_boolean[2];
151 1.1 cgd char zz_character[4];
152 1.1 cgd int *zz_address;
153 1.1 cgd }
154 1.1 cgd zzhack;
155 1.1 cgd
156 1.1 cgd #define value(v) vtable[v].v_value
157 1.1 cgd
158 1.1 cgd #define number(v) ((((zzhack *)(&(v))))->zz_number)
159 1.1 cgd
160 1.1 cgd #if BYTE_ORDER == LITTLE_ENDIAN
161 1.1 cgd #define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[0])
162 1.1 cgd #define character(v) ((((zzhack *)(&(v))))->zz_character[0])
163 1.1 cgd #endif
164 1.1 cgd
165 1.1 cgd #if BYTE_ORDER == BIG_ENDIAN
166 1.1 cgd #define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[1])
167 1.1 cgd #define character(v) ((((zzhack *)(&(v))))->zz_character[3])
168 1.1 cgd #endif
169 1.1 cgd
170 1.1 cgd #define address(v) ((((zzhack *)(&(v))))->zz_address)
171 1.1 cgd
172 1.1 cgd /*
173 1.1 cgd * Escape command table definitions --
174 1.1 cgd * lookup in this table is performed when ``escapec'' is recognized
175 1.1 cgd * at the begining of a line (as defined by the eolmarks variable).
176 1.1 cgd */
177 1.1 cgd
178 1.1 cgd typedef
179 1.1 cgd struct {
180 1.1 cgd char e_char; /* char to match on */
181 1.1 cgd char e_flags; /* experimental, priviledged */
182 1.1 cgd char *e_help; /* help string */
183 1.1 cgd int (*e_func)(); /* command */
184 1.1 cgd }
185 1.1 cgd esctable_t;
186 1.1 cgd
187 1.1 cgd #define NORM 00 /* normal protection, execute anyone */
188 1.1 cgd #define EXP 01 /* experimental, mark it with a `*' on help */
189 1.1 cgd #define PRIV 02 /* priviledged, root execute only */
190 1.1 cgd
191 1.1 cgd extern int vflag; /* verbose during reading of .tiprc file */
192 1.1 cgd extern value_t vtable[]; /* variable table */
193 1.1 cgd
194 1.1 cgd #ifndef ACULOG
195 1.1 cgd #define logent(a, b, c, d)
196 1.1 cgd #define loginit()
197 1.1 cgd #endif
198 1.1 cgd
199 1.1 cgd /*
200 1.1 cgd * Definition of indices into variable table so
201 1.1 cgd * value(DEFINE) turns into a static address.
202 1.1 cgd */
203 1.1 cgd
204 1.1 cgd #define BEAUTIFY 0
205 1.1 cgd #define BAUDRATE 1
206 1.1 cgd #define DIALTIMEOUT 2
207 1.1 cgd #define EOFREAD 3
208 1.1 cgd #define EOFWRITE 4
209 1.1 cgd #define EOL 5
210 1.1 cgd #define ESCAPE 6
211 1.1 cgd #define EXCEPTIONS 7
212 1.1 cgd #define FORCE 8
213 1.1 cgd #define FRAMESIZE 9
214 1.1 cgd #define HOST 10
215 1.1 cgd #define LOG 11
216 1.1 cgd #define PHONES 12
217 1.1 cgd #define PROMPT 13
218 1.1 cgd #define RAISE 14
219 1.1 cgd #define RAISECHAR 15
220 1.1 cgd #define RECORD 16
221 1.1 cgd #define REMOTE 17
222 1.1 cgd #define SCRIPT 18
223 1.1 cgd #define TABEXPAND 19
224 1.1 cgd #define VERBOSE 20
225 1.1 cgd #define SHELL 21
226 1.1 cgd #define HOME 22
227 1.1 cgd #define ECHOCHECK 23
228 1.1 cgd #define DISCONNECT 24
229 1.1 cgd #define TAND 25
230 1.1 cgd #define LDELAY 26
231 1.1 cgd #define CDELAY 27
232 1.1 cgd #define ETIMEOUT 28
233 1.1 cgd #define RAWFTP 29
234 1.1 cgd #define HALFDUPLEX 30
235 1.1 cgd #define LECHO 31
236 1.1 cgd #define PARITY 32
237 1.1 cgd
238 1.1 cgd #define NOVAL ((value_t *)NULL)
239 1.1 cgd #define NOACU ((acu_t *)NULL)
240 1.1 cgd #define NOSTR ((char *)NULL)
241 1.1 cgd #define NOFILE ((FILE *)NULL)
242 1.1 cgd #define NOPWD ((struct passwd *)0)
243 1.1 cgd
244 1.1 cgd struct sgttyb arg; /* current mode of local terminal */
245 1.1 cgd struct sgttyb defarg; /* initial mode of local terminal */
246 1.1 cgd struct tchars tchars; /* current state of terminal */
247 1.1 cgd struct tchars defchars; /* initial state of terminal */
248 1.1 cgd struct ltchars ltchars; /* current local characters of terminal */
249 1.1 cgd struct ltchars deflchars; /* initial local characters of terminal */
250 1.1 cgd
251 1.1 cgd FILE *fscript; /* FILE for scripting */
252 1.1 cgd
253 1.1 cgd int fildes[2]; /* file transfer synchronization channel */
254 1.1 cgd int repdes[2]; /* read process sychronization channel */
255 1.1 cgd int FD; /* open file descriptor to remote host */
256 1.1 cgd int AC; /* open file descriptor to dialer (v831 only) */
257 1.1 cgd int vflag; /* print .tiprc initialization sequence */
258 1.1 cgd int sfd; /* for ~< operation */
259 1.1 cgd int pid; /* pid of tipout */
260 1.1 cgd uid_t uid, euid; /* real and effective user id's */
261 1.1 cgd gid_t gid, egid; /* real and effective group id's */
262 1.1 cgd int stop; /* stop transfer session flag */
263 1.1 cgd int quit; /* same; but on other end */
264 1.1 cgd int intflag; /* recognized interrupt */
265 1.1 cgd int stoprompt; /* for interrupting a prompt session */
266 1.1 cgd int timedout; /* ~> transfer timedout */
267 1.1 cgd int cumode; /* simulating the "cu" program */
268 1.1 cgd
269 1.1 cgd char fname[80]; /* file name buffer for ~< */
270 1.1 cgd char copyname[80]; /* file name buffer for ~> */
271 1.1 cgd char ccc; /* synchronization character */
272 1.1 cgd char ch; /* for tipout */
273 1.1 cgd char *uucplock; /* name of lock file for uucp's */
274 1.1 cgd
275 1.1 cgd int odisc; /* initial tty line discipline */
276 1.1 cgd extern int disc; /* current tty discpline */
277 1.1 cgd
278 1.1 cgd extern char *ctrl();
279 1.1 cgd extern char *vinterp();
280 1.1 cgd extern char *connect();
281