1/*
2 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3 * Use is subject to license terms.
4 */
5/*
6 * Copyright (c) 1983 Regents of the University of California.
7 * All rights reserved.  The Berkeley software License Agreement
8 * specifies the terms and conditions for redistribution.
9 */
10
11#ifndef	_TIP_H
12#define	_TIP_H
13
14#pragma ident	"%Z%%M%	%I%	%E% SMI"
15
16/*
17 * tip - terminal interface program
18 */
19
20#include <sys/types.h>
21#ifdef USG
22#include <fcntl.h>	/* for O_RDWR, etc. */
23#include <unistd.h>	/* for R_OK, etc. */
24#else
25#include <sys/file.h>
26#endif
27
28#include <sys/termios.h>
29#include <sys/filio.h>	/* XXX - for FIONREAD only */
30#include <signal.h>
31#include <stdio.h>
32#include <pwd.h>
33#include <ctype.h>
34#include <setjmp.h>
35#include <errno.h>
36#include <string.h>
37#include <time.h>
38#include <sys/isa_defs.h>	/* for ENDIAN defines */
39#include <stdlib.h>
40#include <sys/wait.h>
41
42#define	_CTRL(c)	(c&037)
43
44#ifdef USG
45#define	signal(_sig_, _hdlr_)	sigset((_sig_), (_hdlr_))
46#endif
47typedef	void (*sig_handler_t)(int);	/* works on BSD and SV */
48
49/*
50 * Remote host attributes
51 */
52char	*DV;			/* UNIX device(s) to open */
53char	*EL;			/* chars marking an EOL */
54char	*CM;			/* initial connection message */
55char	*IE;			/* EOT to expect on input */
56char	*OE;			/* EOT to send to complete FT */
57char	*CU;			/* call unit if making a phone call */
58char	*AT;			/* acu type */
59char	*PN;			/* phone number(s) */
60char	*DI;			/* disconnect string */
61char	*PA;			/* parity to be generated */
62
63char	*PH;			/* phone number file */
64char	*RM;			/* remote file name */
65char	*HO;			/* host name */
66
67int	BR;			/* line speed for conversation */
68int	FS;			/* frame size for transfers */
69
70signed char	DU;		/* this host is dialed up */
71char	HW;			/* this device is hardwired, see hunt.c */
72char	*ES;			/* escape character */
73char	*EX;			/* exceptions */
74char	*FO;			/* force (literal next) char */
75char	*RC;			/* raise character */
76char	*RE;			/* script record file */
77char	*PR;			/* remote prompt */
78int	DL;			/* line delay for file transfers to remote */
79int	CL;			/* char delay for file transfers to remote */
80int	ET;			/* echocheck timeout */
81int	DB;			/* dialback - ignore hangup */
82
83/*
84 * String value table
85 */
86typedef
87	struct {
88		char	*v_name;	/* whose name is it */
89		char	v_type;		/* for interpreting set's */
90		char	v_access;	/* protection of touchy ones */
91		char	*v_abrev;	/* possible abreviation */
92		char	*v_value;	/* casted to a union later */
93	}
94	value_t;
95
96#define	STRING	01		/* string valued */
97#define	BOOL	02		/* true-false value */
98#define	NUMBER	04		/* numeric value */
99#define	CHAR	010		/* character value */
100
101#define	WRITE	01		/* write access to variable */
102#define	READ	02		/* read access */
103
104#define	CHANGED	01		/* low bit is used to show modification */
105#define	PUBLIC	1		/* public access rights */
106#define	PRIVATE	03		/* private to definer */
107#define	ROOT	05		/* root defined */
108
109#define	TRUE	1
110#define	FALSE	0
111
112#define	ENVIRON	020		/* initialize out of the environment */
113#define	IREMOTE	040		/* initialize out of remote structure */
114#define	INIT	0100		/* static data space used for initialization */
115#define	TMASK	017
116
117/*
118 * Definition of ACU line description
119 */
120typedef
121	struct {
122		char	*acu_name;
123		int	(*acu_dialer)(char *, char *);
124		void	(*acu_disconnect)(void);
125		void	(*acu_abort)(void);
126	}
127	acu_t;
128
129#define	equal(a, b)	(strcmp(a, b) == 0)	/* A nice function to compare */
130
131/*
132 * variable manipulation stuff --
133 *   if we defined the value entry in value_t, then we couldn't
134 *   initialize it in vars.c, so we cast it as needed to keep lint
135 *   happy.
136 */
137typedef
138	union {
139		int	zz_number;
140		int	*zz_address;
141#if defined(_LITTLE_ENDIAN)
142		short	zz_boolean;
143		char	zz_character;
144#endif
145#if defined(_BIG_ENDIAN)
146		int	zz_boolean;
147		int	zz_character;
148#endif
149	}
150	zzhack;
151
152#define	value(v)	vtable[v].v_value
153
154#define	boolean(v)	((((zzhack *)(&(v))))->zz_boolean)
155#define	number(v)	((((zzhack *)(&(v))))->zz_number)
156#define	character(v)	((((zzhack *)(&(v))))->zz_character)
157#define	address(v)	((((zzhack *)(&(v))))->zz_address)
158
159/*
160 * Escape command table definitions --
161 *   lookup in this table is performed when ``escapec'' is recognized
162 *   at the begining of a line (as defined by the eolmarks variable).
163 */
164
165typedef
166	struct {
167		char	e_char;		/* char to match on */
168		char	e_flags;	/* experimental, priviledged */
169		char	*e_help;	/* help string */
170		void 	(*e_func)(int);	/* command */
171	}
172	esctable_t;
173
174#define	NORM	00		/* normal protection, execute anyone */
175#define	EXP	01		/* experimental, mark it with a `*' on help */
176#define	PRIV	02		/* priviledged, root execute only */
177
178extern int	vflag;		/* verbose during reading of .tiprc file */
179extern value_t	vtable[];	/* variable table */
180extern int	noparity;
181
182
183#ifndef ACULOG
184#define	logent(a, b, c, d)
185#define	loginit()
186#else
187extern void	logent(char *, char *, char *, char *);
188extern void	loginit(void);
189#endif
190
191/*
192 * Definition of indices into variable table so
193 *  value(DEFINE) turns into a static address.
194 */
195
196#define	BEAUTIFY	0
197#define	BAUDRATE	1
198#define	DIALTIMEOUT	2
199#define	EOFREAD		3
200#define	EOFWRITE	4
201#define	EOL		5
202#define	ESCAPE		6
203#define	EXCEPTIONS	7
204#define	FORCE		8
205#define	FRAMESIZE	9
206#define	HOST		10
207#define	LOG		11
208#define	PHONES		12
209#define	PROMPT		13
210#define	RAISE		14
211#define	RAISECHAR	15
212#define	RECORD		16
213#define	REMOTE		17
214#define	SCRIPT		18
215#define	TABEXPAND	19
216#define	VERBOSE		20
217#define	SHELL		21
218#define	HOME		22
219#define	ECHOCHECK	23
220#define	DISCONNECT	24
221#define	TAND		25
222#define	LDELAY		26
223#define	CDELAY		27
224#define	ETIMEOUT	28
225#define	RAWFTP		29
226#define	HALFDUPLEX	30
227#define	LECHO		31
228#define	PARITY		32
229#define	HARDWAREFLOW	33
230
231#define	NOVAL	((value_t *)NULL)
232#define	NOACU	((acu_t *)NULL)
233#define	NOSTR	((char *)NULL)
234#define	NOFILE	((FILE *)NULL)
235#define	NOPWD	((struct passwd *)0)
236
237struct termios	arg;		/* current mode of local terminal */
238struct termios	defarg;		/* initial mode of local terminal */
239
240FILE	*fscript;		/* FILE for scripting */
241FILE	*phfd;			/* FILE for PHONES file */
242
243int	fildes[2];		/* file transfer synchronization channel */
244int	repdes[2];		/* read process sychronization channel */
245int	FD;			/* open file descriptor to remote host */
246int	AC;			/* open file descriptor to dialer (v831 only) */
247int	vflag;			/* print .tiprc initialization sequence */
248int	sfd;			/* for ~< operation */
249int	pid;			/* pid of tipout */
250int	uid, euid;		/* real and effective user id's */
251int	gid, egid;		/* real and effective group id's */
252int	stoprompt;		/* for interrupting a prompt session */
253int	timedout;		/* ~> transfer timedout */
254int	cumode;			/* simulating the "cu" program */
255
256char	fname[80];		/* file name buffer for ~< */
257char	copyname[80];		/* file name buffer for ~> */
258char	ccc;			/* synchronization character */
259char	ch;			/* for tipout */
260char	*uucplock;		/* name of lock file for uucp's */
261extern int trusted_device;
262
263
264extern char	*connect(void);
265extern char	*ctrl(char);
266extern char	*getremote(char *);
267extern char	*expand(char []);
268extern char	*vinterp(char *, char);
269extern void	cumain(int, char *[]);
270extern void	delock(char *);
271extern void	disconnect(char *);
272extern void	myperm(void);
273extern void	parwrite(int, unsigned char *, int);
274extern void	raw(void);
275extern void	setparity(char *);
276extern void	setscript(void);
277extern void	tandem(char *);
278extern void	tip_abort(char *);
279extern void	ttysetup(int);
280extern void	unraw(void);
281extern void	userperm(void);
282extern void	vinit(void);
283extern void	vlex(char *);
284extern int	any(char, char *);
285extern int	hunt(char *);
286extern int	prompt(char *, char *, size_t);
287extern int	rgetent(char *, char *, int);
288extern int	rgetflag(char *);
289extern int	rgetnum(char *);
290extern int	speed(int);
291extern int	tip_mlock(char *);
292extern int	vstring(char *, char *);
293
294#endif /* _TIP_H */
295