tip.h revision 88276
1112918Sjeff/* $OpenBSD: tip.h,v 1.11 2001/09/09 19:30:49 millert Exp $ */ 2153496Sdavidxu/* $NetBSD: tip.h,v 1.7 1997/04/20 00:02:46 mellon Exp $ */ 3112918Sjeff/* $FreeBSD: head/usr.bin/tip/tip/tip.h 88276 2001-12-20 14:25:46Z markm $ */ 4112918Sjeff 5112918Sjeff/* 6112918Sjeff * Copyright (c) 1989, 1993 7112918Sjeff * The Regents of the University of California. All rights reserved. 8112918Sjeff * 9153496Sdavidxu * 10153496Sdavidxu * Redistribution and use in source and binary forms, with or without 11112918Sjeff * modification, are permitted provided that the following conditions 12112918Sjeff * are met: 13112918Sjeff * 1. Redistributions of source code must retain the above copyright 14112918Sjeff * notice, this list of conditions and the following disclaimer. 15153496Sdavidxu * 2. Redistributions in binary form must reproduce the above copyright 16153496Sdavidxu * notice, this list of conditions and the following disclaimer in the 17153496Sdavidxu * documentation and/or other materials provided with the distribution. 18153496Sdavidxu * 3. All advertising materials mentioning features or use of this software 19153496Sdavidxu * must display the following acknowledgement: 20153496Sdavidxu * This product includes software developed by the University of 21153496Sdavidxu * California, Berkeley and its contributors. 22153496Sdavidxu * 4. Neither the name of the University nor the names of its contributors 23153496Sdavidxu * may be used to endorse or promote products derived from this software 24153496Sdavidxu * without specific prior written permission. 25112918Sjeff * 26112918Sjeff * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27153496Sdavidxu * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28112918Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29144518Sdavidxu * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30157457Sdavidxu * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31112918Sjeff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32112918Sjeff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33157457Sdavidxu * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34144518Sdavidxu * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35112918Sjeff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36112918Sjeff * SUCH DAMAGE. 37157457Sdavidxu * 38157457Sdavidxu * @(#)tip.h 8.1 (Berkeley) 6/6/93 39150901Sdavidxu */ 40150901Sdavidxu 41112918Sjeff/* 42150901Sdavidxu * tip - terminal interface program 43112918Sjeff */ 44144518Sdavidxu 45144518Sdavidxu#include <sys/types.h> 46212536Sdavidxu#include <sys/file.h> 47144518Sdavidxu#include <sys/time.h> 48144518Sdavidxu#include <sys/wait.h> 49212536Sdavidxu#include <sys/ioctl.h> 50144518Sdavidxu 51212840Sdavidxu#include <termios.h> 52144518Sdavidxu#include <signal.h> 53144518Sdavidxu#include <stdio.h> 54112918Sjeff#include <stdlib.h> 55112918Sjeff#include <string.h> 56112918Sjeff#include <pwd.h> 57150901Sdavidxu#include <ctype.h> 58150901Sdavidxu#include <setjmp.h> 59150901Sdavidxu#include <unistd.h> 60150901Sdavidxu#include <errno.h> 61150901Sdavidxu#include <limits.h> 62150901Sdavidxu 63150901Sdavidxu/* 64150901Sdavidxu * Remote host attributes 65150901Sdavidxu */ 66150901Sdavidxuchar *DV; /* UNIX device(s) to open */ 67150901Sdavidxuchar *EL; /* chars marking an EOL */ 68150901Sdavidxuchar *CM; /* initial connection message */ 69150901Sdavidxuchar *IE; /* EOT to expect on input */ 70150901Sdavidxuchar *OE; /* EOT to send to complete FT */ 71211524Sdavidxuchar *CU; /* call unit if making a phone call */ 72211524Sdavidxuchar *AT; /* acu type */ 73211524Sdavidxuchar *PN; /* phone number(s) */ 74211524Sdavidxuchar *DI; /* disconnect string */ 75150901Sdavidxuchar *PA; /* parity to be generated */ 76150901Sdavidxu 77150901Sdavidxuchar *PH; /* phone number file */ 78150901Sdavidxuchar *RM; /* remote file name */ 79144518Sdavidxuchar *HO; /* host name */ 80150901Sdavidxu 81144518Sdavidxulong BR; /* line speed for conversation */ 82151694Sdavidxulong FS; /* frame size for transfers */ 83144518Sdavidxu 84151694Sdavidxushort DU; /* this host is dialed up */ 85144518Sdavidxushort HW; /* this device is hardwired, see hunt.c */ 86144518Sdavidxuchar *ES; /* escape character */ 87112918Sjeffchar *EX; /* exceptions */ 88129484Smtmchar *FO; /* force (literal next) char*/ 89144518Sdavidxuchar *RC; /* raise character */ 90112918Sjeffchar *RE; /* script record file */ 91212536Sdavidxuchar *PR; /* remote prompt */ 92212536Sdavidxulong DL; /* line delay for file transfers to remote */ 93212536Sdavidxulong CL; /* char delay for file transfers to remote */ 94212536Sdavidxulong ET; /* echocheck timeout */ 95164715Sdavidxushort HD; /* this host is half duplex - do local echo */ 96144518Sdavidxushort DC; /* this host is directly connected. */ 97112918Sjeff 98112918Sjeff/* 99112918Sjeff * String value table 100144518Sdavidxu */ 101212536Sdavidxutypedef 102144518Sdavidxu struct { 103144518Sdavidxu char *v_name; /* whose name is it */ 104144518Sdavidxu char v_type; /* for interpreting set's */ 105144518Sdavidxu char v_access; /* protection of touchy ones */ 106112918Sjeff char *v_abrev; /* possible abreviation */ 107212536Sdavidxu char *v_value; /* casted to a union later */ 108112918Sjeff } 109144518Sdavidxu value_t; 110212076Sdavidxu 111112918Sjeff#define STRING 01 /* string valued */ 112151694Sdavidxu#define BOOL 02 /* true-false value */ 113151694Sdavidxu#define NUMBER 04 /* numeric value */ 114211524Sdavidxu#define CHAR 010 /* character value */ 115150901Sdavidxu 116150901Sdavidxu#define WRITE 01 /* write access to variable */ 117150901Sdavidxu#define READ 02 /* read access */ 118150901Sdavidxu 119150901Sdavidxu#define CHANGED 01 /* low bit is used to show modification */ 120150901Sdavidxu#define PUBLIC 1 /* public access rights */ 121150901Sdavidxu#define PRIVATE 03 /* private to definer */ 122150901Sdavidxu#define ROOT 05 /* root defined */ 123150901Sdavidxu 124150901Sdavidxu#define TRUE 1 125151694Sdavidxu#define FALSE 0 126150901Sdavidxu 127150901Sdavidxu#define ENVIRON 020 /* initialize out of the environment */ 128144518Sdavidxu#define IREMOTE 040 /* initialize out of remote structure */ 129129484Smtm#define INIT 0100 /* static data space used for initialization */ 130212076Sdavidxu#define TMASK 017 131144518Sdavidxu 132115314Smtm/* 133150901Sdavidxu * Definition of ACU line description 134212536Sdavidxu */ 135150901Sdavidxutypedef 136212536Sdavidxu struct { 137150901Sdavidxu const char *acu_name; 138153526Sdavidxu int (*acu_dialer) __P((char *, char *)); 139150901Sdavidxu void (*acu_disconnect) __P((void)); 140212536Sdavidxu void (*acu_abort) __P((void)); 141212536Sdavidxu } 142150901Sdavidxu acu_t; 143212536Sdavidxu 144112918Sjeff#define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */ 145150901Sdavidxu 146150901Sdavidxu/* 147150901Sdavidxu * variable manipulation stuff -- 148112918Sjeff * if we defined the value entry in value_t, then we couldn't 149112918Sjeff * initialize it in vars.c, so we cast it as needed to keep lint 150 * happy. 151 */ 152 153#define value(v) vtable[v].v_value 154 155#define number(v) ((long)(v)) 156#define boolean(v) ((short)(long)(v)) 157#define character(v) ((char)(long)(v)) 158#define address(v) ((long *)(v)) 159 160#define setnumber(v,n) do { (v) = (char *)(long)(n); } while (0) 161#define setboolean(v,n) do { (v) = (char *)(long)(n); } while (0) 162#define setcharacter(v,n) do { (v) = (char *)(long)(n); } while (0) 163#define setaddress(v,n) do { (v) = (char *)(n); } while (0) 164 165/* 166 * Escape command table definitions -- 167 * lookup in this table is performed when ``escapec'' is recognized 168 * at the begining of a line (as defined by the eolmarks variable). 169*/ 170 171typedef 172 struct { 173 char e_char; /* char to match on */ 174 char e_flags; /* experimental, priviledged */ 175 const char *e_help; /* help string */ 176 int (*e_func) __P((char)); /* command */ 177 } 178 esctable_t; 179 180#define NORM 00 /* normal protection, execute anyone */ 181#define EXP 01 /* experimental, mark it with a `*' on help */ 182#define PRIV 02 /* priviledged, root execute only */ 183 184extern int vflag; /* verbose during reading of .tiprc file */ 185extern int noesc; /* no escape `~' char */ 186extern value_t vtable[]; /* variable table */ 187 188#ifndef ACULOG 189#define logent(a, b, c, d) 190#define loginit() 191#endif 192 193/* 194 * Definition of indices into variable table so 195 * value(DEFINE) turns into a static address. 196 */ 197 198#define BEAUTIFY 0 199#define BAUDRATE 1 200#define DIALTIMEOUT 2 201#define EOFREAD 3 202#define EOFWRITE 4 203#define EOL 5 204#define ESCAPE 6 205#define EXCEPTIONS 7 206#define FORCE 8 207#define FRAMESIZE 9 208#define HOST 10 209#define LOG 11 210#define PHONES 12 211#define PROMPT 13 212#define RAISE 14 213#define RAISECHAR 15 214#define RECORD 16 215#define REMOTE 17 216#define SCRIPT 18 217#define TABEXPAND 19 218#define VERBOSE 20 219#define SHELL 21 220#define HOME 22 221#define ECHOCHECK 23 222#define DISCONNECT 24 223#define TAND 25 224#define LDELAY 26 225#define CDELAY 27 226#define ETIMEOUT 28 227#define RAWFTP 29 228#define HALFDUPLEX 30 229#define LECHO 31 230#define PARITY 32 231 232#define NOVAL ((value_t *)NULL) 233#define NOACU ((acu_t *)NULL) 234#define NOSTR ((char *)NULL) 235#define NOFILE ((FILE *)NULL) 236#define NOPWD ((struct passwd *)0) 237 238struct termios term; /* current mode of terminal */ 239struct termios defterm; /* initial mode of terminal */ 240struct termios defchars; /* current mode with initial chars */ 241 242FILE *fscript; /* FILE for scripting */ 243 244int fildes[2]; /* file transfer synchronization channel */ 245int repdes[2]; /* read process sychronization channel */ 246int FD; /* open file descriptor to remote host */ 247int AC; /* open file descriptor to dialer (v831 only) */ 248int vflag; /* print .tiprc initialization sequence */ 249int noesc; /* no `~' escape char */ 250int sfd; /* for ~< operation */ 251int pid; /* pid of tipout */ 252uid_t uid, euid; /* real and effective user id's */ 253gid_t gid, egid; /* real and effective group id's */ 254int stop; /* stop transfer session flag */ 255int quit; /* same; but on other end */ 256int intflag; /* recognized interrupt */ 257int stoprompt; /* for interrupting a prompt session */ 258int timedout; /* ~> transfer timedout */ 259int cumode; /* simulating the "cu" program */ 260int bits8; /* terminal is is 8-bit mode */ 261#define STRIP_PAR (bits8 ? 0377 : 0177) 262 263char fname[PATH_MAX]; /* file name buffer for ~< */ 264char copyname[PATH_MAX]; /* file name buffer for ~> */ 265char ccc; /* synchronization character */ 266char ch; /* for tipout */ 267char *uucplock; /* name of lock file for uucp's */ 268 269int odisc; /* initial tty line discipline */ 270extern int disc; /* current tty discpline */ 271 272extern char *__progname; /* program name */ 273 274extern char *ctrl __P((char)); 275extern char *vinterp __P((char *, char)); 276extern const char *connect __P((void)); 277 278char *sname __P((char *s)); 279int any __P((int cc, char *p)); 280int anyof __P((char *s1, char *s2)); 281int args __P((char *buf, char *a[], int num)); 282int escape __P((void)); 283int prompt __P((char *s, char *p, size_t sz)); 284int size __P((char *s)); 285int speed __P((int n)); 286int uu_lock __P((char *_ttyname)); 287int uu_unlock __P((char *_ttyname)); 288int vstring __P((char *s, char *v)); 289long hunt __P((char *name)); 290void cumain __P((int argc, char *argv[])); 291void daemon_uid __P((void)); 292void disconnect __P((char *reason)); 293void execute __P((char *s)); 294void logent __P((char *group, const char *num, const char *acu, const char *message)); 295void loginit __P((void)); 296void prtime __P((char *s, time_t a)); 297void parwrite __P((int fd, char *buf, int n)); 298void raw __P((void)); 299void send __P((int c)); 300void setparity __P((char *defparity)); 301void setscript __P((void)); 302void shell_uid __P((void)); 303void tandem __P((char *option)); 304void tipabort __P((char *msg)); 305void tipin __P((void)); 306void tipout __P((void)); 307void transfer __P((char *buf, int fd, char *eofchars)); 308void transmit __P((FILE *fd, char *eofchars, char *command)); 309void ttysetup __P((int _speed)); 310void unraw __P((void)); 311void user_uid __P((void)); 312void vinit __P((void)); 313void vlex __P((char *s)); 314 315int biz31f_dialer __P((char *, char *)); 316void biz31f_disconnect __P((void)); 317void biz31f_abort __P((void)); 318int ven_dialer __P((char *, char *)); 319void ven_disconnect __P((void)); 320void ven_abort __P((void)); 321int hay_dialer __P((char *, char *)); 322void hay_disconnect __P((void)); 323void hay_abort __P((void)); 324int cour_dialer __P((char *, char *)); 325void cour_disconnect __P((void)); 326void cour_abort __P((void)); 327int t3000_dialer __P((char *, char *)); 328void t3000_disconnect __P((void)); 329void t3000_abort __P((void)); 330int v831_dialer __P((char *, char *)); 331void v831_disconnect __P((void)); 332void v831_abort __P((void)); 333