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