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

1.46    ! nicm        1: /*     $OpenBSD: tip.h,v 1.45 2010/06/29 23:38:05 nicm 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:  * String value table
                     61:  */
1.41      nicm       62: typedef        struct {
                     63:        char    *v_name;        /* variable name */
                     64:        int      v_flags;       /* type and flags */
                     65:        char    *v_abbrev;      /* possible abbreviation */
                     66:        char    *v_value;       /* casted to a union later */
                     67: }  value_t;
                     68:
1.42      nicm       69: #define V_STRING       01      /* string valued */
                     70: #define V_BOOL         02      /* true-false value */
                     71: #define V_NUMBER       04      /* numeric value */
                     72: #define V_CHAR         010     /* character value */
1.41      nicm       73: #define V_TYPEMASK     017
                     74:
1.42      nicm       75: #define V_CHANGED      020     /* to show modification */
                     76: #define V_READONLY     040     /* variable is not writable */
1.46    ! nicm       77: #define V_INIT         0100    /* static data space used for initialization */
1.1       deraadt    78:
                     79: /*
                     80:  * variable manipulation stuff --
                     81:  *   if we defined the value entry in value_t, then we couldn't
                     82:  *   initialize it in vars.c, so we cast it as needed to keep lint
                     83:  *   happy.
                     84:  */
                     85:
                     86: #define value(v)       vtable[v].v_value
1.22      deraadt    87: #define lvalue(v)      (long)vtable[v].v_value
1.1       deraadt    88:
1.5       millert    89: #define        number(v)       ((long)(v))
                     90: #define        boolean(v)      ((short)(long)(v))
                     91: #define        character(v)    ((char)(long)(v))
                     92: #define        address(v)      ((long *)(v))
                     93:
                     94: #define        setnumber(v,n)          do { (v) = (char *)(long)(n); } while (0)
                     95: #define        setboolean(v,n)         do { (v) = (char *)(long)(n); } while (0)
                     96: #define        setcharacter(v,n)       do { (v) = (char *)(long)(n); } while (0)
                     97: #define        setaddress(v,n)         do { (v) = (char *)(n); } while (0)
1.1       deraadt    98:
                     99: /*
                    100:  * Escape command table definitions --
                    101:  *   lookup in this table is performed when ``escapec'' is recognized
                    102:  *   at the begining of a line (as defined by the eolmarks variable).
                    103: */
                    104:
                    105: typedef
                    106:        struct {
1.19      deraadt   107:                char    e_char;                 /* char to match on */
                    108:                char    *e_help;                /* help string */
1.21      moritz    109:                void    (*e_func)(int);         /* command */
1.1       deraadt   110:        }
                    111:        esctable_t;
                    112:
                    113: extern int     vflag;          /* verbose during reading of .tiprc file */
1.9       todd      114: extern int     noesc;          /* no escape `~' char */
1.1       deraadt   115: extern value_t vtable[];       /* variable table */
                    116:
                    117: /*
                    118:  * Definition of indices into variable table so
                    119:  *  value(DEFINE) turns into a static address.
                    120:  */
1.35      nicm      121: enum {
                    122:        BEAUTIFY = 0,
                    123:        BAUDRATE,
1.45      nicm      124:        CONNECT,
                    125:        DEVICE,
1.35      nicm      126:        EOFREAD,
                    127:        EOFWRITE,
                    128:        EOL,
                    129:        ESCAPE,
                    130:        EXCEPTIONS,
                    131:        FORCE,
                    132:        FRAMESIZE,
                    133:        HOST,
                    134:        LOG,
                    135:        PROMPT,
                    136:        RAISE,
                    137:        RAISECHAR,
                    138:        RECORD,
                    139:        REMOTE,
                    140:        SCRIPT,
                    141:        TABEXPAND,
                    142:        VERBOSE,
                    143:        SHELL,
                    144:        HOME,
                    145:        ECHOCHECK,
                    146:        DISCONNECT,
                    147:        TAND,
                    148:        LDELAY,
                    149:        CDELAY,
                    150:        ETIMEOUT,
                    151:        RAWFTP,
                    152:        HALFDUPLEX,
                    153:        LECHO,
                    154:        PARITY,
                    155:        HARDWAREFLOW,
                    156:        LINEDISC,
                    157:        DC
                    158: };
1.1       deraadt   159:
1.2       deraadt   160: struct termios term;           /* current mode of terminal */
                    161: struct termios defterm;        /* initial mode of terminal */
                    162: struct termios defchars;       /* current mode with initial chars */
1.17      deraadt   163: int    gotdefterm;
1.1       deraadt   164:
                    165: FILE   *fscript;               /* FILE for scripting */
                    166:
                    167: int    FD;                     /* open file descriptor to remote host */
                    168: int    AC;                     /* open file descriptor to dialer (v831 only) */
                    169: int    vflag;                  /* print .tiprc initialization sequence */
1.9       todd      170: int    noesc;                  /* no `~' escape char */
1.1       deraadt   171: int    sfd;                    /* for ~< operation */
1.18      deraadt   172: pid_t  tipin_pid;              /* pid of tipin */
1.32      nicm      173: int    tipin_fd;               /* tipin side of socketpair */
1.18      deraadt   174: pid_t  tipout_pid;             /* pid of tipout */
1.32      nicm      175: int    tipout_fd;              /* tipout side of socketpair */
1.31      cloder    176: volatile sig_atomic_t stop;    /* stop transfer session flag */
                    177: volatile sig_atomic_t quit;    /* same; but on other end */
                    178: volatile sig_atomic_t stoprompt;/* for interrupting a prompt session */
                    179: volatile sig_atomic_t timedout;        /* ~> transfer timedout */
1.1       deraadt   180: int    cumode;                 /* simulating the "cu" program */
1.30      jmc       181: int    bits8;                  /* terminal is 8-bit mode */
1.2       deraadt   182: #define STRIP_PAR      (bits8 ? 0377 : 0177)
1.1       deraadt   183:
1.7       millert   184: char   fname[PATH_MAX];        /* file name buffer for ~< */
                    185: char   copyname[PATH_MAX];     /* file name buffer for ~> */
1.1       deraadt   186: char   ccc;                    /* synchronization character */
                    187: char   *uucplock;              /* name of lock file for uucp's */
                    188:
1.11      millert   189: int    odisc;                  /* initial tty line discipline */
                    190: extern int disc;               /* current tty discpline */
                    191:
                    192: extern char *__progname;       /* program name */
1.1       deraadt   193:
1.38      nicm      194: /* cmds.c */
1.21      moritz    195: char   *expand(char *);
1.38      nicm      196: void    chdirectory(int);
                    197: void    consh(int);
                    198: void    cu_put(int);
                    199: void    cu_take(int);
                    200: void    finish(int);
                    201: void    genbrk(int);
                    202: void    getfl(int);
                    203: void    listvariables(int);
                    204: void    parwrite(int, char *, size_t);
                    205: void    pipefile(int);
                    206: void    pipeout(int);
                    207: void    sendfile(int);
                    208: void    setscript(void);
                    209: void    shell(int);
                    210: void    suspend(int);
                    211: void    timeout(int);
                    212: void    tipabort(char *);
                    213: void    variable(int);
                    214:
                    215: /* cu.c */
                    216: void    cumain(int, char **);
                    217:
                    218: /* hunt.c */
                    219: long    hunt(char *);
                    220:
                    221: /* log.c */
                    222: void    logent(char *, char *, char *);
                    223: void    loginit(void);
                    224:
                    225: /* remote.c */
1.21      moritz    226: char   *getremote(char *);
1.38      nicm      227:
                    228: /* tip.c */
                    229: void    con(void);
                    230: char   *ctrl(char);
1.20      moritz    231: char   *interp(char *);
1.38      nicm      232: int     any(int, char *);
                    233: int     prompt(char *, char *, size_t);
                    234: size_t  size(char *);
                    235: void    cleanup(int);
                    236: void    help(int);
                    237: void    parwrite(int, char *, size_t);
                    238: void    raw(void);
                    239: void    setparity(char *);
                    240: int     ttysetup(int);
                    241: void    unraw(void);
                    242:
                    243: /* tipout.c */
                    244: void   tipout(void);
                    245:
                    246: /* value.c */
1.12      millert   247: void   vinit(void);
1.20      moritz    248: void   vlex(char *);
1.38      nicm      249: int    vstring(char *, char *);