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