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