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