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