xref: /freebsd/contrib/tnftp/src/ftp_var.h (revision 43092b7d)
1cc361f65SGavin Atkinson /*	$NetBSD: ftp_var.h,v 1.10 2009/05/20 12:53:47 lukem Exp $	*/
2cc361f65SGavin Atkinson /*	from	NetBSD: ftp_var.h,v 1.81 2009/04/12 10:18:52 lukem Exp	*/
3f982db4aSGavin Atkinson 
4f982db4aSGavin Atkinson /*-
5cc361f65SGavin Atkinson  * Copyright (c) 1996-2009 The NetBSD Foundation, Inc.
6f982db4aSGavin Atkinson  * All rights reserved.
7f982db4aSGavin Atkinson  *
8f982db4aSGavin Atkinson  * This code is derived from software contributed to The NetBSD Foundation
9f982db4aSGavin Atkinson  * by Luke Mewburn.
10f982db4aSGavin Atkinson  *
11f982db4aSGavin Atkinson  * Redistribution and use in source and binary forms, with or without
12f982db4aSGavin Atkinson  * modification, are permitted provided that the following conditions
13f982db4aSGavin Atkinson  * are met:
14f982db4aSGavin Atkinson  * 1. Redistributions of source code must retain the above copyright
15f982db4aSGavin Atkinson  *    notice, this list of conditions and the following disclaimer.
16f982db4aSGavin Atkinson  * 2. Redistributions in binary form must reproduce the above copyright
17f982db4aSGavin Atkinson  *    notice, this list of conditions and the following disclaimer in the
18f982db4aSGavin Atkinson  *    documentation and/or other materials provided with the distribution.
19f982db4aSGavin Atkinson  *
20f982db4aSGavin Atkinson  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21f982db4aSGavin Atkinson  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22f982db4aSGavin Atkinson  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23f982db4aSGavin Atkinson  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24f982db4aSGavin Atkinson  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25f982db4aSGavin Atkinson  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26f982db4aSGavin Atkinson  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27f982db4aSGavin Atkinson  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28f982db4aSGavin Atkinson  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29f982db4aSGavin Atkinson  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30f982db4aSGavin Atkinson  * POSSIBILITY OF SUCH DAMAGE.
31f982db4aSGavin Atkinson  */
32f982db4aSGavin Atkinson 
33f982db4aSGavin Atkinson /*
34f982db4aSGavin Atkinson  * Copyright (c) 1985, 1989, 1993, 1994
35f982db4aSGavin Atkinson  *	The Regents of the University of California.  All rights reserved.
36f982db4aSGavin Atkinson  *
37f982db4aSGavin Atkinson  * Redistribution and use in source and binary forms, with or without
38f982db4aSGavin Atkinson  * modification, are permitted provided that the following conditions
39f982db4aSGavin Atkinson  * are met:
40f982db4aSGavin Atkinson  * 1. Redistributions of source code must retain the above copyright
41f982db4aSGavin Atkinson  *    notice, this list of conditions and the following disclaimer.
42f982db4aSGavin Atkinson  * 2. Redistributions in binary form must reproduce the above copyright
43f982db4aSGavin Atkinson  *    notice, this list of conditions and the following disclaimer in the
44f982db4aSGavin Atkinson  *    documentation and/or other materials provided with the distribution.
45f982db4aSGavin Atkinson  * 3. Neither the name of the University nor the names of its contributors
46f982db4aSGavin Atkinson  *    may be used to endorse or promote products derived from this software
47f982db4aSGavin Atkinson  *    without specific prior written permission.
48f982db4aSGavin Atkinson  *
49f982db4aSGavin Atkinson  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
50f982db4aSGavin Atkinson  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
51f982db4aSGavin Atkinson  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
52f982db4aSGavin Atkinson  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
53f982db4aSGavin Atkinson  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54f982db4aSGavin Atkinson  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55f982db4aSGavin Atkinson  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56f982db4aSGavin Atkinson  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57f982db4aSGavin Atkinson  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58f982db4aSGavin Atkinson  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59f982db4aSGavin Atkinson  * SUCH DAMAGE.
60f982db4aSGavin Atkinson  *
61f982db4aSGavin Atkinson  *	@(#)ftp_var.h	8.4 (Berkeley) 10/9/94
62f982db4aSGavin Atkinson  */
63f982db4aSGavin Atkinson 
64f982db4aSGavin Atkinson /*
65f982db4aSGavin Atkinson  * Copyright (C) 1997 and 1998 WIDE Project.
66f982db4aSGavin Atkinson  * All rights reserved.
67f982db4aSGavin Atkinson  *
68f982db4aSGavin Atkinson  * Redistribution and use in source and binary forms, with or without
69f982db4aSGavin Atkinson  * modification, are permitted provided that the following conditions
70f982db4aSGavin Atkinson  * are met:
71f982db4aSGavin Atkinson  * 1. Redistributions of source code must retain the above copyright
72f982db4aSGavin Atkinson  *    notice, this list of conditions and the following disclaimer.
73f982db4aSGavin Atkinson  * 2. Redistributions in binary form must reproduce the above copyright
74f982db4aSGavin Atkinson  *    notice, this list of conditions and the following disclaimer in the
75f982db4aSGavin Atkinson  *    documentation and/or other materials provided with the distribution.
76f982db4aSGavin Atkinson  * 3. Neither the name of the project nor the names of its contributors
77f982db4aSGavin Atkinson  *    may be used to endorse or promote products derived from this software
78f982db4aSGavin Atkinson  *    without specific prior written permission.
79f982db4aSGavin Atkinson  *
80f982db4aSGavin Atkinson  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
81f982db4aSGavin Atkinson  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
82f982db4aSGavin Atkinson  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
83f982db4aSGavin Atkinson  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
84f982db4aSGavin Atkinson  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
85f982db4aSGavin Atkinson  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
86f982db4aSGavin Atkinson  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
87f982db4aSGavin Atkinson  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
88f982db4aSGavin Atkinson  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
89f982db4aSGavin Atkinson  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
90f982db4aSGavin Atkinson  * SUCH DAMAGE.
91f982db4aSGavin Atkinson  */
92f982db4aSGavin Atkinson 
93f982db4aSGavin Atkinson /*
94f982db4aSGavin Atkinson  * FTP global variables.
95f982db4aSGavin Atkinson  */
96f982db4aSGavin Atkinson 
97f982db4aSGavin Atkinson #ifdef SMALL
98f982db4aSGavin Atkinson #undef	NO_EDITCOMPLETE
99f982db4aSGavin Atkinson #define	NO_EDITCOMPLETE
100f982db4aSGavin Atkinson #undef	NO_PROGRESS
101f982db4aSGavin Atkinson #define	NO_PROGRESS
102f982db4aSGavin Atkinson #endif
103f982db4aSGavin Atkinson 
104cc361f65SGavin Atkinson #if 0	/* tnftp */
105cc361f65SGavin Atkinson 
106f982db4aSGavin Atkinson #include <sys/param.h>
107f982db4aSGavin Atkinson 
108f982db4aSGavin Atkinson #include <netinet/in.h>
109f982db4aSGavin Atkinson #include <arpa/inet.h>
110f982db4aSGavin Atkinson 
111f982db4aSGavin Atkinson #include <poll.h>
112f982db4aSGavin Atkinson 
113f982db4aSGavin Atkinson #include <setjmp.h>
114f982db4aSGavin Atkinson #include <stringlist.h>
115f982db4aSGavin Atkinson 
116cc361f65SGavin Atkinson #endif	/* tnftp */
117cc361f65SGavin Atkinson 
118f982db4aSGavin Atkinson #ifndef NO_EDITCOMPLETE
119f982db4aSGavin Atkinson #include <histedit.h>
120f982db4aSGavin Atkinson #endif /* !NO_EDITCOMPLETE */
121f982db4aSGavin Atkinson 
122f982db4aSGavin Atkinson #include "extern.h"
123f982db4aSGavin Atkinson #include "progressbar.h"
124f982db4aSGavin Atkinson 
125f982db4aSGavin Atkinson /*
126f982db4aSGavin Atkinson  * Format of command table.
127f982db4aSGavin Atkinson  */
128f982db4aSGavin Atkinson struct cmd {
129cc361f65SGavin Atkinson 	const char	*c_name;	/* name of command */
130f982db4aSGavin Atkinson 	const char	*c_help;	/* help string */
131f982db4aSGavin Atkinson 	char		c_bell;		/* give bell when command completes */
132f982db4aSGavin Atkinson 	char		c_conn;		/* must be connected to use command */
133f982db4aSGavin Atkinson 	char		c_proxy;	/* proxy server may execute */
134f982db4aSGavin Atkinson #ifndef NO_EDITCOMPLETE
135f982db4aSGavin Atkinson 	const char	*c_complete;	/* context sensitive completion list */
136f982db4aSGavin Atkinson #endif /* !NO_EDITCOMPLETE */
137f982db4aSGavin Atkinson 	void		(*c_handler)(int, char **); /* function to call */
138f982db4aSGavin Atkinson };
139f982db4aSGavin Atkinson 
140cc361f65SGavin Atkinson #define MAX_C_NAME	12		/* maximum length of cmd.c_name */
141cc361f65SGavin Atkinson 
142f982db4aSGavin Atkinson /*
143f982db4aSGavin Atkinson  * Format of macro table
144f982db4aSGavin Atkinson  */
145f982db4aSGavin Atkinson struct macel {
146f982db4aSGavin Atkinson 	char	 mac_name[9];	/* macro name */
147f982db4aSGavin Atkinson 	char	*mac_start;	/* start of macro in macbuf */
148f982db4aSGavin Atkinson 	char	*mac_end;	/* end of macro in macbuf */
149f982db4aSGavin Atkinson };
150f982db4aSGavin Atkinson 
151f982db4aSGavin Atkinson /*
152f982db4aSGavin Atkinson  * Format of option table
153f982db4aSGavin Atkinson  */
154f982db4aSGavin Atkinson struct option {
155cc361f65SGavin Atkinson 	const char	*name;
156f982db4aSGavin Atkinson 	char		*value;
157f982db4aSGavin Atkinson };
158f982db4aSGavin Atkinson 
159f982db4aSGavin Atkinson /*
160f982db4aSGavin Atkinson  * Indices to features[]; an array containing status of remote server
161f982db4aSGavin Atkinson  * features; -1 not known (FEAT failed), 0 absent, 1 present.
162f982db4aSGavin Atkinson  */
163f982db4aSGavin Atkinson enum {
164f982db4aSGavin Atkinson 	FEAT_FEAT = 0,		/* FEAT, OPTS */
165f982db4aSGavin Atkinson 	FEAT_MDTM,		/* MDTM */
166f982db4aSGavin Atkinson 	FEAT_MLST,		/* MLSD, MLST */
167f982db4aSGavin Atkinson 	FEAT_REST_STREAM,	/* RESTart STREAM */
168f982db4aSGavin Atkinson 	FEAT_SIZE,		/* SIZE */
169f982db4aSGavin Atkinson 	FEAT_TVFS,		/* TVFS (not used) */
170f982db4aSGavin Atkinson 	FEAT_max
171f982db4aSGavin Atkinson };
172f982db4aSGavin Atkinson 
173f982db4aSGavin Atkinson 
174f982db4aSGavin Atkinson /*
175f982db4aSGavin Atkinson  * Global defines
176f982db4aSGavin Atkinson  */
177f982db4aSGavin Atkinson #define	FTPBUFLEN	MAXPATHLEN + 200
178f982db4aSGavin Atkinson #define	MAX_IN_PORT_T	0xffffU
179f982db4aSGavin Atkinson 
180f982db4aSGavin Atkinson #define	HASHBYTES	1024	/* default mark for `hash' command */
181f982db4aSGavin Atkinson #define	DEFAULTINCR	1024	/* default increment for `rate' command */
182f982db4aSGavin Atkinson 
183f982db4aSGavin Atkinson #define	FTP_PORT	21	/* default if ! getservbyname("ftp/tcp") */
184f982db4aSGavin Atkinson #define	HTTP_PORT	80	/* default if ! getservbyname("http/tcp") */
185f982db4aSGavin Atkinson #ifndef	GATE_PORT
186f982db4aSGavin Atkinson #define	GATE_PORT	21	/* default if ! getservbyname("ftpgate/tcp") */
187f982db4aSGavin Atkinson #endif
188f982db4aSGavin Atkinson #ifndef	GATE_SERVER
189f982db4aSGavin Atkinson #define	GATE_SERVER	""	/* default server */
190f982db4aSGavin Atkinson #endif
191f982db4aSGavin Atkinson 
19247cc9ee1SAlan Somers #define	DEFAULTPAGER	"less"	/* default pager if $PAGER isn't set */
193f982db4aSGavin Atkinson #define	DEFAULTPROMPT	"ftp> "	/* default prompt  if `set prompt' is empty */
194f982db4aSGavin Atkinson #define	DEFAULTRPROMPT	""	/* default rprompt if `set rprompt' is empty */
195f982db4aSGavin Atkinson 
196f982db4aSGavin Atkinson #define	TMPFILE		"ftpXXXXXXXXXX"
197f982db4aSGavin Atkinson 
198f982db4aSGavin Atkinson 
199f982db4aSGavin Atkinson #ifndef	GLOBAL
200f982db4aSGavin Atkinson #define	GLOBAL	extern
201f982db4aSGavin Atkinson #endif
202f982db4aSGavin Atkinson 
203f982db4aSGavin Atkinson /*
204f982db4aSGavin Atkinson  * Options and other state info.
205f982db4aSGavin Atkinson  */
206f982db4aSGavin Atkinson GLOBAL	int	trace;		/* trace packets exchanged */
207f982db4aSGavin Atkinson GLOBAL	int	hash;		/* print # for each buffer transferred */
208f982db4aSGavin Atkinson GLOBAL	int	mark;		/* number of bytes between hashes */
209f982db4aSGavin Atkinson GLOBAL	int	sendport;	/* use PORT/LPRT cmd for each data connection */
210f982db4aSGavin Atkinson GLOBAL	int	connected;	/* 1 = connected to server, -1 = logged in */
211f982db4aSGavin Atkinson GLOBAL	int	interactive;	/* interactively prompt on m* cmds */
212f982db4aSGavin Atkinson GLOBAL	int	confirmrest;	/* confirm rest of current m* cmd */
213cc361f65SGavin Atkinson GLOBAL	int	ftp_debug;	/* debugging level */
214f982db4aSGavin Atkinson GLOBAL	int	bell;		/* ring bell on cmd completion */
215f982db4aSGavin Atkinson GLOBAL	int	doglob;		/* glob local file names */
216f982db4aSGavin Atkinson GLOBAL	int	autologin;	/* establish user account on connection */
217f982db4aSGavin Atkinson GLOBAL	int	proxy;		/* proxy server connection active */
218f982db4aSGavin Atkinson GLOBAL	int	proxflag;	/* proxy connection exists */
219f982db4aSGavin Atkinson GLOBAL	int	gatemode;	/* use gate-ftp */
220cc361f65SGavin Atkinson GLOBAL	const char *gateserver;	/* server to use for gate-ftp */
221f982db4aSGavin Atkinson GLOBAL	int	sunique;	/* store files on server with unique name */
222f982db4aSGavin Atkinson GLOBAL	int	runique;	/* store local files with unique name */
223f982db4aSGavin Atkinson GLOBAL	int	mcase;		/* map upper to lower case for mget names */
224f982db4aSGavin Atkinson GLOBAL	int	ntflag;		/* use ntin ntout tables for name translation */
225f982db4aSGavin Atkinson GLOBAL	int	mapflag;	/* use mapin mapout templates on file names */
226f982db4aSGavin Atkinson GLOBAL	int	preserve;	/* preserve modification time on files */
227f982db4aSGavin Atkinson GLOBAL	int	code;		/* return/reply code for ftp command */
228f982db4aSGavin Atkinson GLOBAL	int	crflag;		/* if 1, strip car. rets. on ascii gets */
229f982db4aSGavin Atkinson GLOBAL	int	passivemode;	/* passive mode enabled */
230f982db4aSGavin Atkinson GLOBAL	int	activefallback;	/* fall back to active mode if passive fails */
231f982db4aSGavin Atkinson GLOBAL	char   *altarg;		/* argv[1] with no shell-like preprocessing  */
232f982db4aSGavin Atkinson GLOBAL	char	ntin[17];	/* input translation table */
233f982db4aSGavin Atkinson GLOBAL	char	ntout[17];	/* output translation table */
234f982db4aSGavin Atkinson GLOBAL	char	mapin[MAXPATHLEN]; /* input map template */
235f982db4aSGavin Atkinson GLOBAL	char	mapout[MAXPATHLEN]; /* output map template */
236f982db4aSGavin Atkinson GLOBAL	char	typename[32];	/* name of file transfer type */
237f982db4aSGavin Atkinson GLOBAL	int	type;		/* requested file transfer type */
238f982db4aSGavin Atkinson GLOBAL	int	curtype;	/* current file transfer type */
239f982db4aSGavin Atkinson GLOBAL	char	structname[32];	/* name of file transfer structure */
240f982db4aSGavin Atkinson GLOBAL	int	stru;		/* file transfer structure */
241f982db4aSGavin Atkinson GLOBAL	char	formname[32];	/* name of file transfer format */
242f982db4aSGavin Atkinson GLOBAL	int	form;		/* file transfer format */
243f982db4aSGavin Atkinson GLOBAL	char	modename[32];	/* name of file transfer mode */
244f982db4aSGavin Atkinson GLOBAL	int	mode;		/* file transfer mode */
245f982db4aSGavin Atkinson GLOBAL	char	bytename[32];	/* local byte size in ascii */
246f982db4aSGavin Atkinson GLOBAL	int	bytesize;	/* local byte size in binary */
247f982db4aSGavin Atkinson GLOBAL	int	anonftp;	/* automatic anonymous login */
248f982db4aSGavin Atkinson GLOBAL	int	dirchange;	/* remote directory changed by cd command */
249f982db4aSGavin Atkinson GLOBAL	int	flushcache;	/* set HTTP cache flush headers with request */
250f982db4aSGavin Atkinson GLOBAL	int	rate_get;	/* maximum get xfer rate */
251f982db4aSGavin Atkinson GLOBAL	int	rate_get_incr;	/* increment for get xfer rate */
252f982db4aSGavin Atkinson GLOBAL	int	rate_put;	/* maximum put xfer rate */
253f982db4aSGavin Atkinson GLOBAL	int	rate_put_incr;	/* increment for put xfer rate */
254f982db4aSGavin Atkinson GLOBAL	int	retry_connect;	/* seconds between retrying connection */
255cc361f65SGavin Atkinson GLOBAL	const char *tmpdir;	/* temporary directory */
256f982db4aSGavin Atkinson GLOBAL	int	epsv4;		/* use EPSV/EPRT on IPv4 connections */
257f982db4aSGavin Atkinson GLOBAL	int	epsv4bad;	/* EPSV doesn't work on the current server */
258cc361f65SGavin Atkinson GLOBAL	int	epsv6;		/* use EPSV/EPRT on IPv6 connections */
259cc361f65SGavin Atkinson GLOBAL	int	epsv6bad;	/* EPSV doesn't work on the current server */
260f982db4aSGavin Atkinson GLOBAL	int	editing;	/* command line editing enabled */
261f982db4aSGavin Atkinson GLOBAL	int	features[FEAT_max];	/* remote FEATures supported */
262f982db4aSGavin Atkinson 
263f982db4aSGavin Atkinson #ifndef NO_EDITCOMPLETE
264f982db4aSGavin Atkinson GLOBAL	EditLine *el;		/* editline(3) status structure */
265f982db4aSGavin Atkinson GLOBAL	History  *hist;		/* editline(3) history structure */
266f982db4aSGavin Atkinson GLOBAL	char	 *cursor_pos;	/* cursor position we're looking for */
267f982db4aSGavin Atkinson GLOBAL	size_t	  cursor_argc;	/* location of cursor in margv */
268f982db4aSGavin Atkinson GLOBAL	size_t	  cursor_argo;	/* offset of cursor in margv[cursor_argc] */
269f982db4aSGavin Atkinson #endif /* !NO_EDITCOMPLETE */
270f982db4aSGavin Atkinson 
271f982db4aSGavin Atkinson GLOBAL	char   *hostname;	/* name of host connected to */
272f982db4aSGavin Atkinson GLOBAL	int	unix_server;	/* server is unix, can use binary for ascii */
273f982db4aSGavin Atkinson GLOBAL	int	unix_proxy;	/* proxy is unix, can use binary for ascii */
274f982db4aSGavin Atkinson GLOBAL	char	localcwd[MAXPATHLEN];	/* local dir */
275f982db4aSGavin Atkinson GLOBAL	char	remotecwd[MAXPATHLEN];	/* remote dir */
276f982db4aSGavin Atkinson GLOBAL	char   *username;	/* name of user logged in as. (dynamic) */
277f982db4aSGavin Atkinson 
278f982db4aSGavin Atkinson GLOBAL	sa_family_t family;	/* address family to use for connections */
279cc361f65SGavin Atkinson GLOBAL	const char *ftpport;	/* port number to use for FTP connections */
280cc361f65SGavin Atkinson GLOBAL	const char *httpport;	/* port number to use for HTTP connections */
281cc361f65SGavin Atkinson GLOBAL	const char *gateport;	/* port number to use for gateftp connections */
282cc361f65SGavin Atkinson GLOBAL	struct addrinfo *bindai; /* local address to bind as */
283f982db4aSGavin Atkinson 
284f982db4aSGavin Atkinson GLOBAL	char   *outfile;	/* filename to output URLs to */
285f982db4aSGavin Atkinson GLOBAL	int	restartautofetch; /* restart auto-fetch */
286f982db4aSGavin Atkinson 
287f982db4aSGavin Atkinson GLOBAL	char	line[FTPBUFLEN]; /* input line buffer */
288f982db4aSGavin Atkinson GLOBAL	char	*stringbase;	/* current scan point in line buffer */
289f982db4aSGavin Atkinson GLOBAL	char	argbuf[FTPBUFLEN]; /* argument storage buffer */
290f982db4aSGavin Atkinson GLOBAL	char	*argbase;	/* current storage point in arg buffer */
291f982db4aSGavin Atkinson GLOBAL	StringList *marg_sl;	/* stringlist containing margv */
292f982db4aSGavin Atkinson GLOBAL	int	margc;		/* count of arguments on input line */
293f982db4aSGavin Atkinson #define	margv (marg_sl->sl_str)	/* args parsed from input line */
294f982db4aSGavin Atkinson GLOBAL	int     cpend;		/* flag: if != 0, then pending server reply */
295f982db4aSGavin Atkinson GLOBAL	int	mflag;		/* flag: if != 0, then active multi command */
296f982db4aSGavin Atkinson 
297f982db4aSGavin Atkinson GLOBAL	int	options;	/* used during socket creation */
298f982db4aSGavin Atkinson 
299f982db4aSGavin Atkinson GLOBAL	int	sndbuf_size;	/* socket send buffer size */
300f982db4aSGavin Atkinson GLOBAL	int	rcvbuf_size;	/* socket receive buffer size */
30143092b7dSHiroki Sato GLOBAL	int	auto_sndbuf;	/* flag: if != 0 then use auto sndbuf size */
30243092b7dSHiroki Sato GLOBAL	int	auto_rcvbuf;	/* flag: if != 0 then use auto rcvbuf size */
303f982db4aSGavin Atkinson 
304f982db4aSGavin Atkinson GLOBAL	int	macnum;		/* number of defined macros */
305f982db4aSGavin Atkinson GLOBAL	struct macel macros[16];
306f982db4aSGavin Atkinson GLOBAL	char	macbuf[4096];
307f982db4aSGavin Atkinson 
308f982db4aSGavin Atkinson GLOBAL	char	*localhome;		/* local home directory */
309f982db4aSGavin Atkinson GLOBAL	char	*localname;		/* local user name */
310f982db4aSGavin Atkinson GLOBAL	char	 netrc[MAXPATHLEN];	/* path to .netrc file */
311f982db4aSGavin Atkinson GLOBAL	char	 reply_string[BUFSIZ];	/* first line of previous reply */
312f982db4aSGavin Atkinson GLOBAL	void	(*reply_callback)(const char *);
313f982db4aSGavin Atkinson 					/*
314f982db4aSGavin Atkinson 					 * function to call for each line in
315f982db4aSGavin Atkinson 					 * the server's reply except for the
316f982db4aSGavin Atkinson 					 * first (`xxx-') and last (`xxx ')
317f982db4aSGavin Atkinson 					 */
318f982db4aSGavin Atkinson 
319f982db4aSGavin Atkinson GLOBAL	volatile sig_atomic_t	sigint_raised;
320f982db4aSGavin Atkinson 
321f982db4aSGavin Atkinson GLOBAL	FILE	*cin;
322f982db4aSGavin Atkinson GLOBAL	FILE	*cout;
323f982db4aSGavin Atkinson GLOBAL	int	 data;
324f982db4aSGavin Atkinson 
325f982db4aSGavin Atkinson extern	struct cmd	cmdtab[];
326f982db4aSGavin Atkinson extern	struct option	optiontab[];
327f982db4aSGavin Atkinson 
328f982db4aSGavin Atkinson 
329f982db4aSGavin Atkinson #define	EMPTYSTRING(x)	((x) == NULL || (*(x) == '\0'))
330f982db4aSGavin Atkinson #define	FREEPTR(x)	if ((x) != NULL) { free(x); (x) = NULL; }
331f982db4aSGavin Atkinson 
332f982db4aSGavin Atkinson #ifdef BSD4_4
333cc361f65SGavin Atkinson # define HAVE_STRUCT_SOCKADDR_IN_SIN_LEN	1
334f982db4aSGavin Atkinson #endif
335f982db4aSGavin Atkinson 
336f982db4aSGavin Atkinson #ifdef NO_LONG_LONG
337f982db4aSGavin Atkinson # define STRTOLL(x,y,z)	strtol(x,y,z)
338f982db4aSGavin Atkinson #else
339f982db4aSGavin Atkinson # define STRTOLL(x,y,z)	strtoll(x,y,z)
340f982db4aSGavin Atkinson #endif
341cc361f65SGavin Atkinson 
342cc361f65SGavin Atkinson #ifdef NO_DEBUG
343cc361f65SGavin Atkinson #define DPRINTF(...)
344cc361f65SGavin Atkinson #define DWARN(...)
345cc361f65SGavin Atkinson #else
346cc361f65SGavin Atkinson #define DPRINTF(...)	if (ftp_debug) (void)fprintf(ttyout, __VA_ARGS__)
347cc361f65SGavin Atkinson #define DWARN(...)	if (ftp_debug) warn(__VA_ARGS__)
348cc361f65SGavin Atkinson #endif
349cc361f65SGavin Atkinson 
350cc361f65SGavin Atkinson #define STRorNULL(s)	((s) ? (s) : "<null>")
351cc361f65SGavin Atkinson 
352cc361f65SGavin Atkinson #ifdef NO_USAGE
353cc361f65SGavin Atkinson void xusage(void);
354cc361f65SGavin Atkinson #define UPRINTF(...)	xusage()
355cc361f65SGavin Atkinson #else
356cc361f65SGavin Atkinson #define UPRINTF(...)	(void)fprintf(ttyout, __VA_ARGS__)
357cc361f65SGavin Atkinson #endif
358