Annotation of src/usr.bin/ftp/ftp_var.h, Revision 1.44
1.44 ! deraadt 1: /* $OpenBSD: ftp_var.h,v 1.43 2019/05/16 12:44:18 florian 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.
1.40 krw 7: *
1.18 itojun 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.
1.40 krw 19: *
1.18 itojun 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.
1.22 millert 45: * 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 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:
1.37 deraadt 68: #include <sys/signal.h>
69: #include <limits.h>
1.1 deraadt 70: #include <setjmp.h>
1.6 millert 71:
1.10 millert 72: #ifndef SMALL
1.6 millert 73: #include <histedit.h>
1.10 millert 74: #endif /* !SMALL */
1.15 millert 75:
1.36 jsing 76: #include <tls.h>
1.35 jsing 77:
1.7 millert 78: #include "stringlist.h"
1.1 deraadt 79: #include "extern.h"
1.29 martynas 80: #include "small.h"
1.1 deraadt 81:
1.6 millert 82: #define HASHBYTES 1024
1.37 deraadt 83: #define FTPBUFLEN PATH_MAX + 200
1.6 millert 84:
85: #define STALLTIME 5 /* # of seconds of no xfer before "stalling" */
86:
1.14 millert 87: #define FTP_PORT 21 /* default if ! getservbyname("ftp/tcp") */
1.38 tedu 88: #define GATE_PORT 21 /* default if ! getservbyname("ftpgate/tcp") */
1.14 millert 89: #define HTTP_PORT 80 /* default if ! getservbyname("http/tcp") */
1.23 deraadt 90: #define HTTPS_PORT 443 /* default if ! getservbyname("https/tcp") */
1.20 heko 91: #define HTTP_USER_AGENT "User-Agent: OpenBSD ftp" /* User-Agent string sent to web server */
1.14 millert 92:
1.9 millert 93: #define PAGER "more" /* default pager if $PAGER isn't set */
1.6 millert 94:
1.1 deraadt 95: /*
96: * Options and other state info.
97: */
98: int trace; /* trace packets exchanged */
99: int hash; /* print # for each buffer transferred */
1.5 kstailey 100: int mark; /* number of bytes between hashes */
1.18 itojun 101: int sendport; /* use PORT/LPRT cmd for each data connection */
1.1 deraadt 102: int verbose; /* print messages coming back from server */
1.11 millert 103: int connected; /* 1 = connected to server, -1 = logged in */
1.1 deraadt 104: int fromatty; /* input is from a terminal */
105: int interactive; /* interactively prompt on m* cmds */
1.31 deraadt 106: #ifndef SMALL
1.6 millert 107: int confirmrest; /* confirm rest of current m* cmd */
1.1 deraadt 108: int debug; /* debugging level */
1.31 deraadt 109: int bell; /* ring bell on cmd completion */
110: char *altarg; /* argv[1] with no shell-like preprocessing */
1.27 martynas 111: #endif /* !SMALL */
1.1 deraadt 112: int doglob; /* glob local file names */
113: int autologin; /* establish user account on connection */
114: int proxy; /* proxy server connection active */
115: int proxflag; /* proxy connection exists */
1.14 millert 116: int gatemode; /* use gate-ftp */
117: char *gateserver; /* server to use for gate-ftp */
1.1 deraadt 118: int sunique; /* store files on server with unique name */
119: int runique; /* store local files with unique name */
120: int mcase; /* map upper to lower case for mget names */
121: int ntflag; /* use ntin ntout tables for name translation */
122: int mapflag; /* use mapin mapout templates on file names */
1.6 millert 123: int preserve; /* preserve modification time on files */
124: int progress; /* display transfer progress bar */
1.1 deraadt 125: int code; /* return/reply code for ftp command */
126: int crflag; /* if 1, strip car. rets. on ascii gets */
1.18 itojun 127: char pasv[BUFSIZ]; /* passive port for proxy data connection */
1.1 deraadt 128: int passivemode; /* passive mode enabled */
1.17 millert 129: int activefallback; /* fall back to active mode if passive fails */
1.1 deraadt 130: char ntin[17]; /* input translation table */
131: char ntout[17]; /* output translation table */
1.37 deraadt 132: char mapin[PATH_MAX]; /* input map template */
133: char mapout[PATH_MAX]; /* output map template */
1.1 deraadt 134: char typename[32]; /* name of file transfer type */
135: int type; /* requested file transfer type */
136: int curtype; /* current file transfer type */
137: char structname[32]; /* name of file transfer structure */
138: int stru; /* file transfer structure */
139: char formname[32]; /* name of file transfer format */
140: int form; /* file transfer format */
141: char modename[32]; /* name of file transfer mode */
142: int mode; /* file transfer mode */
143: char bytename[32]; /* local byte size in ascii */
144: int bytesize; /* local byte size in binary */
1.6 millert 145: int anonftp; /* automatic anonymous login */
146: int dirchange; /* remote directory changed by cd command */
1.13 millert 147: unsigned int retry_connect; /* retry connect if failed */
1.6 millert 148: int ttywidth; /* width of tty */
1.19 itojun 149: int epsv4; /* use EPSV/EPRT on IPv4 connections */
150: int epsv4bad; /* EPSV doesn't work on the current server */
1.6 millert 151:
1.10 millert 152: #ifndef SMALL
1.6 millert 153: int editing; /* command line editing enabled */
154: EditLine *el; /* editline(3) status structure */
155: History *hist; /* editline(3) history structure */
156: char *cursor_pos; /* cursor position we're looking for */
1.13 millert 157: size_t cursor_argc; /* location of cursor in margv */
158: size_t cursor_argo; /* offset of cursor in margv[cursor_argc] */
1.25 martynas 159: int resume; /* continue transfer */
1.32 haesbaer 160: char *srcaddr; /* source address to bind to */
1.10 millert 161: #endif /* !SMALL */
1.6 millert 162:
1.39 deraadt 163: char *cookiefile; /* cookie jar to use */
164:
1.6 millert 165: off_t bytes; /* current # of bytes read */
166: off_t filesize; /* size of file being transferred */
167: char *direction; /* direction transfer is occurring */
1.1 deraadt 168:
1.14 millert 169: char *hostname; /* name of host connected to */
1.1 deraadt 170: int unix_server; /* server is unix, can use binary for ascii */
171: int unix_proxy; /* proxy is unix, can use binary for ascii */
1.14 millert 172:
1.18 itojun 173: char *ftpport; /* port number to use for ftp connections */
174: char *httpport; /* port number to use for http connections */
1.39 deraadt 175: #ifndef NOSSL
1.23 deraadt 176: char *httpsport; /* port number to use for https connections */
1.26 martynas 177: #endif /* !SMALL */
1.34 lteo 178: char *httpuseragent; /* user agent for http(s) connections */
1.18 itojun 179: char *gateport; /* port number to use for gateftp connections */
1.1 deraadt 180:
181: jmp_buf toplevel; /* non-local goto stuff for cmd scanner */
182:
1.31 deraadt 183: #ifndef SMALL
1.6 millert 184: char line[FTPBUFLEN]; /* input line buffer */
1.31 deraadt 185: char *argbase; /* current storage point in arg buffer */
1.1 deraadt 186: char *stringbase; /* current scan point in line buffer */
1.6 millert 187: char argbuf[FTPBUFLEN]; /* argument storage buffer */
188: StringList *marg_sl; /* stringlist containing margv */
1.31 deraadt 189: int margc; /* count of arguments on input line */
190: int options; /* used during socket creation */
1.29 martynas 191: #endif /* !SMALL */
1.31 deraadt 192:
1.6 millert 193: #define margv (marg_sl->sl_str) /* args parsed from input line */
1.44 ! deraadt 194: int cpend; /* flag: if != 0, then pending server reply */
1.1 deraadt 195: int mflag; /* flag: if != 0, then active multi command */
196:
197: /*
198: * Format of command table.
199: */
200: struct cmd {
201: char *c_name; /* name of command */
202: char *c_help; /* help string */
1.6 millert 203: char c_bell; /* give bell when command completes */
204: char c_conn; /* must be connected to use command */
205: char c_proxy; /* proxy server may execute */
1.10 millert 206: #ifndef SMALL
1.6 millert 207: char *c_complete; /* context sensitive completion list */
1.10 millert 208: #endif /* !SMALL */
1.21 millert 209: void (*c_handler)(int, char **); /* function to call */
1.1 deraadt 210: };
211:
212: struct macel {
213: char mac_name[9]; /* macro name */
214: char *mac_start; /* start of macro in macbuf */
215: char *mac_end; /* end of macro in macbuf */
216: };
217:
1.28 martynas 218: #ifndef SMALL
1.1 deraadt 219: int macnum; /* number of defined macros */
220: struct macel macros[16];
221: char macbuf[4096];
1.28 martynas 222: #endif /* !SMALL */
1.12 deraadt 223:
224: FILE *ttyout; /* stdout or stderr, depending on interactive */
1.30 jsg 225:
226: extern struct cmd cmdtab[];
1.33 jca 227:
1.39 deraadt 228: #ifndef NOSSL
1.36 jsing 229: extern struct tls_config *tls_config;
1.41 jsing 230: extern int tls_session_fd;
1.39 deraadt 231: #endif /* !NOSSL */