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