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

1.40    ! nicm        1: /*     $OpenBSD: tip.h,v 1.39 2010/06/29 20:09:39 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:  * 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   *PN;                    /* phone number(s) */
                     68: char   *DI;                    /* disconnect string */
                     69: char   *PA;                    /* parity to be generated */
                     70:
                     71: char   *RM;                    /* remote file name */
                     72: char   *HO;                    /* host name */
                     73:
                     74: long   BR;                     /* line speed for conversation */
                     75: long   FS;                     /* frame size for transfers */
                     76:
                     77: char   *ES;                    /* escape character */
                     78: char   *EX;                    /* exceptions */
                     79: char   *FO;                    /* force (literal next) char*/
                     80: char   *RC;                    /* raise character */
                     81: char   *RE;                    /* script record file */
                     82: char   *PR;                    /* remote prompt */
                     83: long   DL;                     /* line delay for file transfers to remote */
                     84: long   CL;                     /* char delay for file transfers to remote */
                     85: long   ET;                     /* echocheck timeout */
1.26      deraadt    86: long   LD;                     /* line disc */
1.6       millert    87: short  HD;                     /* this host is half duplex - do local echo */
1.1       deraadt    88:
                     89: /*
                     90:  * String value table
                     91:  */
                     92: typedef
                     93:        struct {
                     94:                char    *v_name;        /* whose name is it */
                     95:                char    v_type;         /* for interpreting set's */
                     96:                char    v_access;       /* protection of touchy ones */
                     97:                char    *v_abrev;       /* possible abreviation */
                     98:                char    *v_value;       /* casted to a union later */
                     99:        }
                    100:        value_t;
                    101:
                    102: #define STRING 01              /* string valued */
                    103: #define BOOL   02              /* true-false value */
                    104: #define NUMBER 04              /* numeric value */
                    105: #define CHAR   010             /* character value */
                    106:
                    107: #define WRITE  01              /* write access to variable */
                    108: #define        READ    02              /* read access */
                    109:
1.40    ! nicm      110: #define CHANGED        01              /* used to show modification */
        !           111: #define READONLY 02            /* variable is not writable */
1.1       deraadt   112:
                    113: #define        TRUE    1
                    114: #define FALSE  0
                    115:
                    116: #define ENVIRON        020             /* initialize out of the environment */
                    117: #define IREMOTE        040             /* initialize out of remote structure */
                    118: #define INIT   0100            /* static data space used for initialization */
                    119: #define TMASK  017
                    120:
                    121: /*
                    122:  * variable manipulation stuff --
                    123:  *   if we defined the value entry in value_t, then we couldn't
                    124:  *   initialize it in vars.c, so we cast it as needed to keep lint
                    125:  *   happy.
                    126:  */
                    127:
                    128: #define value(v)       vtable[v].v_value
1.22      deraadt   129: #define lvalue(v)      (long)vtable[v].v_value
1.1       deraadt   130:
1.5       millert   131: #define        number(v)       ((long)(v))
                    132: #define        boolean(v)      ((short)(long)(v))
                    133: #define        character(v)    ((char)(long)(v))
                    134: #define        address(v)      ((long *)(v))
                    135:
                    136: #define        setnumber(v,n)          do { (v) = (char *)(long)(n); } while (0)
                    137: #define        setboolean(v,n)         do { (v) = (char *)(long)(n); } while (0)
                    138: #define        setcharacter(v,n)       do { (v) = (char *)(long)(n); } while (0)
                    139: #define        setaddress(v,n)         do { (v) = (char *)(n); } while (0)
1.1       deraadt   140:
                    141: /*
                    142:  * Escape command table definitions --
                    143:  *   lookup in this table is performed when ``escapec'' is recognized
                    144:  *   at the begining of a line (as defined by the eolmarks variable).
                    145: */
                    146:
                    147: typedef
                    148:        struct {
1.19      deraadt   149:                char    e_char;                 /* char to match on */
                    150:                char    *e_help;                /* help string */
1.21      moritz    151:                void    (*e_func)(int);         /* command */
1.1       deraadt   152:        }
                    153:        esctable_t;
                    154:
                    155: extern int     vflag;          /* verbose during reading of .tiprc file */
1.9       todd      156: extern int     noesc;          /* no escape `~' char */
1.1       deraadt   157: extern value_t vtable[];       /* variable table */
                    158:
                    159: /*
                    160:  * Definition of indices into variable table so
                    161:  *  value(DEFINE) turns into a static address.
                    162:  */
1.35      nicm      163: enum {
                    164:        BEAUTIFY = 0,
                    165:        BAUDRATE,
                    166:        EOFREAD,
                    167:        EOFWRITE,
                    168:        EOL,
                    169:        ESCAPE,
                    170:        EXCEPTIONS,
                    171:        FORCE,
                    172:        FRAMESIZE,
                    173:        HOST,
                    174:        LOG,
                    175:        PROMPT,
                    176:        RAISE,
                    177:        RAISECHAR,
                    178:        RECORD,
                    179:        REMOTE,
                    180:        SCRIPT,
                    181:        TABEXPAND,
                    182:        VERBOSE,
                    183:        SHELL,
                    184:        HOME,
                    185:        ECHOCHECK,
                    186:        DISCONNECT,
                    187:        TAND,
                    188:        LDELAY,
                    189:        CDELAY,
                    190:        ETIMEOUT,
                    191:        RAWFTP,
                    192:        HALFDUPLEX,
                    193:        LECHO,
                    194:        PARITY,
                    195:        HARDWAREFLOW,
                    196:        LINEDISC,
                    197:        DC
                    198: };
1.1       deraadt   199:
1.2       deraadt   200: struct termios term;           /* current mode of terminal */
                    201: struct termios defterm;        /* initial mode of terminal */
                    202: struct termios defchars;       /* current mode with initial chars */
1.17      deraadt   203: int    gotdefterm;
1.1       deraadt   204:
                    205: FILE   *fscript;               /* FILE for scripting */
                    206:
                    207: int    FD;                     /* open file descriptor to remote host */
                    208: int    AC;                     /* open file descriptor to dialer (v831 only) */
                    209: int    vflag;                  /* print .tiprc initialization sequence */
1.9       todd      210: int    noesc;                  /* no `~' escape char */
1.1       deraadt   211: int    sfd;                    /* for ~< operation */
1.18      deraadt   212: pid_t  tipin_pid;              /* pid of tipin */
1.32      nicm      213: int    tipin_fd;               /* tipin side of socketpair */
1.18      deraadt   214: pid_t  tipout_pid;             /* pid of tipout */
1.32      nicm      215: int    tipout_fd;              /* tipout side of socketpair */
1.31      cloder    216: volatile sig_atomic_t stop;    /* stop transfer session flag */
                    217: volatile sig_atomic_t quit;    /* same; but on other end */
                    218: volatile sig_atomic_t stoprompt;/* for interrupting a prompt session */
                    219: volatile sig_atomic_t timedout;        /* ~> transfer timedout */
1.1       deraadt   220: int    cumode;                 /* simulating the "cu" program */
1.30      jmc       221: int    bits8;                  /* terminal is 8-bit mode */
1.2       deraadt   222: #define STRIP_PAR      (bits8 ? 0377 : 0177)
1.1       deraadt   223:
1.7       millert   224: char   fname[PATH_MAX];        /* file name buffer for ~< */
                    225: char   copyname[PATH_MAX];     /* file name buffer for ~> */
1.1       deraadt   226: char   ccc;                    /* synchronization character */
                    227: char   *uucplock;              /* name of lock file for uucp's */
                    228:
1.11      millert   229: int    odisc;                  /* initial tty line discipline */
                    230: extern int disc;               /* current tty discpline */
                    231:
                    232: extern char *__progname;       /* program name */
1.1       deraadt   233:
1.38      nicm      234: /* cmds.c */
1.21      moritz    235: char   *expand(char *);
1.38      nicm      236: void    chdirectory(int);
                    237: void    consh(int);
                    238: void    cu_put(int);
                    239: void    cu_take(int);
                    240: void    finish(int);
                    241: void    genbrk(int);
                    242: void    getfl(int);
                    243: void    listvariables(int);
                    244: void    parwrite(int, char *, size_t);
                    245: void    pipefile(int);
                    246: void    pipeout(int);
                    247: void    sendfile(int);
                    248: void    setscript(void);
                    249: void    shell(int);
                    250: void    suspend(int);
                    251: void    timeout(int);
                    252: void    tipabort(char *);
                    253: void    variable(int);
                    254:
                    255: /* cu.c */
                    256: void    cumain(int, char **);
                    257:
                    258: /* hunt.c */
                    259: long    hunt(char *);
                    260:
                    261: /* log.c */
                    262: void    logent(char *, char *, char *);
                    263: void    loginit(void);
                    264:
                    265: /* remote.c */
1.21      moritz    266: char   *getremote(char *);
1.38      nicm      267:
                    268: /* tip.c */
                    269: void    con(void);
                    270: char   *ctrl(char);
1.20      moritz    271: char   *interp(char *);
1.38      nicm      272: int     any(int, char *);
                    273: int     prompt(char *, char *, size_t);
                    274: size_t  size(char *);
                    275: void    cleanup(int);
                    276: void    help(int);
                    277: void    parwrite(int, char *, size_t);
                    278: void    raw(void);
                    279: void    setparity(char *);
                    280: int     ttysetup(int);
                    281: void    unraw(void);
                    282:
                    283: /* tipout.c */
                    284: void   tipout(void);
                    285:
                    286: /* value.c */
1.12      millert   287: void   vinit(void);
1.20      moritz    288: void   vlex(char *);
1.38      nicm      289: int    vstring(char *, char *);