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