Merge branch 'vendor/BYACC'
[dragonfly.git] / usr.bin / tip / tip / tip.h
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  */
38
39 /*
40  * tip - terminal interface program
41  */
42
43 #include <sys/types.h>
44 #include <machine/endian.h>
45 #include <sys/file.h>
46 #include <sys/time.h>
47 #include <limits.h>
48
49 #if HAVE_TERMIOS
50 #include <sys/ioctl.h>         /* for TIOCHPCL */
51 #include <sys/filio.h>    /* for FIONREAD */
52 #include <sys/termios.h>
53 #else
54 #include <sgtty.h>
55 #endif
56
57 #include <signal.h>
58 #include <stdio.h>
59 #include <stdlib.h>
60 #include <string.h>
61 #include <pwd.h>
62 #include <ctype.h>
63 #include <setjmp.h>
64 #include <unistd.h>
65 #include <errno.h>
66
67 /*
68  * Remote host attributes
69  */
70 char    *DV;                    /* UNIX device(s) to open */
71 char    *EL;                    /* chars marking an EOL */
72 char    *CM;                    /* initial connection message */
73 char    *IE;                    /* EOT to expect on input */
74 char    *OE;                    /* EOT to send to complete FT */
75 char    *CU;                    /* call unit if making a phone call */
76 char    *AT;                    /* acu type */
77 char    *PN;                    /* phone number(s) */
78 char    *DI;                    /* disconnect string */
79 char    *PA;                    /* parity to be generated */
80
81 char    *PH;                    /* phone number file */
82 char    *RM;                    /* remote file name */
83 char    *HO;                    /* host name */
84
85 char    *LI;                    /* login script */
86 char    *LO;                    /* logout script */
87
88 long    BR;                     /* line speed for conversation */
89 long    FS;                     /* frame size for transfers */
90
91 char    DU;                     /* this host is dialed up */
92 char    HW;                     /* this device is hardwired, see hunt.c */
93 char    *ES;                    /* escape character */
94 char    *EX;                    /* exceptions */
95 char    *FO;                    /* force (literal next) char*/
96 char    *RC;                    /* raise character */
97 char    *RE;                    /* script record file */
98 char    *PR;                    /* remote prompt */
99 long    DL;                     /* line delay for file transfers to remote */
100 long    CL;                     /* char delay for file transfers to remote */
101 long    ET;                     /* echocheck timeout */
102 char    HD;                     /* this host is half duplex - do local echo */
103
104 /*
105  * String value table
106  */
107 typedef
108         struct {
109                 char    *v_name;        /* whose name is it */
110                 char    v_type;         /* for interpreting set's */
111                 char    v_access;       /* protection of touchy ones */
112                 char    *v_abrev;       /* possible abreviation */
113                 char    *v_value;       /* casted to a union later */
114         }
115         value_t;
116
117 #define STRING  01              /* string valued */
118 #define BOOL    02              /* true-false value */
119 #define NUMBER  04              /* numeric value */
120 #define CHAR    010             /* character value */
121
122 #define WRITE   01              /* write access to variable */
123 #define READ    02              /* read access */
124
125 #define CHANGED 01              /* low bit is used to show modification */
126 #define PUBLIC  1               /* public access rights */
127 #define PRIVATE 03              /* private to definer */
128 #define ROOT    05              /* root defined */
129
130 #define TRUE    1
131 #define FALSE   0
132
133 #define ENVIRON 020             /* initialize out of the environment */
134 #define IREMOTE 040             /* initialize out of remote structure */
135 #define INIT    0100            /* static data space used for initialization */
136 #define TMASK   017
137
138 /*
139  * Definition of ACU line description
140  */
141 typedef
142         struct {
143                 char    *acu_name;
144                 int     (*acu_dialer)(char *, char *);
145                 void    (*acu_disconnect)(void);
146                 void    (*acu_abort)(void);
147         }
148         acu_t;
149
150 #define equal(a, b)     (strcmp(a,b)==0)/* A nice function to string compare */
151
152 /*
153  * variable manipulation stuff --
154  *   if we defined the value entry in value_t, then we couldn't
155  *   initialize it in vars.c, so we cast it as needed to keep lint
156  *   happy.
157  */
158 typedef
159         union {
160                 int     zz_number;
161                 short   zz_boolean[2];
162                 char    zz_character[4];
163                 int     *zz_address;
164         }
165         zzhack;
166
167 #define value(v)        vtable[v].v_value
168
169 #define number(v)       ((((zzhack *)(&(v))))->zz_number)
170
171 #if BYTE_ORDER == LITTLE_ENDIAN
172 #define boolean(v)      ((((zzhack *)(&(v))))->zz_boolean[0])
173 #define character(v)    ((((zzhack *)(&(v))))->zz_character[0])
174 #endif
175
176 #if BYTE_ORDER == BIG_ENDIAN
177 #define boolean(v)      ((((zzhack *)(&(v))))->zz_boolean[1])
178 #define character(v)    ((((zzhack *)(&(v))))->zz_character[3])
179 #endif
180
181 #define address(v)      ((((zzhack *)(&(v))))->zz_address)
182
183 /*
184  * Escape command table definitions --
185  *   lookup in this table is performed when ``escapec'' is recognized
186  *   at the begining of a line (as defined by the eolmarks variable).
187 */
188
189 typedef
190         struct {
191                 char    e_char;         /* char to match on */
192                 char    e_flags;        /* experimental, priviledged */
193                 char    *e_help;        /* help string */
194                 void    (*e_func)(int); /* command */
195         }
196         esctable_t;
197
198 #define NORM    00              /* normal protection, execute anyone */
199 #define EXP     01              /* experimental, mark it with a `*' on help */
200 #define PRIV    02              /* priviledged, root execute only */
201
202 extern int      vflag;          /* verbose during reading of .tiprc file */
203 extern value_t  vtable[];       /* variable table */
204
205 #if !ACULOG
206 #define logent(a, b, c, d)
207 #define loginit(x)
208 #else
209 void logent(char *, char *, char *, char*);
210 void  loginit(void);
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
258 #if HAVE_TERMIOS
259 struct termios otermios;
260 struct termios ctermios;
261 #else /* HAVE_TERMIOS */
262 struct sgttyb   arg;            /* current mode of local terminal */
263 struct sgttyb   defarg;         /* initial mode of local terminal */
264 struct tchars   tchars;         /* current state of terminal */
265 struct tchars   defchars;       /* initial state of terminal */
266 struct ltchars  ltchars;        /* current local characters of terminal */
267 struct ltchars  deflchars;      /* initial local characters of terminal */
268 #endif /* HAVE_TERMIOS */
269
270 FILE    *fscript;               /* FILE for scripting */
271
272 int     fildes[2];              /* file transfer synchronization channel */
273 int     repdes[2];              /* read process sychronization channel */
274 int     FD;                     /* open file descriptor to remote host */
275 int     AC;                     /* open file descriptor to dialer (v831 only) */
276 int     vflag;                  /* print .tiprc initialization sequence */
277 int     sfd;                    /* for ~< operation */
278 int     pid;                    /* pid of tipout */
279 uid_t   uid, euid;              /* real and effective user id's */
280 gid_t   gid, egid;              /* real and effective group id's */
281 int     stop;                   /* stop transfer session flag */
282 int     quit;                   /* same; but on other end */
283 int     intflag;                /* recognized interrupt */
284 int     stoprompt;              /* for interrupting a prompt session */
285 int     timedout;               /* ~> transfer timedout */
286 int     cumode;                 /* simulating the "cu" program */
287
288 char    fname[PATH_MAX];        /* file name buffer for ~< */
289 char    copyname[PATH_MAX];     /* file name buffer for ~> */
290 char    ccc;                    /* synchronization character */
291 char    ch;                     /* for tipout */
292 char    *uucplock;              /* name of lock file for uucp's */
293
294 int     odisc;                          /* initial tty line discipline */
295 extern  int disc;                       /* current tty discpline */
296
297 char    *ctrl(char);
298 char    *vinterp(char *, char);
299 char    *connect(void);
300 int     size(char *);
301 int     any(char, char *);
302 void    setscript(void);
303 void    tipout(void);
304 void    vinit(void);
305 long    hunt(char *);
306 int     vstring(char *, char *);
307 void    setparity(char *);
308 void    vlex(char *);
309 void    daemon_uid(void);
310 void    disconnect(char *);
311 void    shell_uid(void);
312 void    unraw(void);
313 void    user_uid(void);
314 void    xpwrite(int, char *, int);
315 int     prompt(char *, char *, size_t);
316 void    tipabort(char *);
317 void    cumain(int, char **);
318 char    *getremote(char *);
319 char    *interp(char *);
320
321 void    chdirectory(int);
322 void    cleanup(int);
323 void    consh(int);
324 void    cu_put(int);
325 void    cu_take(int);
326 void    dollar(int);
327 char    *expand(char *);
328 void    finish(int);
329 void    genbrk(int);
330 void    getfl(int);
331 void    help(int);
332 void    pipefile(int);
333 void    pipeout(int);
334 void    sendfile(int);
335 void    shell(int);
336 int     speed(int);
337 void    suspend(int);
338 void    timeoutfunc(int);
339 void    ttysetup(int);
340 void    variable(int);
341
342 void    biz22_abort(void);
343 int     biz22f_dialer(char *, char *);
344 int     biz22w_dialer(char *, char *);
345 void    biz22_disconnect(void);
346
347 void    cour_abort(void);
348 int     cour_dialer(char *, char *);
349 void    cour_disconnect(void);
350
351 void    df_abort(void);
352 int     df02_dialer(char *, char *);
353 int     df03_dialer(char *, char *);
354 void    df_disconnect(void);
355
356 void    dn_abort(void);
357 int     dn_dialer(char *, char *);
358 void    dn_disconnect(void);
359
360 void    hay_abort(void);
361 int     hay_dialer(char *, char *);
362 void    hay_disconnect(void);
363
364 void    multitech_abort(void);
365 int     multitech_dialer(char *, char *);
366 void    multitech_disconnect(void);
367
368 void    t3000_abort(void);
369 int     t3000_dialer(char *, char *);
370 void    t3000_disconnect(void);
371
372 acu_t   *unidialer_getmodem(const char *);
373
374 void    v3451_abort(void);
375 int     v3451_dialer(char *, char *);
376 void    v3451_disconnect(void);
377
378 void    v831_abort(void);
379 int     v831_dialer(char *, char *);
380 void    v831_disconnect(void);
381
382 void    ven_abort(void);
383 int     ven_dialer(char *, char *);
384 void    ven_disconnect(void);
385
386 #define TL_VERBOSE       0x00000001
387 #define TL_SIGNAL_TIPOUT 0x00000002
388
389 int tiplink(char *cmd, unsigned int flags);
390 void raw(void);
391
392 /* end of tip.h */