tip.h revision 129004
1/* $OpenBSD: tip.h,v 1.11 2001/09/09 19:30:49 millert Exp $ */ 2/* $NetBSD: tip.h,v 1.7 1997/04/20 00:02:46 mellon Exp $ */ 3/* $FreeBSD: head/usr.bin/tip/tip/tip.h 129004 2004-05-06 13:25:09Z stefanf $ */ 4 5/* 6 * Copyright (c) 1989, 1993 7 * The Regents of the University of California. All rights reserved. 8 * 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the University of 21 * California, Berkeley and its contributors. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)tip.h 8.1 (Berkeley) 6/6/93 39 */ 40 41/* 42 * tip - terminal interface program 43 */ 44 45#include <sys/types.h> 46#include <sys/file.h> 47#include <sys/time.h> 48#include <sys/wait.h> 49#include <sys/ioctl.h> 50 51#include <termios.h> 52#include <signal.h> 53#include <stdio.h> 54#include <stdlib.h> 55#include <string.h> 56#include <pwd.h> 57#include <ctype.h> 58#include <setjmp.h> 59#include <unistd.h> 60#include <errno.h> 61#include <limits.h> 62 63/* 64 * Remote host attributes 65 */ 66char *DV; /* UNIX device(s) to open */ 67char *EL; /* chars marking an EOL */ 68char *CM; /* initial connection message */ 69char *IE; /* EOT to expect on input */ 70char *OE; /* EOT to send to complete FT */ 71char *CU; /* call unit if making a phone call */ 72char *AT; /* acu type */ 73char *PN; /* phone number(s) */ 74char *DI; /* disconnect string */ 75char *PA; /* parity to be generated */ 76 77char *PH; /* phone number file */ 78char *RM; /* remote file name */ 79char *HO; /* host name */ 80 81long BR; /* line speed for conversation */ 82long FS; /* frame size for transfers */ 83 84short DU; /* this host is dialed up */ 85short HW; /* this device is hardwired, see hunt.c */ 86char *ES; /* escape character */ 87char *EX; /* exceptions */ 88char *FO; /* force (literal next) char*/ 89char *RC; /* raise character */ 90char *RE; /* script record file */ 91char *PR; /* remote prompt */ 92long DL; /* line delay for file transfers to remote */ 93long CL; /* char delay for file transfers to remote */ 94long ET; /* echocheck timeout */ 95short HD; /* this host is half duplex - do local echo */ 96short DC; /* this host is directly connected. */ 97 98/* 99 * String value table 100 */ 101typedef 102 struct { 103 char *v_name; /* whose name is it */ 104 char v_type; /* for interpreting set's */ 105 char v_access; /* protection of touchy ones */ 106 char *v_abrev; /* possible abreviation */ 107 char *v_value; /* casted to a union later */ 108 } 109 value_t; 110 111#define STRING 01 /* string valued */ 112#define BOOL 02 /* true-false value */ 113#define NUMBER 04 /* numeric value */ 114#define CHAR 010 /* character value */ 115 116#define WRITE 01 /* write access to variable */ 117#define READ 02 /* read access */ 118 119#define CHANGED 01 /* low bit is used to show modification */ 120#define PUBLIC 1 /* public access rights */ 121#define PRIVATE 03 /* private to definer */ 122#define ROOT 05 /* root defined */ 123 124#define TRUE 1 125#define FALSE 0 126 127#define ENVIRON 020 /* initialize out of the environment */ 128#define IREMOTE 040 /* initialize out of remote structure */ 129#define INIT 0100 /* static data space used for initialization */ 130#define TMASK 017 131 132/* 133 * Definition of ACU line description 134 */ 135typedef 136 struct { 137 const char *acu_name; 138 int (*acu_dialer)(char *, char *); 139 void (*acu_disconnect)(void); 140 void (*acu_abort)(void); 141 } 142 acu_t; 143 144#define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */ 145 146/* 147 * variable manipulation stuff -- 148 * if we defined the value entry in value_t, then we couldn't 149 * 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 void (*e_func)(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(char); 275extern char *vinterp(char *, char); 276extern const char *connect(void); 277 278char *sname(char *s); 279int any(int cc, char *p); 280int anyof(char *s1, char *s2); 281int args(char *buf, char *a[], int num); 282int escape(void); 283int prompt(char *s, char *p, size_t sz); 284int size(char *s); 285int speed(int n); 286int uu_lock(char *_ttyname); 287int uu_unlock(char *_ttyname); 288int vstring(char *s, char *v); 289long hunt(char *name); 290void cumain(int argc, char *argv[]); 291void daemon_uid(void); 292void disconnect(char *reason); 293void execute(char *s); 294char *interp(char *s); 295void logent(char *group, const char *num, const char *acu, const char *message); 296void loginit(void); 297void prtime(char *s, time_t a); 298void parwrite(int fd, char *buf, int n); 299void raw(void); 300void send(int c); 301void setparity(char *defparity); 302void setscript(void); 303void shell_uid(void); 304void tandem(char *option); 305void tipabort(char *msg); 306void tipin(void); 307void tipout(void); 308void transfer(char *buf, int fd, char *eofchars); 309void transmit(FILE *fd, char *eofchars, char *command); 310void ttysetup(int _speed); 311void unraw(void); 312void user_uid(void); 313void vinit(void); 314void vlex(char *s); 315 316int biz31f_dialer(char *, char *); 317void biz31f_disconnect(void); 318void biz31f_abort(void); 319int ven_dialer(char *, char *); 320void ven_disconnect(void); 321void ven_abort(void); 322int hay_dialer(char *, char *); 323void hay_disconnect(void); 324void hay_abort(void); 325int cour_dialer(char *, char *); 326void cour_disconnect(void); 327void cour_abort(void); 328int t3000_dialer(char *, char *); 329void t3000_disconnect(void); 330void t3000_abort(void); 331int v831_dialer(char *, char *); 332void v831_disconnect(void); 333void v831_abort(void); 334 335void shell(char c), getfl(char c), sendfile(char c), chdirectory(char c); 336void finish(char c), help(char c), pipefile(char c), pipeout(char c); 337void consh(char c), variable(char c), cu_take(char c), cu_put(char c); 338void dollar(char c), genbrk(char c), suspend(char c), listvariables(char c); 339