1*0a6a1f1dSLionel Sambuc /* $NetBSD: ftp_var.h,v 1.83 2015/01/12 14:17:08 christos Exp $ */ 204203a83SThomas Cort 304203a83SThomas Cort /*- 404203a83SThomas Cort * Copyright (c) 1996-2009 The NetBSD Foundation, Inc. 504203a83SThomas Cort * All rights reserved. 604203a83SThomas Cort * 704203a83SThomas Cort * This code is derived from software contributed to The NetBSD Foundation 804203a83SThomas Cort * by Luke Mewburn. 904203a83SThomas Cort * 1004203a83SThomas Cort * Redistribution and use in source and binary forms, with or without 1104203a83SThomas Cort * modification, are permitted provided that the following conditions 1204203a83SThomas Cort * are met: 1304203a83SThomas Cort * 1. Redistributions of source code must retain the above copyright 1404203a83SThomas Cort * notice, this list of conditions and the following disclaimer. 1504203a83SThomas Cort * 2. Redistributions in binary form must reproduce the above copyright 1604203a83SThomas Cort * notice, this list of conditions and the following disclaimer in the 1704203a83SThomas Cort * documentation and/or other materials provided with the distribution. 1804203a83SThomas Cort * 1904203a83SThomas Cort * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2004203a83SThomas Cort * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2104203a83SThomas Cort * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2204203a83SThomas Cort * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2304203a83SThomas Cort * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2404203a83SThomas Cort * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2504203a83SThomas Cort * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2604203a83SThomas Cort * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2704203a83SThomas Cort * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2804203a83SThomas Cort * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2904203a83SThomas Cort * POSSIBILITY OF SUCH DAMAGE. 3004203a83SThomas Cort */ 3104203a83SThomas Cort 3204203a83SThomas Cort /* 3304203a83SThomas Cort * Copyright (c) 1985, 1989, 1993, 1994 3404203a83SThomas Cort * The Regents of the University of California. All rights reserved. 3504203a83SThomas Cort * 3604203a83SThomas Cort * Redistribution and use in source and binary forms, with or without 3704203a83SThomas Cort * modification, are permitted provided that the following conditions 3804203a83SThomas Cort * are met: 3904203a83SThomas Cort * 1. Redistributions of source code must retain the above copyright 4004203a83SThomas Cort * notice, this list of conditions and the following disclaimer. 4104203a83SThomas Cort * 2. Redistributions in binary form must reproduce the above copyright 4204203a83SThomas Cort * notice, this list of conditions and the following disclaimer in the 4304203a83SThomas Cort * documentation and/or other materials provided with the distribution. 4404203a83SThomas Cort * 3. Neither the name of the University nor the names of its contributors 4504203a83SThomas Cort * may be used to endorse or promote products derived from this software 4604203a83SThomas Cort * without specific prior written permission. 4704203a83SThomas Cort * 4804203a83SThomas Cort * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 4904203a83SThomas Cort * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 5004203a83SThomas Cort * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 5104203a83SThomas Cort * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 5204203a83SThomas Cort * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 5304203a83SThomas Cort * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 5404203a83SThomas Cort * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 5504203a83SThomas Cort * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 5604203a83SThomas Cort * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 5704203a83SThomas Cort * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 5804203a83SThomas Cort * SUCH DAMAGE. 5904203a83SThomas Cort * 6004203a83SThomas Cort * @(#)ftp_var.h 8.4 (Berkeley) 10/9/94 6104203a83SThomas Cort */ 6204203a83SThomas Cort 6304203a83SThomas Cort /* 6404203a83SThomas Cort * Copyright (C) 1997 and 1998 WIDE Project. 6504203a83SThomas Cort * All rights reserved. 6604203a83SThomas Cort * 6704203a83SThomas Cort * Redistribution and use in source and binary forms, with or without 6804203a83SThomas Cort * modification, are permitted provided that the following conditions 6904203a83SThomas Cort * are met: 7004203a83SThomas Cort * 1. Redistributions of source code must retain the above copyright 7104203a83SThomas Cort * notice, this list of conditions and the following disclaimer. 7204203a83SThomas Cort * 2. Redistributions in binary form must reproduce the above copyright 7304203a83SThomas Cort * notice, this list of conditions and the following disclaimer in the 7404203a83SThomas Cort * documentation and/or other materials provided with the distribution. 7504203a83SThomas Cort * 3. Neither the name of the project nor the names of its contributors 7604203a83SThomas Cort * may be used to endorse or promote products derived from this software 7704203a83SThomas Cort * without specific prior written permission. 7804203a83SThomas Cort * 7904203a83SThomas Cort * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 8004203a83SThomas Cort * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 8104203a83SThomas Cort * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 8204203a83SThomas Cort * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 8304203a83SThomas Cort * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 8404203a83SThomas Cort * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 8504203a83SThomas Cort * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 8604203a83SThomas Cort * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 8704203a83SThomas Cort * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 8804203a83SThomas Cort * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 8904203a83SThomas Cort * SUCH DAMAGE. 9004203a83SThomas Cort */ 9104203a83SThomas Cort 9204203a83SThomas Cort /* 9304203a83SThomas Cort * FTP global variables. 9404203a83SThomas Cort */ 9504203a83SThomas Cort 9604203a83SThomas Cort #ifdef SMALL 9704203a83SThomas Cort #undef NO_EDITCOMPLETE 9804203a83SThomas Cort #define NO_EDITCOMPLETE 9904203a83SThomas Cort #undef NO_PROGRESS 10004203a83SThomas Cort #define NO_PROGRESS 10104203a83SThomas Cort #endif 10204203a83SThomas Cort 10304203a83SThomas Cort #include <sys/param.h> 10404203a83SThomas Cort 10504203a83SThomas Cort #include <netinet/in.h> 10604203a83SThomas Cort #include <arpa/inet.h> 10704203a83SThomas Cort 10804203a83SThomas Cort #include <poll.h> 10904203a83SThomas Cort 11004203a83SThomas Cort #include <setjmp.h> 11104203a83SThomas Cort #include <stringlist.h> 11204203a83SThomas Cort 11304203a83SThomas Cort #ifndef NO_EDITCOMPLETE 11404203a83SThomas Cort #include <histedit.h> 11504203a83SThomas Cort #endif /* !NO_EDITCOMPLETE */ 11604203a83SThomas Cort 11704203a83SThomas Cort #include "extern.h" 11804203a83SThomas Cort #include "progressbar.h" 11904203a83SThomas Cort 12004203a83SThomas Cort /* 12104203a83SThomas Cort * Format of command table. 12204203a83SThomas Cort */ 12304203a83SThomas Cort struct cmd { 12404203a83SThomas Cort const char *c_name; /* name of command */ 12504203a83SThomas Cort const char *c_help; /* help string */ 12604203a83SThomas Cort char c_bell; /* give bell when command completes */ 12704203a83SThomas Cort char c_conn; /* must be connected to use command */ 12804203a83SThomas Cort char c_proxy; /* proxy server may execute */ 12904203a83SThomas Cort #ifndef NO_EDITCOMPLETE 13004203a83SThomas Cort const char *c_complete; /* context sensitive completion list */ 13104203a83SThomas Cort #endif /* !NO_EDITCOMPLETE */ 13204203a83SThomas Cort void (*c_handler)(int, char **); /* function to call */ 13304203a83SThomas Cort }; 13404203a83SThomas Cort 13504203a83SThomas Cort #define MAX_C_NAME 12 /* maximum length of cmd.c_name */ 13604203a83SThomas Cort 13704203a83SThomas Cort /* 13804203a83SThomas Cort * Format of macro table 13904203a83SThomas Cort */ 14004203a83SThomas Cort struct macel { 14104203a83SThomas Cort char mac_name[9]; /* macro name */ 14204203a83SThomas Cort char *mac_start; /* start of macro in macbuf */ 14304203a83SThomas Cort char *mac_end; /* end of macro in macbuf */ 14404203a83SThomas Cort }; 14504203a83SThomas Cort 14604203a83SThomas Cort /* 14704203a83SThomas Cort * Format of option table 14804203a83SThomas Cort */ 14904203a83SThomas Cort struct option { 15004203a83SThomas Cort const char *name; 15104203a83SThomas Cort char *value; 15204203a83SThomas Cort }; 15304203a83SThomas Cort 15404203a83SThomas Cort /* 15504203a83SThomas Cort * Indices to features[]; an array containing status of remote server 15604203a83SThomas Cort * features; -1 not known (FEAT failed), 0 absent, 1 present. 15704203a83SThomas Cort */ 15804203a83SThomas Cort enum { 15904203a83SThomas Cort FEAT_FEAT = 0, /* FEAT, OPTS */ 16004203a83SThomas Cort FEAT_MDTM, /* MDTM */ 16104203a83SThomas Cort FEAT_MLST, /* MLSD, MLST */ 16204203a83SThomas Cort FEAT_REST_STREAM, /* RESTart STREAM */ 16304203a83SThomas Cort FEAT_SIZE, /* SIZE */ 16404203a83SThomas Cort FEAT_TVFS, /* TVFS (not used) */ 16504203a83SThomas Cort FEAT_max 16604203a83SThomas Cort }; 16704203a83SThomas Cort 16804203a83SThomas Cort 16904203a83SThomas Cort /* 17004203a83SThomas Cort * Global defines 17104203a83SThomas Cort */ 172*0a6a1f1dSLionel Sambuc #define FTPBUFLEN (4 * MAXPATHLEN) 17304203a83SThomas Cort #define MAX_IN_PORT_T 0xffffU 17404203a83SThomas Cort 17504203a83SThomas Cort #define HASHBYTES 1024 /* default mark for `hash' command */ 17604203a83SThomas Cort #define DEFAULTINCR 1024 /* default increment for `rate' command */ 17704203a83SThomas Cort 17804203a83SThomas Cort #define FTP_PORT 21 /* default if ! getservbyname("ftp/tcp") */ 17904203a83SThomas Cort #define HTTP_PORT 80 /* default if ! getservbyname("http/tcp") */ 18004203a83SThomas Cort #define HTTPS_PORT 443 /* default if ! getservbyname("https/tcp") */ 18104203a83SThomas Cort #ifndef GATE_PORT 18204203a83SThomas Cort #define GATE_PORT 21 /* default if ! getservbyname("ftpgate/tcp") */ 18304203a83SThomas Cort #endif 18404203a83SThomas Cort #ifndef GATE_SERVER 18504203a83SThomas Cort #define GATE_SERVER "" /* default server */ 18604203a83SThomas Cort #endif 18704203a83SThomas Cort 18804203a83SThomas Cort #define DEFAULTPAGER "more" /* default pager if $PAGER isn't set */ 18904203a83SThomas Cort #define DEFAULTPROMPT "ftp> " /* default prompt if `set prompt' is empty */ 19004203a83SThomas Cort #define DEFAULTRPROMPT "" /* default rprompt if `set rprompt' is empty */ 19104203a83SThomas Cort 19204203a83SThomas Cort #define TMPFILE "ftpXXXXXXXXXX" 19304203a83SThomas Cort 19404203a83SThomas Cort 19504203a83SThomas Cort #ifndef GLOBAL 19604203a83SThomas Cort #define GLOBAL extern 19704203a83SThomas Cort #endif 19804203a83SThomas Cort 19904203a83SThomas Cort /* 20004203a83SThomas Cort * Options and other state info. 20104203a83SThomas Cort */ 20204203a83SThomas Cort GLOBAL int trace; /* trace packets exchanged */ 20304203a83SThomas Cort GLOBAL int hash; /* print # for each buffer transferred */ 20404203a83SThomas Cort GLOBAL int mark; /* number of bytes between hashes */ 20504203a83SThomas Cort GLOBAL int sendport; /* use PORT/LPRT cmd for each data connection */ 20604203a83SThomas Cort GLOBAL int connected; /* 1 = connected to server, -1 = logged in */ 20704203a83SThomas Cort GLOBAL int interactive; /* interactively prompt on m* cmds */ 20804203a83SThomas Cort GLOBAL int confirmrest; /* confirm rest of current m* cmd */ 20904203a83SThomas Cort GLOBAL int ftp_debug; /* debugging level */ 21004203a83SThomas Cort GLOBAL int bell; /* ring bell on cmd completion */ 21104203a83SThomas Cort GLOBAL int doglob; /* glob local file names */ 21204203a83SThomas Cort GLOBAL int autologin; /* establish user account on connection */ 21304203a83SThomas Cort GLOBAL int proxy; /* proxy server connection active */ 21404203a83SThomas Cort GLOBAL int proxflag; /* proxy connection exists */ 21504203a83SThomas Cort GLOBAL int gatemode; /* use gate-ftp */ 21604203a83SThomas Cort GLOBAL const char *gateserver; /* server to use for gate-ftp */ 21704203a83SThomas Cort GLOBAL int sunique; /* store files on server with unique name */ 21804203a83SThomas Cort GLOBAL int runique; /* store local files with unique name */ 21904203a83SThomas Cort GLOBAL int mcase; /* map upper to lower case for mget names */ 22004203a83SThomas Cort GLOBAL int ntflag; /* use ntin ntout tables for name translation */ 22104203a83SThomas Cort GLOBAL int mapflag; /* use mapin mapout templates on file names */ 22204203a83SThomas Cort GLOBAL int preserve; /* preserve modification time on files */ 22304203a83SThomas Cort GLOBAL int code; /* return/reply code for ftp command */ 22404203a83SThomas Cort GLOBAL int crflag; /* if 1, strip car. rets. on ascii gets */ 22504203a83SThomas Cort GLOBAL int passivemode; /* passive mode enabled */ 22604203a83SThomas Cort GLOBAL int activefallback; /* fall back to active mode if passive fails */ 22704203a83SThomas Cort GLOBAL char *altarg; /* argv[1] with no shell-like preprocessing */ 22804203a83SThomas Cort GLOBAL char ntin[17]; /* input translation table */ 22904203a83SThomas Cort GLOBAL char ntout[17]; /* output translation table */ 23004203a83SThomas Cort GLOBAL char mapin[MAXPATHLEN]; /* input map template */ 23104203a83SThomas Cort GLOBAL char mapout[MAXPATHLEN]; /* output map template */ 23204203a83SThomas Cort GLOBAL char typename[32]; /* name of file transfer type */ 23304203a83SThomas Cort GLOBAL int type; /* requested file transfer type */ 23404203a83SThomas Cort GLOBAL int curtype; /* current file transfer type */ 23504203a83SThomas Cort GLOBAL char structname[32]; /* name of file transfer structure */ 23604203a83SThomas Cort GLOBAL int stru; /* file transfer structure */ 23704203a83SThomas Cort GLOBAL char formname[32]; /* name of file transfer format */ 23804203a83SThomas Cort GLOBAL int form; /* file transfer format */ 23904203a83SThomas Cort GLOBAL char modename[32]; /* name of file transfer mode */ 24004203a83SThomas Cort GLOBAL int mode; /* file transfer mode */ 24104203a83SThomas Cort GLOBAL char bytename[32]; /* local byte size in ascii */ 24204203a83SThomas Cort GLOBAL int bytesize; /* local byte size in binary */ 24304203a83SThomas Cort GLOBAL int anonftp; /* automatic anonymous login */ 24404203a83SThomas Cort GLOBAL int dirchange; /* remote directory changed by cd command */ 24504203a83SThomas Cort GLOBAL int flushcache; /* set HTTP cache flush headers with request */ 24604203a83SThomas Cort GLOBAL int rate_get; /* maximum get xfer rate */ 24704203a83SThomas Cort GLOBAL int rate_get_incr; /* increment for get xfer rate */ 24804203a83SThomas Cort GLOBAL int rate_put; /* maximum put xfer rate */ 24904203a83SThomas Cort GLOBAL int rate_put_incr; /* increment for put xfer rate */ 25004203a83SThomas Cort GLOBAL int retry_connect; /* seconds between retrying connection */ 25104203a83SThomas Cort GLOBAL const char *tmpdir; /* temporary directory */ 25204203a83SThomas Cort GLOBAL int epsv4; /* use EPSV/EPRT on IPv4 connections */ 25304203a83SThomas Cort GLOBAL int epsv4bad; /* EPSV doesn't work on the current server */ 25404203a83SThomas Cort GLOBAL int epsv6; /* use EPSV/EPRT on IPv6 connections */ 25504203a83SThomas Cort GLOBAL int epsv6bad; /* EPSV doesn't work on the current server */ 25604203a83SThomas Cort GLOBAL int editing; /* command line editing enabled */ 25704203a83SThomas Cort GLOBAL int features[FEAT_max]; /* remote FEATures supported */ 25804203a83SThomas Cort 25904203a83SThomas Cort #ifndef NO_EDITCOMPLETE 26004203a83SThomas Cort GLOBAL EditLine *el; /* editline(3) status structure */ 26104203a83SThomas Cort GLOBAL History *hist; /* editline(3) history structure */ 26204203a83SThomas Cort GLOBAL char *cursor_pos; /* cursor position we're looking for */ 26304203a83SThomas Cort GLOBAL size_t cursor_argc; /* location of cursor in margv */ 26404203a83SThomas Cort GLOBAL size_t cursor_argo; /* offset of cursor in margv[cursor_argc] */ 26504203a83SThomas Cort #endif /* !NO_EDITCOMPLETE */ 26604203a83SThomas Cort 26704203a83SThomas Cort GLOBAL char *hostname; /* name of host connected to */ 26804203a83SThomas Cort GLOBAL int unix_server; /* server is unix, can use binary for ascii */ 26904203a83SThomas Cort GLOBAL int unix_proxy; /* proxy is unix, can use binary for ascii */ 27004203a83SThomas Cort GLOBAL char localcwd[MAXPATHLEN]; /* local dir */ 27104203a83SThomas Cort GLOBAL char remotecwd[MAXPATHLEN]; /* remote dir */ 27204203a83SThomas Cort GLOBAL char *username; /* name of user logged in as. (dynamic) */ 27304203a83SThomas Cort 27404203a83SThomas Cort GLOBAL sa_family_t family; /* address family to use for connections */ 27504203a83SThomas Cort GLOBAL const char *ftpport; /* port number to use for FTP connections */ 27604203a83SThomas Cort GLOBAL const char *httpport; /* port number to use for HTTP connections */ 27704203a83SThomas Cort #ifdef WITH_SSL 27804203a83SThomas Cort GLOBAL const char *httpsport; /* port number to use for HTTPS connections */ 27904203a83SThomas Cort #endif 28004203a83SThomas Cort GLOBAL const char *gateport; /* port number to use for gateftp connections */ 28104203a83SThomas Cort GLOBAL struct addrinfo *bindai; /* local address to bind as */ 28204203a83SThomas Cort 28304203a83SThomas Cort GLOBAL char *outfile; /* filename to output URLs to */ 28404203a83SThomas Cort GLOBAL int restartautofetch; /* restart auto-fetch */ 28504203a83SThomas Cort 28604203a83SThomas Cort GLOBAL char line[FTPBUFLEN]; /* input line buffer */ 28704203a83SThomas Cort GLOBAL char *stringbase; /* current scan point in line buffer */ 28804203a83SThomas Cort GLOBAL char argbuf[FTPBUFLEN]; /* argument storage buffer */ 28904203a83SThomas Cort GLOBAL char *argbase; /* current storage point in arg buffer */ 29004203a83SThomas Cort GLOBAL StringList *marg_sl; /* stringlist containing margv */ 29104203a83SThomas Cort GLOBAL int margc; /* count of arguments on input line */ 29204203a83SThomas Cort #define margv (marg_sl->sl_str) /* args parsed from input line */ 29304203a83SThomas Cort GLOBAL int cpend; /* flag: if != 0, then pending server reply */ 29404203a83SThomas Cort GLOBAL int mflag; /* flag: if != 0, then active multi command */ 29504203a83SThomas Cort 29604203a83SThomas Cort GLOBAL int options; /* used during socket creation */ 29704203a83SThomas Cort 29804203a83SThomas Cort GLOBAL int sndbuf_size; /* socket send buffer size */ 29904203a83SThomas Cort GLOBAL int rcvbuf_size; /* socket receive buffer size */ 30004203a83SThomas Cort 30104203a83SThomas Cort GLOBAL int macnum; /* number of defined macros */ 30204203a83SThomas Cort GLOBAL struct macel macros[16]; 30304203a83SThomas Cort GLOBAL char macbuf[4096]; 30404203a83SThomas Cort 30504203a83SThomas Cort GLOBAL char *localhome; /* local home directory */ 30604203a83SThomas Cort GLOBAL char *localname; /* local user name */ 30704203a83SThomas Cort GLOBAL char netrc[MAXPATHLEN]; /* path to .netrc file */ 30804203a83SThomas Cort GLOBAL char reply_string[BUFSIZ]; /* first line of previous reply */ 30904203a83SThomas Cort GLOBAL void (*reply_callback)(const char *); 31004203a83SThomas Cort /* 31104203a83SThomas Cort * function to call for each line in 31204203a83SThomas Cort * the server's reply except for the 31304203a83SThomas Cort * first (`xxx-') and last (`xxx ') 31404203a83SThomas Cort */ 31504203a83SThomas Cort 31604203a83SThomas Cort GLOBAL volatile sig_atomic_t sigint_raised; 31704203a83SThomas Cort 31804203a83SThomas Cort GLOBAL FILE *cin; 31904203a83SThomas Cort GLOBAL FILE *cout; 32004203a83SThomas Cort GLOBAL int data; 32104203a83SThomas Cort 32204203a83SThomas Cort extern struct cmd cmdtab[]; 32304203a83SThomas Cort extern struct option optiontab[]; 32404203a83SThomas Cort 32504203a83SThomas Cort 32604203a83SThomas Cort #define EMPTYSTRING(x) ((x) == NULL || (*(x) == '\0')) 32704203a83SThomas Cort #define FREEPTR(x) if ((x) != NULL) { free(x); (x) = NULL; } 32804203a83SThomas Cort 32904203a83SThomas Cort #ifdef BSD4_4 33004203a83SThomas Cort # define HAVE_STRUCT_SOCKADDR_IN_SIN_LEN 1 33104203a83SThomas Cort #endif 33204203a83SThomas Cort 33304203a83SThomas Cort #ifdef NO_LONG_LONG 33404203a83SThomas Cort # define STRTOLL(x,y,z) strtol(x,y,z) 33504203a83SThomas Cort #else 33604203a83SThomas Cort # define STRTOLL(x,y,z) strtoll(x,y,z) 33704203a83SThomas Cort #endif 33804203a83SThomas Cort 33904203a83SThomas Cort #ifdef NO_DEBUG 34004203a83SThomas Cort #define DPRINTF(...) 34104203a83SThomas Cort #define DWARN(...) 34204203a83SThomas Cort #else 34304203a83SThomas Cort #define DPRINTF(...) if (ftp_debug) (void)fprintf(ttyout, __VA_ARGS__) 34404203a83SThomas Cort #define DWARN(...) if (ftp_debug) warn(__VA_ARGS__) 34504203a83SThomas Cort #endif 34604203a83SThomas Cort 34704203a83SThomas Cort #define STRorNULL(s) ((s) ? (s) : "<null>") 34804203a83SThomas Cort 34904203a83SThomas Cort #ifdef NO_USAGE 35004203a83SThomas Cort void xusage(void); 35104203a83SThomas Cort #define UPRINTF(...) xusage() 35204203a83SThomas Cort #else 35304203a83SThomas Cort #define UPRINTF(...) (void)fprintf(ttyout, __VA_ARGS__) 35404203a83SThomas Cort #endif 355