tip.h revision 28686
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed by the University of 17 * California, Berkeley and its contributors. 18 * 4. Neither the name of the University nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)tip.h 8.1 (Berkeley) 6/6/93 35 */ 36 37/* 38 * tip - terminal interface program 39 */ 40 41#include <sys/types.h> 42#include <machine/endian.h> 43#include <sys/file.h> 44#include <sys/time.h> 45#include <limits.h> 46 47#if HAVE_TERMIOS 48#include <sys/ioctl.h> /* for TIOCHPCL */ 49#include <sys/filio.h> /* for FIONREAD */ 50#include <sys/termios.h> 51#else 52#include <sgtty.h> 53#endif 54 55#include <signal.h> 56#include <stdio.h> 57#include <stdlib.h> 58#include <string.h> 59#include <pwd.h> 60#include <ctype.h> 61#include <setjmp.h> 62#include <unistd.h> 63#include <errno.h> 64 65/* 66 * Remote host attributes 67 */ 68char *DV; /* UNIX device(s) to open */ 69char *EL; /* chars marking an EOL */ 70char *CM; /* initial connection message */ 71char *IE; /* EOT to expect on input */ 72char *OE; /* EOT to send to complete FT */ 73char *CU; /* call unit if making a phone call */ 74char *AT; /* acu type */ 75char *PN; /* phone number(s) */ 76char *DI; /* disconnect string */ 77char *PA; /* parity to be generated */ 78 79char *PH; /* phone number file */ 80char *RM; /* remote file name */ 81char *HO; /* host name */ 82 83char *LI; /* login script */ 84char *LO; /* logout script */ 85 86long BR; /* line speed for conversation */ 87long FS; /* frame size for transfers */ 88 89char DU; /* this host is dialed up */ 90char HW; /* this device is hardwired, see hunt.c */ 91char *ES; /* escape character */ 92char *EX; /* exceptions */ 93char *FO; /* force (literal next) char*/ 94char *RC; /* raise character */ 95char *RE; /* script record file */ 96char *PR; /* remote prompt */ 97long DL; /* line delay for file transfers to remote */ 98long CL; /* char delay for file transfers to remote */ 99long ET; /* echocheck timeout */ 100char HD; /* this host is half duplex - do local echo */ 101 102/* 103 * String value table 104 */ 105typedef 106 struct { 107 char *v_name; /* whose name is it */ 108 char v_type; /* for interpreting set's */ 109 char v_access; /* protection of touchy ones */ 110 char *v_abrev; /* possible abreviation */ 111 char *v_value; /* casted to a union later */ 112 } 113 value_t; 114 115#define STRING 01 /* string valued */ 116#define BOOL 02 /* true-false value */ 117#define NUMBER 04 /* numeric value */ 118#define CHAR 010 /* character value */ 119 120#define WRITE 01 /* write access to variable */ 121#define READ 02 /* read access */ 122 123#define CHANGED 01 /* low bit is used to show modification */ 124#define PUBLIC 1 /* public access rights */ 125#define PRIVATE 03 /* private to definer */ 126#define ROOT 05 /* root defined */ 127 128#define TRUE 1 129#define FALSE 0 130 131#define ENVIRON 020 /* initialize out of the environment */ 132#define IREMOTE 040 /* initialize out of remote structure */ 133#define INIT 0100 /* static data space used for initialization */ 134#define TMASK 017 135 136/* 137 * Definition of ACU line description 138 */ 139typedef 140 struct { 141 char *acu_name; 142 int (*acu_dialer)(); 143 void (*acu_disconnect)(); 144 void (*acu_abort)(); 145 } 146 acu_t; 147 148#define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */ 149 150/* 151 * variable manipulation stuff -- 152 * if we defined the value entry in value_t, then we couldn't 153 * initialize it in vars.c, so we cast it as needed to keep lint 154 * happy. 155 */ 156typedef 157 union { 158 int zz_number; 159 short zz_boolean[2]; 160 char zz_character[4]; 161 int *zz_address; 162 } 163 zzhack; 164 165#define value(v) vtable[v].v_value 166 167#define number(v) ((((zzhack *)(&(v))))->zz_number) 168 169#if BYTE_ORDER == LITTLE_ENDIAN 170#define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[0]) 171#define character(v) ((((zzhack *)(&(v))))->zz_character[0]) 172#endif 173 174#if BYTE_ORDER == BIG_ENDIAN 175#define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[1]) 176#define character(v) ((((zzhack *)(&(v))))->zz_character[3]) 177#endif 178 179#define address(v) ((((zzhack *)(&(v))))->zz_address) 180 181/* 182 * Escape command table definitions -- 183 * lookup in this table is performed when ``escapec'' is recognized 184 * at the begining of a line (as defined by the eolmarks variable). 185*/ 186 187typedef 188 struct { 189 char e_char; /* char to match on */ 190 char e_flags; /* experimental, priviledged */ 191 char *e_help; /* help string */ 192 int (*e_func)(); /* command */ 193 } 194 esctable_t; 195 196#define NORM 00 /* normal protection, execute anyone */ 197#define EXP 01 /* experimental, mark it with a `*' on help */ 198#define PRIV 02 /* priviledged, root execute only */ 199 200extern int vflag; /* verbose during reading of .tiprc file */ 201extern value_t vtable[]; /* variable table */ 202 203#if !ACULOG 204#define logent(a, b, c, d) 205#define loginit() 206#else 207void logent __P((char *, char *, char *, char*)); 208#endif 209 210/* 211 * Definition of indices into variable table so 212 * value(DEFINE) turns into a static address. 213 */ 214 215/* 216'a,.!awk '{ printf("\%s \%s \%d\n", $1, $2, NR - 1); }' 217*/ 218 219#define BEAUTIFY 0 220#define BAUDRATE 1 221#define DIALTIMEOUT 2 222#define EOFREAD 3 223#define EOFWRITE 4 224#define EOL 5 225#define ESCAPE 6 226#define EXCEPTIONS 7 227#define FORCE 8 228#define FRAMESIZE 9 229#define HOST 10 230#define LOG 11 231#define LOGIN 12 232#define LOGOUT 13 233#define PHONES 14 234#define PROMPT 15 235#define RAISE 16 236#define RAISECHAR 17 237#define RECORD 18 238#define REMOTE 19 239#define SCRIPT 20 240#define TABEXPAND 21 241#define VERBOSE 22 242#define SHELL 23 243#define HOME 24 244#define ECHOCHECK 25 245#define DISCONNECT 26 246#define TAND 27 247#define LDELAY 28 248#define CDELAY 29 249#define ETIMEOUT 30 250#define RAWFTP 31 251#define HALFDUPLEX 32 252#define LECHO 33 253#define PARITY 34 254#define NOVAL ((value_t *)NULL) 255#define NOACU ((acu_t *)NULL) 256#define NOSTR ((char *)NULL) 257#ifdef NOFILE 258#undef NOFILE 259#endif 260#define NOFILE ((FILE *)NULL) 261#define NOPWD ((struct passwd *)0) 262 263#if HAVE_TERMIOS 264struct termios otermios; 265struct termios ctermios; 266#else /* HAVE_TERMIOS */ 267struct sgttyb arg; /* current mode of local terminal */ 268struct sgttyb defarg; /* initial mode of local terminal */ 269struct tchars tchars; /* current state of terminal */ 270struct tchars defchars; /* initial state of terminal */ 271struct ltchars ltchars; /* current local characters of terminal */ 272struct ltchars deflchars; /* initial local characters of terminal */ 273#endif /* HAVE_TERMIOS */ 274 275FILE *fscript; /* FILE for scripting */ 276 277int fildes[2]; /* file transfer synchronization channel */ 278int repdes[2]; /* read process sychronization channel */ 279int FD; /* open file descriptor to remote host */ 280int AC; /* open file descriptor to dialer (v831 only) */ 281int vflag; /* print .tiprc initialization sequence */ 282int sfd; /* for ~< operation */ 283int pid; /* pid of tipout */ 284uid_t uid, euid; /* real and effective user id's */ 285gid_t gid, egid; /* real and effective group id's */ 286int stop; /* stop transfer session flag */ 287int quit; /* same; but on other end */ 288int intflag; /* recognized interrupt */ 289int stoprompt; /* for interrupting a prompt session */ 290int timedout; /* ~> transfer timedout */ 291int cumode; /* simulating the "cu" program */ 292 293char fname[PATH_MAX]; /* file name buffer for ~< */ 294char copyname[PATH_MAX]; /* file name buffer for ~> */ 295char ccc; /* synchronization character */ 296char ch; /* for tipout */ 297char *uucplock; /* name of lock file for uucp's */ 298 299int odisc; /* initial tty line discipline */ 300extern int disc; /* current tty discpline */ 301 302extern char *ctrl(); 303extern char *vinterp(); 304extern char *connect(); 305extern int size __P((char *)); 306extern int any __P((char, char *)); 307extern void setscript __P((void)); 308extern void tipout __P((void)); 309extern void vinit __P((void)); 310extern void loginit __P((void)); 311extern int hunt __P((char *)); 312extern int vstring __P((char *, char *)); 313extern void setparity __P((char *)); 314extern void vlex __P((char *)); 315extern void daemon_uid __P((void)); 316extern void disconnect __P((char *)); 317extern void shell_uid __P((void)); 318extern void unraw __P((void)); 319extern void pwrite __P((int, char *, int)); 320extern int prompt __P((char *, char *, size_t)); 321extern void consh __P((int)); 322extern void tipabort __P((char *)); 323 324#define TL_VERBOSE 0x00000001 325#define TL_SIGNAL_TIPOUT 0x00000002 326 327int tiplink (char *cmd, unsigned int flags); 328void raw (); 329 330/* end of tip.h */ 331