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