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