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