119805Sdist /* 235464Sbostic * Copyright (c) 1983 The Regents of the University of California. 335464Sbostic * All rights reserved. 419805Sdist * 542770Sbostic * %sccs.include.redist.c% 635464Sbostic * 7*46262Storek * @(#)tip.h 5.6 (Berkeley) 02/04/91 819805Sdist */ 913280Ssam 103697Sroot /* 113697Sroot * tip - terminal interface program 123697Sroot */ 133697Sroot 1413280Ssam #include <sys/types.h> 1513280Ssam #include <sys/file.h> 16*46262Storek #include <sys/time.h> 1713280Ssam 183697Sroot #include <sgtty.h> 193697Sroot #include <signal.h> 203697Sroot #include <stdio.h> 21*46262Storek #include <stdlib.h> 22*46262Storek #include <string.h> 233697Sroot #include <pwd.h> 245258Sshannon #include <ctype.h> 2513280Ssam #include <setjmp.h> 26*46262Storek #include <unistd.h> 2713280Ssam #include <errno.h> 283697Sroot 293697Sroot /* 303697Sroot * Remote host attributes 313697Sroot */ 323697Sroot char *DV; /* UNIX device(s) to open */ 333697Sroot char *EL; /* chars marking an EOL */ 343697Sroot char *CM; /* initial connection message */ 353697Sroot char *IE; /* EOT to expect on input */ 363697Sroot char *OE; /* EOT to send to complete FT */ 373697Sroot char *CU; /* call unit if making a phone call */ 383697Sroot char *AT; /* acu type */ 393697Sroot char *PN; /* phone number(s) */ 4013144Sralph char *DI; /* disconnect string */ 4113144Sralph char *PA; /* parity to be generated */ 423697Sroot 433697Sroot char *PH; /* phone number file */ 443697Sroot char *RM; /* remote file name */ 453697Sroot char *HO; /* host name */ 463697Sroot 473697Sroot int BR; /* line speed for conversation */ 483697Sroot int FS; /* frame size for transfers */ 493697Sroot 503697Sroot char DU; /* this host is dialed up */ 513899Ssam char HW; /* this device is hardwired, see hunt.c */ 5213144Sralph char *ES; /* escape character */ 5313144Sralph char *EX; /* exceptions */ 5413144Sralph char *FO; /* force (literal next) char*/ 5513144Sralph char *RC; /* raise character */ 5613144Sralph char *RE; /* script record file */ 5713144Sralph char *PR; /* remote prompt */ 5813144Sralph int DL; /* line delay for file transfers to remote */ 5913144Sralph int CL; /* char delay for file transfers to remote */ 6013144Sralph int ET; /* echocheck timeout */ 6113144Sralph char HD; /* this host is half duplex - do local echo */ 623697Sroot 633697Sroot /* 643697Sroot * String value table 653697Sroot */ 663697Sroot typedef 673697Sroot struct { 683697Sroot char *v_name; /* whose name is it */ 693697Sroot char v_type; /* for interpreting set's */ 703697Sroot char v_access; /* protection of touchy ones */ 713697Sroot char *v_abrev; /* possible abreviation */ 723697Sroot char *v_value; /* casted to a union later */ 733697Sroot } 743697Sroot value_t; 753697Sroot 763697Sroot #define STRING 01 /* string valued */ 773697Sroot #define BOOL 02 /* true-false value */ 783697Sroot #define NUMBER 04 /* numeric value */ 793697Sroot #define CHAR 010 /* character value */ 803697Sroot 813697Sroot #define WRITE 01 /* write access to variable */ 823697Sroot #define READ 02 /* read access */ 833697Sroot 843697Sroot #define CHANGED 01 /* low bit is used to show modification */ 853697Sroot #define PUBLIC 1 /* public access rights */ 863697Sroot #define PRIVATE 03 /* private to definer */ 873697Sroot #define ROOT 05 /* root defined */ 883697Sroot 893697Sroot #define TRUE 1 903697Sroot #define FALSE 0 913697Sroot 923697Sroot #define ENVIRON 020 /* initialize out of the environment */ 933697Sroot #define IREMOTE 040 /* initialize out of remote structure */ 943697Sroot #define INIT 0100 /* static data space used for initialization */ 953697Sroot #define TMASK 017 963697Sroot 973697Sroot /* 983697Sroot * Definition of ACU line description 993697Sroot */ 1003697Sroot typedef 1013697Sroot struct { 1023697Sroot char *acu_name; 1033697Sroot int (*acu_dialer)(); 1043697Sroot int (*acu_disconnect)(); 1053697Sroot int (*acu_abort)(); 1063697Sroot } 1073697Sroot acu_t; 1083697Sroot 1093697Sroot #define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */ 1103697Sroot 1113697Sroot /* 1123697Sroot * variable manipulation stuff -- 1133697Sroot * if we defined the value entry in value_t, then we couldn't 1143697Sroot * initialize it in vars.c, so we cast it as needed to keep lint 1153697Sroot * happy. 1163697Sroot */ 1173697Sroot typedef 1183697Sroot union { 1193697Sroot int zz_number; 12029893Ssam short zz_boolean[2]; 12129893Ssam char zz_character[4]; 1223697Sroot int *zz_address; 1233697Sroot } 1243697Sroot zzhack; 1253697Sroot 1263697Sroot #define value(v) vtable[v].v_value 1273697Sroot 1283697Sroot #define number(v) ((((zzhack *)(&(v))))->zz_number) 12929893Ssam #ifdef vax 13029893Ssam #define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[0]) 13129893Ssam #define character(v) ((((zzhack *)(&(v))))->zz_character[0]) 13229893Ssam #else 13329893Ssam #define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[1]) 13429893Ssam #define character(v) ((((zzhack *)(&(v))))->zz_character[3]) 13529893Ssam #endif 1363697Sroot #define address(v) ((((zzhack *)(&(v))))->zz_address) 1373697Sroot 1383697Sroot /* 1393697Sroot * Escape command table definitions -- 1403697Sroot * lookup in this table is performed when ``escapec'' is recognized 1413697Sroot * at the begining of a line (as defined by the eolmarks variable). 1423697Sroot */ 1433697Sroot 1443697Sroot typedef 1453697Sroot struct { 1463697Sroot char e_char; /* char to match on */ 1473697Sroot char e_flags; /* experimental, priviledged */ 1483697Sroot char *e_help; /* help string */ 1493697Sroot int (*e_func)(); /* command */ 1503697Sroot } 1513697Sroot esctable_t; 1523697Sroot 1533697Sroot #define NORM 00 /* normal protection, execute anyone */ 1543697Sroot #define EXP 01 /* experimental, mark it with a `*' on help */ 1553697Sroot #define PRIV 02 /* priviledged, root execute only */ 1563697Sroot 1573697Sroot extern int vflag; /* verbose during reading of .tiprc file */ 1583697Sroot extern value_t vtable[]; /* variable table */ 1593697Sroot 1603697Sroot #ifndef ACULOG 1613697Sroot #define logent(a, b, c, d) 1623697Sroot #define loginit() 1633697Sroot #endif 1643697Sroot 1653697Sroot /* 1663697Sroot * Definition of indices into variable table so 1673697Sroot * value(DEFINE) turns into a static address. 1683697Sroot */ 1693697Sroot 1703697Sroot #define BEAUTIFY 0 1713697Sroot #define BAUDRATE 1 1723697Sroot #define DIALTIMEOUT 2 1733697Sroot #define EOFREAD 3 1743697Sroot #define EOFWRITE 4 1753697Sroot #define EOL 5 1763697Sroot #define ESCAPE 6 1773697Sroot #define EXCEPTIONS 7 1783697Sroot #define FORCE 8 1793697Sroot #define FRAMESIZE 9 1803697Sroot #define HOST 10 18113280Ssam #define LOG 11 18213280Ssam #define PHONES 12 18313280Ssam #define PROMPT 13 18413280Ssam #define RAISE 14 18513280Ssam #define RAISECHAR 15 18613280Ssam #define RECORD 16 18713280Ssam #define REMOTE 17 18813280Ssam #define SCRIPT 18 18913280Ssam #define TABEXPAND 19 19013280Ssam #define VERBOSE 20 19113280Ssam #define SHELL 21 19213280Ssam #define HOME 22 19313280Ssam #define ECHOCHECK 23 19413280Ssam #define DISCONNECT 24 19513280Ssam #define TAND 25 19613280Ssam #define LDELAY 26 19713280Ssam #define CDELAY 27 19813280Ssam #define ETIMEOUT 28 19913280Ssam #define RAWFTP 29 20013280Ssam #define HALFDUPLEX 30 20113280Ssam #define LECHO 31 20213280Ssam #define PARITY 32 2033697Sroot 2043697Sroot #define NOVAL ((value_t *)NULL) 2053697Sroot #define NOACU ((acu_t *)NULL) 2063697Sroot #define NOSTR ((char *)NULL) 2073697Sroot #define NOFILE ((FILE *)NULL) 2083697Sroot #define NOPWD ((struct passwd *)0) 2093697Sroot 2103697Sroot struct sgttyb arg; /* current mode of local terminal */ 2113697Sroot struct sgttyb defarg; /* initial mode of local terminal */ 2123697Sroot struct tchars tchars; /* current state of terminal */ 2133697Sroot struct tchars defchars; /* initial state of terminal */ 21412479Sroot struct ltchars ltchars; /* current local characters of terminal */ 21512479Sroot struct ltchars deflchars; /* initial local characters of terminal */ 2163697Sroot 2173697Sroot FILE *fscript; /* FILE for scripting */ 2183697Sroot 2193697Sroot int fildes[2]; /* file transfer synchronization channel */ 2203697Sroot int repdes[2]; /* read process sychronization channel */ 2213697Sroot int FD; /* open file descriptor to remote host */ 22213144Sralph int AC; /* open file descriptor to dialer (v831 only) */ 2233697Sroot int vflag; /* print .tiprc initialization sequence */ 2243697Sroot int sfd; /* for ~< operation */ 2253697Sroot int pid; /* pid of tipout */ 22625906Skarels uid_t uid, euid; /* real and effective user id's */ 22725906Skarels gid_t gid, egid; /* real and effective group id's */ 2283697Sroot int stop; /* stop transfer session flag */ 2293697Sroot int quit; /* same; but on other end */ 2303697Sroot int intflag; /* recognized interrupt */ 2313697Sroot int stoprompt; /* for interrupting a prompt session */ 2323697Sroot int timedout; /* ~> transfer timedout */ 2334974Ssam int cumode; /* simulating the "cu" program */ 2343697Sroot 2353697Sroot char fname[80]; /* file name buffer for ~< */ 2363697Sroot char copyname[80]; /* file name buffer for ~> */ 2373697Sroot char ccc; /* synchronization character */ 2383697Sroot char ch; /* for tipout */ 2393697Sroot char *uucplock; /* name of lock file for uucp's */ 2403697Sroot 2413697Sroot int odisc; /* initial tty line discipline */ 24213280Ssam extern int disc; /* current tty discpline */ 2433697Sroot 24413280Ssam extern char *ctrl(); 24513280Ssam extern char *vinterp(); 24613280Ssam extern char *connect(); 247