xref: /csrg-svn/usr.bin/tip/tip.h (revision 13144)
1*13144Sralph /*	tip.h	4.10	83/06/15	*/
23697Sroot /*
33697Sroot  * tip - terminal interface program
43697Sroot  *
53697Sroot  * Samuel J. Leffler
63697Sroot  */
73697Sroot 
83697Sroot #include <sgtty.h>
93697Sroot #include <signal.h>
103697Sroot #include <stdio.h>
113697Sroot #include <pwd.h>
123697Sroot #include <sys/types.h>
135258Sshannon #include <ctype.h>
143697Sroot 
153697Sroot /*
163697Sroot  * Remote host attributes
173697Sroot  */
183697Sroot char	*DV;			/* UNIX device(s) to open */
193697Sroot char	*EL;			/* chars marking an EOL */
203697Sroot char	*CM;			/* initial connection message */
213697Sroot char	*IE;			/* EOT to expect on input */
223697Sroot char	*OE;			/* EOT to send to complete FT */
233697Sroot char	*CU;			/* call unit if making a phone call */
243697Sroot char	*AT;			/* acu type */
253697Sroot char	*PN;			/* phone number(s) */
26*13144Sralph char	*DI;			/* disconnect string */
27*13144Sralph char	*PA;			/* parity to be generated */
283697Sroot 
293697Sroot char	*PH;			/* phone number file */
303697Sroot char	*RM;			/* remote file name */
313697Sroot char	*HO;			/* host name */
323697Sroot 
333697Sroot int	BR;			/* line speed for conversation */
343697Sroot int	FS;			/* frame size for transfers */
353697Sroot 
363697Sroot char	DU;			/* this host is dialed up */
373899Ssam char	HW;			/* this device is hardwired, see hunt.c */
38*13144Sralph char	*ES;			/* escape character */
39*13144Sralph char	*EX;			/* exceptions */
40*13144Sralph char	*FO;			/* force (literal next) char*/
41*13144Sralph char	*RC;			/* raise character */
42*13144Sralph char	*RE;			/* script record file */
43*13144Sralph char	*PR;			/* remote prompt */
44*13144Sralph int	DL;			/* line delay for file transfers to remote */
45*13144Sralph int	CL;			/* char delay for file transfers to remote */
46*13144Sralph int	ET;			/* echocheck timeout */
47*13144Sralph char	HD;			/* this host is half duplex - do local echo */
483697Sroot 
493697Sroot /*
503697Sroot  * String value table
513697Sroot  */
523697Sroot typedef
533697Sroot 	struct {
543697Sroot 		char	*v_name;	/* whose name is it */
553697Sroot 		char	v_type;		/* for interpreting set's */
563697Sroot 		char	v_access;	/* protection of touchy ones */
573697Sroot 		char	*v_abrev;	/* possible abreviation */
583697Sroot 		char	*v_value;	/* casted to a union later */
593697Sroot 	}
603697Sroot 	value_t;
613697Sroot 
623697Sroot #define STRING	01		/* string valued */
633697Sroot #define BOOL	02		/* true-false value */
643697Sroot #define NUMBER	04		/* numeric value */
653697Sroot #define CHAR	010		/* character value */
663697Sroot 
673697Sroot #define WRITE	01		/* write access to variable */
683697Sroot #define	READ	02		/* read access */
693697Sroot 
703697Sroot #define CHANGED	01		/* low bit is used to show modification */
713697Sroot #define PUBLIC	1		/* public access rights */
723697Sroot #define PRIVATE	03		/* private to definer */
733697Sroot #define ROOT	05		/* root defined */
743697Sroot 
753697Sroot #define	TRUE	1
763697Sroot #define FALSE	0
773697Sroot 
783697Sroot #define ENVIRON	020		/* initialize out of the environment */
793697Sroot #define IREMOTE	040		/* initialize out of remote structure */
803697Sroot #define INIT	0100		/* static data space used for initialization */
813697Sroot #define TMASK	017
823697Sroot 
833697Sroot /*
843697Sroot  * Definition of ACU line description
853697Sroot  */
863697Sroot typedef
873697Sroot 	struct {
883697Sroot 		char	*acu_name;
893697Sroot 		int	(*acu_dialer)();
903697Sroot 		int	(*acu_disconnect)();
913697Sroot 		int	(*acu_abort)();
923697Sroot 	}
933697Sroot 	acu_t;
943697Sroot 
953697Sroot #define	equal(a, b)	(strcmp(a,b)==0)/* A nice function to string compare */
963697Sroot 
973697Sroot /*
983697Sroot  * variable manipulation stuff --
993697Sroot  *   if we defined the value entry in value_t, then we couldn't
1003697Sroot  *   initialize it in vars.c, so we cast it as needed to keep lint
1013697Sroot  *   happy.
1023697Sroot  */
1033697Sroot typedef
1043697Sroot 	union {
1053697Sroot 		int	zz_number;
106*13144Sralph 		short	zz_boolean;
107*13144Sralph 		char	zz_character;
1083697Sroot 		int	*zz_address;
1093697Sroot 	}
1103697Sroot 	zzhack;
1113697Sroot 
1123697Sroot #define value(v)	vtable[v].v_value
1133697Sroot 
1143697Sroot #define boolean(v)	((((zzhack *)(&(v))))->zz_boolean)
1153697Sroot #define number(v)	((((zzhack *)(&(v))))->zz_number)
1163697Sroot #define character(v)	((((zzhack *)(&(v))))->zz_character)
1173697Sroot #define address(v)	((((zzhack *)(&(v))))->zz_address)
1183697Sroot 
1193697Sroot /*
1203697Sroot  * Escape command table definitions --
1213697Sroot  *   lookup in this table is performed when ``escapec'' is recognized
1223697Sroot  *   at the begining of a line (as defined by the eolmarks variable).
1233697Sroot */
1243697Sroot 
1253697Sroot typedef
1263697Sroot 	struct {
1273697Sroot 		char	e_char;		/* char to match on */
1283697Sroot 		char	e_flags;	/* experimental, priviledged */
1293697Sroot 		char	*e_help;	/* help string */
1303697Sroot 		int 	(*e_func)();	/* command */
1313697Sroot 	}
1323697Sroot 	esctable_t;
1333697Sroot 
1343697Sroot #define NORM	00		/* normal protection, execute anyone */
1353697Sroot #define EXP	01		/* experimental, mark it with a `*' on help */
1363697Sroot #define PRIV	02		/* priviledged, root execute only */
1373697Sroot 
1383697Sroot extern int	vflag;		/* verbose during reading of .tiprc file */
1393697Sroot extern value_t	vtable[];	/* variable table */
1403697Sroot 
1413697Sroot #ifndef ACULOG
1423697Sroot #define logent(a, b, c, d)
1433697Sroot #define loginit()
1443697Sroot #endif
1453697Sroot 
1463697Sroot /*
1473697Sroot  * Definition of indices into variable table so
1483697Sroot  *  value(DEFINE) turns into a static address.
1493697Sroot  */
1503697Sroot 
1513697Sroot #define BEAUTIFY	0
1523697Sroot #define BAUDRATE	1
1533697Sroot #define DIALTIMEOUT	2
1543697Sroot #define EOFREAD		3
1553697Sroot #define EOFWRITE	4
1563697Sroot #define EOL		5
1573697Sroot #define ESCAPE		6
1583697Sroot #define EXCEPTIONS	7
1593697Sroot #define FORCE		8
1603697Sroot #define FRAMESIZE	9
1613697Sroot #define HOST		10
1623697Sroot #if ACULOG
1633697Sroot #define LOCK		11
1643697Sroot #define LOG		12
1653697Sroot #define PHONES		13
1663697Sroot #define PROMPT		14
1673697Sroot #define RAISE		15
1683697Sroot #define RAISECHAR	16
1693697Sroot #define RECORD		17
1703697Sroot #define REMOTE		18
1713697Sroot #define SCRIPT		19
1723697Sroot #define TABEXPAND	20
1733697Sroot #define VERBOSE		21
1743697Sroot #define SHELL		22
1753697Sroot #define HOME		23
1763843Ssam #define ECHOCHECK	24
177*13144Sralph #define DISCONNECT	25
178*13144Sralph #define TAND		26
179*13144Sralph #define LDELAY		27
180*13144Sralph #define CDELAY		28
181*13144Sralph #define ETIMEOUT	29
182*13144Sralph #define RAWFTP		30
183*13144Sralph #define HALFDUPLEX	31
184*13144Sralph #define	LECHO		32
185*13144Sralph #define	PARITY		33
1863697Sroot #else
1873697Sroot #define PHONES		11
1883697Sroot #define PROMPT		12
1893697Sroot #define RAISE		13
1903697Sroot #define RAISECHAR	14
1913697Sroot #define RECORD		15
1923697Sroot #define REMOTE		16
1933697Sroot #define SCRIPT		17
1943697Sroot #define TABEXPAND	18
1953697Sroot #define VERBOSE		19
1963697Sroot #define SHELL		20
1973697Sroot #define HOME		21
1983843Ssam #define ECHOCHECK	22
199*13144Sralph #define DISCONNECT	23
200*13144Sralph #define TAND		24
201*13144Sralph #define LDELAY		25
202*13144Sralph #define CDELAY		26
203*13144Sralph #define ETIMEOUT	27
204*13144Sralph #define RAWFTP		28
205*13144Sralph #define HALFDUPLEX	29
206*13144Sralph #define	LECHO		30
207*13144Sralph #define	PARITY		31
2083697Sroot #endif
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 */
228*13144Sralph 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 */
2323697Sroot int	stop;			/* stop transfer session flag */
2333697Sroot int	quit;			/* same; but on other end */
2343697Sroot int	intflag;		/* recognized interrupt */
2353697Sroot int	stoprompt;		/* for interrupting a prompt session */
2363697Sroot int	timedout;		/* ~> transfer timedout */
2374974Ssam int	cumode;			/* simulating the "cu" program */
2383697Sroot 
2393697Sroot char	fname[80];		/* file name buffer for ~< */
2403697Sroot char	copyname[80];		/* file name buffer for ~> */
2413697Sroot char	ccc;			/* synchronization character */
2423697Sroot char	ch;			/* for tipout */
2433697Sroot char	*uucplock;		/* name of lock file for uucp's */
2443697Sroot 
2453697Sroot /*
2463697Sroot  * From <sys/tty.h> (PDP-11 V7) ... it's put in here to avoid lots
2473697Sroot  *  of naming conflicts with stuff we have to pull in to use tty.h
2483697Sroot  */
2493697Sroot #ifndef TIOCFLUSH
2503697Sroot #	define TIOCFLUSH	(('t'<<8)|16)
2513697Sroot #endif
2523697Sroot 
2533697Sroot /*
2543697Sroot  * On PDP-11 V7 systems with Rand's capacity call use this
2553697Sroot  *  stuff, otherwise <assuming it's a VM system> use FIONREAD
2563697Sroot  */
2573697Sroot #ifndef FIONREAD
2583697Sroot #define	FIOCAPACITY	(('f'<<8)|3)
2593697Sroot 
2603697Sroot struct capacity {
2613697Sroot 	off_t	cp_nbytes;
2623697Sroot 	char	cp_eof;
2633697Sroot };
2643697Sroot #endif
2653697Sroot 
2663697Sroot #ifdef VMUNIX
2673697Sroot int	odisc;				/* initial tty line discipline */
2684005Ssam extern int disc;			/* current tty discpline */
2693697Sroot #endif
2703697Sroot 
2713697Sroot extern char		*ctrl();
2723697Sroot extern char		*ctime();
2733697Sroot extern long		time();
2743697Sroot extern struct passwd 	*getpwuid();
2753697Sroot extern char		*getlogin();
2763697Sroot extern char		*vinterp();
2773697Sroot extern char		*getenv();
2783697Sroot extern char		*rindex();
2793697Sroot extern char		*index();
2803697Sroot extern char		*malloc();
2813697Sroot extern char		*connect();
282