1 /* $Id: lukemftpd.h,v 1.18 2002/03/14 06:02:24 lukem Exp $ */
3 #define FTPD_VERSION "lukemftpd 1.2 beta 1"
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>
52 # define dirent direct
54 # include <sys/ndir.h>
64 #if TIME_WITH_SYS_TIME
65 # include <sys/time.h>
69 # include <sys/time.h>
89 #define _PATH_BSHELL "/bin/sh"
92 #define _PATH_CSHELL "/bin/csh"
95 #define _PATH_SHELLS "/etc/shells"
98 #define _PATH_DEVNULL "/dev/null"
100 #ifndef _PATH_NOLOGIN
101 #define _PATH_NOLOGIN "/etc/nologin"
106 # define FTPD_LOGTYPE LOG_FTP
108 # define FTPD_LOGTYPE LOG_DAEMON
114 # define LOG_AUTHPRIV LOG_AUTH
116 # define LOG_AUTHPRIV LOG_DAEMON
120 typedef struct _stringlist {
126 StringList *sl_init(void);
127 int sl_add(StringList *, char *);
128 void sl_free(StringList *, int);
129 char *sl_find(StringList *, char *);
142 # include <libutil.h>
146 typedef unsigned short in_port_t;
150 typedef unsigned int socklen_t;
153 #if HAVE_AF_INET6 && HAVE_SOCKADDR_IN6
158 #if ! HAVE_RFC2553_NETDB
161 #undef EAI_ADDRFAMILY
162 #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
164 #define EAI_AGAIN 2 /* temporary failure in name resolution */
166 #define EAI_BADFLAGS 3 /* invalid value for ai_flags */
168 #define EAI_FAIL 4 /* non-recoverable failure in name resolution */
170 #define EAI_FAMILY 5 /* ai_family not supported */
172 #define EAI_MEMORY 6 /* memory allocation failure */
174 #define EAI_NODATA 7 /* no address associated with hostname */
176 #define EAI_NONAME 8 /* hostname nor servname provided, or not known */
178 #define EAI_SERVICE 9 /* servname not supported for ai_socktype */
180 #define EAI_SOCKTYPE 10 /* ai_socktype not supported */
182 #define EAI_SYSTEM 11 /* system error returned in errno */
184 /* KAME extensions? */
186 #define EAI_BADHINTS 12
188 #define EAI_PROTOCOL 13
194 #define NI_MAXHOST 1025
196 #define NI_MAXSERV 32
199 #define NI_NOFQDN 0x00000001
200 #undef NI_NUMERICHOST
201 #define NI_NUMERICHOST 0x00000002
203 #define NI_NAMEREQD 0x00000004
204 #undef NI_NUMERICSERV
205 #define NI_NUMERICSERV 0x00000008
207 #define NI_DGRAM 0x00000010
211 #define AI_PASSIVE 0x00000001 /* get address to use bind() */
213 #define AI_CANONNAME 0x00000002 /* fill ai_canonname */
215 /* KAME extensions ? */
216 #undef AI_NUMERICHOST
217 #define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
219 #define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
223 #define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
224 #undef AI_V4MAPPED_CFG
225 #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
227 #define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
229 #define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
231 #endif /* ! HAVE_RFC2553_NETDB */
234 #if ! HAVE_RFC2553_NETDB && ! HAVE_ADDRINFO
237 int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
238 int ai_family; /* PF_xxx */
239 int ai_socktype; /* SOCK_xxx */
240 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
241 size_t ai_addrlen; /* length of ai_addr */
242 char *ai_canonname; /* canonical name for hostname */
243 struct sockaddr *ai_addr; /* binary address */
244 struct addrinfo *ai_next; /* next structure in linked list */
247 int getaddrinfo(const char *, const char *,
248 const struct addrinfo *, struct addrinfo **);
249 int getnameinfo(const struct sockaddr *, socklen_t, char *,
250 size_t, char *, size_t, int);
251 void freeaddrinfo(struct addrinfo *);
252 char *gai_strerror(int);
254 #endif /* ! HAVE_RFC2553_NETDB && ! HAVE_ADDRINFO */
258 # define DIRENT_MISSING_D_NAMLEN
262 char *crypt(const char *, const char *);
282 void err(int, const char *, ...);
283 void errx(int, const char *, ...);
284 void warn(const char *, ...);
285 void warnx(const char *, ...);
289 char *fgetln(FILE *, size_t *);
293 # define FPARSELN_UNESCESC 0x01
294 # define FPARSELN_UNESCCONT 0x02
295 # define FPARSELN_UNESCCOMM 0x04
296 # define FPARSELN_UNESCREST 0x08
297 # define FPARSELN_UNESCALL 0x0f
298 char *fparseln(FILE *, size_t *, size_t *, const char[3], int);
301 #if ! HAVE_GETUSERSHELL || ! HAVE_GETUSERSHELL_D
302 char *getusershell(void);
303 void setusershell(void);
304 void endusershell(void);
308 const char *inet_ntop(int, const void *, char *, size_t);
312 int inet_pton(int, const char *, void *);
316 int mkstemp(const char *);
320 int snprintf(char *, size_t, const char *, ...);
324 char *strdup(const char *);
331 #if HAVE_QUAD_SUPPORT
332 # if ! HAVE_STRTOLL && HAVE_LONG_LONG
333 long long strtoll(const char *, char **, int);
334 # if ! defined(QUAD_MIN)
335 # define QUAD_MIN (-0x7fffffffffffffffL-1)
337 # if ! defined(QUAD_MAX)
338 # define QUAD_MAX (0x7fffffffffffffffL)
341 #else /* ! HAVE_QUAD_SUPPORT */
342 # define NO_LONG_LONG 1
343 #endif /* ! HAVE_QUAD_SUPPORT */
346 size_t strlcat(char *, const char *, size_t);
350 size_t strlcpy(char *, const char *, size_t);
354 void strmode(mode_t, char *);
358 char *strsep(char **, const char *);
361 #if ! HAVE_USER_FROM_UID
362 const char *user_from_uid(uid_t, int);
363 const char *group_from_gid(gid_t, int);
367 void vsyslog(int level, const char *, va_list);
372 # define MIN(a, b) ((a) < (b) ? (a) : (b))
375 # define MAX(a, b) ((a) < (b) ? (b) : (a))
378 #if ! defined(timersub)
379 # define timersub(tvp, uvp, vvp) \
381 (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
382 (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
383 if ((vvp)->tv_usec < 0) { \
385 (vvp)->tv_usec += 1000000; \
390 #if ! defined(S_ISLNK)
391 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
394 #define DAYSPERNYEAR 365
395 #define SECSPERDAY 86400
396 #define TM_YEAR_BASE 1900