2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by the University of
17 * California, Berkeley and its contributors.
18 * 4. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * @(#)tip.h 8.1 (Berkeley) 6/6/93
38 * tip - terminal interface program
41 #include <sys/types.h>
42 #include <machine/endian.h>
48 #include <sys/ioctl.h> /* for TIOCHPCL */
49 #include <sys/filio.h> /* for FIONREAD */
50 #include <sys/termios.h>
66 * Remote host attributes
68 char *DV; /* UNIX device(s) to open */
69 char *EL; /* chars marking an EOL */
70 char *CM; /* initial connection message */
71 char *IE; /* EOT to expect on input */
72 char *OE; /* EOT to send to complete FT */
73 char *CU; /* call unit if making a phone call */
74 char *AT; /* acu type */
75 char *PN; /* phone number(s) */
76 char *DI; /* disconnect string */
77 char *PA; /* parity to be generated */
79 char *PH; /* phone number file */
80 char *RM; /* remote file name */
81 char *HO; /* host name */
83 char *LI; /* login script */
84 char *LO; /* logout script */
86 long BR; /* line speed for conversation */
87 long FS; /* frame size for transfers */
89 char DU; /* this host is dialed up */
90 char HW; /* this device is hardwired, see hunt.c */
91 char *ES; /* escape character */
92 char *EX; /* exceptions */
93 char *FO; /* force (literal next) char*/
94 char *RC; /* raise character */
95 char *RE; /* script record file */
96 char *PR; /* remote prompt */
97 long DL; /* line delay for file transfers to remote */
98 long CL; /* char delay for file transfers to remote */
99 long ET; /* echocheck timeout */
100 char HD; /* this host is half duplex - do local echo */
107 char *v_name; /* whose name is it */
108 char v_type; /* for interpreting set's */
109 char v_access; /* protection of touchy ones */
110 char *v_abrev; /* possible abreviation */
111 char *v_value; /* casted to a union later */
115 #define STRING 01 /* string valued */
116 #define BOOL 02 /* true-false value */
117 #define NUMBER 04 /* numeric value */
118 #define CHAR 010 /* character value */
120 #define WRITE 01 /* write access to variable */
121 #define READ 02 /* read access */
123 #define CHANGED 01 /* low bit is used to show modification */
124 #define PUBLIC 1 /* public access rights */
125 #define PRIVATE 03 /* private to definer */
126 #define ROOT 05 /* root defined */
131 #define ENVIRON 020 /* initialize out of the environment */
132 #define IREMOTE 040 /* initialize out of remote structure */
133 #define INIT 0100 /* static data space used for initialization */
137 * Definition of ACU line description
143 void (*acu_disconnect)();
148 #define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */
151 * variable manipulation stuff --
152 * if we defined the value entry in value_t, then we couldn't
153 * initialize it in vars.c, so we cast it as needed to keep lint
160 char zz_character[4];
165 #define value(v) vtable[v].v_value
167 #define number(v) ((((zzhack *)(&(v))))->zz_number)
169 #if BYTE_ORDER == LITTLE_ENDIAN
170 #define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[0])
171 #define character(v) ((((zzhack *)(&(v))))->zz_character[0])
174 #if BYTE_ORDER == BIG_ENDIAN
175 #define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[1])
176 #define character(v) ((((zzhack *)(&(v))))->zz_character[3])
179 #define address(v) ((((zzhack *)(&(v))))->zz_address)
182 * Escape command table definitions --
183 * lookup in this table is performed when ``escapec'' is recognized
184 * at the begining of a line (as defined by the eolmarks variable).
189 char e_char; /* char to match on */
190 char e_flags; /* experimental, priviledged */
191 char *e_help; /* help string */
192 int (*e_func)(); /* command */
196 #define NORM 00 /* normal protection, execute anyone */
197 #define EXP 01 /* experimental, mark it with a `*' on help */
198 #define PRIV 02 /* priviledged, root execute only */
200 extern int vflag; /* verbose during reading of .tiprc file */
201 extern value_t vtable[]; /* variable table */
204 #define logent(a, b, c, d)
207 void logent __P((char *, char *, char *, char*));
211 * Definition of indices into variable table so
212 * value(DEFINE) turns into a static address.
216 'a,.!awk '{ printf("\%s \%s \%d\n", $1, $2, NR - 1); }'
221 #define DIALTIMEOUT 2
245 #define DISCONNECT 26
251 #define HALFDUPLEX 32
254 #define NOVAL ((value_t *)NULL)
255 #define NOACU ((acu_t *)NULL)
256 #define NOSTR ((char *)NULL)
260 #define NOFILE ((FILE *)NULL)
261 #define NOPWD ((struct passwd *)0)
264 struct termios otermios;
265 struct termios ctermios;
266 #else /* HAVE_TERMIOS */
267 struct sgttyb arg; /* current mode of local terminal */
268 struct sgttyb defarg; /* initial mode of local terminal */
269 struct tchars tchars; /* current state of terminal */
270 struct tchars defchars; /* initial state of terminal */
271 struct ltchars ltchars; /* current local characters of terminal */
272 struct ltchars deflchars; /* initial local characters of terminal */
273 #endif /* HAVE_TERMIOS */
275 FILE *fscript; /* FILE for scripting */
277 int fildes[2]; /* file transfer synchronization channel */
278 int repdes[2]; /* read process sychronization channel */
279 int FD; /* open file descriptor to remote host */
280 int AC; /* open file descriptor to dialer (v831 only) */
281 int vflag; /* print .tiprc initialization sequence */
282 int sfd; /* for ~< operation */
283 int pid; /* pid of tipout */
284 uid_t uid, euid; /* real and effective user id's */
285 gid_t gid, egid; /* real and effective group id's */
286 int stop; /* stop transfer session flag */
287 int quit; /* same; but on other end */
288 int intflag; /* recognized interrupt */
289 int stoprompt; /* for interrupting a prompt session */
290 int timedout; /* ~> transfer timedout */
291 int cumode; /* simulating the "cu" program */
293 char fname[PATH_MAX]; /* file name buffer for ~< */
294 char copyname[PATH_MAX]; /* file name buffer for ~> */
295 char ccc; /* synchronization character */
296 char ch; /* for tipout */
297 char *uucplock; /* name of lock file for uucp's */
299 int odisc; /* initial tty line discipline */
300 extern int disc; /* current tty discpline */
303 extern char *vinterp();
304 extern char *connect();
305 extern int size __P((char *));
306 extern int any __P((char, char *));
307 extern void setscript __P((void));
308 extern void tipout __P((void));
309 extern void vinit __P((void));
310 extern void loginit __P((void));
311 extern int hunt __P((char *));
312 extern int vstring __P((char *, char *));
313 extern void setparity __P((char *));
314 extern void vlex __P((char *));
315 extern void daemon_uid __P((void));
316 extern void disconnect __P((char *));
317 extern void shell_uid __P((void));
318 extern void unraw __P((void));
319 extern void xpwrite __P((int, char *, int));
320 extern int prompt __P((char *, char *, size_t));
321 extern void consh __P((int));
322 extern void tipabort __P((char *));
324 #define TL_VERBOSE 0x00000001
325 #define TL_SIGNAL_TIPOUT 0x00000002
327 int tiplink (char *cmd, unsigned int flags);