xref: /csrg-svn/usr.bin/tip/tip.h (revision 35464)
119805Sdist /*
2*35464Sbostic  * Copyright (c) 1983 The Regents of the University of California.
3*35464Sbostic  * All rights reserved.
419805Sdist  *
5*35464Sbostic  * Redistribution and use in source and binary forms are permitted
6*35464Sbostic  * provided that the above copyright notice and this paragraph are
7*35464Sbostic  * duplicated in all such forms and that any documentation,
8*35464Sbostic  * advertising materials, and other materials related to such
9*35464Sbostic  * distribution and use acknowledge that the software was developed
10*35464Sbostic  * by the University of California, Berkeley.  The name of the
11*35464Sbostic  * University may not be used to endorse or promote products derived
12*35464Sbostic  * from this software without specific prior written permission.
13*35464Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*35464Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*35464Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16*35464Sbostic  *
17*35464Sbostic  *	@(#)tip.h	5.4 (Berkeley) 09/02/88
1819805Sdist  */
1913280Ssam 
203697Sroot /*
213697Sroot  * tip - terminal interface program
223697Sroot  */
233697Sroot 
2413280Ssam #include <sys/types.h>
2513280Ssam #include <sys/file.h>
2613280Ssam 
273697Sroot #include <sgtty.h>
283697Sroot #include <signal.h>
293697Sroot #include <stdio.h>
303697Sroot #include <pwd.h>
315258Sshannon #include <ctype.h>
3213280Ssam #include <setjmp.h>
3313280Ssam #include <errno.h>
343697Sroot 
353697Sroot /*
363697Sroot  * Remote host attributes
373697Sroot  */
383697Sroot char	*DV;			/* UNIX device(s) to open */
393697Sroot char	*EL;			/* chars marking an EOL */
403697Sroot char	*CM;			/* initial connection message */
413697Sroot char	*IE;			/* EOT to expect on input */
423697Sroot char	*OE;			/* EOT to send to complete FT */
433697Sroot char	*CU;			/* call unit if making a phone call */
443697Sroot char	*AT;			/* acu type */
453697Sroot char	*PN;			/* phone number(s) */
4613144Sralph char	*DI;			/* disconnect string */
4713144Sralph char	*PA;			/* parity to be generated */
483697Sroot 
493697Sroot char	*PH;			/* phone number file */
503697Sroot char	*RM;			/* remote file name */
513697Sroot char	*HO;			/* host name */
523697Sroot 
533697Sroot int	BR;			/* line speed for conversation */
543697Sroot int	FS;			/* frame size for transfers */
553697Sroot 
563697Sroot char	DU;			/* this host is dialed up */
573899Ssam char	HW;			/* this device is hardwired, see hunt.c */
5813144Sralph char	*ES;			/* escape character */
5913144Sralph char	*EX;			/* exceptions */
6013144Sralph char	*FO;			/* force (literal next) char*/
6113144Sralph char	*RC;			/* raise character */
6213144Sralph char	*RE;			/* script record file */
6313144Sralph char	*PR;			/* remote prompt */
6413144Sralph int	DL;			/* line delay for file transfers to remote */
6513144Sralph int	CL;			/* char delay for file transfers to remote */
6613144Sralph int	ET;			/* echocheck timeout */
6713144Sralph char	HD;			/* this host is half duplex - do local echo */
683697Sroot 
693697Sroot /*
703697Sroot  * String value table
713697Sroot  */
723697Sroot typedef
733697Sroot 	struct {
743697Sroot 		char	*v_name;	/* whose name is it */
753697Sroot 		char	v_type;		/* for interpreting set's */
763697Sroot 		char	v_access;	/* protection of touchy ones */
773697Sroot 		char	*v_abrev;	/* possible abreviation */
783697Sroot 		char	*v_value;	/* casted to a union later */
793697Sroot 	}
803697Sroot 	value_t;
813697Sroot 
823697Sroot #define STRING	01		/* string valued */
833697Sroot #define BOOL	02		/* true-false value */
843697Sroot #define NUMBER	04		/* numeric value */
853697Sroot #define CHAR	010		/* character value */
863697Sroot 
873697Sroot #define WRITE	01		/* write access to variable */
883697Sroot #define	READ	02		/* read access */
893697Sroot 
903697Sroot #define CHANGED	01		/* low bit is used to show modification */
913697Sroot #define PUBLIC	1		/* public access rights */
923697Sroot #define PRIVATE	03		/* private to definer */
933697Sroot #define ROOT	05		/* root defined */
943697Sroot 
953697Sroot #define	TRUE	1
963697Sroot #define FALSE	0
973697Sroot 
983697Sroot #define ENVIRON	020		/* initialize out of the environment */
993697Sroot #define IREMOTE	040		/* initialize out of remote structure */
1003697Sroot #define INIT	0100		/* static data space used for initialization */
1013697Sroot #define TMASK	017
1023697Sroot 
1033697Sroot /*
1043697Sroot  * Definition of ACU line description
1053697Sroot  */
1063697Sroot typedef
1073697Sroot 	struct {
1083697Sroot 		char	*acu_name;
1093697Sroot 		int	(*acu_dialer)();
1103697Sroot 		int	(*acu_disconnect)();
1113697Sroot 		int	(*acu_abort)();
1123697Sroot 	}
1133697Sroot 	acu_t;
1143697Sroot 
1153697Sroot #define	equal(a, b)	(strcmp(a,b)==0)/* A nice function to string compare */
1163697Sroot 
1173697Sroot /*
1183697Sroot  * variable manipulation stuff --
1193697Sroot  *   if we defined the value entry in value_t, then we couldn't
1203697Sroot  *   initialize it in vars.c, so we cast it as needed to keep lint
1213697Sroot  *   happy.
1223697Sroot  */
1233697Sroot typedef
1243697Sroot 	union {
1253697Sroot 		int	zz_number;
12629893Ssam 		short	zz_boolean[2];
12729893Ssam 		char	zz_character[4];
1283697Sroot 		int	*zz_address;
1293697Sroot 	}
1303697Sroot 	zzhack;
1313697Sroot 
1323697Sroot #define value(v)	vtable[v].v_value
1333697Sroot 
1343697Sroot #define number(v)	((((zzhack *)(&(v))))->zz_number)
13529893Ssam #ifdef vax
13629893Ssam #define boolean(v)	((((zzhack *)(&(v))))->zz_boolean[0])
13729893Ssam #define character(v)	((((zzhack *)(&(v))))->zz_character[0])
13829893Ssam #else
13929893Ssam #define boolean(v)	((((zzhack *)(&(v))))->zz_boolean[1])
14029893Ssam #define character(v)	((((zzhack *)(&(v))))->zz_character[3])
14129893Ssam #endif
1423697Sroot #define address(v)	((((zzhack *)(&(v))))->zz_address)
1433697Sroot 
1443697Sroot /*
1453697Sroot  * Escape command table definitions --
1463697Sroot  *   lookup in this table is performed when ``escapec'' is recognized
1473697Sroot  *   at the begining of a line (as defined by the eolmarks variable).
1483697Sroot */
1493697Sroot 
1503697Sroot typedef
1513697Sroot 	struct {
1523697Sroot 		char	e_char;		/* char to match on */
1533697Sroot 		char	e_flags;	/* experimental, priviledged */
1543697Sroot 		char	*e_help;	/* help string */
1553697Sroot 		int 	(*e_func)();	/* command */
1563697Sroot 	}
1573697Sroot 	esctable_t;
1583697Sroot 
1593697Sroot #define NORM	00		/* normal protection, execute anyone */
1603697Sroot #define EXP	01		/* experimental, mark it with a `*' on help */
1613697Sroot #define PRIV	02		/* priviledged, root execute only */
1623697Sroot 
1633697Sroot extern int	vflag;		/* verbose during reading of .tiprc file */
1643697Sroot extern value_t	vtable[];	/* variable table */
1653697Sroot 
1663697Sroot #ifndef ACULOG
1673697Sroot #define logent(a, b, c, d)
1683697Sroot #define loginit()
1693697Sroot #endif
1703697Sroot 
1713697Sroot /*
1723697Sroot  * Definition of indices into variable table so
1733697Sroot  *  value(DEFINE) turns into a static address.
1743697Sroot  */
1753697Sroot 
1763697Sroot #define BEAUTIFY	0
1773697Sroot #define BAUDRATE	1
1783697Sroot #define DIALTIMEOUT	2
1793697Sroot #define EOFREAD		3
1803697Sroot #define EOFWRITE	4
1813697Sroot #define EOL		5
1823697Sroot #define ESCAPE		6
1833697Sroot #define EXCEPTIONS	7
1843697Sroot #define FORCE		8
1853697Sroot #define FRAMESIZE	9
1863697Sroot #define HOST		10
18713280Ssam #define LOG		11
18813280Ssam #define PHONES		12
18913280Ssam #define PROMPT		13
19013280Ssam #define RAISE		14
19113280Ssam #define RAISECHAR	15
19213280Ssam #define RECORD		16
19313280Ssam #define REMOTE		17
19413280Ssam #define SCRIPT		18
19513280Ssam #define TABEXPAND	19
19613280Ssam #define VERBOSE		20
19713280Ssam #define SHELL		21
19813280Ssam #define HOME		22
19913280Ssam #define ECHOCHECK	23
20013280Ssam #define DISCONNECT	24
20113280Ssam #define TAND		25
20213280Ssam #define LDELAY		26
20313280Ssam #define CDELAY		27
20413280Ssam #define ETIMEOUT	28
20513280Ssam #define RAWFTP		29
20613280Ssam #define HALFDUPLEX	30
20713280Ssam #define	LECHO		31
20813280Ssam #define	PARITY		32
2093697Sroot 
2103697Sroot #define NOVAL	((value_t *)NULL)
2113697Sroot #define NOACU	((acu_t *)NULL)
2123697Sroot #define NOSTR	((char *)NULL)
2133697Sroot #define NOFILE	((FILE *)NULL)
2143697Sroot #define NOPWD	((struct passwd *)0)
2153697Sroot 
2163697Sroot struct sgttyb	arg;		/* current mode of local terminal */
2173697Sroot struct sgttyb	defarg;		/* initial mode of local terminal */
2183697Sroot struct tchars	tchars;		/* current state of terminal */
2193697Sroot struct tchars	defchars;	/* initial state of terminal */
22012479Sroot struct ltchars	ltchars;	/* current local characters of terminal */
22112479Sroot struct ltchars	deflchars;	/* initial local characters of terminal */
2223697Sroot 
2233697Sroot FILE	*fscript;		/* FILE for scripting */
2243697Sroot 
2253697Sroot int	fildes[2];		/* file transfer synchronization channel */
2263697Sroot int	repdes[2];		/* read process sychronization channel */
2273697Sroot int	FD;			/* open file descriptor to remote host */
22813144Sralph int	AC;			/* open file descriptor to dialer (v831 only) */
2293697Sroot int	vflag;			/* print .tiprc initialization sequence */
2303697Sroot int	sfd;			/* for ~< operation */
2313697Sroot int	pid;			/* pid of tipout */
23225906Skarels uid_t	uid, euid;		/* real and effective user id's */
23325906Skarels gid_t	gid, egid;		/* real and effective group id's */
2343697Sroot int	stop;			/* stop transfer session flag */
2353697Sroot int	quit;			/* same; but on other end */
2363697Sroot int	intflag;		/* recognized interrupt */
2373697Sroot int	stoprompt;		/* for interrupting a prompt session */
2383697Sroot int	timedout;		/* ~> transfer timedout */
2394974Ssam int	cumode;			/* simulating the "cu" program */
2403697Sroot 
2413697Sroot char	fname[80];		/* file name buffer for ~< */
2423697Sroot char	copyname[80];		/* file name buffer for ~> */
2433697Sroot char	ccc;			/* synchronization character */
2443697Sroot char	ch;			/* for tipout */
2453697Sroot char	*uucplock;		/* name of lock file for uucp's */
2463697Sroot 
2473697Sroot int	odisc;				/* initial tty line discipline */
24813280Ssam extern	int disc;			/* current tty discpline */
2493697Sroot 
25013280Ssam extern	char *ctrl();
25113280Ssam extern	char *ctime();
25213280Ssam extern	long time();
25313280Ssam extern	struct passwd *getpwuid();
25413280Ssam extern	char *getlogin();
25513280Ssam extern	char *vinterp();
25613280Ssam extern	char *getenv();
25713280Ssam extern	char *rindex();
25813280Ssam extern	char *index();
25913280Ssam extern	char *malloc();
26013280Ssam extern	char *connect();
261