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

Annotation of src/usr.bin/ftp/ftp_var.h, Revision 1.19

1.19    ! itojun      1: /*     $OpenBSD: ftp_var.h,v 1.18 1999/12/08 12:57:06 itojun Exp $     */
1.14      millert     2: /*     $NetBSD: ftp_var.h,v 1.18 1997/08/18 10:20:25 lukem Exp $       */
1.1       deraadt     3:
                      4: /*
1.18      itojun      5:  * Copyright (C) 1997 and 1998 WIDE Project.
                      6:  * All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. Neither the name of the project nor the names of its contributors
                     17:  *    may be used to endorse or promote products derived from this software
                     18:  *    without specific prior written permission.
                     19:  *
                     20:  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
                     21:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     22:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     23:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
                     24:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     25:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     26:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     27:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     28:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     29:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     30:  * SUCH DAMAGE.
                     31:  */
                     32:
                     33: /*
1.1       deraadt    34:  * Copyright (c) 1985, 1989, 1993, 1994
                     35:  *     The Regents of the University of California.  All rights reserved.
                     36:  *
                     37:  * Redistribution and use in source and binary forms, with or without
                     38:  * modification, are permitted provided that the following conditions
                     39:  * are met:
                     40:  * 1. Redistributions of source code must retain the above copyright
                     41:  *    notice, this list of conditions and the following disclaimer.
                     42:  * 2. Redistributions in binary form must reproduce the above copyright
                     43:  *    notice, this list of conditions and the following disclaimer in the
                     44:  *    documentation and/or other materials provided with the distribution.
                     45:  * 3. All advertising materials mentioning features or use of this software
                     46:  *    must display the following acknowledgement:
                     47:  *     This product includes software developed by the University of
                     48:  *     California, Berkeley and its contributors.
                     49:  * 4. Neither the name of the University nor the names of its contributors
                     50:  *    may be used to endorse or promote products derived from this software
                     51:  *    without specific prior written permission.
                     52:  *
                     53:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     54:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     55:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     56:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     57:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     58:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     59:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     60:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     61:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     62:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     63:  * SUCH DAMAGE.
                     64:  *
                     65:  *     @(#)ftp_var.h   8.4 (Berkeley) 10/9/94
                     66:  */
                     67:
                     68: /*
                     69:  * FTP global variables.
                     70:  */
                     71:
                     72: #include <sys/param.h>
                     73: #include <setjmp.h>
1.6       millert    74:
1.10      millert    75: #ifndef SMALL
1.6       millert    76: #include <histedit.h>
1.10      millert    77: #endif /* !SMALL */
1.15      millert    78:
                     79: #ifdef SOCKS
                     80: #include <socks.h>
1.16      imp        81: int fclose(FILE *);
1.15      millert    82: #endif
1.1       deraadt    83:
1.7       millert    84: #include "stringlist.h"
1.1       deraadt    85: #include "extern.h"
                     86:
1.6       millert    87: #define HASHBYTES      1024
                     88: #define FTPBUFLEN      MAXPATHLEN + 200
                     89:
                     90: #define STALLTIME      5       /* # of seconds of no xfer before "stalling" */
                     91:
1.14      millert    92: #define        FTP_PORT        21      /* default if ! getservbyname("ftp/tcp") */
                     93: #define        HTTP_PORT       80      /* default if ! getservbyname("http/tcp") */
                     94: #ifndef        GATE_PORT
                     95: #define        GATE_PORT       21      /* default if ! getservbyname("ftpgate/tcp") */
                     96: #endif
                     97: #ifndef        GATE_SERVER
                     98: #define        GATE_SERVER     ""      /* default server */
                     99: #endif
                    100:
1.9       millert   101: #define PAGER          "more"  /* default pager if $PAGER isn't set */
1.6       millert   102:
1.1       deraadt   103: /*
                    104:  * Options and other state info.
                    105:  */
                    106: int    trace;                  /* trace packets exchanged */
                    107: int    hash;                   /* print # for each buffer transferred */
1.5       kstailey  108: int    mark;                   /* number of bytes between hashes */
1.18      itojun    109: int    sendport;               /* use PORT/LPRT cmd for each data connection */
1.1       deraadt   110: int    verbose;                /* print messages coming back from server */
1.11      millert   111: int    connected;              /* 1 = connected to server, -1 = logged in */
1.1       deraadt   112: int    fromatty;               /* input is from a terminal */
                    113: int    interactive;            /* interactively prompt on m* cmds */
1.6       millert   114: int    confirmrest;            /* confirm rest of current m* cmd */
1.1       deraadt   115: int    debug;                  /* debugging level */
                    116: int    bell;                   /* ring bell on cmd completion */
                    117: int    doglob;                 /* glob local file names */
                    118: int    autologin;              /* establish user account on connection */
                    119: int    proxy;                  /* proxy server connection active */
                    120: int    proxflag;               /* proxy connection exists */
1.14      millert   121: int    gatemode;               /* use gate-ftp */
                    122: char   *gateserver;            /* server to use for gate-ftp */
1.1       deraadt   123: int    sunique;                /* store files on server with unique name */
                    124: int    runique;                /* store local files with unique name */
                    125: int    mcase;                  /* map upper to lower case for mget names */
                    126: int    ntflag;                 /* use ntin ntout tables for name translation */
                    127: int    mapflag;                /* use mapin mapout templates on file names */
1.6       millert   128: int    preserve;               /* preserve modification time on files */
                    129: int    progress;               /* display transfer progress bar */
1.1       deraadt   130: int    code;                   /* return/reply code for ftp command */
                    131: int    crflag;                 /* if 1, strip car. rets. on ascii gets */
1.18      itojun    132: char   pasv[BUFSIZ];           /* passive port for proxy data connection */
1.1       deraadt   133: int    passivemode;            /* passive mode enabled */
1.17      millert   134: int    activefallback;         /* fall back to active mode if passive fails */
1.14      millert   135: char   *altarg;                        /* argv[1] with no shell-like preprocessing  */
1.1       deraadt   136: char   ntin[17];               /* input translation table */
                    137: char   ntout[17];              /* output translation table */
                    138: char   mapin[MAXPATHLEN];      /* input map template */
                    139: char   mapout[MAXPATHLEN];     /* output map template */
                    140: char   typename[32];           /* name of file transfer type */
                    141: int    type;                   /* requested file transfer type */
                    142: int    curtype;                /* current file transfer type */
                    143: char   structname[32];         /* name of file transfer structure */
                    144: int    stru;                   /* file transfer structure */
                    145: char   formname[32];           /* name of file transfer format */
                    146: int    form;                   /* file transfer format */
                    147: char   modename[32];           /* name of file transfer mode */
                    148: int    mode;                   /* file transfer mode */
                    149: char   bytename[32];           /* local byte size in ascii */
                    150: int    bytesize;               /* local byte size in binary */
1.6       millert   151: int    anonftp;                /* automatic anonymous login */
                    152: int    dirchange;              /* remote directory changed by cd command */
1.13      millert   153: unsigned int retry_connect;    /* retry connect if failed */
1.6       millert   154: int    ttywidth;               /* width of tty */
1.19    ! itojun    155: int    epsv4;                  /* use EPSV/EPRT on IPv4 connections */
        !           156: int    epsv4bad;               /* EPSV doesn't work on the current server */
1.6       millert   157:
1.10      millert   158: #ifndef SMALL
1.6       millert   159: int      editing;              /* command line editing enabled */
                    160: EditLine *el;                  /* editline(3) status structure */
                    161: History  *hist;                        /* editline(3) history structure */
                    162: char    *cursor_pos;           /* cursor position we're looking for */
1.13      millert   163: size_t   cursor_argc;          /* location of cursor in margv */
                    164: size_t   cursor_argo;          /* offset of cursor in margv[cursor_argc] */
1.10      millert   165: #endif /* !SMALL */
1.6       millert   166:
                    167: off_t  bytes;                  /* current # of bytes read */
                    168: off_t  filesize;               /* size of file being transferred */
                    169: char   *direction;             /* direction transfer is occurring */
1.1       deraadt   170:
1.14      millert   171: char   *hostname;              /* name of host connected to */
1.1       deraadt   172: int    unix_server;            /* server is unix, can use binary for ascii */
                    173: int    unix_proxy;             /* proxy is unix, can use binary for ascii */
1.14      millert   174:
1.18      itojun    175: char *ftpport;                 /* port number to use for ftp connections */
                    176: char *httpport;                        /* port number to use for http connections */
                    177: char *gateport;                        /* port number to use for gateftp connections */
1.1       deraadt   178:
                    179: jmp_buf        toplevel;               /* non-local goto stuff for cmd scanner */
                    180:
1.6       millert   181: char   line[FTPBUFLEN];        /* input line buffer */
1.1       deraadt   182: char   *stringbase;            /* current scan point in line buffer */
1.6       millert   183: char   argbuf[FTPBUFLEN];      /* argument storage buffer */
1.1       deraadt   184: char   *argbase;               /* current storage point in arg buffer */
1.6       millert   185: StringList *marg_sl;           /* stringlist containing margv */
1.1       deraadt   186: int    margc;                  /* count of arguments on input line */
1.6       millert   187: #define margv (marg_sl->sl_str)        /* args parsed from input line */
1.1       deraadt   188: int     cpend;                  /* flag: if != 0, then pending server reply */
                    189: int    mflag;                  /* flag: if != 0, then active multi command */
                    190:
                    191: int    options;                /* used during socket creation */
                    192:
                    193: /*
                    194:  * Format of command table.
                    195:  */
                    196: struct cmd {
                    197:        char    *c_name;        /* name of command */
                    198:        char    *c_help;        /* help string */
1.6       millert   199:        char     c_bell;        /* give bell when command completes */
                    200:        char     c_conn;        /* must be connected to use command */
                    201:        char     c_proxy;       /* proxy server may execute */
1.10      millert   202: #ifndef SMALL
1.6       millert   203:        char    *c_complete;    /* context sensitive completion list */
1.10      millert   204: #endif /* !SMALL */
1.1       deraadt   205:        void    (*c_handler) __P((int, char **)); /* function to call */
                    206: };
                    207:
                    208: struct macel {
                    209:        char mac_name[9];       /* macro name */
                    210:        char *mac_start;        /* start of macro in macbuf */
                    211:        char *mac_end;          /* end of macro in macbuf */
                    212: };
                    213:
                    214: int macnum;                    /* number of defined macros */
                    215: struct macel macros[16];
                    216: char macbuf[4096];
1.12      deraadt   217:
                    218: FILE   *ttyout;                /* stdout or stderr, depending on interactive */