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