386BSD 0.1 development
[unix-history] / usr / src / usr.bin / tip / tip.h
CommitLineData
4b3ef9ea
WJ
1/*
2 * Copyright (c) 1983 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)tip.h 5.7 (Berkeley) 3/27/91
34 */
35
36/*
37 * tip - terminal interface program
38 */
39
40#include <sys/types.h>
41#include <machine/endian.h>
42#include <sys/file.h>
43#include <sys/time.h>
44
45#include <sgtty.h>
46#include <signal.h>
47#include <stdio.h>
48#include <stdlib.h>
49#include <string.h>
50#include <pwd.h>
51#include <ctype.h>
52#include <setjmp.h>
53#include <unistd.h>
54#include <errno.h>
55
56/*
57 * Remote host attributes
58 */
59char *DV; /* UNIX device(s) to open */
60char *EL; /* chars marking an EOL */
61char *CM; /* initial connection message */
62char *IE; /* EOT to expect on input */
63char *OE; /* EOT to send to complete FT */
64char *CU; /* call unit if making a phone call */
65char *AT; /* acu type */
66char *PN; /* phone number(s) */
67char *DI; /* disconnect string */
68char *PA; /* parity to be generated */
69
70char *PH; /* phone number file */
71char *RM; /* remote file name */
72char *HO; /* host name */
73
74int BR; /* line speed for conversation */
75int FS; /* frame size for transfers */
76
77char DU; /* this host is dialed up */
78char HW; /* this device is hardwired, see hunt.c */
79char *ES; /* escape character */
80char *EX; /* exceptions */
81char *FO; /* force (literal next) char*/
82char *RC; /* raise character */
83char *RE; /* script record file */
84char *PR; /* remote prompt */
85int DL; /* line delay for file transfers to remote */
86int CL; /* char delay for file transfers to remote */
87int ET; /* echocheck timeout */
88char HD; /* this host is half duplex - do local echo */
89
90/*
91 * String value table
92 */
93typedef
94 struct {
95 char *v_name; /* whose name is it */
96 char v_type; /* for interpreting set's */
97 char v_access; /* protection of touchy ones */
98 char *v_abrev; /* possible abreviation */
99 char *v_value; /* casted to a union later */
100 }
101 value_t;
102
103#define STRING 01 /* string valued */
104#define BOOL 02 /* true-false value */
105#define NUMBER 04 /* numeric value */
106#define CHAR 010 /* character value */
107
108#define WRITE 01 /* write access to variable */
109#define READ 02 /* read access */
110
111#define CHANGED 01 /* low bit is used to show modification */
112#define PUBLIC 1 /* public access rights */
113#define PRIVATE 03 /* private to definer */
114#define ROOT 05 /* root defined */
115
116#define TRUE 1
117#define FALSE 0
118
119#define ENVIRON 020 /* initialize out of the environment */
120#define IREMOTE 040 /* initialize out of remote structure */
121#define INIT 0100 /* static data space used for initialization */
122#define TMASK 017
123
124/*
125 * Definition of ACU line description
126 */
127typedef
128 struct {
129 char *acu_name;
130 int (*acu_dialer)();
131 int (*acu_disconnect)();
132 int (*acu_abort)();
133 }
134 acu_t;
135
136#define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */
137
138/*
139 * variable manipulation stuff --
140 * if we defined the value entry in value_t, then we couldn't
141 * initialize it in vars.c, so we cast it as needed to keep lint
142 * happy.
143 */
144typedef
145 union {
146 int zz_number;
147 short zz_boolean[2];
148 char zz_character[4];
149 int *zz_address;
150 }
151 zzhack;
152
153#define value(v) vtable[v].v_value
154
155#define number(v) ((((zzhack *)(&(v))))->zz_number)
156
157#if BYTE_ORDER == LITTLE_ENDIAN
158#define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[0])
159#define character(v) ((((zzhack *)(&(v))))->zz_character[0])
160#endif
161
162#if BYTE_ORDER == BIG_ENDIAN
163#define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[1])
164#define character(v) ((((zzhack *)(&(v))))->zz_character[3])
165#endif
166
167#define address(v) ((((zzhack *)(&(v))))->zz_address)
168
169/*
170 * Escape command table definitions --
171 * lookup in this table is performed when ``escapec'' is recognized
172 * at the begining of a line (as defined by the eolmarks variable).
173*/
174
175typedef
176 struct {
177 char e_char; /* char to match on */
178 char e_flags; /* experimental, priviledged */
179 char *e_help; /* help string */
180 int (*e_func)(); /* command */
181 }
182 esctable_t;
183
184#define NORM 00 /* normal protection, execute anyone */
185#define EXP 01 /* experimental, mark it with a `*' on help */
186#define PRIV 02 /* priviledged, root execute only */
187
188extern int vflag; /* verbose during reading of .tiprc file */
189extern value_t vtable[]; /* variable table */
190
191#ifndef ACULOG
192#define logent(a, b, c, d)
193#define loginit()
194#endif
195
196/*
197 * Definition of indices into variable table so
198 * value(DEFINE) turns into a static address.
199 */
200
201#define BEAUTIFY 0
202#define BAUDRATE 1
203#define DIALTIMEOUT 2
204#define EOFREAD 3
205#define EOFWRITE 4
206#define EOL 5
207#define ESCAPE 6
208#define EXCEPTIONS 7
209#define FORCE 8
210#define FRAMESIZE 9
211#define HOST 10
212#define LOG 11
213#define PHONES 12
214#define PROMPT 13
215#define RAISE 14
216#define RAISECHAR 15
217#define RECORD 16
218#define REMOTE 17
219#define SCRIPT 18
220#define TABEXPAND 19
221#define VERBOSE 20
222#define SHELL 21
223#define HOME 22
224#define ECHOCHECK 23
225#define DISCONNECT 24
226#define TAND 25
227#define LDELAY 26
228#define CDELAY 27
229#define ETIMEOUT 28
230#define RAWFTP 29
231#define HALFDUPLEX 30
232#define LECHO 31
233#define PARITY 32
234
235#define NOVAL ((value_t *)NULL)
236#define NOACU ((acu_t *)NULL)
237#define NOSTR ((char *)NULL)
238#define NOFILE ((FILE *)NULL)
239#define NOPWD ((struct passwd *)0)
240
241struct sgttyb arg; /* current mode of local terminal */
242struct sgttyb defarg; /* initial mode of local terminal */
243struct tchars tchars; /* current state of terminal */
244struct tchars defchars; /* initial state of terminal */
245struct ltchars ltchars; /* current local characters of terminal */
246struct ltchars deflchars; /* initial local characters of terminal */
247
248FILE *fscript; /* FILE for scripting */
249
250int fildes[2]; /* file transfer synchronization channel */
251int repdes[2]; /* read process sychronization channel */
252int FD; /* open file descriptor to remote host */
253int AC; /* open file descriptor to dialer (v831 only) */
254int vflag; /* print .tiprc initialization sequence */
255int sfd; /* for ~< operation */
256int pid; /* pid of tipout */
257uid_t uid, euid; /* real and effective user id's */
258gid_t gid, egid; /* real and effective group id's */
259int stop; /* stop transfer session flag */
260int quit; /* same; but on other end */
261int intflag; /* recognized interrupt */
262int stoprompt; /* for interrupting a prompt session */
263int timedout; /* ~> transfer timedout */
264int cumode; /* simulating the "cu" program */
265
266char fname[80]; /* file name buffer for ~< */
267char copyname[80]; /* file name buffer for ~> */
268char ccc; /* synchronization character */
269char ch; /* for tipout */
270char *uucplock; /* name of lock file for uucp's */
271
272int odisc; /* initial tty line discipline */
273extern int disc; /* current tty discpline */
274
275extern char *ctrl();
276extern char *vinterp();
277extern char *connect();