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