Annotation of src/usr.bin/tip/tip.h, Revision 1.43
1.43 ! nicm 1: /* $OpenBSD: tip.h,v 1.42 2010/06/29 23:10:56 nicm Exp $ */
1.6 millert 2: /* $NetBSD: tip.h,v 1.7 1997/04/20 00:02:46 mellon Exp $ */
1.1 deraadt 3:
4: /*
5: * Copyright (c) 1989, 1993
6: * The Regents of the University of California. All rights reserved.
7: *
8: *
9: * Redistribution and use in source and binary forms, with or without
10: * modification, are permitted provided that the following conditions
11: * are met:
12: * 1. Redistributions of source code must retain the above copyright
13: * notice, this list of conditions and the following disclaimer.
14: * 2. Redistributions in binary form must reproduce the above copyright
15: * notice, this list of conditions and the following disclaimer in the
16: * documentation and/or other materials provided with the distribution.
1.15 millert 17: * 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 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 8.1 (Berkeley) 6/6/93
34: */
35:
36: /*
37: * tip - terminal interface program
38: */
39:
40: #include <sys/types.h>
41: #include <sys/file.h>
42: #include <sys/time.h>
1.8 deraadt 43: #include <sys/wait.h>
44: #include <sys/ioctl.h>
1.1 deraadt 45:
1.2 deraadt 46: #include <termios.h>
1.1 deraadt 47: #include <signal.h>
48: #include <stdio.h>
49: #include <stdlib.h>
50: #include <string.h>
51: #include <pwd.h>
52: #include <ctype.h>
53: #include <setjmp.h>
54: #include <unistd.h>
55: #include <errno.h>
1.28 millert 56: #include <err.h>
1.7 millert 57: #include <limits.h>
1.1 deraadt 58:
59: /*
60: * Remote host attributes
61: */
62: char *DV; /* UNIX device(s) to open */
63: char *CM; /* initial connection message */
64: char *PN; /* phone number(s) */
65: char *DI; /* disconnect string */
66:
67: /*
68: * String value table
69: */
1.41 nicm 70: typedef struct {
71: char *v_name; /* variable name */
72: int v_flags; /* type and flags */
73: char *v_abbrev; /* possible abbreviation */
74: char *v_value; /* casted to a union later */
75: } value_t;
76:
1.42 nicm 77: #define V_STRING 01 /* string valued */
78: #define V_BOOL 02 /* true-false value */
79: #define V_NUMBER 04 /* numeric value */
80: #define V_CHAR 010 /* character value */
1.41 nicm 81: #define V_TYPEMASK 017
82:
1.42 nicm 83: #define V_CHANGED 020 /* to show modification */
84: #define V_READONLY 040 /* variable is not writable */
1.41 nicm 85:
1.42 nicm 86: #define V_ENVIRON 0100 /* initialize out of the environment */
87: #define V_INIT 0400 /* static data space used for initialization */
1.1 deraadt 88:
89: /*
90: * variable manipulation stuff --
91: * if we defined the value entry in value_t, then we couldn't
92: * initialize it in vars.c, so we cast it as needed to keep lint
93: * happy.
94: */
95:
96: #define value(v) vtable[v].v_value
1.22 deraadt 97: #define lvalue(v) (long)vtable[v].v_value
1.1 deraadt 98:
1.5 millert 99: #define number(v) ((long)(v))
100: #define boolean(v) ((short)(long)(v))
101: #define character(v) ((char)(long)(v))
102: #define address(v) ((long *)(v))
103:
104: #define setnumber(v,n) do { (v) = (char *)(long)(n); } while (0)
105: #define setboolean(v,n) do { (v) = (char *)(long)(n); } while (0)
106: #define setcharacter(v,n) do { (v) = (char *)(long)(n); } while (0)
107: #define setaddress(v,n) do { (v) = (char *)(n); } while (0)
1.1 deraadt 108:
109: /*
110: * Escape command table definitions --
111: * lookup in this table is performed when ``escapec'' is recognized
112: * at the begining of a line (as defined by the eolmarks variable).
113: */
114:
115: typedef
116: struct {
1.19 deraadt 117: char e_char; /* char to match on */
118: char *e_help; /* help string */
1.21 moritz 119: void (*e_func)(int); /* command */
1.1 deraadt 120: }
121: esctable_t;
122:
123: extern int vflag; /* verbose during reading of .tiprc file */
1.9 todd 124: extern int noesc; /* no escape `~' char */
1.1 deraadt 125: extern value_t vtable[]; /* variable table */
126:
127: /*
128: * Definition of indices into variable table so
129: * value(DEFINE) turns into a static address.
130: */
1.35 nicm 131: enum {
132: BEAUTIFY = 0,
133: BAUDRATE,
134: EOFREAD,
135: EOFWRITE,
136: EOL,
137: ESCAPE,
138: EXCEPTIONS,
139: FORCE,
140: FRAMESIZE,
141: HOST,
142: LOG,
143: PROMPT,
144: RAISE,
145: RAISECHAR,
146: RECORD,
147: REMOTE,
148: SCRIPT,
149: TABEXPAND,
150: VERBOSE,
151: SHELL,
152: HOME,
153: ECHOCHECK,
154: DISCONNECT,
155: TAND,
156: LDELAY,
157: CDELAY,
158: ETIMEOUT,
159: RAWFTP,
160: HALFDUPLEX,
161: LECHO,
162: PARITY,
163: HARDWAREFLOW,
164: LINEDISC,
165: DC
166: };
1.1 deraadt 167:
1.2 deraadt 168: struct termios term; /* current mode of terminal */
169: struct termios defterm; /* initial mode of terminal */
170: struct termios defchars; /* current mode with initial chars */
1.17 deraadt 171: int gotdefterm;
1.1 deraadt 172:
173: FILE *fscript; /* FILE for scripting */
174:
175: int FD; /* open file descriptor to remote host */
176: int AC; /* open file descriptor to dialer (v831 only) */
177: int vflag; /* print .tiprc initialization sequence */
1.9 todd 178: int noesc; /* no `~' escape char */
1.1 deraadt 179: int sfd; /* for ~< operation */
1.18 deraadt 180: pid_t tipin_pid; /* pid of tipin */
1.32 nicm 181: int tipin_fd; /* tipin side of socketpair */
1.18 deraadt 182: pid_t tipout_pid; /* pid of tipout */
1.32 nicm 183: int tipout_fd; /* tipout side of socketpair */
1.31 cloder 184: volatile sig_atomic_t stop; /* stop transfer session flag */
185: volatile sig_atomic_t quit; /* same; but on other end */
186: volatile sig_atomic_t stoprompt;/* for interrupting a prompt session */
187: volatile sig_atomic_t timedout; /* ~> transfer timedout */
1.1 deraadt 188: int cumode; /* simulating the "cu" program */
1.30 jmc 189: int bits8; /* terminal is 8-bit mode */
1.2 deraadt 190: #define STRIP_PAR (bits8 ? 0377 : 0177)
1.1 deraadt 191:
1.7 millert 192: char fname[PATH_MAX]; /* file name buffer for ~< */
193: char copyname[PATH_MAX]; /* file name buffer for ~> */
1.1 deraadt 194: char ccc; /* synchronization character */
195: char *uucplock; /* name of lock file for uucp's */
196:
1.11 millert 197: int odisc; /* initial tty line discipline */
198: extern int disc; /* current tty discpline */
199:
200: extern char *__progname; /* program name */
1.1 deraadt 201:
1.38 nicm 202: /* cmds.c */
1.21 moritz 203: char *expand(char *);
1.38 nicm 204: void chdirectory(int);
205: void consh(int);
206: void cu_put(int);
207: void cu_take(int);
208: void finish(int);
209: void genbrk(int);
210: void getfl(int);
211: void listvariables(int);
212: void parwrite(int, char *, size_t);
213: void pipefile(int);
214: void pipeout(int);
215: void sendfile(int);
216: void setscript(void);
217: void shell(int);
218: void suspend(int);
219: void timeout(int);
220: void tipabort(char *);
221: void variable(int);
222:
223: /* cu.c */
224: void cumain(int, char **);
225:
226: /* hunt.c */
227: long hunt(char *);
228:
229: /* log.c */
230: void logent(char *, char *, char *);
231: void loginit(void);
232:
233: /* remote.c */
1.21 moritz 234: char *getremote(char *);
1.38 nicm 235:
236: /* tip.c */
237: void con(void);
238: char *ctrl(char);
1.20 moritz 239: char *interp(char *);
1.38 nicm 240: int any(int, char *);
241: int prompt(char *, char *, size_t);
242: size_t size(char *);
243: void cleanup(int);
244: void help(int);
245: void parwrite(int, char *, size_t);
246: void raw(void);
247: void setparity(char *);
248: int ttysetup(int);
249: void unraw(void);
250:
251: /* tipout.c */
252: void tipout(void);
253:
254: /* value.c */
1.12 millert 255: void vinit(void);
1.20 moritz 256: void vlex(char *);
1.38 nicm 257: int vstring(char *, char *);