| 1 | /* tip.h 4.9 83/05/17 */ |
| 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 | |
| 85 | /* |
| 86 | * variable manipulation stuff -- |
| 87 | * if we defined the value entry in value_t, then we couldn't |
| 88 | * initialize it in vars.c, so we cast it as needed to keep lint |
| 89 | * happy. |
| 90 | */ |
| 91 | typedef |
| 92 | union { |
| 93 | int zz_number; |
| 94 | int zz_boolean; |
| 95 | int zz_character; |
| 96 | int *zz_address; |
| 97 | } |
| 98 | zzhack; |
| 99 | |
| 100 | #define value(v) vtable[v].v_value |
| 101 | |
| 102 | #define boolean(v) ((((zzhack *)(&(v))))->zz_boolean) |
| 103 | #define number(v) ((((zzhack *)(&(v))))->zz_number) |
| 104 | #define character(v) ((((zzhack *)(&(v))))->zz_character) |
| 105 | #define address(v) ((((zzhack *)(&(v))))->zz_address) |
| 106 | |
| 107 | /* |
| 108 | * Escape command table definitions -- |
| 109 | * lookup in this table is performed when ``escapec'' is recognized |
| 110 | * at the begining of a line (as defined by the eolmarks variable). |
| 111 | */ |
| 112 | |
| 113 | typedef |
| 114 | struct { |
| 115 | char e_char; /* char to match on */ |
| 116 | char e_flags; /* experimental, priviledged */ |
| 117 | char *e_help; /* help string */ |
| 118 | int (*e_func)(); /* command */ |
| 119 | } |
| 120 | esctable_t; |
| 121 | |
| 122 | #define NORM 00 /* normal protection, execute anyone */ |
| 123 | #define EXP 01 /* experimental, mark it with a `*' on help */ |
| 124 | #define PRIV 02 /* priviledged, root execute only */ |
| 125 | |
| 126 | extern int vflag; /* verbose during reading of .tiprc file */ |
| 127 | extern value_t vtable[]; /* variable table */ |
| 128 | |
| 129 | #ifndef ACULOG |
| 130 | #define logent(a, b, c, d) |
| 131 | #define loginit() |
| 132 | #endif |
| 133 | |
| 134 | /* |
| 135 | * Definition of indices into variable table so |
| 136 | * value(DEFINE) turns into a static address. |
| 137 | */ |
| 138 | |
| 139 | #define BEAUTIFY 0 |
| 140 | #define BAUDRATE 1 |
| 141 | #define DIALTIMEOUT 2 |
| 142 | #define EOFREAD 3 |
| 143 | #define EOFWRITE 4 |
| 144 | #define EOL 5 |
| 145 | #define ESCAPE 6 |
| 146 | #define EXCEPTIONS 7 |
| 147 | #define FORCE 8 |
| 148 | #define FRAMESIZE 9 |
| 149 | #define HOST 10 |
| 150 | #if ACULOG |
| 151 | #define LOCK 11 |
| 152 | #define LOG 12 |
| 153 | #define PHONES 13 |
| 154 | #define PROMPT 14 |
| 155 | #define RAISE 15 |
| 156 | #define RAISECHAR 16 |
| 157 | #define RECORD 17 |
| 158 | #define REMOTE 18 |
| 159 | #define SCRIPT 19 |
| 160 | #define TABEXPAND 20 |
| 161 | #define VERBOSE 21 |
| 162 | #define SHELL 22 |
| 163 | #define HOME 23 |
| 164 | #define ECHOCHECK 24 |
| 165 | #else |
| 166 | #define PHONES 11 |
| 167 | #define PROMPT 12 |
| 168 | #define RAISE 13 |
| 169 | #define RAISECHAR 14 |
| 170 | #define RECORD 15 |
| 171 | #define REMOTE 16 |
| 172 | #define SCRIPT 17 |
| 173 | #define TABEXPAND 18 |
| 174 | #define VERBOSE 19 |
| 175 | #define SHELL 20 |
| 176 | #define HOME 21 |
| 177 | #define ECHOCHECK 22 |
| 178 | #endif |
| 179 | |
| 180 | #define NOVAL ((value_t *)NULL) |
| 181 | #define NOACU ((acu_t *)NULL) |
| 182 | #define NOSTR ((char *)NULL) |
| 183 | #define NOFILE ((FILE *)NULL) |
| 184 | #define NOPWD ((struct passwd *)0) |
| 185 | |
| 186 | struct sgttyb arg; /* current mode of local terminal */ |
| 187 | struct sgttyb defarg; /* initial mode of local terminal */ |
| 188 | struct tchars tchars; /* current state of terminal */ |
| 189 | struct tchars defchars; /* initial state of terminal */ |
| 190 | struct ltchars ltchars; /* current local characters of terminal */ |
| 191 | struct ltchars deflchars; /* initial local characters of terminal */ |
| 192 | |
| 193 | FILE *fscript; /* FILE for scripting */ |
| 194 | |
| 195 | int fildes[2]; /* file transfer synchronization channel */ |
| 196 | int repdes[2]; /* read process sychronization channel */ |
| 197 | int FD; /* open file descriptor to remote host */ |
| 198 | int vflag; /* print .tiprc initialization sequence */ |
| 199 | int sfd; /* for ~< operation */ |
| 200 | int pid; /* pid of tipout */ |
| 201 | int stop; /* stop transfer session flag */ |
| 202 | int quit; /* same; but on other end */ |
| 203 | int intflag; /* recognized interrupt */ |
| 204 | int stoprompt; /* for interrupting a prompt session */ |
| 205 | int timedout; /* ~> transfer timedout */ |
| 206 | int cumode; /* simulating the "cu" program */ |
| 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 | extern int disc; /* current tty discpline */ |
| 238 | #endif |
| 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(); |