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