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

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