[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.30

1.30    ! jmc         1: /*     $OpenBSD: tip.h,v 1.29 2007/05/15 19:42:05 moritz 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.28      millert    56: #include <err.h>
1.7       millert    57: #include <limits.h>
1.1       deraadt    58:
                     59: /*
                     60:  * Remote host attributes
                     61:  */
                     62: char   *DV;                    /* UNIX device(s) to open */
                     63: char   *EL;                    /* chars marking an EOL */
                     64: char   *CM;                    /* initial connection message */
                     65: char   *IE;                    /* EOT to expect on input */
                     66: char   *OE;                    /* EOT to send to complete FT */
                     67: char   *CU;                    /* call unit if making a phone call */
                     68: char   *AT;                    /* acu type */
                     69: char   *PN;                    /* phone number(s) */
                     70: char   *DI;                    /* disconnect string */
                     71: char   *PA;                    /* parity to be generated */
                     72:
                     73: char   *PH;                    /* phone number file */
                     74: char   *RM;                    /* remote file name */
                     75: char   *HO;                    /* host name */
                     76:
                     77: long   BR;                     /* line speed for conversation */
                     78: long   FS;                     /* frame size for transfers */
                     79:
1.6       millert    80: short  DU;                     /* this host is dialed up */
                     81: short  HW;                     /* this device is hardwired, see hunt.c */
1.1       deraadt    82: char   *ES;                    /* escape character */
                     83: char   *EX;                    /* exceptions */
                     84: char   *FO;                    /* force (literal next) char*/
                     85: char   *RC;                    /* raise character */
                     86: char   *RE;                    /* script record file */
                     87: char   *PR;                    /* remote prompt */
                     88: long   DL;                     /* line delay for file transfers to remote */
                     89: long   CL;                     /* char delay for file transfers to remote */
                     90: long   ET;                     /* echocheck timeout */
1.26      deraadt    91: long   LD;                     /* line disc */
1.6       millert    92: short  HD;                     /* this host is half duplex - do local echo */
1.1       deraadt    93:
                     94: /*
                     95:  * String value table
                     96:  */
                     97: typedef
                     98:        struct {
                     99:                char    *v_name;        /* whose name is it */
                    100:                char    v_type;         /* for interpreting set's */
                    101:                char    v_access;       /* protection of touchy ones */
                    102:                char    *v_abrev;       /* possible abreviation */
                    103:                char    *v_value;       /* casted to a union later */
                    104:        }
                    105:        value_t;
                    106:
                    107: #define STRING 01              /* string valued */
                    108: #define BOOL   02              /* true-false value */
                    109: #define NUMBER 04              /* numeric value */
                    110: #define CHAR   010             /* character value */
                    111:
                    112: #define WRITE  01              /* write access to variable */
                    113: #define        READ    02              /* read access */
                    114:
                    115: #define CHANGED        01              /* low bit is used to show modification */
                    116: #define PUBLIC 1               /* public access rights */
                    117: #define PRIVATE        03              /* private to definer */
                    118: #define ROOT   05              /* root defined */
                    119:
                    120: #define        TRUE    1
                    121: #define FALSE  0
                    122:
                    123: #define ENVIRON        020             /* initialize out of the environment */
                    124: #define IREMOTE        040             /* initialize out of remote structure */
                    125: #define INIT   0100            /* static data space used for initialization */
                    126: #define TMASK  017
                    127:
                    128: /*
                    129:  * Definition of ACU line description
                    130:  */
                    131: typedef
                    132:        struct {
                    133:                char    *acu_name;
1.23      moritz    134:                int     (*acu_dialer)(char *, char *);
                    135:                void    (*acu_disconnect)(void);
                    136:                void    (*acu_abort)(void);
1.1       deraadt   137:        }
                    138:        acu_t;
                    139:
                    140: #define        equal(a, b)     (strcmp(a,b)==0)/* A nice function to string compare */
                    141:
                    142: /*
                    143:  * variable manipulation stuff --
                    144:  *   if we defined the value entry in value_t, then we couldn't
                    145:  *   initialize it in vars.c, so we cast it as needed to keep lint
                    146:  *   happy.
                    147:  */
                    148:
                    149: #define value(v)       vtable[v].v_value
1.22      deraadt   150: #define lvalue(v)      (long)vtable[v].v_value
1.1       deraadt   151:
1.5       millert   152: #define        number(v)       ((long)(v))
                    153: #define        boolean(v)      ((short)(long)(v))
                    154: #define        character(v)    ((char)(long)(v))
                    155: #define        address(v)      ((long *)(v))
                    156:
                    157: #define        setnumber(v,n)          do { (v) = (char *)(long)(n); } while (0)
                    158: #define        setboolean(v,n)         do { (v) = (char *)(long)(n); } while (0)
                    159: #define        setcharacter(v,n)       do { (v) = (char *)(long)(n); } while (0)
                    160: #define        setaddress(v,n)         do { (v) = (char *)(n); } while (0)
1.1       deraadt   161:
                    162: /*
                    163:  * Escape command table definitions --
                    164:  *   lookup in this table is performed when ``escapec'' is recognized
                    165:  *   at the begining of a line (as defined by the eolmarks variable).
                    166: */
                    167:
                    168: typedef
                    169:        struct {
1.19      deraadt   170:                char    e_char;                 /* char to match on */
                    171:                char    e_flags;                /* experimental, privileged */
                    172:                char    *e_help;                /* help string */
1.21      moritz    173:                void    (*e_func)(int);         /* command */
1.1       deraadt   174:        }
                    175:        esctable_t;
                    176:
                    177: #define NORM   00              /* normal protection, execute anyone */
                    178: #define EXP    01              /* experimental, mark it with a `*' on help */
1.14      deraadt   179: #define PRIV   02              /* privileged, root execute only */
1.1       deraadt   180:
                    181: extern int     vflag;          /* verbose during reading of .tiprc file */
1.9       todd      182: extern int     noesc;          /* no escape `~' char */
1.1       deraadt   183: extern value_t vtable[];       /* variable table */
                    184:
                    185: #ifndef ACULOG
                    186: #define logent(a, b, c, d)
                    187: #define loginit()
                    188: #endif
                    189:
                    190: /*
                    191:  * Definition of indices into variable table so
                    192:  *  value(DEFINE) turns into a static address.
                    193:  */
                    194:
                    195: #define BEAUTIFY       0
                    196: #define BAUDRATE       1
                    197: #define DIALTIMEOUT    2
                    198: #define EOFREAD                3
                    199: #define EOFWRITE       4
                    200: #define EOL            5
                    201: #define ESCAPE         6
                    202: #define EXCEPTIONS     7
                    203: #define FORCE          8
                    204: #define FRAMESIZE      9
                    205: #define HOST           10
                    206: #define LOG            11
                    207: #define PHONES         12
                    208: #define PROMPT         13
                    209: #define RAISE          14
                    210: #define RAISECHAR      15
                    211: #define RECORD         16
                    212: #define REMOTE         17
                    213: #define SCRIPT         18
                    214: #define TABEXPAND      19
                    215: #define VERBOSE                20
                    216: #define SHELL          21
                    217: #define HOME           22
                    218: #define ECHOCHECK      23
                    219: #define DISCONNECT     24
                    220: #define TAND           25
                    221: #define LDELAY         26
                    222: #define CDELAY         27
                    223: #define ETIMEOUT       28
                    224: #define RAWFTP         29
                    225: #define HALFDUPLEX     30
                    226: #define        LECHO           31
                    227: #define        PARITY          32
1.16      millert   228: #define        HARDWAREFLOW    33
1.26      deraadt   229: #define        LINEDISC        34
1.27      jason     230: #define        DC              35
1.1       deraadt   231:
1.2       deraadt   232: struct termios term;           /* current mode of terminal */
                    233: struct termios defterm;        /* initial mode of terminal */
                    234: struct termios defchars;       /* current mode with initial chars */
1.17      deraadt   235: int    gotdefterm;
1.1       deraadt   236:
                    237: FILE   *fscript;               /* FILE for scripting */
                    238:
                    239: int    fildes[2];              /* file transfer synchronization channel */
                    240: int    repdes[2];              /* read process sychronization channel */
                    241: int    FD;                     /* open file descriptor to remote host */
                    242: int    AC;                     /* open file descriptor to dialer (v831 only) */
                    243: int    vflag;                  /* print .tiprc initialization sequence */
1.9       todd      244: int    noesc;                  /* no `~' escape char */
1.1       deraadt   245: int    sfd;                    /* for ~< operation */
1.18      deraadt   246: pid_t  tipin_pid;              /* pid of tipin */
                    247: pid_t  tipout_pid;             /* pid of tipout */
1.1       deraadt   248: uid_t  uid, euid;              /* real and effective user id's */
                    249: gid_t  gid, egid;              /* real and effective group id's */
                    250: int    stop;                   /* stop transfer session flag */
                    251: int    quit;                   /* same; but on other end */
                    252: int    intflag;                /* recognized interrupt */
                    253: int    stoprompt;              /* for interrupting a prompt session */
                    254: int    timedout;               /* ~> transfer timedout */
                    255: int    cumode;                 /* simulating the "cu" program */
1.30    ! jmc       256: int    bits8;                  /* terminal is 8-bit mode */
1.2       deraadt   257: #define STRIP_PAR      (bits8 ? 0377 : 0177)
1.1       deraadt   258:
1.7       millert   259: char   fname[PATH_MAX];        /* file name buffer for ~< */
                    260: char   copyname[PATH_MAX];     /* file name buffer for ~> */
1.1       deraadt   261: char   ccc;                    /* synchronization character */
                    262: char   *uucplock;              /* name of lock file for uucp's */
                    263:
1.11      millert   264: int    odisc;                  /* initial tty line discipline */
                    265: extern int disc;               /* current tty discpline */
                    266:
                    267: extern char *__progname;       /* program name */
1.1       deraadt   268:
1.21      moritz    269: char   *con(void);
                    270: char   *ctrl(char);
                    271: char   *expand(char *);
                    272: char   *getremote(char *);
1.20      moritz    273: char   *interp(char *);
                    274: int    any(int, char *);
1.23      moritz    275: int    biz22w_dialer(char *, char *);
                    276: int    biz22f_dialer(char *, char *);
                    277: int    biz31w_dialer(char *, char *);
                    278: int    biz31f_dialer(char *, char *);
                    279: int    cour_dialer(char *, char *);
                    280: int    df02_dialer(char *, char *);
                    281: int    df03_dialer(char *, char *);
                    282: int    dn_dialer(char *, char *);
                    283: int    hay_dialer(char *, char *);
1.20      moritz    284: int    prompt(char *, char *, size_t);
1.25      deraadt   285: size_t size(char *);
1.23      moritz    286: int    t3000_dialer(char *, char *);
1.20      moritz    287: int    ttysetup(int);
                    288: int    uu_lock(char *);
                    289: int    uu_unlock(char *);
1.23      moritz    290: int    v3451_dialer(char *, char *);
                    291: int    v831_dialer(char *, char *);
                    292: int    ven_dialer(char *, char *);
1.20      moritz    293: int    vstring(char *, char *);
                    294: long   hunt(char *);
1.23      moritz    295: void   biz22_disconnect(void);
                    296: void   biz22_abort(void);
                    297: void   biz31_disconnect(void);
                    298: void   biz31_abort(void);
1.21      moritz    299: void   chdirectory(int);
                    300: void   cleanup(int);
                    301: void   consh(int);
1.23      moritz    302: void   cour_abort(void);
                    303: void   cour_disconnect(void);
1.21      moritz    304: void   cu_put(int);
                    305: void   cu_take(int);
1.20      moritz    306: void   cumain(int, char **);
1.12      millert   307: void   daemon_uid(void);
1.23      moritz    308: void   df_abort(void);
                    309: void   df_disconnect(void);
1.20      moritz    310: void   disconnect(char *);
1.23      moritz    311: void   dn_abort(void);
                    312: void   dn_disconnect(void);
1.21      moritz    313: void   finish(int);
                    314: void   genbrk(int);
                    315: void   getfl(int);
1.23      moritz    316: void   hay_abort(void);
                    317: void   hay_disconnect(void);
1.21      moritz    318: void   help(int);
                    319: void   listvariables(int);
1.20      moritz    320: void   logent(char *, char *, char *, char *);
1.12      millert   321: void   loginit(void);
1.24      deraadt   322: void   parwrite(int, char *, size_t);
1.21      moritz    323: void   pipefile(int);
                    324: void   pipeout(int);
1.12      millert   325: void   raw(void);
1.21      moritz    326: void   sendfile(int);
1.20      moritz    327: void   setparity(char *);
1.12      millert   328: void   setscript(void);
1.21      moritz    329: void   shell(int);
1.12      millert   330: void   shell_uid(void);
1.21      moritz    331: void   suspend(int);
1.23      moritz    332: void   t3000_disconnect(void);
                    333: void   t3000_abort(void);
1.21      moritz    334: void   timeout(int);
1.20      moritz    335: void   tipabort(char *);
1.12      millert   336: void   tipout(void);
1.21      moritz    337: void   user_uid(void);
1.12      millert   338: void   unraw(void);
1.23      moritz    339: void   v3451_abort(void);
                    340: void   v3451_disconnect(void);
                    341: void   v831_disconnect(void);
                    342: void   v831_abort(void);
1.21      moritz    343: void   variable(int);
1.23      moritz    344: void   ven_disconnect(void);
                    345: void   ven_abort(void);
1.12      millert   346: void   vinit(void);
1.20      moritz    347: void   vlex(char *);