1 /* $Id: lukemftpd.h,v 1.20 2002/05/23 02:43:58 lukem Exp $ */
3 #define FTPD_VERSION "lukemftpd 1.2 beta 2"
10 #include <sys/socket.h>
13 #if HAVE_SYS_SYSMACROS_H
14 # include <sys/sysmacros.h>
17 #include <netinet/in.h>
18 #include <netinet/in_systm.h>
19 #include <netinet/ip.h>
22 # include <arpa/ftp.h>
26 #include <arpa/inet.h>
51 # define dirent direct
53 # include <sys/ndir.h>
63 #if TIME_WITH_SYS_TIME
64 # include <sys/time.h>
68 # include <sys/time.h>
87 # include "ftpfnmatch.h"
94 #define _PATH_BSHELL "/bin/sh"
97 #define _PATH_CSHELL "/bin/csh"
100 #define _PATH_SHELLS "/etc/shells"
102 #ifndef _PATH_DEVNULL
103 #define _PATH_DEVNULL "/dev/null"
105 #ifndef _PATH_NOLOGIN
106 #define _PATH_NOLOGIN "/etc/nologin"
111 # define FTPD_LOGTYPE LOG_FTP
113 # define FTPD_LOGTYPE LOG_DAEMON
119 # define LOG_AUTHPRIV LOG_AUTH
121 # define LOG_AUTHPRIV LOG_DAEMON
125 typedef struct _stringlist {
131 StringList *sl_init(void);
132 int sl_add(StringList *, char *);
133 void sl_free(StringList *, int);
134 char *sl_find(StringList *, char *);
147 # include <libutil.h>
151 typedef unsigned short in_port_t;
155 typedef unsigned int socklen_t;
158 #if HAVE_AF_INET6 && HAVE_SOCKADDR_IN6
163 #if ! HAVE_RFC2553_NETDB
166 #undef EAI_ADDRFAMILY
167 #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
169 #define EAI_AGAIN 2 /* temporary failure in name resolution */
171 #define EAI_BADFLAGS 3 /* invalid value for ai_flags */
173 #define EAI_FAIL 4 /* non-recoverable failure in name resolution */
175 #define EAI_FAMILY 5 /* ai_family not supported */
177 #define EAI_MEMORY 6 /* memory allocation failure */
179 #define EAI_NODATA 7 /* no address associated with hostname */
181 #define EAI_NONAME 8 /* hostname nor servname provided, or not known */
183 #define EAI_SERVICE 9 /* servname not supported for ai_socktype */
185 #define EAI_SOCKTYPE 10 /* ai_socktype not supported */
187 #define EAI_SYSTEM 11 /* system error returned in errno */
189 /* KAME extensions? */
191 #define EAI_BADHINTS 12
193 #define EAI_PROTOCOL 13
199 #define NI_MAXHOST 1025
201 #define NI_MAXSERV 32
204 #define NI_NOFQDN 0x00000001
205 #undef NI_NUMERICHOST
206 #define NI_NUMERICHOST 0x00000002
208 #define NI_NAMEREQD 0x00000004
209 #undef NI_NUMERICSERV
210 #define NI_NUMERICSERV 0x00000008
212 #define NI_DGRAM 0x00000010
216 #define AI_PASSIVE 0x00000001 /* get address to use bind() */
218 #define AI_CANONNAME 0x00000002 /* fill ai_canonname */
220 /* KAME extensions ? */
221 #undef AI_NUMERICHOST
222 #define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
224 #define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
228 #define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
229 #undef AI_V4MAPPED_CFG
230 #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
232 #define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
234 #define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
236 #endif /* ! HAVE_RFC2553_NETDB */
239 #if ! HAVE_RFC2553_NETDB && ! HAVE_ADDRINFO
242 int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
243 int ai_family; /* PF_xxx */
244 int ai_socktype; /* SOCK_xxx */
245 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
246 size_t ai_addrlen; /* length of ai_addr */
247 char *ai_canonname; /* canonical name for hostname */
248 struct sockaddr *ai_addr; /* binary address */
249 struct addrinfo *ai_next; /* next structure in linked list */
252 int getaddrinfo(const char *, const char *,
253 const struct addrinfo *, struct addrinfo **);
254 int getnameinfo(const struct sockaddr *, socklen_t, char *,
255 size_t, char *, size_t, int);
256 void freeaddrinfo(struct addrinfo *);
257 char *gai_strerror(int);
259 #endif /* ! HAVE_RFC2553_NETDB && ! HAVE_ADDRINFO */
263 # define DIRENT_MISSING_D_NAMLEN
267 char *crypt(const char *, const char *);
287 void err(int, const char *, ...);
288 void errx(int, const char *, ...);
289 void warn(const char *, ...);
290 void warnx(const char *, ...);
294 char *fgetln(FILE *, size_t *);
298 # define FPARSELN_UNESCESC 0x01
299 # define FPARSELN_UNESCCONT 0x02
300 # define FPARSELN_UNESCCOMM 0x04
301 # define FPARSELN_UNESCREST 0x08
302 # define FPARSELN_UNESCALL 0x0f
303 char *fparseln(FILE *, size_t *, size_t *, const char[3], int);
306 #if ! HAVE_GETUSERSHELL || ! HAVE_GETUSERSHELL_D
307 char *getusershell(void);
308 void setusershell(void);
309 void endusershell(void);
313 const char *inet_ntop(int, const void *, char *, size_t);
317 int inet_pton(int, const char *, void *);
321 int mkstemp(const char *);
325 int snprintf(char *, size_t, const char *, ...);
329 char *strdup(const char *);
336 #if HAVE_QUAD_SUPPORT
337 # if ! HAVE_STRTOLL && HAVE_LONG_LONG
338 long long strtoll(const char *, char **, int);
339 # if ! defined(QUAD_MIN)
340 # define QUAD_MIN (-0x7fffffffffffffffL-1)
342 # if ! defined(QUAD_MAX)
343 # define QUAD_MAX (0x7fffffffffffffffL)
346 #else /* ! HAVE_QUAD_SUPPORT */
347 # define NO_LONG_LONG 1
348 #endif /* ! HAVE_QUAD_SUPPORT */
351 size_t strlcat(char *, const char *, size_t);
355 size_t strlcpy(char *, const char *, size_t);
359 void strmode(mode_t, char *);
363 char *strsep(char **, const char *);
366 #if ! HAVE_USER_FROM_UID
367 const char *user_from_uid(uid_t, int);
368 const char *group_from_gid(gid_t, int);
372 void vsyslog(int level, const char *, va_list);
377 # define MIN(a, b) ((a) < (b) ? (a) : (b))
380 # define MAX(a, b) ((a) < (b) ? (b) : (a))
383 #if ! defined(timersub)
384 # define timersub(tvp, uvp, vvp) \
386 (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
387 (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
388 if ((vvp)->tv_usec < 0) { \
390 (vvp)->tv_usec += 1000000; \
395 #if ! defined(S_ISLNK)
396 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
399 #define DAYSPERNYEAR 365
400 #define SECSPERDAY 86400
401 #define TM_YEAR_BASE 1900