1161754Sru/*	$OpenBSD: tip.h,v 1.27 2006/08/18 03:06:18 jason Exp $	*/
288276Smarkm/*	$NetBSD: tip.h,v 1.7 1997/04/20 00:02:46 mellon Exp $	*/
388276Smarkm/*	$FreeBSD: releng/10.3/usr.bin/tip/tip/tip.h 228992 2011-12-30 11:02:40Z uqs $	*/
488276Smarkm
57527Sjkh/*
67527Sjkh * Copyright (c) 1989, 1993
77527Sjkh *	The Regents of the University of California.  All rights reserved.
87527Sjkh *
97527Sjkh *
107527Sjkh * Redistribution and use in source and binary forms, with or without
117527Sjkh * modification, are permitted provided that the following conditions
127527Sjkh * are met:
137527Sjkh * 1. Redistributions of source code must retain the above copyright
147527Sjkh *    notice, this list of conditions and the following disclaimer.
157527Sjkh * 2. Redistributions in binary form must reproduce the above copyright
167527Sjkh *    notice, this list of conditions and the following disclaimer in the
177527Sjkh *    documentation and/or other materials provided with the distribution.
18161754Sru * 3. Neither the name of the University nor the names of its contributors
197527Sjkh *    may be used to endorse or promote products derived from this software
207527Sjkh *    without specific prior written permission.
217527Sjkh *
227527Sjkh * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
237527Sjkh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
247527Sjkh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
257527Sjkh * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
267527Sjkh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
277527Sjkh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
287527Sjkh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
297527Sjkh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
307527Sjkh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
317527Sjkh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
327527Sjkh * SUCH DAMAGE.
337527Sjkh *
347527Sjkh *      @(#)tip.h	8.1 (Berkeley) 6/6/93
357527Sjkh */
367527Sjkh
377527Sjkh/*
387527Sjkh * tip - terminal interface program
397527Sjkh */
407527Sjkh
417527Sjkh#include <sys/types.h>
427527Sjkh#include <sys/file.h>
437527Sjkh#include <sys/time.h>
4488276Smarkm#include <sys/wait.h>
4588276Smarkm#include <sys/ioctl.h>
467527Sjkh
4788276Smarkm#include <termios.h>
487527Sjkh#include <signal.h>
497527Sjkh#include <stdio.h>
507527Sjkh#include <stdlib.h>
517527Sjkh#include <string.h>
527527Sjkh#include <pwd.h>
537527Sjkh#include <ctype.h>
547527Sjkh#include <setjmp.h>
557527Sjkh#include <unistd.h>
567527Sjkh#include <errno.h>
5788276Smarkm#include <limits.h>
587527Sjkh
597527Sjkh/*
607527Sjkh * Remote host attributes
617527Sjkh */
627527Sjkhchar	*DV;			/* UNIX device(s) to open */
637527Sjkhchar	*EL;			/* chars marking an EOL */
647527Sjkhchar	*CM;			/* initial connection message */
657527Sjkhchar	*IE;			/* EOT to expect on input */
667527Sjkhchar	*OE;			/* EOT to send to complete FT */
677527Sjkhchar	*CU;			/* call unit if making a phone call */
687527Sjkhchar	*AT;			/* acu type */
697527Sjkhchar	*PN;			/* phone number(s) */
707527Sjkhchar	*DI;			/* disconnect string */
717527Sjkhchar	*PA;			/* parity to be generated */
727527Sjkh
737527Sjkhchar	*PH;			/* phone number file */
747527Sjkhchar	*RM;			/* remote file name */
757527Sjkhchar	*HO;			/* host name */
767527Sjkh
777527Sjkhlong	BR;			/* line speed for conversation */
787527Sjkhlong	FS;			/* frame size for transfers */
797527Sjkh
8088276Smarkmshort	DU;			/* this host is dialed up */
8188276Smarkmshort	HW;			/* this device is hardwired, see hunt.c */
827527Sjkhchar	*ES;			/* escape character */
837527Sjkhchar	*EX;			/* exceptions */
847527Sjkhchar	*FO;			/* force (literal next) char*/
857527Sjkhchar	*RC;			/* raise character */
867527Sjkhchar	*RE;			/* script record file */
877527Sjkhchar	*PR;			/* remote prompt */
887527Sjkhlong	DL;			/* line delay for file transfers to remote */
897527Sjkhlong	CL;			/* char delay for file transfers to remote */
907527Sjkhlong	ET;			/* echocheck timeout */
91161754Srulong	LD;			/* line disc */
9288276Smarkmshort	HD;			/* this host is half duplex - do local echo */
937527Sjkh
947527Sjkh/*
957527Sjkh * String value table
967527Sjkh */
977527Sjkhtypedef
987527Sjkh	struct {
997527Sjkh		char	*v_name;	/* whose name is it */
1007527Sjkh		char	v_type;		/* for interpreting set's */
1017527Sjkh		char	v_access;	/* protection of touchy ones */
102228992Suqs		char	*v_abrev;	/* possible abbreviation */
1037527Sjkh		char	*v_value;	/* casted to a union later */
1047527Sjkh	}
1057527Sjkh	value_t;
1067527Sjkh
1077527Sjkh#define STRING	01		/* string valued */
1087527Sjkh#define BOOL	02		/* true-false value */
1097527Sjkh#define NUMBER	04		/* numeric value */
1107527Sjkh#define CHAR	010		/* character value */
1117527Sjkh
1127527Sjkh#define WRITE	01		/* write access to variable */
1137527Sjkh#define	READ	02		/* read access */
1147527Sjkh
1157527Sjkh#define CHANGED	01		/* low bit is used to show modification */
1167527Sjkh#define PUBLIC	1		/* public access rights */
1177527Sjkh#define PRIVATE	03		/* private to definer */
1187527Sjkh#define ROOT	05		/* root defined */
1197527Sjkh
1207527Sjkh#define	TRUE	1
1217527Sjkh#define FALSE	0
1227527Sjkh
1237527Sjkh#define ENVIRON	020		/* initialize out of the environment */
1247527Sjkh#define IREMOTE	040		/* initialize out of remote structure */
1257527Sjkh#define INIT	0100		/* static data space used for initialization */
1267527Sjkh#define TMASK	017
1277527Sjkh
1287527Sjkh/*
1297527Sjkh * Definition of ACU line description
1307527Sjkh */
1317527Sjkhtypedef
1327527Sjkh	struct {
133161754Sru		char	*acu_name;
134161754Sru		int	(*acu_dialer)(char *, char *);
135161754Sru		void	(*acu_disconnect)(void);
136161754Sru		void	(*acu_abort)(void);
1377527Sjkh	}
1387527Sjkh	acu_t;
1397527Sjkh
1407527Sjkh#define	equal(a, b)	(strcmp(a,b)==0)/* A nice function to string compare */
1417527Sjkh
1427527Sjkh/*
1437527Sjkh * variable manipulation stuff --
1447527Sjkh *   if we defined the value entry in value_t, then we couldn't
1457527Sjkh *   initialize it in vars.c, so we cast it as needed to keep lint
1467527Sjkh *   happy.
1477527Sjkh */
1487527Sjkh
1497527Sjkh#define value(v)	vtable[v].v_value
150161754Sru#define lvalue(v)	(long)vtable[v].v_value
1517527Sjkh
15288276Smarkm#define	number(v)	((long)(v))
15388276Smarkm#define	boolean(v)      ((short)(long)(v))
15488276Smarkm#define	character(v)    ((char)(long)(v))
15588276Smarkm#define	address(v)      ((long *)(v))
1567527Sjkh
15788276Smarkm#define	setnumber(v,n)		do { (v) = (char *)(long)(n); } while (0)
15888276Smarkm#define	setboolean(v,n)		do { (v) = (char *)(long)(n); } while (0)
15988276Smarkm#define	setcharacter(v,n)	do { (v) = (char *)(long)(n); } while (0)
16088276Smarkm#define	setaddress(v,n)		do { (v) = (char *)(n); } while (0)
1617527Sjkh
1627527Sjkh/*
1637527Sjkh * Escape command table definitions --
1647527Sjkh *   lookup in this table is performed when ``escapec'' is recognized
165228992Suqs *   at the beginning of a line (as defined by the eolmarks variable).
1667527Sjkh*/
1677527Sjkh
1687527Sjkhtypedef
1697527Sjkh	struct {
170161754Sru		char	e_char;			/* char to match on */
171161754Sru		char	e_flags;		/* experimental, privileged */
172161754Sru		char	*e_help;		/* help string */
173161754Sru		void	(*e_func)(int);		/* command */
1747527Sjkh	}
1757527Sjkh	esctable_t;
1767527Sjkh
1777527Sjkh#define NORM	00		/* normal protection, execute anyone */
1787527Sjkh#define EXP	01		/* experimental, mark it with a `*' on help */
179161754Sru#define PRIV	02		/* privileged, root execute only */
1807527Sjkh
1817527Sjkhextern int	vflag;		/* verbose during reading of .tiprc file */
18288276Smarkmextern int	noesc;		/* no escape `~' char */
1837527Sjkhextern value_t	vtable[];	/* variable table */
1847527Sjkh
18588276Smarkm#ifndef ACULOG
1867527Sjkh#define logent(a, b, c, d)
1877527Sjkh#define loginit()
1887527Sjkh#endif
1897527Sjkh
1907527Sjkh/*
1917527Sjkh * Definition of indices into variable table so
1927527Sjkh *  value(DEFINE) turns into a static address.
1937527Sjkh */
1947527Sjkh
19588276Smarkm#define BEAUTIFY	0
19688276Smarkm#define BAUDRATE	1
19788276Smarkm#define DIALTIMEOUT	2
19888276Smarkm#define EOFREAD		3
19988276Smarkm#define EOFWRITE	4
20088276Smarkm#define EOL		5
20188276Smarkm#define ESCAPE		6
20288276Smarkm#define EXCEPTIONS	7
20388276Smarkm#define FORCE		8
20488276Smarkm#define FRAMESIZE	9
20588276Smarkm#define HOST		10
20688276Smarkm#define LOG		11
20788276Smarkm#define PHONES		12
20888276Smarkm#define PROMPT		13
20988276Smarkm#define RAISE		14
21088276Smarkm#define RAISECHAR	15
21188276Smarkm#define RECORD		16
21288276Smarkm#define REMOTE		17
21388276Smarkm#define SCRIPT		18
21488276Smarkm#define TABEXPAND	19
21588276Smarkm#define VERBOSE		20
21688276Smarkm#define SHELL		21
21788276Smarkm#define HOME		22
21888276Smarkm#define ECHOCHECK	23
21988276Smarkm#define DISCONNECT	24
22088276Smarkm#define TAND		25
22188276Smarkm#define LDELAY		26
22288276Smarkm#define CDELAY		27
22388276Smarkm#define ETIMEOUT	28
22488276Smarkm#define RAWFTP		29
22588276Smarkm#define HALFDUPLEX	30
22688276Smarkm#define	LECHO		31
22788276Smarkm#define	PARITY		32
228161754Sru#define	HARDWAREFLOW	33
229161754Sru#define	LINEDISC	34
230161754Sru#define	DC		35
2317527Sjkh
2327527Sjkh#define NOVAL	((value_t *)NULL)
2337527Sjkh#define NOACU	((acu_t *)NULL)
2347527Sjkh#define NOSTR	((char *)NULL)
2357527Sjkh#define NOFILE	((FILE *)NULL)
2367527Sjkh#define NOPWD	((struct passwd *)0)
2377527Sjkh
23888276Smarkmstruct termios	term;		/* current mode of terminal */
23988276Smarkmstruct termios	defterm;	/* initial mode of terminal */
24088276Smarkmstruct termios	defchars;	/* current mode with initial chars */
241161754Sruint	gotdefterm;
2427527Sjkh
2437527SjkhFILE	*fscript;		/* FILE for scripting */
2447527Sjkh
2457527Sjkhint	fildes[2];		/* file transfer synchronization channel */
2467527Sjkhint	repdes[2];		/* read process sychronization channel */
2477527Sjkhint	FD;			/* open file descriptor to remote host */
2487527Sjkhint	AC;			/* open file descriptor to dialer (v831 only) */
2497527Sjkhint	vflag;			/* print .tiprc initialization sequence */
25088276Smarkmint	noesc;			/* no `~' escape char */
2517527Sjkhint	sfd;			/* for ~< operation */
252161754Srupid_t	tipin_pid;		/* pid of tipin */
253161754Srupid_t	tipout_pid;		/* pid of tipout */
2547527Sjkhuid_t	uid, euid;		/* real and effective user id's */
2557527Sjkhgid_t	gid, egid;		/* real and effective group id's */
2567527Sjkhint	stop;			/* stop transfer session flag */
2577527Sjkhint	quit;			/* same; but on other end */
2587527Sjkhint	intflag;		/* recognized interrupt */
2597527Sjkhint	stoprompt;		/* for interrupting a prompt session */
2607527Sjkhint	timedout;		/* ~> transfer timedout */
2617527Sjkhint	cumode;			/* simulating the "cu" program */
262218965Sbrucecint	bits8;			/* terminal is 8-bit mode */
26388276Smarkm#define STRIP_PAR	(bits8 ? 0377 : 0177)
2647527Sjkh
26528686Simpchar	fname[PATH_MAX];	/* file name buffer for ~< */
26628686Simpchar	copyname[PATH_MAX];	/* file name buffer for ~> */
2677527Sjkhchar	ccc;			/* synchronization character */
2687527Sjkhchar	*uucplock;		/* name of lock file for uucp's */
2697527Sjkh
27088276Smarkmint	odisc;			/* initial tty line discipline */
27188276Smarkmextern	int disc;		/* current tty discpline */
2727527Sjkh
27388276Smarkmextern	char *__progname;	/* program name */
2747527Sjkh
275161754Sruchar	*con(void);
276161754Sruchar	*ctrl(char);
277161754Sruchar	*expand(char *);
278161754Sruchar	*getremote(char *);
279161754Sruchar	*interp(char *);
280161754Sruint	any(int, char *);
281161754Sruint	biz22w_dialer(char *, char *);
282161754Sruint	biz22f_dialer(char *, char *);
283161754Sruint	biz31w_dialer(char *, char *);
284161754Sruint	biz31f_dialer(char *, char *);
285161754Sruint	cour_dialer(char *, char *);
286161754Sruint	df02_dialer(char *, char *);
287161754Sruint	df03_dialer(char *, char *);
288161754Sruint	dn_dialer(char *, char *);
289161754Sruint	hay_dialer(char *, char *);
290161754Sruint	prompt(char *, char *, size_t);
291161754Srusize_t	size(char *);
292161754Sruint	t3000_dialer(char *, char *);
293161754Sruint	ttysetup(int);
294161754Sruint	uu_lock(char *);
295161754Sruint	uu_unlock(char *);
296161754Sruint	v3451_dialer(char *, char *);
297161754Sruint	v831_dialer(char *, char *);
298161754Sruint	ven_dialer(char *, char *);
299161754Sruint	vstring(char *, char *);
300161754Srulong	hunt(char *);
301161754Sruvoid	biz22_disconnect(void);
302161754Sruvoid	biz22_abort(void);
303161754Sruvoid	biz31_disconnect(void);
304161754Sruvoid	biz31_abort(void);
305161754Sruvoid	chdirectory(int);
306161754Sruvoid	cleanup(int);
307161754Sruvoid	consh(int);
308161754Sruvoid	cour_abort(void);
309161754Sruvoid	cour_disconnect(void);
310161754Sruvoid	cu_put(int);
311161754Sruvoid	cu_take(int);
312161754Sruvoid	cumain(int, char **);
31392922Simpvoid	daemon_uid(void);
314161754Sruvoid	df_abort(void);
315161754Sruvoid	df_disconnect(void);
316161754Sruvoid	disconnect(char *);
317161754Sruvoid	dn_abort(void);
318161754Sruvoid	dn_disconnect(void);
319161754Sruvoid	finish(int);
320161754Sruvoid	genbrk(int);
321161754Sruvoid	getfl(int);
322161754Sruvoid	hay_abort(void);
323161754Sruvoid	hay_disconnect(void);
324161754Sruvoid	help(int);
325161754Sruvoid	listvariables(int);
326161754Sruvoid	logent(char *, char *, char *, char *);
32792922Simpvoid	loginit(void);
328161754Sruvoid	parwrite(int, char *, size_t);
329161754Sruvoid	pipefile(int);
330161754Sruvoid	pipeout(int);
33192922Simpvoid	raw(void);
332161754Sruvoid	sendfile(int);
333161754Sruvoid	setparity(char *);
33492922Simpvoid	setscript(void);
335161754Sruvoid	shell(int);
33692922Simpvoid	shell_uid(void);
337161754Sruvoid	suspend(int);
338161754Sruvoid	t3000_disconnect(void);
339161754Sruvoid	t3000_abort(void);
340161754Sruvoid	timeout(int);
341161754Sruvoid	tipabort(char *);
34292922Simpvoid	tipout(void);
343161754Sruvoid	user_uid(void);
344178736Sbmsvoid	unexcl(void);
34592922Simpvoid	unraw(void);
346161754Sruvoid	v3451_abort(void);
347161754Sruvoid	v3451_disconnect(void);
348161754Sruvoid	v831_disconnect(void);
349161754Sruvoid	v831_abort(void);
350161754Sruvoid	variable(int);
35192922Simpvoid	ven_disconnect(void);
35292922Simpvoid	ven_abort(void);
353161754Sruvoid	vinit(void);
354161754Sruvoid	vlex(char *);
355