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