4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / usr.bin / tip / tip.h
CommitLineData
051b1e55 1/*
abfba3de
KB
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
051b1e55 4 *
b076e718 5 *
cb956e54 6 * %sccs.include.redist.c%
c9686c12 7 *
abfba3de 8 * @(#)tip.h 8.1 (Berkeley) %G%
051b1e55 9 */
05862919 10
11adac90
BJ
11/*
12 * tip - terminal interface program
11adac90
BJ
13 */
14
05862919 15#include <sys/types.h>
4d50e976 16#include <machine/endian.h>
05862919 17#include <sys/file.h>
5ed0621b 18#include <sys/time.h>
05862919 19
11adac90
BJ
20#include <sgtty.h>
21#include <signal.h>
22#include <stdio.h>
5ed0621b
CT
23#include <stdlib.h>
24#include <string.h>
11adac90 25#include <pwd.h>
c731dacc 26#include <ctype.h>
05862919 27#include <setjmp.h>
5ed0621b 28#include <unistd.h>
05862919 29#include <errno.h>
11adac90
BJ
30
31/*
32 * Remote host attributes
33 */
34char *DV; /* UNIX device(s) to open */
35char *EL; /* chars marking an EOL */
36char *CM; /* initial connection message */
37char *IE; /* EOT to expect on input */
38char *OE; /* EOT to send to complete FT */
39char *CU; /* call unit if making a phone call */
40char *AT; /* acu type */
41char *PN; /* phone number(s) */
8b6d643c
RC
42char *DI; /* disconnect string */
43char *PA; /* parity to be generated */
11adac90
BJ
44
45char *PH; /* phone number file */
46char *RM; /* remote file name */
47char *HO; /* host name */
48
b076e718
EA
49long BR; /* line speed for conversation */
50long FS; /* frame size for transfers */
11adac90
BJ
51
52char DU; /* this host is dialed up */
f0211bf2 53char HW; /* this device is hardwired, see hunt.c */
8b6d643c
RC
54char *ES; /* escape character */
55char *EX; /* exceptions */
56char *FO; /* force (literal next) char*/
57char *RC; /* raise character */
58char *RE; /* script record file */
59char *PR; /* remote prompt */
b076e718
EA
60long DL; /* line delay for file transfers to remote */
61long CL; /* char delay for file transfers to remote */
62long ET; /* echocheck timeout */
8b6d643c 63char HD; /* this host is half duplex - do local echo */
11adac90
BJ
64
65/*
66 * String value table
67 */
68typedef
69 struct {
70 char *v_name; /* whose name is it */
71 char v_type; /* for interpreting set's */
72 char v_access; /* protection of touchy ones */
73 char *v_abrev; /* possible abreviation */
74 char *v_value; /* casted to a union later */
75 }
76 value_t;
77
78#define STRING 01 /* string valued */
79#define BOOL 02 /* true-false value */
80#define NUMBER 04 /* numeric value */
81#define CHAR 010 /* character value */
82
83#define WRITE 01 /* write access to variable */
84#define READ 02 /* read access */
85
86#define CHANGED 01 /* low bit is used to show modification */
87#define PUBLIC 1 /* public access rights */
88#define PRIVATE 03 /* private to definer */
89#define ROOT 05 /* root defined */
90
91#define TRUE 1
92#define FALSE 0
93
94#define ENVIRON 020 /* initialize out of the environment */
95#define IREMOTE 040 /* initialize out of remote structure */
96#define INIT 0100 /* static data space used for initialization */
97#define TMASK 017
98
99/*
100 * Definition of ACU line description
101 */
102typedef
103 struct {
104 char *acu_name;
105 int (*acu_dialer)();
106 int (*acu_disconnect)();
107 int (*acu_abort)();
108 }
109 acu_t;
110
111#define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */
11adac90
BJ
112
113/*
114 * variable manipulation stuff --
115 * if we defined the value entry in value_t, then we couldn't
116 * initialize it in vars.c, so we cast it as needed to keep lint
117 * happy.
118 */
119typedef
120 union {
121 int zz_number;
f14fa07a
SL
122 short zz_boolean[2];
123 char zz_character[4];
11adac90
BJ
124 int *zz_address;
125 }
126 zzhack;
127
128#define value(v) vtable[v].v_value
129
11adac90 130#define number(v) ((((zzhack *)(&(v))))->zz_number)
4d50e976
WN
131
132#if BYTE_ORDER == LITTLE_ENDIAN
f14fa07a
SL
133#define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[0])
134#define character(v) ((((zzhack *)(&(v))))->zz_character[0])
4d50e976
WN
135#endif
136
137#if BYTE_ORDER == BIG_ENDIAN
f14fa07a
SL
138#define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[1])
139#define character(v) ((((zzhack *)(&(v))))->zz_character[3])
140#endif
4d50e976 141
11adac90
BJ
142#define address(v) ((((zzhack *)(&(v))))->zz_address)
143
144/*
145 * Escape command table definitions --
146 * lookup in this table is performed when ``escapec'' is recognized
147 * at the begining of a line (as defined by the eolmarks variable).
148*/
149
150typedef
151 struct {
152 char e_char; /* char to match on */
153 char e_flags; /* experimental, priviledged */
154 char *e_help; /* help string */
155 int (*e_func)(); /* command */
156 }
157 esctable_t;
158
159#define NORM 00 /* normal protection, execute anyone */
160#define EXP 01 /* experimental, mark it with a `*' on help */
161#define PRIV 02 /* priviledged, root execute only */
162
163extern int vflag; /* verbose during reading of .tiprc file */
164extern value_t vtable[]; /* variable table */
165
166#ifndef ACULOG
167#define logent(a, b, c, d)
168#define loginit()
169#endif
170
171/*
172 * Definition of indices into variable table so
173 * value(DEFINE) turns into a static address.
174 */
175
176#define BEAUTIFY 0
177#define BAUDRATE 1
178#define DIALTIMEOUT 2
179#define EOFREAD 3
180#define EOFWRITE 4
181#define EOL 5
182#define ESCAPE 6
183#define EXCEPTIONS 7
184#define FORCE 8
185#define FRAMESIZE 9
186#define HOST 10
05862919
SL
187#define LOG 11
188#define PHONES 12
189#define PROMPT 13
190#define RAISE 14
191#define RAISECHAR 15
192#define RECORD 16
193#define REMOTE 17
194#define SCRIPT 18
195#define TABEXPAND 19
196#define VERBOSE 20
197#define SHELL 21
198#define HOME 22
199#define ECHOCHECK 23
200#define DISCONNECT 24
201#define TAND 25
202#define LDELAY 26
203#define CDELAY 27
204#define ETIMEOUT 28
205#define RAWFTP 29
206#define HALFDUPLEX 30
207#define LECHO 31
208#define PARITY 32
11adac90
BJ
209
210#define NOVAL ((value_t *)NULL)
211#define NOACU ((acu_t *)NULL)
212#define NOSTR ((char *)NULL)
213#define NOFILE ((FILE *)NULL)
214#define NOPWD ((struct passwd *)0)
215
216struct sgttyb arg; /* current mode of local terminal */
217struct sgttyb defarg; /* initial mode of local terminal */
218struct tchars tchars; /* current state of terminal */
219struct tchars defchars; /* initial state of terminal */
c5d1037a
BJ
220struct ltchars ltchars; /* current local characters of terminal */
221struct ltchars deflchars; /* initial local characters of terminal */
11adac90
BJ
222
223FILE *fscript; /* FILE for scripting */
224
225int fildes[2]; /* file transfer synchronization channel */
226int repdes[2]; /* read process sychronization channel */
227int FD; /* open file descriptor to remote host */
8b6d643c 228int AC; /* open file descriptor to dialer (v831 only) */
11adac90
BJ
229int vflag; /* print .tiprc initialization sequence */
230int sfd; /* for ~< operation */
231int pid; /* pid of tipout */
f95c3446
MK
232uid_t uid, euid; /* real and effective user id's */
233gid_t gid, egid; /* real and effective group id's */
11adac90
BJ
234int stop; /* stop transfer session flag */
235int quit; /* same; but on other end */
236int intflag; /* recognized interrupt */
237int stoprompt; /* for interrupting a prompt session */
238int timedout; /* ~> transfer timedout */
257b33f8 239int cumode; /* simulating the "cu" program */
11adac90
BJ
240
241char fname[80]; /* file name buffer for ~< */
242char copyname[80]; /* file name buffer for ~> */
243char ccc; /* synchronization character */
244char ch; /* for tipout */
245char *uucplock; /* name of lock file for uucp's */
246
11adac90 247int odisc; /* initial tty line discipline */
05862919
SL
248extern int disc; /* current tty discpline */
249
250extern char *ctrl();
05862919 251extern char *vinterp();
05862919 252extern char *connect();