119805Sdist /* 2*62315Sbostic * Copyright (c) 1989, 1993 3*62315Sbostic * The Regents of the University of California. All rights reserved. 419805Sdist * 556258Selan * 642770Sbostic * %sccs.include.redist.c% 735464Sbostic * 8*62315Sbostic * @(#)tip.h 8.1 (Berkeley) 06/06/93 919805Sdist */ 1013280Ssam 113697Sroot /* 123697Sroot * tip - terminal interface program 133697Sroot */ 143697Sroot 1513280Ssam #include <sys/types.h> 1647671Swilliam #include <machine/endian.h> 1713280Ssam #include <sys/file.h> 1846262Storek #include <sys/time.h> 1913280Ssam 203697Sroot #include <sgtty.h> 213697Sroot #include <signal.h> 223697Sroot #include <stdio.h> 2346262Storek #include <stdlib.h> 2446262Storek #include <string.h> 253697Sroot #include <pwd.h> 265258Sshannon #include <ctype.h> 2713280Ssam #include <setjmp.h> 2846262Storek #include <unistd.h> 2913280Ssam #include <errno.h> 303697Sroot 313697Sroot /* 323697Sroot * Remote host attributes 333697Sroot */ 343697Sroot char *DV; /* UNIX device(s) to open */ 353697Sroot char *EL; /* chars marking an EOL */ 363697Sroot char *CM; /* initial connection message */ 373697Sroot char *IE; /* EOT to expect on input */ 383697Sroot char *OE; /* EOT to send to complete FT */ 393697Sroot char *CU; /* call unit if making a phone call */ 403697Sroot char *AT; /* acu type */ 413697Sroot char *PN; /* phone number(s) */ 4213144Sralph char *DI; /* disconnect string */ 4313144Sralph char *PA; /* parity to be generated */ 443697Sroot 453697Sroot char *PH; /* phone number file */ 463697Sroot char *RM; /* remote file name */ 473697Sroot char *HO; /* host name */ 483697Sroot 4956258Selan long BR; /* line speed for conversation */ 5056258Selan long FS; /* frame size for transfers */ 513697Sroot 523697Sroot char DU; /* this host is dialed up */ 533899Ssam char HW; /* this device is hardwired, see hunt.c */ 5413144Sralph char *ES; /* escape character */ 5513144Sralph char *EX; /* exceptions */ 5613144Sralph char *FO; /* force (literal next) char*/ 5713144Sralph char *RC; /* raise character */ 5813144Sralph char *RE; /* script record file */ 5913144Sralph char *PR; /* remote prompt */ 6056258Selan long DL; /* line delay for file transfers to remote */ 6156258Selan long CL; /* char delay for file transfers to remote */ 6256258Selan long ET; /* echocheck timeout */ 6313144Sralph char HD; /* this host is half duplex - do local echo */ 643697Sroot 653697Sroot /* 663697Sroot * String value table 673697Sroot */ 683697Sroot typedef 693697Sroot struct { 703697Sroot char *v_name; /* whose name is it */ 713697Sroot char v_type; /* for interpreting set's */ 723697Sroot char v_access; /* protection of touchy ones */ 733697Sroot char *v_abrev; /* possible abreviation */ 743697Sroot char *v_value; /* casted to a union later */ 753697Sroot } 763697Sroot value_t; 773697Sroot 783697Sroot #define STRING 01 /* string valued */ 793697Sroot #define BOOL 02 /* true-false value */ 803697Sroot #define NUMBER 04 /* numeric value */ 813697Sroot #define CHAR 010 /* character value */ 823697Sroot 833697Sroot #define WRITE 01 /* write access to variable */ 843697Sroot #define READ 02 /* read access */ 853697Sroot 863697Sroot #define CHANGED 01 /* low bit is used to show modification */ 873697Sroot #define PUBLIC 1 /* public access rights */ 883697Sroot #define PRIVATE 03 /* private to definer */ 893697Sroot #define ROOT 05 /* root defined */ 903697Sroot 913697Sroot #define TRUE 1 923697Sroot #define FALSE 0 933697Sroot 943697Sroot #define ENVIRON 020 /* initialize out of the environment */ 953697Sroot #define IREMOTE 040 /* initialize out of remote structure */ 963697Sroot #define INIT 0100 /* static data space used for initialization */ 973697Sroot #define TMASK 017 983697Sroot 993697Sroot /* 1003697Sroot * Definition of ACU line description 1013697Sroot */ 1023697Sroot typedef 1033697Sroot struct { 1043697Sroot char *acu_name; 1053697Sroot int (*acu_dialer)(); 1063697Sroot int (*acu_disconnect)(); 1073697Sroot int (*acu_abort)(); 1083697Sroot } 1093697Sroot acu_t; 1103697Sroot 1113697Sroot #define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */ 1123697Sroot 1133697Sroot /* 1143697Sroot * variable manipulation stuff -- 1153697Sroot * if we defined the value entry in value_t, then we couldn't 1163697Sroot * initialize it in vars.c, so we cast it as needed to keep lint 1173697Sroot * happy. 1183697Sroot */ 1193697Sroot typedef 1203697Sroot union { 1213697Sroot int zz_number; 12229893Ssam short zz_boolean[2]; 12329893Ssam char zz_character[4]; 1243697Sroot int *zz_address; 1253697Sroot } 1263697Sroot zzhack; 1273697Sroot 1283697Sroot #define value(v) vtable[v].v_value 1293697Sroot 1303697Sroot #define number(v) ((((zzhack *)(&(v))))->zz_number) 13147671Swilliam 13247671Swilliam #if BYTE_ORDER == LITTLE_ENDIAN 13329893Ssam #define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[0]) 13429893Ssam #define character(v) ((((zzhack *)(&(v))))->zz_character[0]) 13547671Swilliam #endif 13647671Swilliam 13747671Swilliam #if BYTE_ORDER == BIG_ENDIAN 13829893Ssam #define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[1]) 13929893Ssam #define character(v) ((((zzhack *)(&(v))))->zz_character[3]) 14029893Ssam #endif 14147671Swilliam 1423697Sroot #define address(v) ((((zzhack *)(&(v))))->zz_address) 1433697Sroot 1443697Sroot /* 1453697Sroot * Escape command table definitions -- 1463697Sroot * lookup in this table is performed when ``escapec'' is recognized 1473697Sroot * at the begining of a line (as defined by the eolmarks variable). 1483697Sroot */ 1493697Sroot 1503697Sroot typedef 1513697Sroot struct { 1523697Sroot char e_char; /* char to match on */ 1533697Sroot char e_flags; /* experimental, priviledged */ 1543697Sroot char *e_help; /* help string */ 1553697Sroot int (*e_func)(); /* command */ 1563697Sroot } 1573697Sroot esctable_t; 1583697Sroot 1593697Sroot #define NORM 00 /* normal protection, execute anyone */ 1603697Sroot #define EXP 01 /* experimental, mark it with a `*' on help */ 1613697Sroot #define PRIV 02 /* priviledged, root execute only */ 1623697Sroot 1633697Sroot extern int vflag; /* verbose during reading of .tiprc file */ 1643697Sroot extern value_t vtable[]; /* variable table */ 1653697Sroot 1663697Sroot #ifndef ACULOG 1673697Sroot #define logent(a, b, c, d) 1683697Sroot #define loginit() 1693697Sroot #endif 1703697Sroot 1713697Sroot /* 1723697Sroot * Definition of indices into variable table so 1733697Sroot * value(DEFINE) turns into a static address. 1743697Sroot */ 1753697Sroot 1763697Sroot #define BEAUTIFY 0 1773697Sroot #define BAUDRATE 1 1783697Sroot #define DIALTIMEOUT 2 1793697Sroot #define EOFREAD 3 1803697Sroot #define EOFWRITE 4 1813697Sroot #define EOL 5 1823697Sroot #define ESCAPE 6 1833697Sroot #define EXCEPTIONS 7 1843697Sroot #define FORCE 8 1853697Sroot #define FRAMESIZE 9 1863697Sroot #define HOST 10 18713280Ssam #define LOG 11 18813280Ssam #define PHONES 12 18913280Ssam #define PROMPT 13 19013280Ssam #define RAISE 14 19113280Ssam #define RAISECHAR 15 19213280Ssam #define RECORD 16 19313280Ssam #define REMOTE 17 19413280Ssam #define SCRIPT 18 19513280Ssam #define TABEXPAND 19 19613280Ssam #define VERBOSE 20 19713280Ssam #define SHELL 21 19813280Ssam #define HOME 22 19913280Ssam #define ECHOCHECK 23 20013280Ssam #define DISCONNECT 24 20113280Ssam #define TAND 25 20213280Ssam #define LDELAY 26 20313280Ssam #define CDELAY 27 20413280Ssam #define ETIMEOUT 28 20513280Ssam #define RAWFTP 29 20613280Ssam #define HALFDUPLEX 30 20713280Ssam #define LECHO 31 20813280Ssam #define PARITY 32 2093697Sroot 2103697Sroot #define NOVAL ((value_t *)NULL) 2113697Sroot #define NOACU ((acu_t *)NULL) 2123697Sroot #define NOSTR ((char *)NULL) 2133697Sroot #define NOFILE ((FILE *)NULL) 2143697Sroot #define NOPWD ((struct passwd *)0) 2153697Sroot 2163697Sroot struct sgttyb arg; /* current mode of local terminal */ 2173697Sroot struct sgttyb defarg; /* initial mode of local terminal */ 2183697Sroot struct tchars tchars; /* current state of terminal */ 2193697Sroot struct tchars defchars; /* initial state of terminal */ 22012479Sroot struct ltchars ltchars; /* current local characters of terminal */ 22112479Sroot struct ltchars deflchars; /* initial local characters of terminal */ 2223697Sroot 2233697Sroot FILE *fscript; /* FILE for scripting */ 2243697Sroot 2253697Sroot int fildes[2]; /* file transfer synchronization channel */ 2263697Sroot int repdes[2]; /* read process sychronization channel */ 2273697Sroot int FD; /* open file descriptor to remote host */ 22813144Sralph int AC; /* open file descriptor to dialer (v831 only) */ 2293697Sroot int vflag; /* print .tiprc initialization sequence */ 2303697Sroot int sfd; /* for ~< operation */ 2313697Sroot int pid; /* pid of tipout */ 23225906Skarels uid_t uid, euid; /* real and effective user id's */ 23325906Skarels gid_t gid, egid; /* real and effective group id's */ 2343697Sroot int stop; /* stop transfer session flag */ 2353697Sroot int quit; /* same; but on other end */ 2363697Sroot int intflag; /* recognized interrupt */ 2373697Sroot int stoprompt; /* for interrupting a prompt session */ 2383697Sroot int timedout; /* ~> transfer timedout */ 2394974Ssam int cumode; /* simulating the "cu" program */ 2403697Sroot 2413697Sroot char fname[80]; /* file name buffer for ~< */ 2423697Sroot char copyname[80]; /* file name buffer for ~> */ 2433697Sroot char ccc; /* synchronization character */ 2443697Sroot char ch; /* for tipout */ 2453697Sroot char *uucplock; /* name of lock file for uucp's */ 2463697Sroot 2473697Sroot int odisc; /* initial tty line discipline */ 24813280Ssam extern int disc; /* current tty discpline */ 2493697Sroot 25013280Ssam extern char *ctrl(); 25113280Ssam extern char *vinterp(); 25213280Ssam extern char *connect(); 253