Annotation of src/usr.bin/tip/tip.h, Revision 1.12
1.12 ! millert 1: /* $OpenBSD: tip.h,v 1.11 2001/09/09 19:30:49 millert Exp $ */
1.6 millert 2: /* $NetBSD: tip.h,v 1.7 1997/04/20 00:02:46 mellon 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>
1.8 deraadt 47: #include <sys/wait.h>
48: #include <sys/ioctl.h>
1.1 deraadt 49:
1.2 deraadt 50: #include <termios.h>
1.1 deraadt 51: #include <signal.h>
52: #include <stdio.h>
53: #include <stdlib.h>
54: #include <string.h>
55: #include <pwd.h>
56: #include <ctype.h>
57: #include <setjmp.h>
58: #include <unistd.h>
59: #include <errno.h>
1.7 millert 60: #include <limits.h>
1.1 deraadt 61:
62: /*
63: * Remote host attributes
64: */
65: char *DV; /* UNIX device(s) to open */
66: char *EL; /* chars marking an EOL */
67: char *CM; /* initial connection message */
68: char *IE; /* EOT to expect on input */
69: char *OE; /* EOT to send to complete FT */
70: char *CU; /* call unit if making a phone call */
71: char *AT; /* acu type */
72: char *PN; /* phone number(s) */
73: char *DI; /* disconnect string */
74: char *PA; /* parity to be generated */
75:
76: char *PH; /* phone number file */
77: char *RM; /* remote file name */
78: char *HO; /* host name */
79:
80: long BR; /* line speed for conversation */
81: long FS; /* frame size for transfers */
82:
1.6 millert 83: short DU; /* this host is dialed up */
84: short HW; /* this device is hardwired, see hunt.c */
1.1 deraadt 85: char *ES; /* escape character */
86: char *EX; /* exceptions */
87: char *FO; /* force (literal next) char*/
88: char *RC; /* raise character */
89: char *RE; /* script record file */
90: char *PR; /* remote prompt */
91: long DL; /* line delay for file transfers to remote */
92: long CL; /* char delay for file transfers to remote */
93: long ET; /* echocheck timeout */
1.6 millert 94: short HD; /* this host is half duplex - do local echo */
95: short DC; /* this host is directly connected. */
1.1 deraadt 96:
97: /*
98: * String value table
99: */
100: typedef
101: struct {
102: char *v_name; /* whose name is it */
103: char v_type; /* for interpreting set's */
104: char v_access; /* protection of touchy ones */
105: char *v_abrev; /* possible abreviation */
106: char *v_value; /* casted to a union later */
107: }
108: value_t;
109:
110: #define STRING 01 /* string valued */
111: #define BOOL 02 /* true-false value */
112: #define NUMBER 04 /* numeric value */
113: #define CHAR 010 /* character value */
114:
115: #define WRITE 01 /* write access to variable */
116: #define READ 02 /* read access */
117:
118: #define CHANGED 01 /* low bit is used to show modification */
119: #define PUBLIC 1 /* public access rights */
120: #define PRIVATE 03 /* private to definer */
121: #define ROOT 05 /* root defined */
122:
123: #define TRUE 1
124: #define FALSE 0
125:
126: #define ENVIRON 020 /* initialize out of the environment */
127: #define IREMOTE 040 /* initialize out of remote structure */
128: #define INIT 0100 /* static data space used for initialization */
129: #define TMASK 017
130:
131: /*
132: * Definition of ACU line description
133: */
134: typedef
135: struct {
136: char *acu_name;
137: int (*acu_dialer)();
138: int (*acu_disconnect)();
139: int (*acu_abort)();
140: }
141: acu_t;
142:
143: #define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */
144:
145: /*
146: * variable manipulation stuff --
147: * if we defined the value entry in value_t, then we couldn't
148: * initialize it in vars.c, so we cast it as needed to keep lint
149: * happy.
150: */
151:
152: #define value(v) vtable[v].v_value
153:
1.5 millert 154: #define number(v) ((long)(v))
155: #define boolean(v) ((short)(long)(v))
156: #define character(v) ((char)(long)(v))
157: #define address(v) ((long *)(v))
158:
159: #define setnumber(v,n) do { (v) = (char *)(long)(n); } while (0)
160: #define setboolean(v,n) do { (v) = (char *)(long)(n); } while (0)
161: #define setcharacter(v,n) do { (v) = (char *)(long)(n); } while (0)
162: #define setaddress(v,n) do { (v) = (char *)(n); } while (0)
1.1 deraadt 163:
164: /*
165: * Escape command table definitions --
166: * lookup in this table is performed when ``escapec'' is recognized
167: * at the begining of a line (as defined by the eolmarks variable).
168: */
169:
170: typedef
171: struct {
172: char e_char; /* char to match on */
173: char e_flags; /* experimental, priviledged */
174: char *e_help; /* help string */
175: int (*e_func)(); /* command */
176: }
177: esctable_t;
178:
179: #define NORM 00 /* normal protection, execute anyone */
180: #define EXP 01 /* experimental, mark it with a `*' on help */
181: #define PRIV 02 /* priviledged, root execute only */
182:
183: extern int vflag; /* verbose during reading of .tiprc file */
1.9 todd 184: extern int noesc; /* no escape `~' char */
1.1 deraadt 185: extern value_t vtable[]; /* variable table */
186:
187: #ifndef ACULOG
188: #define logent(a, b, c, d)
189: #define loginit()
190: #endif
191:
192: /*
193: * Definition of indices into variable table so
194: * value(DEFINE) turns into a static address.
195: */
196:
197: #define BEAUTIFY 0
198: #define BAUDRATE 1
199: #define DIALTIMEOUT 2
200: #define EOFREAD 3
201: #define EOFWRITE 4
202: #define EOL 5
203: #define ESCAPE 6
204: #define EXCEPTIONS 7
205: #define FORCE 8
206: #define FRAMESIZE 9
207: #define HOST 10
208: #define LOG 11
209: #define PHONES 12
210: #define PROMPT 13
211: #define RAISE 14
212: #define RAISECHAR 15
213: #define RECORD 16
214: #define REMOTE 17
215: #define SCRIPT 18
216: #define TABEXPAND 19
217: #define VERBOSE 20
218: #define SHELL 21
219: #define HOME 22
220: #define ECHOCHECK 23
221: #define DISCONNECT 24
222: #define TAND 25
223: #define LDELAY 26
224: #define CDELAY 27
225: #define ETIMEOUT 28
226: #define RAWFTP 29
227: #define HALFDUPLEX 30
228: #define LECHO 31
229: #define PARITY 32
230:
231: #define NOVAL ((value_t *)NULL)
232: #define NOACU ((acu_t *)NULL)
233: #define NOSTR ((char *)NULL)
234: #define NOFILE ((FILE *)NULL)
235: #define NOPWD ((struct passwd *)0)
236:
1.2 deraadt 237: struct termios term; /* current mode of terminal */
238: struct termios defterm; /* initial mode of terminal */
239: struct termios defchars; /* current mode with initial chars */
1.1 deraadt 240:
241: FILE *fscript; /* FILE for scripting */
242:
243: int fildes[2]; /* file transfer synchronization channel */
244: int repdes[2]; /* read process sychronization channel */
245: int FD; /* open file descriptor to remote host */
246: int AC; /* open file descriptor to dialer (v831 only) */
247: int vflag; /* print .tiprc initialization sequence */
1.9 todd 248: int noesc; /* no `~' escape char */
1.1 deraadt 249: int sfd; /* for ~< operation */
250: int pid; /* pid of tipout */
251: uid_t uid, euid; /* real and effective user id's */
252: gid_t gid, egid; /* real and effective group id's */
253: int stop; /* stop transfer session flag */
254: int quit; /* same; but on other end */
255: int intflag; /* recognized interrupt */
256: int stoprompt; /* for interrupting a prompt session */
257: int timedout; /* ~> transfer timedout */
258: int cumode; /* simulating the "cu" program */
1.2 deraadt 259: int bits8; /* terminal is is 8-bit mode */
260: #define STRIP_PAR (bits8 ? 0377 : 0177)
1.1 deraadt 261:
1.7 millert 262: char fname[PATH_MAX]; /* file name buffer for ~< */
263: char copyname[PATH_MAX]; /* file name buffer for ~> */
1.1 deraadt 264: char ccc; /* synchronization character */
265: char ch; /* for tipout */
266: char *uucplock; /* name of lock file for uucp's */
267:
1.11 millert 268: int odisc; /* initial tty line discipline */
269: extern int disc; /* current tty discpline */
270:
271: extern char *__progname; /* program name */
1.1 deraadt 272:
273: extern char *ctrl();
274: extern char *vinterp();
275: extern char *connect();
1.8 deraadt 276:
1.12 ! millert 277: char *sname(char *s);
! 278: int any(int cc, char *p);
! 279: int anyof(char *s1, char *s2);
! 280: int args(char *buf, char *a[], int num);
! 281: int escape(void);
! 282: int prompt(char *s, char *p, size_t sz);
! 283: int size(char *s);
! 284: int speed(int n);
! 285: int uu_lock(char *ttyname);
! 286: int uu_unlock(char *ttyname);
! 287: int vstring(char *s, char *v);
! 288: long hunt(char *name);
! 289: void cumain(int argc, char *argv[]);
! 290: void daemon_uid(void);
! 291: void disconnect(char *reason);
! 292: void execute(char *s);
! 293: void logent(char *group, char *num, char *acu, char *message);
! 294: void loginit(void);
! 295: void prtime(char *s, time_t a);
! 296: void parwrite(int fd, char *buf, int n);
! 297: void raw(void);
! 298: void send(int c);
! 299: void setparity(char *defparity);
! 300: void setscript(void);
! 301: void shell_uid(void);
! 302: void tandem(char *option);
! 303: void tipabort(char *msg);
! 304: void tipin(void);
! 305: void tipout(void);
! 306: void transfer(char *buf, int fd, char *eofchars);
! 307: void transmit(FILE *fd, char *eofchars, char *command);
! 308: void ttysetup(int speed);
! 309: void unraw(void);
! 310: void user_uid(void);
! 311: void vinit(void);
! 312: void vlex(char *s);