Annotation of src/usr.bin/ftp/ftp_var.h, Revision 1.47
1.47 ! lukem 1: /* $NetBSD: ftp_var.h,v 1.46 1999/11/09 22:03:50 lukem Exp $ */
1.42 lukem 2:
3: /*-
4: * Copyright (c) 1996-1999 The NetBSD Foundation, Inc.
5: * All rights reserved.
6: *
7: * This code is derived from software contributed to The NetBSD Foundation
8: * by Luke Mewburn.
9: *
10: * Redistribution and use in source and binary forms, with or without
11: * modification, are permitted provided that the following conditions
12: * are met:
13: * 1. Redistributions of source code must retain the above copyright
14: * notice, this list of conditions and the following disclaimer.
15: * 2. Redistributions in binary form must reproduce the above copyright
16: * notice, this list of conditions and the following disclaimer in the
17: * documentation and/or other materials provided with the distribution.
18: * 3. All advertising materials mentioning features or use of this software
19: * must display the following acknowledgement:
20: * This product includes software developed by the NetBSD
21: * Foundation, Inc. and its contributors.
22: * 4. Neither the name of The NetBSD Foundation nor the names of its
23: * contributors may be used to endorse or promote products derived
24: * from this software without specific prior written permission.
25: *
26: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36: * POSSIBILITY OF SUCH DAMAGE.
37: */
1.34 itojun 38:
39: /*
1.37 lukem 40: * Copyright (c) 1985, 1989, 1993, 1994
41: * The Regents of the University of California. All rights reserved.
42: *
1.34 itojun 43: * Redistribution and use in source and binary forms, with or without
44: * modification, are permitted provided that the following conditions
45: * are met:
46: * 1. Redistributions of source code must retain the above copyright
47: * notice, this list of conditions and the following disclaimer.
48: * 2. Redistributions in binary form must reproduce the above copyright
49: * notice, this list of conditions and the following disclaimer in the
50: * documentation and/or other materials provided with the distribution.
1.37 lukem 51: * 3. All advertising materials mentioning features or use of this software
52: * must display the following acknowledgement:
53: * This product includes software developed by the University of
54: * California, Berkeley and its contributors.
55: * 4. Neither the name of the University nor the names of its contributors
1.34 itojun 56: * may be used to endorse or promote products derived from this software
57: * without specific prior written permission.
1.37 lukem 58: *
59: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1.34 itojun 60: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1.37 lukem 62: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1.34 itojun 63: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69: * SUCH DAMAGE.
1.37 lukem 70: *
71: * @(#)ftp_var.h 8.4 (Berkeley) 10/9/94
1.34 itojun 72: */
1.6 tls 73:
1.1 cgd 74: /*
1.37 lukem 75: * Copyright (C) 1997 and 1998 WIDE Project.
76: * All rights reserved.
77: *
1.1 cgd 78: * Redistribution and use in source and binary forms, with or without
79: * modification, are permitted provided that the following conditions
80: * are met:
81: * 1. Redistributions of source code must retain the above copyright
82: * notice, this list of conditions and the following disclaimer.
83: * 2. Redistributions in binary form must reproduce the above copyright
84: * notice, this list of conditions and the following disclaimer in the
85: * documentation and/or other materials provided with the distribution.
1.37 lukem 86: * 3. Neither the name of the project nor the names of its contributors
1.1 cgd 87: * may be used to endorse or promote products derived from this software
88: * without specific prior written permission.
1.37 lukem 89: *
90: * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
1.1 cgd 91: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
92: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1.37 lukem 93: * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
1.1 cgd 94: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
95: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
96: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
97: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
98: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
99: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
100: * SUCH DAMAGE.
101: */
102:
103: /*
104: * FTP global variables.
105: */
1.45 lukem 106:
1.46 lukem 107: #ifndef FTP_PRODUCT
108: #define FTP_PRODUCT "NetBSD-ftp"
109: #endif
1.45 lukem 110: #ifndef FTP_VERSION
1.47 ! lukem 111: #define FTP_VERSION "19991111"
1.45 lukem 112: #endif
1.1 cgd 113:
1.32 cgd 114: #ifdef SMALL
115: #undef NO_EDITCOMPLETE
116: #define NO_EDITCOMPLETE
117: #undef NO_PROGRESS
118: #define NO_PROGRESS
119: #endif
120:
1.3 cgd 121: #include <sys/param.h>
1.26 lukem 122:
123: #include <netinet/in.h>
124: #include <arpa/inet.h>
125:
1.3 cgd 126: #include <setjmp.h>
1.12 lukem 127: #include <stringlist.h>
128:
1.32 cgd 129: #ifndef NO_EDITCOMPLETE
1.12 lukem 130: #include <histedit.h>
1.32 cgd 131: #endif /* !NO_EDITCOMPLETE */
1.3 cgd 132:
133: #include "extern.h"
134:
1.38 lukem 135:
136: /*
137: * Format of command table.
138: */
139: struct cmd {
140: char *c_name; /* name of command */
141: char *c_help; /* help string */
142: char c_bell; /* give bell when command completes */
143: char c_conn; /* must be connected to use command */
144: char c_proxy; /* proxy server may execute */
145: #ifndef NO_EDITCOMPLETE
146: char *c_complete; /* context sensitive completion list */
147: #endif /* !NO_EDITCOMPLETE */
148: void (*c_handler) __P((int, char **)); /* function to call */
149: };
150:
151: /*
152: * Format of macro table
153: */
154: struct macel {
155: char mac_name[9]; /* macro name */
156: char *mac_start; /* start of macro in macbuf */
157: char *mac_end; /* end of macro in macbuf */
158: };
159:
1.44 lukem 160: /*
161: * Format of option table
162: */
163: struct option {
164: char *name;
165: char *value;
166: };
167:
1.38 lukem 168:
169: /*
170: * Global defines
171: */
1.41 lukem 172: #define FTPBUFLEN MAXPATHLEN + 200
173: #define MAX_IN_PORT_T 0xffffU
1.8 lukem 174:
1.41 lukem 175: #define HASHBYTES 1024 /* default mark for `hash' command */
1.33 lukem 176: #define DEFAULTINCR 1024 /* default increment for `rate' command */
1.41 lukem 177: #define STALLTIME 5 /* # of seconds of no xfer before "stalling" */
1.13 lukem 178:
1.18 lukem 179: #define FTP_PORT 21 /* default if ! getservbyname("ftp/tcp") */
180: #define HTTP_PORT 80 /* default if ! getservbyname("http/tcp") */
181: #ifndef GATE_PORT
182: #define GATE_PORT 21 /* default if ! getservbyname("ftpgate/tcp") */
183: #endif
184: #ifndef GATE_SERVER
185: #define GATE_SERVER "" /* default server */
186: #endif
1.14 lukem 187:
1.44 lukem 188: #define DEFAULTPAGER "more" /* default pager if $PAGER isn't set */
1.47 ! lukem 189: #define DEFAULTPROMPT "ftp> " /* default prompt if `set prompt' is empty */
1.8 lukem 190:
1.38 lukem 191: #define TMPFILE "ftpXXXXXXXXXX"
192:
193:
1.39 lukem 194: #ifndef GLOBAL
195: #define GLOBAL extern
196: #endif
197:
1.1 cgd 198: /*
199: * Options and other state info.
200: */
1.39 lukem 201: GLOBAL int trace; /* trace packets exchanged */
202: GLOBAL int hash; /* print # for each buffer transferred */
203: GLOBAL int mark; /* number of bytes between hashes */
204: GLOBAL int sendport; /* use PORT/LPRT cmd for each data connection */
205: GLOBAL int verbose; /* print messages coming back from server */
206: GLOBAL int connected; /* 1 = connected to server, -1 = logged in */
207: GLOBAL int fromatty; /* input is from a terminal */
208: GLOBAL int interactive; /* interactively prompt on m* cmds */
209: GLOBAL int confirmrest; /* confirm rest of current m* cmd */
210: GLOBAL int debug; /* debugging level */
211: GLOBAL int bell; /* ring bell on cmd completion */
212: GLOBAL int doglob; /* glob local file names */
213: GLOBAL int autologin; /* establish user account on connection */
214: GLOBAL int proxy; /* proxy server connection active */
215: GLOBAL int proxflag; /* proxy connection exists */
216: GLOBAL int gatemode; /* use gate-ftp */
217: GLOBAL char *gateserver; /* server to use for gate-ftp */
218: GLOBAL int sunique; /* store files on server with unique name */
219: GLOBAL int runique; /* store local files with unique name */
220: GLOBAL int mcase; /* map upper to lower case for mget names */
221: GLOBAL int ntflag; /* use ntin ntout tables for name translation */
222: GLOBAL int mapflag; /* use mapin mapout templates on file names */
223: GLOBAL int preserve; /* preserve modification time on files */
224: GLOBAL int progress; /* display transfer progress bar */
225: GLOBAL int code; /* return/reply code for ftp command */
226: GLOBAL int crflag; /* if 1, strip car. rets. on ascii gets */
227: GLOBAL int passivemode; /* passive mode enabled */
228: GLOBAL int activefallback; /* fall back to active mode if passive fails */
229: GLOBAL char *altarg; /* argv[1] with no shell-like preprocessing */
230: GLOBAL char ntin[17]; /* input translation table */
231: GLOBAL char ntout[17]; /* output translation table */
232: GLOBAL char mapin[MAXPATHLEN]; /* input map template */
233: GLOBAL char mapout[MAXPATHLEN]; /* output map template */
234: GLOBAL char typename[32]; /* name of file transfer type */
235: GLOBAL int type; /* requested file transfer type */
236: GLOBAL int curtype; /* current file transfer type */
237: GLOBAL char structname[32]; /* name of file transfer structure */
238: GLOBAL int stru; /* file transfer structure */
239: GLOBAL char formname[32]; /* name of file transfer format */
240: GLOBAL int form; /* file transfer format */
241: GLOBAL char modename[32]; /* name of file transfer mode */
242: GLOBAL int mode; /* file transfer mode */
243: GLOBAL char bytename[32]; /* local byte size in ascii */
244: GLOBAL int bytesize; /* local byte size in binary */
245: GLOBAL int anonftp; /* automatic anonymous login */
246: GLOBAL int dirchange; /* remote directory changed by cd command */
247: GLOBAL int flushcache; /* set HTTP cache flush headers with request */
248: GLOBAL int rate_get; /* maximum get xfer rate */
249: GLOBAL int rate_get_incr; /* increment for get xfer rate */
250: GLOBAL int rate_put; /* maximum put xfer rate */
251: GLOBAL int rate_put_incr; /* increment for put xfer rate */
252: GLOBAL int retry_connect; /* seconds between retrying connection */
253: GLOBAL int ttywidth; /* width of tty */
254: GLOBAL char *tmpdir; /* temporary directory */
255: GLOBAL FILE *ttyout; /* stdout, or stderr if retrieving to stdout */
256: GLOBAL int epsv4; /* use EPSV/EPRT on IPv4 connections */
1.40 lukem 257: GLOBAL int epsv4bad; /* EPSV doesn't work on the current server */
1.41 lukem 258: GLOBAL int editing; /* command line editing enabled */
1.12 lukem 259:
1.32 cgd 260: #ifndef NO_EDITCOMPLETE
1.39 lukem 261: GLOBAL EditLine *el; /* editline(3) status structure */
262: GLOBAL History *hist; /* editline(3) history structure */
263: GLOBAL char *cursor_pos; /* cursor position we're looking for */
264: GLOBAL size_t cursor_argc; /* location of cursor in margv */
265: GLOBAL size_t cursor_argo; /* offset of cursor in margv[cursor_argc] */
1.32 cgd 266: #endif /* !NO_EDITCOMPLETE */
1.12 lukem 267:
1.39 lukem 268: GLOBAL off_t bytes; /* current # of bytes read */
269: GLOBAL off_t filesize; /* size of file being transferred */
270: GLOBAL char *direction; /* direction transfer is occurring */
271: GLOBAL off_t restart_point; /* offset to restart transfer */
272:
273: GLOBAL char *hostname; /* name of host connected to */
274: GLOBAL int unix_server; /* server is unix, can use binary for ascii */
275: GLOBAL int unix_proxy; /* proxy is unix, can use binary for ascii */
1.47 ! lukem 276: GLOBAL char remotepwd[MAXPATHLEN]; /* remote dir */
! 277: GLOBAL char *username; /* name of user logged in as. (dynamic) */
1.39 lukem 278:
1.47 ! lukem 279: GLOBAL char *ftpport; /* port number to use for FTP connections */
1.39 lukem 280: GLOBAL char *httpport; /* port number to use for HTTP connections */
281: GLOBAL char *gateport; /* port number to use for gateftp connections */
282:
283: GLOBAL char *outfile; /* filename to output URLs to */
284: GLOBAL int restartautofetch; /* restart auto-fetch */
285:
1.43 lukem 286: GLOBAL sigjmp_buf toplevel; /* non-local goto stuff for cmd scanner */
1.39 lukem 287:
288: GLOBAL char line[FTPBUFLEN]; /* input line buffer */
289: GLOBAL char *stringbase; /* current scan point in line buffer */
290: GLOBAL char argbuf[FTPBUFLEN]; /* argument storage buffer */
291: GLOBAL char *argbase; /* current storage point in arg buffer */
292: GLOBAL StringList *marg_sl; /* stringlist containing margv */
293: GLOBAL int margc; /* count of arguments on input line */
1.41 lukem 294: #define margv (marg_sl->sl_str) /* args parsed from input line */
1.39 lukem 295: GLOBAL int cpend; /* flag: if != 0, then pending server reply */
296: GLOBAL int mflag; /* flag: if != 0, then active multi command */
297:
298: GLOBAL int options; /* used during socket creation */
299:
300: GLOBAL int sndbuf_size; /* socket send buffer size */
301: GLOBAL int rcvbuf_size; /* socket receive buffer size */
302:
303: GLOBAL int macnum; /* number of defined macros */
304: GLOBAL struct macel macros[16];
305: GLOBAL char macbuf[4096];
306:
307: GLOBAL char home[MAXPATHLEN]; /* home directory (for lcd) */
308: GLOBAL char reply_string[BUFSIZ]; /* first line of previous reply */
1.1 cgd 309:
1.47 ! lukem 310: GLOBAL FILE *cin;
! 311: GLOBAL FILE *cout;
1.39 lukem 312: GLOBAL int data;
1.25 thorpej 313:
1.44 lukem 314: extern struct cmd cmdtab[];
315: extern struct option optiontab[];
1.1 cgd 316:
1.39 lukem 317: extern char *__progname; /* from crt0.o */
1.44 lukem 318:
319:
320: #define EMPTYSTRING(x) ((x) == NULL || (*(x) == '\0'))
321: #define FREEPTR(x) if ((x) != NULL) { free(x); (x) = NULL; }
CVSweb <webmaster@jp.NetBSD.org>