17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 37c478bd9Sstevel@tonic-gate * Use is subject to license terms. 47c478bd9Sstevel@tonic-gate */ 57c478bd9Sstevel@tonic-gate /* 67c478bd9Sstevel@tonic-gate * Copyright (c) 1983 Regents of the University of California. 77c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 87c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 97c478bd9Sstevel@tonic-gate */ 107c478bd9Sstevel@tonic-gate 11*8d489c7aSmuffin #ifndef _TIP_H 12*8d489c7aSmuffin #define _TIP_H 13*8d489c7aSmuffin 147c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 157c478bd9Sstevel@tonic-gate 167c478bd9Sstevel@tonic-gate /* 177c478bd9Sstevel@tonic-gate * tip - terminal interface program 187c478bd9Sstevel@tonic-gate */ 197c478bd9Sstevel@tonic-gate 207c478bd9Sstevel@tonic-gate #include <sys/types.h> 217c478bd9Sstevel@tonic-gate #ifdef USG 227c478bd9Sstevel@tonic-gate #include <fcntl.h> /* for O_RDWR, etc. */ 237c478bd9Sstevel@tonic-gate #include <unistd.h> /* for R_OK, etc. */ 247c478bd9Sstevel@tonic-gate #else 257c478bd9Sstevel@tonic-gate #include <sys/file.h> 267c478bd9Sstevel@tonic-gate #endif 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <sys/termios.h> 297c478bd9Sstevel@tonic-gate #include <sys/filio.h> /* XXX - for FIONREAD only */ 307c478bd9Sstevel@tonic-gate #include <signal.h> 317c478bd9Sstevel@tonic-gate #include <stdio.h> 327c478bd9Sstevel@tonic-gate #include <pwd.h> 337c478bd9Sstevel@tonic-gate #include <ctype.h> 347c478bd9Sstevel@tonic-gate #include <setjmp.h> 357c478bd9Sstevel@tonic-gate #include <errno.h> 367c478bd9Sstevel@tonic-gate #include <string.h> 377c478bd9Sstevel@tonic-gate #include <time.h> 387c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> /* for ENDIAN defines */ 39*8d489c7aSmuffin #include <stdlib.h> 40*8d489c7aSmuffin #include <sys/wait.h> 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #define _CTRL(c) (c&037) 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #ifdef USG 457c478bd9Sstevel@tonic-gate #define signal(_sig_, _hdlr_) sigset((_sig_), (_hdlr_)) 467c478bd9Sstevel@tonic-gate #endif 47*8d489c7aSmuffin typedef void (*sig_handler_t)(int); /* works on BSD and SV */ 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* 507c478bd9Sstevel@tonic-gate * Remote host attributes 517c478bd9Sstevel@tonic-gate */ 527c478bd9Sstevel@tonic-gate char *DV; /* UNIX device(s) to open */ 537c478bd9Sstevel@tonic-gate char *EL; /* chars marking an EOL */ 547c478bd9Sstevel@tonic-gate char *CM; /* initial connection message */ 557c478bd9Sstevel@tonic-gate char *IE; /* EOT to expect on input */ 567c478bd9Sstevel@tonic-gate char *OE; /* EOT to send to complete FT */ 577c478bd9Sstevel@tonic-gate char *CU; /* call unit if making a phone call */ 587c478bd9Sstevel@tonic-gate char *AT; /* acu type */ 597c478bd9Sstevel@tonic-gate char *PN; /* phone number(s) */ 607c478bd9Sstevel@tonic-gate char *DI; /* disconnect string */ 617c478bd9Sstevel@tonic-gate char *PA; /* parity to be generated */ 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate char *PH; /* phone number file */ 647c478bd9Sstevel@tonic-gate char *RM; /* remote file name */ 657c478bd9Sstevel@tonic-gate char *HO; /* host name */ 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate int BR; /* line speed for conversation */ 687c478bd9Sstevel@tonic-gate int FS; /* frame size for transfers */ 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate signed char DU; /* this host is dialed up */ 717c478bd9Sstevel@tonic-gate char HW; /* this device is hardwired, see hunt.c */ 727c478bd9Sstevel@tonic-gate char *ES; /* escape character */ 737c478bd9Sstevel@tonic-gate char *EX; /* exceptions */ 747c478bd9Sstevel@tonic-gate char *FO; /* force (literal next) char */ 757c478bd9Sstevel@tonic-gate char *RC; /* raise character */ 767c478bd9Sstevel@tonic-gate char *RE; /* script record file */ 777c478bd9Sstevel@tonic-gate char *PR; /* remote prompt */ 787c478bd9Sstevel@tonic-gate int DL; /* line delay for file transfers to remote */ 797c478bd9Sstevel@tonic-gate int CL; /* char delay for file transfers to remote */ 807c478bd9Sstevel@tonic-gate int ET; /* echocheck timeout */ 817c478bd9Sstevel@tonic-gate int DB; /* dialback - ignore hangup */ 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate /* 847c478bd9Sstevel@tonic-gate * String value table 857c478bd9Sstevel@tonic-gate */ 867c478bd9Sstevel@tonic-gate typedef 877c478bd9Sstevel@tonic-gate struct { 887c478bd9Sstevel@tonic-gate char *v_name; /* whose name is it */ 897c478bd9Sstevel@tonic-gate char v_type; /* for interpreting set's */ 907c478bd9Sstevel@tonic-gate char v_access; /* protection of touchy ones */ 917c478bd9Sstevel@tonic-gate char *v_abrev; /* possible abreviation */ 927c478bd9Sstevel@tonic-gate char *v_value; /* casted to a union later */ 937c478bd9Sstevel@tonic-gate } 947c478bd9Sstevel@tonic-gate value_t; 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #define STRING 01 /* string valued */ 977c478bd9Sstevel@tonic-gate #define BOOL 02 /* true-false value */ 987c478bd9Sstevel@tonic-gate #define NUMBER 04 /* numeric value */ 997c478bd9Sstevel@tonic-gate #define CHAR 010 /* character value */ 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate #define WRITE 01 /* write access to variable */ 1027c478bd9Sstevel@tonic-gate #define READ 02 /* read access */ 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate #define CHANGED 01 /* low bit is used to show modification */ 1057c478bd9Sstevel@tonic-gate #define PUBLIC 1 /* public access rights */ 1067c478bd9Sstevel@tonic-gate #define PRIVATE 03 /* private to definer */ 1077c478bd9Sstevel@tonic-gate #define ROOT 05 /* root defined */ 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #define TRUE 1 1107c478bd9Sstevel@tonic-gate #define FALSE 0 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate #define ENVIRON 020 /* initialize out of the environment */ 1137c478bd9Sstevel@tonic-gate #define IREMOTE 040 /* initialize out of remote structure */ 1147c478bd9Sstevel@tonic-gate #define INIT 0100 /* static data space used for initialization */ 1157c478bd9Sstevel@tonic-gate #define TMASK 017 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate /* 1187c478bd9Sstevel@tonic-gate * Definition of ACU line description 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate typedef 1217c478bd9Sstevel@tonic-gate struct { 1227c478bd9Sstevel@tonic-gate char *acu_name; 123*8d489c7aSmuffin int (*acu_dialer)(char *, char *); 124*8d489c7aSmuffin void (*acu_disconnect)(void); 125*8d489c7aSmuffin void (*acu_abort)(void); 1267c478bd9Sstevel@tonic-gate } 1277c478bd9Sstevel@tonic-gate acu_t; 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate #define equal(a, b) (strcmp(a, b) == 0) /* A nice function to compare */ 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /* 1327c478bd9Sstevel@tonic-gate * variable manipulation stuff -- 1337c478bd9Sstevel@tonic-gate * if we defined the value entry in value_t, then we couldn't 1347c478bd9Sstevel@tonic-gate * initialize it in vars.c, so we cast it as needed to keep lint 1357c478bd9Sstevel@tonic-gate * happy. 1367c478bd9Sstevel@tonic-gate */ 1377c478bd9Sstevel@tonic-gate typedef 1387c478bd9Sstevel@tonic-gate union { 1397c478bd9Sstevel@tonic-gate int zz_number; 1407c478bd9Sstevel@tonic-gate int *zz_address; 1417c478bd9Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN) 1427c478bd9Sstevel@tonic-gate short zz_boolean; 1437c478bd9Sstevel@tonic-gate char zz_character; 1447c478bd9Sstevel@tonic-gate #endif 1457c478bd9Sstevel@tonic-gate #if defined(_BIG_ENDIAN) 1467c478bd9Sstevel@tonic-gate int zz_boolean; 1477c478bd9Sstevel@tonic-gate int zz_character; 1487c478bd9Sstevel@tonic-gate #endif 1497c478bd9Sstevel@tonic-gate } 1507c478bd9Sstevel@tonic-gate zzhack; 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate #define value(v) vtable[v].v_value 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate #define boolean(v) ((((zzhack *)(&(v))))->zz_boolean) 1557c478bd9Sstevel@tonic-gate #define number(v) ((((zzhack *)(&(v))))->zz_number) 1567c478bd9Sstevel@tonic-gate #define character(v) ((((zzhack *)(&(v))))->zz_character) 1577c478bd9Sstevel@tonic-gate #define address(v) ((((zzhack *)(&(v))))->zz_address) 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate /* 1607c478bd9Sstevel@tonic-gate * Escape command table definitions -- 1617c478bd9Sstevel@tonic-gate * lookup in this table is performed when ``escapec'' is recognized 1627c478bd9Sstevel@tonic-gate * at the begining of a line (as defined by the eolmarks variable). 1637c478bd9Sstevel@tonic-gate */ 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate typedef 1667c478bd9Sstevel@tonic-gate struct { 1677c478bd9Sstevel@tonic-gate char e_char; /* char to match on */ 1687c478bd9Sstevel@tonic-gate char e_flags; /* experimental, priviledged */ 1697c478bd9Sstevel@tonic-gate char *e_help; /* help string */ 170*8d489c7aSmuffin void (*e_func)(int); /* command */ 1717c478bd9Sstevel@tonic-gate } 1727c478bd9Sstevel@tonic-gate esctable_t; 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate #define NORM 00 /* normal protection, execute anyone */ 1757c478bd9Sstevel@tonic-gate #define EXP 01 /* experimental, mark it with a `*' on help */ 1767c478bd9Sstevel@tonic-gate #define PRIV 02 /* priviledged, root execute only */ 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate extern int vflag; /* verbose during reading of .tiprc file */ 1797c478bd9Sstevel@tonic-gate extern value_t vtable[]; /* variable table */ 1807c478bd9Sstevel@tonic-gate extern int noparity; 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate #ifndef ACULOG 1847c478bd9Sstevel@tonic-gate #define logent(a, b, c, d) 1857c478bd9Sstevel@tonic-gate #define loginit() 186*8d489c7aSmuffin #else 187*8d489c7aSmuffin extern void logent(char *, char *, char *, char *); 188*8d489c7aSmuffin extern void loginit(void); 1897c478bd9Sstevel@tonic-gate #endif 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate /* 1927c478bd9Sstevel@tonic-gate * Definition of indices into variable table so 1937c478bd9Sstevel@tonic-gate * value(DEFINE) turns into a static address. 1947c478bd9Sstevel@tonic-gate */ 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate #define BEAUTIFY 0 1977c478bd9Sstevel@tonic-gate #define BAUDRATE 1 1987c478bd9Sstevel@tonic-gate #define DIALTIMEOUT 2 1997c478bd9Sstevel@tonic-gate #define EOFREAD 3 2007c478bd9Sstevel@tonic-gate #define EOFWRITE 4 2017c478bd9Sstevel@tonic-gate #define EOL 5 2027c478bd9Sstevel@tonic-gate #define ESCAPE 6 2037c478bd9Sstevel@tonic-gate #define EXCEPTIONS 7 2047c478bd9Sstevel@tonic-gate #define FORCE 8 2057c478bd9Sstevel@tonic-gate #define FRAMESIZE 9 2067c478bd9Sstevel@tonic-gate #define HOST 10 2077c478bd9Sstevel@tonic-gate #define LOG 11 2087c478bd9Sstevel@tonic-gate #define PHONES 12 2097c478bd9Sstevel@tonic-gate #define PROMPT 13 2107c478bd9Sstevel@tonic-gate #define RAISE 14 2117c478bd9Sstevel@tonic-gate #define RAISECHAR 15 2127c478bd9Sstevel@tonic-gate #define RECORD 16 2137c478bd9Sstevel@tonic-gate #define REMOTE 17 2147c478bd9Sstevel@tonic-gate #define SCRIPT 18 2157c478bd9Sstevel@tonic-gate #define TABEXPAND 19 2167c478bd9Sstevel@tonic-gate #define VERBOSE 20 2177c478bd9Sstevel@tonic-gate #define SHELL 21 2187c478bd9Sstevel@tonic-gate #define HOME 22 2197c478bd9Sstevel@tonic-gate #define ECHOCHECK 23 2207c478bd9Sstevel@tonic-gate #define DISCONNECT 24 2217c478bd9Sstevel@tonic-gate #define TAND 25 2227c478bd9Sstevel@tonic-gate #define LDELAY 26 2237c478bd9Sstevel@tonic-gate #define CDELAY 27 2247c478bd9Sstevel@tonic-gate #define ETIMEOUT 28 2257c478bd9Sstevel@tonic-gate #define RAWFTP 29 2267c478bd9Sstevel@tonic-gate #define HALFDUPLEX 30 2277c478bd9Sstevel@tonic-gate #define LECHO 31 2287c478bd9Sstevel@tonic-gate #define PARITY 32 2297c478bd9Sstevel@tonic-gate #define HARDWAREFLOW 33 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate #define NOVAL ((value_t *)NULL) 2327c478bd9Sstevel@tonic-gate #define NOACU ((acu_t *)NULL) 2337c478bd9Sstevel@tonic-gate #define NOSTR ((char *)NULL) 2347c478bd9Sstevel@tonic-gate #define NOFILE ((FILE *)NULL) 2357c478bd9Sstevel@tonic-gate #define NOPWD ((struct passwd *)0) 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate struct termios arg; /* current mode of local terminal */ 2387c478bd9Sstevel@tonic-gate struct termios defarg; /* initial mode of local terminal */ 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate FILE *fscript; /* FILE for scripting */ 2417c478bd9Sstevel@tonic-gate FILE *phfd; /* FILE for PHONES file */ 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate int fildes[2]; /* file transfer synchronization channel */ 2447c478bd9Sstevel@tonic-gate int repdes[2]; /* read process sychronization channel */ 2457c478bd9Sstevel@tonic-gate int FD; /* open file descriptor to remote host */ 2467c478bd9Sstevel@tonic-gate int AC; /* open file descriptor to dialer (v831 only) */ 2477c478bd9Sstevel@tonic-gate int vflag; /* print .tiprc initialization sequence */ 2487c478bd9Sstevel@tonic-gate int sfd; /* for ~< operation */ 2497c478bd9Sstevel@tonic-gate int pid; /* pid of tipout */ 2507c478bd9Sstevel@tonic-gate int uid, euid; /* real and effective user id's */ 2517c478bd9Sstevel@tonic-gate int gid, egid; /* real and effective group id's */ 2527c478bd9Sstevel@tonic-gate int stoprompt; /* for interrupting a prompt session */ 2537c478bd9Sstevel@tonic-gate int timedout; /* ~> transfer timedout */ 2547c478bd9Sstevel@tonic-gate int cumode; /* simulating the "cu" program */ 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate char fname[80]; /* file name buffer for ~< */ 2577c478bd9Sstevel@tonic-gate char copyname[80]; /* file name buffer for ~> */ 2587c478bd9Sstevel@tonic-gate char ccc; /* synchronization character */ 2597c478bd9Sstevel@tonic-gate char ch; /* for tipout */ 2607c478bd9Sstevel@tonic-gate char *uucplock; /* name of lock file for uucp's */ 2617c478bd9Sstevel@tonic-gate extern int trusted_device; 2627c478bd9Sstevel@tonic-gate 263*8d489c7aSmuffin 264*8d489c7aSmuffin extern char *connect(void); 265*8d489c7aSmuffin extern char *ctrl(char); 266*8d489c7aSmuffin extern char *getremote(char *); 267*8d489c7aSmuffin extern char *expand(char []); 268*8d489c7aSmuffin extern char *vinterp(char *, char); 269*8d489c7aSmuffin extern void cumain(int, char *[]); 270*8d489c7aSmuffin extern void delock(char *); 271*8d489c7aSmuffin extern void disconnect(char *); 272*8d489c7aSmuffin extern void myperm(void); 273*8d489c7aSmuffin extern void parwrite(int, unsigned char *, int); 274*8d489c7aSmuffin extern void raw(void); 275*8d489c7aSmuffin extern void setparity(char *); 276*8d489c7aSmuffin extern void setscript(void); 277*8d489c7aSmuffin extern void tandem(char *); 278*8d489c7aSmuffin extern void tip_abort(char *); 279*8d489c7aSmuffin extern void ttysetup(int); 280*8d489c7aSmuffin extern void unraw(void); 281*8d489c7aSmuffin extern void userperm(void); 282*8d489c7aSmuffin extern void vinit(void); 283*8d489c7aSmuffin extern void vlex(char *); 284*8d489c7aSmuffin extern int any(char, char *); 285*8d489c7aSmuffin extern int hunt(char *); 286*8d489c7aSmuffin extern int prompt(char *, char *, size_t); 287*8d489c7aSmuffin extern int rgetent(char *, char *, int); 288*8d489c7aSmuffin extern int rgetflag(char *); 289*8d489c7aSmuffin extern int rgetnum(char *); 290*8d489c7aSmuffin extern int speed(int); 291*8d489c7aSmuffin extern int tip_mlock(char *); 292*8d489c7aSmuffin extern int vstring(char *, char *); 293*8d489c7aSmuffin 294*8d489c7aSmuffin #endif /* _TIP_H */ 295