2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 * Copyright (c) 1983 Regents of the University of California.
7 * All rights reserved. The Berkeley software License Agreement
8 * specifies the terms and conditions for redistribution.
14 #pragma ident "%Z%%M% %I% %E% SMI"
17 * tip - terminal interface program
20 #include <sys/types.h>
22 #include <fcntl.h> /* for O_RDWR, etc. */
23 #include <unistd.h> /* for R_OK, etc. */
28 #include <sys/termios.h>
29 #include <sys/filio.h> /* XXX - for FIONREAD only */
38 #include <sys/isa_defs.h> /* for ENDIAN defines */
42 #define _CTRL(c) (c&037)
45 #define signal(_sig_, _hdlr_) sigset((_sig_), (_hdlr_))
47 typedef void (*sig_handler_t
)(int); /* works on BSD and SV */
50 * Remote host attributes
52 char *DV
; /* UNIX device(s) to open */
53 char *EL
; /* chars marking an EOL */
54 char *CM
; /* initial connection message */
55 char *IE
; /* EOT to expect on input */
56 char *OE
; /* EOT to send to complete FT */
57 char *CU
; /* call unit if making a phone call */
58 char *AT
; /* acu type */
59 char *PN
; /* phone number(s) */
60 char *DI
; /* disconnect string */
61 char *PA
; /* parity to be generated */
63 char *PH
; /* phone number file */
64 char *RM
; /* remote file name */
65 char *HO
; /* host name */
67 int BR
; /* line speed for conversation */
68 int FS
; /* frame size for transfers */
70 signed char DU
; /* this host is dialed up */
71 char HW
; /* this device is hardwired, see hunt.c */
72 char *ES
; /* escape character */
73 char *EX
; /* exceptions */
74 char *FO
; /* force (literal next) char */
75 char *RC
; /* raise character */
76 char *RE
; /* script record file */
77 char *PR
; /* remote prompt */
78 int DL
; /* line delay for file transfers to remote */
79 int CL
; /* char delay for file transfers to remote */
80 int ET
; /* echocheck timeout */
81 int DB
; /* dialback - ignore hangup */
88 char *v_name
; /* whose name is it */
89 char v_type
; /* for interpreting set's */
90 char v_access
; /* protection of touchy ones */
91 char *v_abrev
; /* possible abreviation */
92 char *v_value
; /* casted to a union later */
96 #define STRING 01 /* string valued */
97 #define BOOL 02 /* true-false value */
98 #define NUMBER 04 /* numeric value */
99 #define CHAR 010 /* character value */
101 #define WRITE 01 /* write access to variable */
102 #define READ 02 /* read access */
104 #define CHANGED 01 /* low bit is used to show modification */
105 #define PUBLIC 1 /* public access rights */
106 #define PRIVATE 03 /* private to definer */
107 #define ROOT 05 /* root defined */
112 #define ENVIRON 020 /* initialize out of the environment */
113 #define IREMOTE 040 /* initialize out of remote structure */
114 #define INIT 0100 /* static data space used for initialization */
118 * Definition of ACU line description
123 int (*acu_dialer
)(char *, char *);
124 void (*acu_disconnect
)(void);
125 void (*acu_abort
)(void);
129 #define equal(a, b) (strcmp(a, b) == 0) /* A nice function to compare */
132 * variable manipulation stuff --
133 * if we defined the value entry in value_t, then we couldn't
134 * initialize it in vars.c, so we cast it as needed to keep lint
141 #if defined(_LITTLE_ENDIAN)
145 #if defined(_BIG_ENDIAN)
152 #define value(v) vtable[v].v_value
154 #define boolean(v) ((((zzhack *)(&(v))))->zz_boolean)
155 #define number(v) ((((zzhack *)(&(v))))->zz_number)
156 #define character(v) ((((zzhack *)(&(v))))->zz_character)
157 #define address(v) ((((zzhack *)(&(v))))->zz_address)
160 * Escape command table definitions --
161 * lookup in this table is performed when ``escapec'' is recognized
162 * at the begining of a line (as defined by the eolmarks variable).
167 char e_char
; /* char to match on */
168 char e_flags
; /* experimental, priviledged */
169 char *e_help
; /* help string */
170 void (*e_func
)(int); /* command */
174 #define NORM 00 /* normal protection, execute anyone */
175 #define EXP 01 /* experimental, mark it with a `*' on help */
176 #define PRIV 02 /* priviledged, root execute only */
178 extern int vflag
; /* verbose during reading of .tiprc file */
179 extern value_t vtable
[]; /* variable table */
184 #define logent(a, b, c, d)
187 extern void logent(char *, char *, char *, char *);
188 extern void loginit(void);
192 * Definition of indices into variable table so
193 * value(DEFINE) turns into a static address.
198 #define DIALTIMEOUT 2
220 #define DISCONNECT 24
226 #define HALFDUPLEX 30
229 #define HARDWAREFLOW 33
231 #define NOVAL ((value_t *)NULL)
232 #define NOACU ((acu_t *)NULL)
233 #define NOSTR ((char *)NULL)
234 #define NOFILE ((FILE *)NULL)
235 #define NOPWD ((struct passwd *)NULL)
237 struct termios arg
; /* current mode of local terminal */
238 struct termios defarg
; /* initial mode of local terminal */
240 FILE *fscript
; /* FILE for scripting */
241 FILE *phfd
; /* FILE for PHONES file */
243 int fildes
[2]; /* file transfer synchronization channel */
244 int repdes
[2]; /* read process sychronization channel */
245 int FD
; /* open file descriptor to remote host */
246 int AC
; /* open file descriptor to dialer (v831 only) */
247 int vflag
; /* print .tiprc initialization sequence */
248 int sfd
; /* for ~< operation */
249 int pid
; /* pid of tipout */
250 int uid
, euid
; /* real and effective user id's */
251 int gid
, egid
; /* real and effective group id's */
252 int stoprompt
; /* for interrupting a prompt session */
253 int timedout
; /* ~> transfer timedout */
254 int cumode
; /* simulating the "cu" program */
256 char fname
[80]; /* file name buffer for ~< */
257 char copyname
[80]; /* file name buffer for ~> */
258 char ccc
; /* synchronization character */
259 char ch
; /* for tipout */
260 char *uucplock
; /* name of lock file for uucp's */
261 extern int trusted_device
;
264 extern char *connect(void);
265 extern char *ctrl(char);
266 extern char *getremote(char *);
267 extern char *expand(char []);
268 extern char *vinterp(char *, char);
269 extern void cumain(int, char *[]);
270 extern void delock(char *);
271 extern void disconnect(char *);
272 extern void myperm(void);
273 extern void parwrite(int, unsigned char *, int);
274 extern void raw(void);
275 extern void setparity(char *);
276 extern void setscript(void);
277 extern void tandem(char *);
278 extern void tip_abort(char *);
279 extern void ttysetup(int);
280 extern void unraw(void);
281 extern void userperm(void);
282 extern void vinit(void);
283 extern void vlex(char *);
284 extern int any(char, char *);
285 extern int hunt(char *);
286 extern int prompt(char *, char *, size_t);
287 extern int rgetent(char *, char *, int);
288 extern int rgetflag(char *);
289 extern int rgetnum(char *);
290 extern int speed(int);
291 extern int tip_mlock(char *);
292 extern int vstring(char *, char *);