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