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