17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
37c478bdstevel@tonic-gate * Use is subject to license terms.
47c478bdstevel@tonic-gate */
57c478bdstevel@tonic-gate/*
67c478bdstevel@tonic-gate * Copyright (c) 1983 Regents of the University of California.
77c478bdstevel@tonic-gate * All rights reserved.  The Berkeley software License Agreement
87c478bdstevel@tonic-gate * specifies the terms and conditions for redistribution.
97c478bdstevel@tonic-gate */
107c478bdstevel@tonic-gate
118d489c7muffin#ifndef	_TIP_H
128d489c7muffin#define	_TIP_H
138d489c7muffin
147c478bdstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
157c478bdstevel@tonic-gate
167c478bdstevel@tonic-gate/*
177c478bdstevel@tonic-gate * tip - terminal interface program
187c478bdstevel@tonic-gate */
197c478bdstevel@tonic-gate
207c478bdstevel@tonic-gate#include <sys/types.h>
217c478bdstevel@tonic-gate#ifdef USG
227c478bdstevel@tonic-gate#include <fcntl.h>	/* for O_RDWR, etc. */
237c478bdstevel@tonic-gate#include <unistd.h>	/* for R_OK, etc. */
247c478bdstevel@tonic-gate#else
257c478bdstevel@tonic-gate#include <sys/file.h>
267c478bdstevel@tonic-gate#endif
277c478bdstevel@tonic-gate
287c478bdstevel@tonic-gate#include <sys/termios.h>
297c478bdstevel@tonic-gate#include <sys/filio.h>	/* XXX - for FIONREAD only */
307c478bdstevel@tonic-gate#include <signal.h>
317c478bdstevel@tonic-gate#include <stdio.h>
327c478bdstevel@tonic-gate#include <pwd.h>
337c478bdstevel@tonic-gate#include <ctype.h>
347c478bdstevel@tonic-gate#include <setjmp.h>
357c478bdstevel@tonic-gate#include <errno.h>
367c478bdstevel@tonic-gate#include <string.h>
377c478bdstevel@tonic-gate#include <time.h>
387c478bdstevel@tonic-gate#include <sys/isa_defs.h>	/* for ENDIAN defines */
398d489c7muffin#include <stdlib.h>
408d489c7muffin#include <sys/wait.h>
417c478bdstevel@tonic-gate
427c478bdstevel@tonic-gate#define	_CTRL(c)	(c&037)
437c478bdstevel@tonic-gate
447c478bdstevel@tonic-gate#ifdef USG
457c478bdstevel@tonic-gate#define	signal(_sig_, _hdlr_)	sigset((_sig_), (_hdlr_))
467c478bdstevel@tonic-gate#endif
478d489c7muffintypedef	void (*sig_handler_t)(int);	/* works on BSD and SV */
487c478bdstevel@tonic-gate
497c478bdstevel@tonic-gate/*
507c478bdstevel@tonic-gate * Remote host attributes
517c478bdstevel@tonic-gate */
527c478bdstevel@tonic-gatechar	*DV;			/* UNIX device(s) to open */
537c478bdstevel@tonic-gatechar	*EL;			/* chars marking an EOL */
547c478bdstevel@tonic-gatechar	*CM;			/* initial connection message */
557c478bdstevel@tonic-gatechar	*IE;			/* EOT to expect on input */
567c478bdstevel@tonic-gatechar	*OE;			/* EOT to send to complete FT */
577c478bdstevel@tonic-gatechar	*CU;			/* call unit if making a phone call */
587c478bdstevel@tonic-gatechar	*AT;			/* acu type */
597c478bdstevel@tonic-gatechar	*PN;			/* phone number(s) */
607c478bdstevel@tonic-gatechar	*DI;			/* disconnect string */
617c478bdstevel@tonic-gatechar	*PA;			/* parity to be generated */
627c478bdstevel@tonic-gate
637c478bdstevel@tonic-gatechar	*PH;			/* phone number file */
647c478bdstevel@tonic-gatechar	*RM;			/* remote file name */
657c478bdstevel@tonic-gatechar	*HO;			/* host name */
667c478bdstevel@tonic-gate
677c478bdstevel@tonic-gateint	BR;			/* line speed for conversation */
687c478bdstevel@tonic-gateint	FS;			/* frame size for transfers */
697c478bdstevel@tonic-gate
707c478bdstevel@tonic-gatesigned char	DU;		/* this host is dialed up */
717c478bdstevel@tonic-gatechar	HW;			/* this device is hardwired, see hunt.c */
727c478bdstevel@tonic-gatechar	*ES;			/* escape character */
737c478bdstevel@tonic-gatechar	*EX;			/* exceptions */
747c478bdstevel@tonic-gatechar	*FO;			/* force (literal next) char */
757c478bdstevel@tonic-gatechar	*RC;			/* raise character */
767c478bdstevel@tonic-gatechar	*RE;			/* script record file */
777c478bdstevel@tonic-gatechar	*PR;			/* remote prompt */
787c478bdstevel@tonic-gateint	DL;			/* line delay for file transfers to remote */
797c478bdstevel@tonic-gateint	CL;			/* char delay for file transfers to remote */
807c478bdstevel@tonic-gateint	ET;			/* echocheck timeout */
817c478bdstevel@tonic-gateint	DB;			/* dialback - ignore hangup */
827c478bdstevel@tonic-gate
837c478bdstevel@tonic-gate/*
847c478bdstevel@tonic-gate * String value table
857c478bdstevel@tonic-gate */
867c478bdstevel@tonic-gatetypedef
877c478bdstevel@tonic-gate	struct {
887c478bdstevel@tonic-gate		char	*v_name;	/* whose name is it */
897c478bdstevel@tonic-gate		char	v_type;		/* for interpreting set's */
907c478bdstevel@tonic-gate		char	v_access;	/* protection of touchy ones */
917c478bdstevel@tonic-gate		char	*v_abrev;	/* possible abreviation */
927c478bdstevel@tonic-gate		char	*v_value;	/* casted to a union later */
937c478bdstevel@tonic-gate	}
947c478bdstevel@tonic-gate	value_t;
957c478bdstevel@tonic-gate
967c478bdstevel@tonic-gate#define	STRING	01		/* string valued */
977c478bdstevel@tonic-gate#define	BOOL	02		/* true-false value */
987c478bdstevel@tonic-gate#define	NUMBER	04		/* numeric value */
997c478bdstevel@tonic-gate#define	CHAR	010		/* character value */
1007c478bdstevel@tonic-gate
1017c478bdstevel@tonic-gate#define	WRITE	01		/* write access to variable */
1027c478bdstevel@tonic-gate#define	READ	02		/* read access */
1037c478bdstevel@tonic-gate
1047c478bdstevel@tonic-gate#define	CHANGED	01		/* low bit is used to show modification */
1057c478bdstevel@tonic-gate#define	PUBLIC	1		/* public access rights */
1067c478bdstevel@tonic-gate#define	PRIVATE	03		/* private to definer */
1077c478bdstevel@tonic-gate#define	ROOT	05		/* root defined */
1087c478bdstevel@tonic-gate
1097c478bdstevel@tonic-gate#define	TRUE	1
1107c478bdstevel@tonic-gate#define	FALSE	0
1117c478bdstevel@tonic-gate
1127c478bdstevel@tonic-gate#define	ENVIRON	020		/* initialize out of the environment */
1137c478bdstevel@tonic-gate#define	IREMOTE	040		/* initialize out of remote structure */
1147c478bdstevel@tonic-gate#define	INIT	0100		/* static data space used for initialization */
1157c478bdstevel@tonic-gate#define	TMASK	017
1167c478bdstevel@tonic-gate
1177c478bdstevel@tonic-gate/*
1187c478bdstevel@tonic-gate * Definition of ACU line description
1197c478bdstevel@tonic-gate */
1207c478bdstevel@tonic-gatetypedef
1217c478bdstevel@tonic-gate	struct {
1227c478bdstevel@tonic-gate		char	*acu_name;
1238d489c7muffin		int	(*acu_dialer)(char *, char *);
1248d489c7muffin		void	(*acu_disconnect)(void);
1258d489c7muffin		void	(*acu_abort)(void);
1267c478bdstevel@tonic-gate	}
1277c478bdstevel@tonic-gate	acu_t;
1287c478bdstevel@tonic-gate
1297c478bdstevel@tonic-gate#define	equal(a, b)	(strcmp(a, b) == 0)	/* A nice function to compare */
1307c478bdstevel@tonic-gate
1317c478bdstevel@tonic-gate/*
1327c478bdstevel@tonic-gate * variable manipulation stuff --
1337c478bdstevel@tonic-gate *   if we defined the value entry in value_t, then we couldn't
1347c478bdstevel@tonic-gate *   initialize it in vars.c, so we cast it as needed to keep lint
1357c478bdstevel@tonic-gate *   happy.
1367c478bdstevel@tonic-gate */
1377c478bdstevel@tonic-gatetypedef
1387c478bdstevel@tonic-gate	union {
1397c478bdstevel@tonic-gate		int	zz_number;
1407c478bdstevel@tonic-gate		int	*zz_address;
1417c478bdstevel@tonic-gate#if defined(_LITTLE_ENDIAN)
1427c478bdstevel@tonic-gate		short	zz_boolean;
1437c478bdstevel@tonic-gate		char	zz_character;
1447c478bdstevel@tonic-gate#endif
1457c478bdstevel@tonic-gate#if defined(_BIG_ENDIAN)
1467c478bdstevel@tonic-gate		int	zz_boolean;
1477c478bdstevel@tonic-gate		int	zz_character;
1487c478bdstevel@tonic-gate#endif
1497c478bdstevel@tonic-gate	}
1507c478bdstevel@tonic-gate	zzhack;
1517c478bdstevel@tonic-gate
1527c478bdstevel@tonic-gate#define	value(v)	vtable[v].v_value
1537c478bdstevel@tonic-gate
1547c478bdstevel@tonic-gate#define	boolean(v)	((((zzhack *)(&(v))))->zz_boolean)
1557c478bdstevel@tonic-gate#define	number(v)	((((zzhack *)(&(v))))->zz_number)
1567c478bdstevel@tonic-gate#define	character(v)	((((zzhack *)(&(v))))->zz_character)
1577c478bdstevel@tonic-gate#define	address(v)	((((zzhack *)(&(v))))->zz_address)
1587c478bdstevel@tonic-gate
1597c478bdstevel@tonic-gate/*
1607c478bdstevel@tonic-gate * Escape command table definitions --
1617c478bdstevel@tonic-gate *   lookup in this table is performed when ``escapec'' is recognized
1627c478bdstevel@tonic-gate *   at the begining of a line (as defined by the eolmarks variable).
1637c478bdstevel@tonic-gate */
1647c478bdstevel@tonic-gate
1657c478bdstevel@tonic-gatetypedef
1667c478bdstevel@tonic-gate	struct {
1677c478bdstevel@tonic-gate		char	e_char;		/* char to match on */
1687c478bdstevel@tonic-gate		char	e_flags;	/* experimental, priviledged */
1697c478bdstevel@tonic-gate		char	*e_help;	/* help string */
1708d489c7muffin		void 	(*e_func)(int);	/* command */
1717c478bdstevel@tonic-gate	}
1727c478bdstevel@tonic-gate	esctable_t;
1737c478bdstevel@tonic-gate
1747c478bdstevel@tonic-gate#define	NORM	00		/* normal protection, execute anyone */
1757c478bdstevel@tonic-gate#define	EXP	01		/* experimental, mark it with a `*' on help */
1767c478bdstevel@tonic-gate#define	PRIV	02		/* priviledged, root execute only */
1777c478bdstevel@tonic-gate
1787c478bdstevel@tonic-gateextern int	vflag;		/* verbose during reading of .tiprc file */
1797c478bdstevel@tonic-gateextern value_t	vtable[];	/* variable table */
1807c478bdstevel@tonic-gateextern int	noparity;
1817c478bdstevel@tonic-gate
1827c478bdstevel@tonic-gate
1837c478bdstevel@tonic-gate#ifndef ACULOG
1847c478bdstevel@tonic-gate#define	logent(a, b, c, d)
1857c478bdstevel@tonic-gate#define	loginit()
1868d489c7muffin#else
1878d489c7muffinextern void	logent(char *, char *, char *, char *);
1888d489c7muffinextern void	loginit(void);
1897c478bdstevel@tonic-gate#endif
1907c478bdstevel@tonic-gate
1917c478bdstevel@tonic-gate/*
1927c478bdstevel@tonic-gate * Definition of indices into variable table so
1937c478bdstevel@tonic-gate *  value(DEFINE) turns into a static address.
1947c478bdstevel@tonic-gate */
1957c478bdstevel@tonic-gate
1967c478bdstevel@tonic-gate#define	BEAUTIFY	0
1977c478bdstevel@tonic-gate#define	BAUDRATE	1
1987c478bdstevel@tonic-gate#define	DIALTIMEOUT	2
1997c478bdstevel@tonic-gate#define	EOFREAD		3
2007c478bdstevel@tonic-gate#define	EOFWRITE	4
2017c478bdstevel@tonic-gate#define	EOL		5
2027c478bdstevel@tonic-gate#define	ESCAPE		6
2037c478bdstevel@tonic-gate#define	EXCEPTIONS	7
2047c478bdstevel@tonic-gate#define	FORCE		8
2057c478bdstevel@tonic-gate#define	FRAMESIZE	9
2067c478bdstevel@tonic-gate#define	HOST		10
2077c478bdstevel@tonic-gate#define	LOG		11
2087c478bdstevel@tonic-gate#define	PHONES		12
2097c478bdstevel@tonic-gate#define	PROMPT		13
2107c478bdstevel@tonic-gate#define	RAISE		14
2117c478bdstevel@tonic-gate#define	RAISECHAR	15
2127c478bdstevel@tonic-gate#define	RECORD		16
2137c478bdstevel@tonic-gate#define	REMOTE		17
2147c478bdstevel@tonic-gate#define	SCRIPT		18
2157c478bdstevel@tonic-gate#define	TABEXPAND	19
2167c478bdstevel@tonic-gate#define	VERBOSE		20
2177c478bdstevel@tonic-gate#define	SHELL		21
2187c478bdstevel@tonic-gate#define	HOME		22
2197c478bdstevel@tonic-gate#define	ECHOCHECK	23
2207c478bdstevel@tonic-gate#define	DISCONNECT	24
2217c478bdstevel@tonic-gate#define	TAND		25
2227c478bdstevel@tonic-gate#define	LDELAY		26
2237c478bdstevel@tonic-gate#define	CDELAY		27
2247c478bdstevel@tonic-gate#define	ETIMEOUT	28
2257c478bdstevel@tonic-gate#define	RAWFTP		29
2267c478bdstevel@tonic-gate#define	HALFDUPLEX	30
2277c478bdstevel@tonic-gate#define	LECHO		31
2287c478bdstevel@tonic-gate#define	PARITY		32
2297c478bdstevel@tonic-gate#define	HARDWAREFLOW	33
2307c478bdstevel@tonic-gate
2317c478bdstevel@tonic-gate#define	NOVAL	((value_t *)NULL)
2327c478bdstevel@tonic-gate#define	NOACU	((acu_t *)NULL)
2337c478bdstevel@tonic-gate#define	NOSTR	((char *)NULL)
2347c478bdstevel@tonic-gate#define	NOFILE	((FILE *)NULL)
2357c478bdstevel@tonic-gate#define	NOPWD	((struct passwd *)0)
2367c478bdstevel@tonic-gate
2377c478bdstevel@tonic-gatestruct termios	arg;		/* current mode of local terminal */
2387c478bdstevel@tonic-gatestruct termios	defarg;		/* initial mode of local terminal */
2397c478bdstevel@tonic-gate
2407c478bdstevel@tonic-gateFILE	*fscript;		/* FILE for scripting */
2417c478bdstevel@tonic-gateFILE	*phfd;			/* FILE for PHONES file */
2427c478bdstevel@tonic-gate
2437c478bdstevel@tonic-gateint	fildes[2];		/* file transfer synchronization channel */
2447c478bdstevel@tonic-gateint	repdes[2];		/* read process sychronization channel */
2457c478bdstevel@tonic-gateint	FD;			/* open file descriptor to remote host */
2467c478bdstevel@tonic-gateint	AC;			/* open file descriptor to dialer (v831 only) */
2477c478bdstevel@tonic-gateint	vflag;			/* print .tiprc initialization sequence */
2487c478bdstevel@tonic-gateint	sfd;			/* for ~< operation */
2497c478bdstevel@tonic-gateint	pid;			/* pid of tipout */
2507c478bdstevel@tonic-gateint	uid, euid;		/* real and effective user id's */
2517c478bdstevel@tonic-gateint	gid, egid;		/* real and effective group id's */
2527c478bdstevel@tonic-gateint	stoprompt;		/* for interrupting a prompt session */
2537c478bdstevel@tonic-gateint	timedout;		/* ~> transfer timedout */
2547c478bdstevel@tonic-gateint	cumode;			/* simulating the "cu" program */
2557c478bdstevel@tonic-gate
2567c478bdstevel@tonic-gatechar	fname[80];		/* file name buffer for ~< */
2577c478bdstevel@tonic-gatechar	copyname[80];		/* file name buffer for ~> */
2587c478bdstevel@tonic-gatechar	ccc;			/* synchronization character */
2597c478bdstevel@tonic-gatechar	ch;			/* for tipout */
2607c478bdstevel@tonic-gatechar	*uucplock;		/* name of lock file for uucp's */
2617c478bdstevel@tonic-gateextern int trusted_device;
2627c478bdstevel@tonic-gate
2638d489c7muffin
2648d489c7muffinextern char	*connect(void);
2658d489c7muffinextern char	*ctrl(char);
2668d489c7muffinextern char	*getremote(char *);
2678d489c7muffinextern char	*expand(char []);
2688d489c7muffinextern char	*vinterp(char *, char);
2698d489c7muffinextern void	cumain(int, char *[]);
2708d489c7muffinextern void	delock(char *);
2718d489c7muffinextern void	disconnect(char *);
2728d489c7muffinextern void	myperm(void);
2738d489c7muffinextern void	parwrite(int, unsigned char *, int);
2748d489c7muffinextern void	raw(void);
2758d489c7muffinextern void	setparity(char *);
2768d489c7muffinextern void	setscript(void);
2778d489c7muffinextern void	tandem(char *);
2788d489c7muffinextern void	tip_abort(char *);
2798d489c7muffinextern void	ttysetup(int);
2808d489c7muffinextern void	unraw(void);
2818d489c7muffinextern void	userperm(void);
2828d489c7muffinextern void	vinit(void);
2838d489c7muffinextern void	vlex(char *);
2848d489c7muffinextern int	any(char, char *);
2858d489c7muffinextern int	hunt(char *);
2868d489c7muffinextern int	prompt(char *, char *, size_t);
2878d489c7muffinextern int	rgetent(char *, char *, int);
2888d489c7muffinextern int	rgetflag(char *);
2898d489c7muffinextern int	rgetnum(char *);
2908d489c7muffinextern int	speed(int);
2918d489c7muffinextern int	tip_mlock(char *);
2928d489c7muffinextern int	vstring(char *, char *);
2938d489c7muffin
2948d489c7muffin#endif /* _TIP_H */
295