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