xref: /minix3/libexec/ftpd/extern.h (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc /*	$NetBSD: extern.h,v 1.63 2013/03/21 05:53:01 lukem Exp $	*/
262da0113SBen Gras 
362da0113SBen Gras /*-
462da0113SBen Gras  * Copyright (c) 1992, 1993
562da0113SBen Gras  *	The Regents of the University of California.  All rights reserved.
662da0113SBen Gras  *
762da0113SBen Gras  * Redistribution and use in source and binary forms, with or without
862da0113SBen Gras  * modification, are permitted provided that the following conditions
962da0113SBen Gras  * are met:
1062da0113SBen Gras  * 1. Redistributions of source code must retain the above copyright
1162da0113SBen Gras  *    notice, this list of conditions and the following disclaimer.
1262da0113SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
1362da0113SBen Gras  *    notice, this list of conditions and the following disclaimer in the
1462da0113SBen Gras  *    documentation and/or other materials provided with the distribution.
1562da0113SBen Gras  * 3. Neither the name of the University nor the names of its contributors
1662da0113SBen Gras  *    may be used to endorse or promote products derived from this software
1762da0113SBen Gras  *    without specific prior written permission.
1862da0113SBen Gras  *
1962da0113SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2062da0113SBen Gras  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2162da0113SBen Gras  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2262da0113SBen Gras  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2362da0113SBen Gras  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2462da0113SBen Gras  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2562da0113SBen Gras  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2662da0113SBen Gras  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2762da0113SBen Gras  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2862da0113SBen Gras  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2962da0113SBen Gras  * SUCH DAMAGE.
3062da0113SBen Gras  *
3162da0113SBen Gras  *	@(#)extern.h	8.2 (Berkeley) 4/4/94
3262da0113SBen Gras  */
3362da0113SBen Gras 
3462da0113SBen Gras /*-
3562da0113SBen Gras  * Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
3662da0113SBen Gras  * All rights reserved.
3762da0113SBen Gras  *
3862da0113SBen Gras  * This code is derived from software contributed to The NetBSD Foundation
3962da0113SBen Gras  * by Luke Mewburn.
4062da0113SBen Gras  *
4162da0113SBen Gras  * Redistribution and use in source and binary forms, with or without
4262da0113SBen Gras  * modification, are permitted provided that the following conditions
4362da0113SBen Gras  * are met:
4462da0113SBen Gras  * 1. Redistributions of source code must retain the above copyright
4562da0113SBen Gras  *    notice, this list of conditions and the following disclaimer.
4662da0113SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
4762da0113SBen Gras  *    notice, this list of conditions and the following disclaimer in the
4862da0113SBen Gras  *    documentation and/or other materials provided with the distribution.
4962da0113SBen Gras  *
5062da0113SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
5162da0113SBen Gras  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
5262da0113SBen Gras  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
5362da0113SBen Gras  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
5462da0113SBen Gras  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
5562da0113SBen Gras  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5662da0113SBen Gras  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
5762da0113SBen Gras  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
5862da0113SBen Gras  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5962da0113SBen Gras  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
6062da0113SBen Gras  * POSSIBILITY OF SUCH DAMAGE.
6162da0113SBen Gras  */
6262da0113SBen Gras 
6362da0113SBen Gras /*
6462da0113SBen Gras  * Copyright (C) 1997 and 1998 WIDE Project.
6562da0113SBen Gras  * All rights reserved.
6662da0113SBen Gras  *
6762da0113SBen Gras  * Redistribution and use in source and binary forms, with or without
6862da0113SBen Gras  * modification, are permitted provided that the following conditions
6962da0113SBen Gras  * are met:
7062da0113SBen Gras  * 1. Redistributions of source code must retain the above copyright
7162da0113SBen Gras  *    notice, this list of conditions and the following disclaimer.
7262da0113SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
7362da0113SBen Gras  *    notice, this list of conditions and the following disclaimer in the
7462da0113SBen Gras  *    documentation and/or other materials provided with the distribution.
7562da0113SBen Gras  * 3. Neither the name of the project nor the names of its contributors
7662da0113SBen Gras  *    may be used to endorse or promote products derived from this software
7762da0113SBen Gras  *    without specific prior written permission.
7862da0113SBen Gras  *
7962da0113SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
8062da0113SBen Gras  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
8162da0113SBen Gras  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
8262da0113SBen Gras  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
8362da0113SBen Gras  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
8462da0113SBen Gras  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
8562da0113SBen Gras  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
8662da0113SBen Gras  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
8762da0113SBen Gras  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
8862da0113SBen Gras  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
8962da0113SBen Gras  * SUCH DAMAGE.
9062da0113SBen Gras  */
9162da0113SBen Gras 
9262da0113SBen Gras #ifdef NO_LONG_LONG
9362da0113SBen Gras # define LLF		"%ld"
9462da0113SBen Gras # define LLFP(x)	"%" x "ld"
9562da0113SBen Gras # define LLT		long
9662da0113SBen Gras # define ULLF		"%lu"
9762da0113SBen Gras # define ULLFP(x)	"%" x "lu"
9862da0113SBen Gras # define ULLT		unsigned long
9962da0113SBen Gras # define STRTOLL(x,y,z)	strtol(x,y,z)
10062da0113SBen Gras # define LLTMIN		LONG_MIN
10162da0113SBen Gras # define LLTMAX		LONG_MAX
10262da0113SBen Gras #else
10362da0113SBen Gras # define LLF		"%lld"
10462da0113SBen Gras # define LLFP(x)	"%" x "lld"
10562da0113SBen Gras # define LLT		long long
10662da0113SBen Gras # define ULLF		"%llu"
10762da0113SBen Gras # define ULLFP(x)	"%" x "llu"
10862da0113SBen Gras # define ULLT		unsigned long long
10962da0113SBen Gras # define STRTOLL(x,y,z)	strtoll(x,y,z)
11062da0113SBen Gras # define LLTMIN		LLONG_MIN
11162da0113SBen Gras # define LLTMAX		LLONG_MAX
11262da0113SBen Gras #endif
11362da0113SBen Gras 
11462da0113SBen Gras #define FTP_BUFLEN	512
11562da0113SBen Gras 
11662da0113SBen Gras void	abor(void);
11762da0113SBen Gras void	closedataconn(FILE *);
11862da0113SBen Gras char   *conffilename(const char *);
11962da0113SBen Gras void	count_users(void);
12062da0113SBen Gras void	cprintf(FILE *, const char *, ...)
121*84d9c625SLionel Sambuc 	    __printflike(2, 3);
12262da0113SBen Gras void	cwd(const char *);
12362da0113SBen Gras FILE   *dataconn(const char *, off_t, const char *);
12462da0113SBen Gras void	delete(const char *);
12562da0113SBen Gras int	display_file(const char *, int);
12662da0113SBen Gras const char **do_conversion(const char *);
12762da0113SBen Gras __dead void	dologout(int);
12862da0113SBen Gras __dead void	fatal(const char *);
12962da0113SBen Gras void	feat(void);
13062da0113SBen Gras void	format_path(char *, const char *);
13162da0113SBen Gras int	ftpd_pclose(FILE *);
13262da0113SBen Gras FILE   *ftpd_popen(const char *[], const char *, int);
13362da0113SBen Gras int	get_line(char *, int, FILE *);
13462da0113SBen Gras void	init_curclass(void);
13562da0113SBen Gras void	logxfer(const char *, off_t, const char *, const char *,
13662da0113SBen Gras 	    const struct timeval *, const char *);
13762da0113SBen Gras struct tab *lookup(struct tab *, const char *);
13862da0113SBen Gras void	makedir(const char *);
13962da0113SBen Gras void	mlsd(const char *);
14062da0113SBen Gras void	mlst(const char *);
14162da0113SBen Gras void	opts(const char *);
14262da0113SBen Gras void	parse_conf(const char *);
14362da0113SBen Gras void	pass(const char *);
14462da0113SBen Gras void	passive(void);
14562da0113SBen Gras int	lpsvproto2af(int);
14662da0113SBen Gras int	af2lpsvproto(int);
14762da0113SBen Gras int	epsvproto2af(int);
14862da0113SBen Gras int	af2epsvproto(int);
14962da0113SBen Gras void	long_passive(const char *, int);
15062da0113SBen Gras int	extended_port(const char *);
15162da0113SBen Gras void	epsv_protounsupp(const char *);
15262da0113SBen Gras void	perror_reply(int, const char *);
15362da0113SBen Gras void	pwd(void);
15462da0113SBen Gras void	removedir(const char *);
15562da0113SBen Gras void	renamecmd(const char *, const char *);
15662da0113SBen Gras char   *renamefrom(const char *);
15762da0113SBen Gras void	reply(int, const char *, ...)
158*84d9c625SLionel Sambuc 	    __printflike(2, 3);
15962da0113SBen Gras void	retrieve(const char *[], const char *);
16062da0113SBen Gras void	send_file_list(const char *);
16162da0113SBen Gras void	show_chdir_messages(int);
16262da0113SBen Gras void	sizecmd(const char *);
16362da0113SBen Gras void	statcmd(void);
16462da0113SBen Gras void	statfilecmd(const char *);
16562da0113SBen Gras void	statxfer(void);
16662da0113SBen Gras void	store(const char *, const char *, int);
16762da0113SBen Gras void	user(const char *);
16862da0113SBen Gras char   *ftpd_strdup(const char *);
16962da0113SBen Gras void	yyerror(const char *);
17062da0113SBen Gras 
17162da0113SBen Gras #ifdef SUPPORT_UTMP
17262da0113SBen Gras struct utmp;
17362da0113SBen Gras 
17462da0113SBen Gras void	ftpd_initwtmp(void);
17562da0113SBen Gras void	ftpd_logwtmp(const char *, const char *, const char *);
17662da0113SBen Gras void	ftpd_login(const struct utmp *);
17762da0113SBen Gras int	ftpd_logout(const char *);
17862da0113SBen Gras #endif
17962da0113SBen Gras 
18062da0113SBen Gras #ifdef SUPPORT_UTMPX
18162da0113SBen Gras struct utmpx;
18262da0113SBen Gras struct sockinet;
18362da0113SBen Gras 
18462da0113SBen Gras void	ftpd_initwtmpx(void);
18562da0113SBen Gras void	ftpd_logwtmpx(const char *, const char *, const char *,
18662da0113SBen Gras     struct sockinet *, int, int);
18762da0113SBen Gras void	ftpd_loginx(const struct utmpx *);
18862da0113SBen Gras int	ftpd_logoutx(const char *, int, int);
18962da0113SBen Gras #endif
19062da0113SBen Gras 
19162da0113SBen Gras #include <netinet/in.h>
19262da0113SBen Gras 
19362da0113SBen Gras #if defined(__NetBSD__)
19462da0113SBen Gras # define HAVE_SETPROCTITLE		1
19562da0113SBen Gras # define HAVE_STRUCT_SOCKADDR_SA_LEN	1
19662da0113SBen Gras # define HAVE_SOCKADDR_SNPRINTF		1
19762da0113SBen Gras #endif
19862da0113SBen Gras 
19962da0113SBen Gras struct sockinet {
20062da0113SBen Gras 	union sockunion {
20162da0113SBen Gras 		struct sockaddr_in  su_sin;
20262da0113SBen Gras #ifdef INET6
20362da0113SBen Gras 		struct sockaddr_in6 su_sin6;
20462da0113SBen Gras #endif
20562da0113SBen Gras 	} si_su;
20662da0113SBen Gras #if !defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
20762da0113SBen Gras 	int	si_len;
20862da0113SBen Gras #endif
20962da0113SBen Gras };
21062da0113SBen Gras 
21162da0113SBen Gras #if !defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
21262da0113SBen Gras # define su_len		si_len
21362da0113SBen Gras #else
21462da0113SBen Gras # define su_len		si_su.su_sin.sin_len
21562da0113SBen Gras #endif
21662da0113SBen Gras #define su_addr		si_su.su_sin.sin_addr
21762da0113SBen Gras #define su_family	si_su.su_sin.sin_family
21862da0113SBen Gras #define su_port		si_su.su_sin.sin_port
21962da0113SBen Gras #ifdef INET6
22062da0113SBen Gras # define su_6addr	si_su.su_sin6.sin6_addr
22162da0113SBen Gras # define su_scope_id	si_su.su_sin6.sin6_scope_id
22262da0113SBen Gras #endif
22362da0113SBen Gras 
22462da0113SBen Gras struct tab {
22562da0113SBen Gras 	const char	*name;
22662da0113SBen Gras 	short	 	token;
22762da0113SBen Gras 	short	 	state;
22862da0113SBen Gras 	short	 	flags;	/* 1 if command implemented, 2 if has options,
22962da0113SBen Gras 				   4 if can occur OOB */
23062da0113SBen Gras 	const char	*help;
23162da0113SBen Gras 	char		*options;
23262da0113SBen Gras };
23362da0113SBen Gras 
23462da0113SBen Gras struct ftpconv {
23562da0113SBen Gras 	struct ftpconv	*next;
23662da0113SBen Gras 	char 		*suffix;	/* Suffix of requested name */
23762da0113SBen Gras 	char		*types;		/* Valid file types */
23862da0113SBen Gras 	char		*disable;	/* File to disable conversions */
23962da0113SBen Gras 	char		*command;	/* Command to do the conversion */
24062da0113SBen Gras };
24162da0113SBen Gras 
24262da0113SBen Gras typedef enum {
24362da0113SBen Gras 	CLASS_GUEST,
24462da0113SBen Gras 	CLASS_CHROOT,
24562da0113SBen Gras 	CLASS_REAL
24662da0113SBen Gras } class_ft;
24762da0113SBen Gras 
24862da0113SBen Gras typedef enum {
24962da0113SBen Gras 	FLAG_checkportcmd =	1<<0,	/* Check port commands */
25062da0113SBen Gras 	FLAG_denyquick =	1<<1,	/* Check ftpusers(5) before PASS */
25162da0113SBen Gras 	FLAG_hidesymlinks =	1<<2,	/* For symbolic links, list the file
25262da0113SBen Gras 					   or directory the link references
25362da0113SBen Gras 					   rather than the link itself */
25462da0113SBen Gras 	FLAG_modify =		1<<3,	/* Allow CHMOD, DELE, MKD, RMD, RNFR,
25562da0113SBen Gras 					   UMASK */
25662da0113SBen Gras 	FLAG_passive =		1<<4,	/* Allow PASV mode */
25762da0113SBen Gras 	FLAG_private =		1<<5,	/* Don't publish class info in STAT */
25862da0113SBen Gras 	FLAG_sanenames =	1<<6,	/* Restrict names of uploaded files */
25962da0113SBen Gras 	FLAG_upload =		1<<7,	/* As per modify, but also allow
26062da0113SBen Gras 					   APPE, STOR, STOU */
26162da0113SBen Gras } classflag_t;
26262da0113SBen Gras 
26362da0113SBen Gras #define CURCLASS_FLAGS_SET(x)	(curclass.flags |=  (FLAG_ ## x))
26462da0113SBen Gras #define CURCLASS_FLAGS_CLR(x)	(curclass.flags &= ~(FLAG_ ## x))
26562da0113SBen Gras #define CURCLASS_FLAGS_ISSET(x)	(curclass.flags &   (FLAG_ ## x))
26662da0113SBen Gras 
26762da0113SBen Gras struct ftpclass {
26862da0113SBen Gras 	struct sockinet	 advertise;	/* PASV address to advertise as */
26962da0113SBen Gras 	char		*chroot;	/* Directory to chroot(2) to at login */
27062da0113SBen Gras 	char		*classname;	/* Current class */
27162da0113SBen Gras 	struct ftpconv	*conversions;	/* List of conversions */
27262da0113SBen Gras 	char		*display;	/* File to display upon chdir */
27362da0113SBen Gras 	char		*homedir;	/* Directory to chdir(2) to at login */
27462da0113SBen Gras 	classflag_t	 flags;		/* Flags; see classflag_t above */
27562da0113SBen Gras 	LLT		 limit;		/* Max connections (-1 = unlimited) */
27662da0113SBen Gras 	char		*limitfile;	/* File to display if limit reached */
27762da0113SBen Gras 	LLT		 maxfilesize;	/* Maximum file size of uploads */
27862da0113SBen Gras 	LLT		 maxrateget;	/* Maximum get transfer rate throttle */
27962da0113SBen Gras 	LLT		 maxrateput;	/* Maximum put transfer rate throttle */
28062da0113SBen Gras 	LLT		 maxtimeout;	/* Maximum permitted timeout */
28162da0113SBen Gras 	char		*motd;		/* MotD file to display after login */
28262da0113SBen Gras 	char		*notify;	/* Files to notify about upon chdir */
28362da0113SBen Gras 	LLT		 portmin;	/* Minumum port for passive mode */
28462da0113SBen Gras 	LLT		 portmax;	/* Maximum port for passive mode */
28562da0113SBen Gras 	LLT		 rateget;	/* Get (RETR) transfer rate throttle */
28662da0113SBen Gras 	LLT		 rateput;	/* Put (STOR) transfer rate throttle */
28762da0113SBen Gras 	LLT		 timeout;	/* Default timeout */
28862da0113SBen Gras 	class_ft	 type;		/* Class type */
28962da0113SBen Gras 	mode_t		 umask;		/* Umask to use */
29062da0113SBen Gras 	LLT		 mmapsize;	/* mmap window size */
29162da0113SBen Gras 	LLT		 readsize;	/* data read size */
29262da0113SBen Gras 	LLT		 writesize;	/* data write size */
29362da0113SBen Gras 	LLT		 recvbufsize;	/* SO_RCVBUF size */
29462da0113SBen Gras 	LLT		 sendbufsize;	/* SO_SNDBUF size */
29562da0113SBen Gras 	LLT		 sendlowat;	/* SO_SNDLOWAT size */
29662da0113SBen Gras };
29762da0113SBen Gras 
298*84d9c625SLionel Sambuc __dead extern void		ftp_loop(void);
29962da0113SBen Gras extern void		ftp_handle_line(char *);
30062da0113SBen Gras 
30162da0113SBen Gras #ifndef	GLOBAL
30262da0113SBen Gras #define	GLOBAL	extern
30362da0113SBen Gras #endif
30462da0113SBen Gras 
30562da0113SBen Gras 
30662da0113SBen Gras GLOBAL	struct sockinet ctrl_addr;
30762da0113SBen Gras GLOBAL	struct sockinet	data_dest;
30862da0113SBen Gras GLOBAL	struct sockinet	data_source;
30962da0113SBen Gras GLOBAL	struct sockinet	his_addr;
31062da0113SBen Gras GLOBAL	struct sockinet	pasv_addr;
31162da0113SBen Gras GLOBAL	int		connections;
31262da0113SBen Gras GLOBAL	struct ftpclass	curclass;
31362da0113SBen Gras GLOBAL	int		ftpd_debug;
31462da0113SBen Gras GLOBAL	char		*emailaddr;
31562da0113SBen Gras GLOBAL	int		form;
31662da0113SBen Gras GLOBAL	int		gidcount;	/* number of entries in gidlist[] */
31762da0113SBen Gras GLOBAL	gid_t		*gidlist;
31862da0113SBen Gras GLOBAL	int		hasyyerrored;
31962da0113SBen Gras GLOBAL	char		hostname[MAXHOSTNAMELEN+1];
32062da0113SBen Gras GLOBAL	char		homedir[MAXPATHLEN];
32162da0113SBen Gras #ifdef KERBEROS5
32262da0113SBen Gras GLOBAL	krb5_context	kcontext;
32362da0113SBen Gras #endif
32462da0113SBen Gras GLOBAL	int		logged_in;
32562da0113SBen Gras GLOBAL	int		logging;
32662da0113SBen Gras GLOBAL	int		pdata;			/* for passive mode */
32762da0113SBen Gras #if defined(HAVE_SETPROCTITLE)
32862da0113SBen Gras GLOBAL	char		proctitle[BUFSIZ];	/* initial part of title */
32962da0113SBen Gras #endif
33062da0113SBen Gras GLOBAL	struct passwd  *pw;
33162da0113SBen Gras GLOBAL	int		quietmessages;
33262da0113SBen Gras GLOBAL	char		remotehost[MAXHOSTNAMELEN+1];
33362da0113SBen Gras GLOBAL	char		remoteloghost[2 * MAXHOSTNAMELEN+1];
33462da0113SBen Gras GLOBAL	off_t		restart_point;
33562da0113SBen Gras GLOBAL	char		tmpline[FTP_BUFLEN];
33662da0113SBen Gras GLOBAL	int		type;
33762da0113SBen Gras GLOBAL	int		usedefault;		/* for data transfers */
33862da0113SBen Gras GLOBAL	const char     *version;
33962da0113SBen Gras GLOBAL	int		is_oob;
34062da0113SBen Gras 
34162da0113SBen Gras 						/* total file data bytes */
34262da0113SBen Gras GLOBAL	off_t		total_data_in,  total_data_out,  total_data;
34362da0113SBen Gras 						/* total number of data files */
34462da0113SBen Gras GLOBAL	off_t		total_files_in, total_files_out, total_files;
34562da0113SBen Gras 						/* total bytes */
34662da0113SBen Gras GLOBAL	off_t		total_bytes_in, total_bytes_out, total_bytes;
34762da0113SBen Gras 						/* total number of xfers */
34862da0113SBen Gras GLOBAL	off_t		total_xfers_in, total_xfers_out, total_xfers;
34962da0113SBen Gras 
35062da0113SBen Gras extern	struct tab	cmdtab[];
35162da0113SBen Gras 
35262da0113SBen Gras #define	INTERNAL_LS	"/bin/ls"
35362da0113SBen Gras 
35462da0113SBen Gras 
35562da0113SBen Gras #define CMD_IMPLEMENTED(x)	((x)->flags != 0)
35662da0113SBen Gras #define CMD_HAS_OPTIONS(x)	((x)->flags & 0x2)
35762da0113SBen Gras #define CMD_OOB(x)		((x)->flags & 0x4)
35862da0113SBen Gras 
35962da0113SBen Gras #define	CPUTC(c, f)	do { \
36062da0113SBen Gras 				putc(c, f); total_bytes++; total_bytes_out++; \
36162da0113SBen Gras 			} while (0);
36262da0113SBen Gras 
36362da0113SBen Gras #define CURCLASSTYPE	curclass.type == CLASS_GUEST  ? "GUEST"  : \
36462da0113SBen Gras 			curclass.type == CLASS_CHROOT ? "CHROOT" : \
36562da0113SBen Gras 			curclass.type == CLASS_REAL   ? "REAL"   : \
36662da0113SBen Gras 			"<unknown>"
36762da0113SBen Gras 
36862da0113SBen Gras #define ISDOTDIR(x)	(x[0] == '.' && x[1] == '\0')
36962da0113SBen Gras #define ISDOTDOTDIR(x)	(x[0] == '.' && x[1] == '.' && x[2] == '\0')
37062da0113SBen Gras 
37162da0113SBen Gras #define EMPTYSTR(p)	((p) == NULL || *(p) == '\0')
37262da0113SBen Gras #define NEXTWORD(P, W)	do { \
37362da0113SBen Gras 				(W) = strsep(&(P), " \t"); \
37462da0113SBen Gras 			} while ((W) != NULL && *(W) == '\0')
37562da0113SBen Gras #define PLURAL(s)	((s) == 1 ? "" : "s")
37662da0113SBen Gras #define REASSIGN(X,Y)	do { if (X) free(X); (X)=(Y); } while (/*CONSTCOND*/0)
37762da0113SBen Gras 
37862da0113SBen Gras #ifndef IPPORT_ANONMAX
37962da0113SBen Gras # define IPPORT_ANONMAX	65535
38062da0113SBen Gras #endif
381