1353095Skevans/* $OpenBSD: ftp_var.h,v 1.46 2021/02/02 12:58:42 robert Exp $ */ 2353095Skevans/* $NetBSD: ftp_var.h,v 1.18 1997/08/18 10:20:25 lukem Exp $ */ 3353095Skevans 4353095Skevans/* 5353095Skevans * Copyright (C) 1997 and 1998 WIDE Project. 6353095Skevans * All rights reserved. 7353095Skevans * 8370509Sgit2svn * Redistribution and use in source and binary forms, with or without 9370509Sgit2svn * modification, are permitted provided that the following conditions 10353095Skevans * are met: 11353095Skevans * 1. Redistributions of source code must retain the above copyright 12353095Skevans * notice, this list of conditions and the following disclaimer. 13353095Skevans * 2. Redistributions in binary form must reproduce the above copyright 14353095Skevans * notice, this list of conditions and the following disclaimer in the 15353095Skevans * documentation and/or other materials provided with the distribution. 16353095Skevans * 3. Neither the name of the project nor the names of its contributors 17353095Skevans * may be used to endorse or promote products derived from this software 18353095Skevans * without specific prior written permission. 19353095Skevans * 20353095Skevans * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 21353095Skevans * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22353095Skevans * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23353095Skevans * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 24353095Skevans * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25353095Skevans * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26353095Skevans * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27353095Skevans * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28353095Skevans * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29353095Skevans * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30353095Skevans * SUCH DAMAGE. 31353095Skevans */ 32353095Skevans 33353095Skevans/* 34353095Skevans * Copyright (c) 1985, 1989, 1993, 1994 35353095Skevans * The Regents of the University of California. All rights reserved. 36353095Skevans * 37353095Skevans * Redistribution and use in source and binary forms, with or without 38353095Skevans * modification, are permitted provided that the following conditions 39353095Skevans * are met: 40353095Skevans * 1. Redistributions of source code must retain the above copyright 41353095Skevans * notice, this list of conditions and the following disclaimer. 42353095Skevans * 2. Redistributions in binary form must reproduce the above copyright 43353095Skevans * notice, this list of conditions and the following disclaimer in the 44353095Skevans * documentation and/or other materials provided with the distribution. 45353095Skevans * 3. Neither the name of the University nor the names of its contributors 46353095Skevans * may be used to endorse or promote products derived from this software 47353095Skevans * without specific prior written permission. 48353095Skevans * 49353095Skevans * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 50353095Skevans * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 51353095Skevans * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 52353095Skevans * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 53353095Skevans * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 54353095Skevans * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 55353095Skevans * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 56353095Skevans * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 57353095Skevans * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 58353095Skevans * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 59353095Skevans * SUCH DAMAGE. 60353095Skevans * 61353095Skevans * @(#)ftp_var.h 8.4 (Berkeley) 10/9/94 62353095Skevans */ 63353095Skevans 64353095Skevans/* 65353095Skevans * FTP global variables. 66353095Skevans */ 67353095Skevans 68353095Skevans#include <sys/signal.h> 69353095Skevans#include <limits.h> 70353095Skevans#include <setjmp.h> 71353095Skevans 72353095Skevans#ifndef SMALL 73353095Skevans#include <histedit.h> 74353095Skevans#endif /* !SMALL */ 75353095Skevans 76353095Skevans#include <tls.h> 77353095Skevans 78353095Skevans#include "stringlist.h" 79353095Skevans#include "extern.h" 80353095Skevans#include "small.h" 81353095Skevans 82353095Skevans#define HASHBYTES 1024 83353095Skevans#define FTPBUFLEN PATH_MAX + 200 84353095Skevans 85353095Skevans#define STALLTIME 5 /* # of seconds of no xfer before "stalling" */ 86353095Skevans 87353095Skevans#define FTP_PORT 21 /* default if ! getservbyname("ftp/tcp") */ 88353095Skevans#define GATE_PORT 21 /* default if ! getservbyname("ftpgate/tcp") */ 89353095Skevans#define HTTP_PORT 80 /* default if ! getservbyname("http/tcp") */ 90353095Skevans#define HTTPS_PORT 443 /* default if ! getservbyname("https/tcp") */ 91353095Skevans#define HTTP_USER_AGENT "User-Agent: OpenBSD ftp" /* User-Agent string sent to web server */ 92353095Skevans 93353095Skevans#define PAGER "more" /* default pager if $PAGER isn't set */ 94353095Skevans 95353095Skevans/* 96353095Skevans * Options and other state info. 97353095Skevans */ 98353095Skevansextern int trace; /* trace packets exchanged */ 99353095Skevansextern int hash; /* print # for each buffer transferred */ 100353095Skevansextern int mark; /* number of bytes between hashes */ 101353095Skevansextern int sendport; /* use PORT/LPRT cmd for each data connection */ 102353095Skevansextern int verbose; /* print messages coming back from server */ 103353095Skevansextern int connected; /* 1 = connected to server, -1 = logged in */ 104353095Skevansextern int fromatty; /* input is from a terminal */ 105353095Skevansextern int interactive; /* interactively prompt on m* cmds */ 106353095Skevans#ifndef SMALL 107353095Skevansextern int confirmrest; /* confirm rest of current m* cmd */ 108353095Skevansextern int debug; /* debugging level */ 109353095Skevansextern int bell; /* ring bell on cmd completion */ 110353095Skevansextern char *altarg; /* argv[1] with no shell-like preprocessing */ 111353095Skevans#endif /* !SMALL */ 112353095Skevansextern int doglob; /* glob local file names */ 113353095Skevansextern int autologin; /* establish user account on connection */ 114353095Skevansextern int proxy; /* proxy server connection active */ 115353095Skevansextern int proxflag; /* proxy connection exists */ 116353095Skevansextern int gatemode; /* use gate-ftp */ 117353095Skevansextern char *gateserver; /* server to use for gate-ftp */ 118353095Skevansextern int sunique; /* store files on server with unique name */ 119353095Skevansextern int runique; /* store local files with unique name */ 120353095Skevansextern int mcase; /* map upper to lower case for mget names */ 121353095Skevansextern int ntflag; /* use ntin ntout tables for name translation */ 122353095Skevansextern int mapflag; /* use mapin mapout templates on file names */ 123353095Skevansextern int preserve; /* preserve modification time on files */ 124353095Skevansextern int progress; /* display transfer progress bar */ 125353095Skevansextern int code; /* return/reply code for ftp command */ 126353095Skevansextern int crflag; /* if 1, strip car. rets. on ascii gets */ 127353095Skevansextern char pasv[BUFSIZ]; /* passive port for proxy data connection */ 128353095Skevansextern int passivemode; /* passive mode enabled */ 129353095Skevansextern int activefallback; /* fall back to active mode if passive fails */ 130353095Skevansextern char ntin[17]; /* input translation table */ 131353095Skevansextern char ntout[17]; /* output translation table */ 132353095Skevansextern char mapin[PATH_MAX]; /* input map template */ 133353095Skevansextern char mapout[PATH_MAX]; /* output map template */ 134353095Skevansextern char typename[32]; /* name of file transfer type */ 135353095Skevansextern int type; /* requested file transfer type */ 136353095Skevansextern int curtype; /* current file transfer type */ 137353095Skevansextern char structname[32]; /* name of file transfer structure */ 138353095Skevansextern int stru; /* file transfer structure */ 139353095Skevansextern char formname[32]; /* name of file transfer format */ 140353095Skevansextern int form; /* file transfer format */ 141353095Skevansextern char modename[32]; /* name of file transfer mode */ 142353095Skevansextern int mode; /* file transfer mode */ 143353095Skevansextern char bytename[32]; /* local byte size in ascii */ 144extern int bytesize; /* local byte size in binary */ 145extern int anonftp; /* automatic anonymous login */ 146extern int dirchange; /* remote directory changed by cd command */ 147extern unsigned int retry_connect; /* retry connect if failed */ 148extern int ttywidth; /* width of tty */ 149extern int epsv4; /* use EPSV/EPRT on IPv4 connections */ 150extern int epsv4bad; /* EPSV doesn't work on the current server */ 151 152#ifndef SMALL 153extern int editing; /* command line editing enabled */ 154extern EditLine *el; /* editline(3) status structure */ 155extern History *hist; /* editline(3) history structure */ 156extern char *cursor_pos; /* cursor position we're looking for */ 157extern size_t cursor_argc; /* location of cursor in margv */ 158extern size_t cursor_argo; /* offset of cursor in margv[cursor_argc] */ 159extern int resume; /* continue transfer */ 160extern int timestamp; /* send an If-Modified-Since header */ 161extern char *srcaddr; /* source address to bind to */ 162#endif /* !SMALL */ 163 164extern char *cookiefile; /* cookie jar to use */ 165 166extern off_t bytes; /* current # of bytes read */ 167extern off_t filesize; /* size of file being transferred */ 168extern char *direction; /* direction transfer is occurring */ 169 170extern char *hostname; /* name of host connected to */ 171extern int unix_server; /* server is unix, can use binary for ascii */ 172extern int unix_proxy; /* proxy is unix, can use binary for ascii */ 173 174extern char *ftpport; /* port number to use for ftp connections */ 175extern char *httpport; /* port number to use for http connections */ 176#ifndef NOSSL 177extern char *httpsport; /* port number to use for https connections */ 178#endif /* !SMALL */ 179extern char *httpuseragent; /* user agent for http(s) connections */ 180extern char *gateport; /* port number to use for gateftp connections */ 181 182extern jmp_buf toplevel; /* non-local goto stuff for cmd scanner */ 183 184#ifndef SMALL 185extern char line[FTPBUFLEN]; /* input line buffer */ 186extern char *argbase; /* current storage point in arg buffer */ 187extern char *stringbase; /* current scan point in line buffer */ 188extern char argbuf[FTPBUFLEN]; /* argument storage buffer */ 189extern StringList *marg_sl; /* stringlist containing margv */ 190extern int margc; /* count of arguments on input line */ 191extern int options; /* used during socket creation */ 192#endif /* !SMALL */ 193 194#define margv (marg_sl->sl_str) /* args parsed from input line */ 195extern int cpend; /* flag: if != 0, then pending server reply */ 196extern int mflag; /* flag: if != 0, then active multi command */ 197 198/* 199 * Format of command table. 200 */ 201struct cmd { 202 char *c_name; /* name of command */ 203 char *c_help; /* help string */ 204 char c_bell; /* give bell when command completes */ 205 char c_conn; /* must be connected to use command */ 206 char c_proxy; /* proxy server may execute */ 207#ifndef SMALL 208 char *c_complete; /* context sensitive completion list */ 209#endif /* !SMALL */ 210 void (*c_handler)(int, char **); /* function to call */ 211}; 212 213struct macel { 214 char mac_name[9]; /* macro name */ 215 char *mac_start; /* start of macro in macbuf */ 216 char *mac_end; /* end of macro in macbuf */ 217}; 218 219#ifndef SMALL 220extern int macnum; /* number of defined macros */ 221extern struct macel macros[16]; 222extern char macbuf[4096]; 223#endif /* !SMALL */ 224 225extern FILE *ttyout; /* stdout or stderr, depending on interactive */ 226 227extern struct cmd cmdtab[]; 228 229#ifndef NOSSL 230extern struct tls_config *tls_config; 231extern int tls_session_fd; 232#endif /* !NOSSL */ 233