[BACK]Return to tip.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / tip

Annotation of src/usr.bin/tip/tip.h, Revision 1.20

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