1 /* $NetBSD: tnftp.h,v 1.33 2009/11/14 08:32:42 lukem Exp $ */
3 #define FTP_PRODUCT PACKAGE_NAME
4 #define FTP_VERSION PACKAGE_VERSION
6 #include "tnftp_config.h"
12 #if defined(HAVE_SYS_TYPES_H)
13 # include <sys/types.h>
15 #if defined(STDC_HEADERS)
20 #if defined(HAVE_LIBGEN_H)
23 #if defined(HAVE_UNISTD_H)
26 #if defined(HAVE_POLL_H)
28 #elif defined(HAVE_SYS_POLL_H)
29 # include <sys/poll.h>
31 #if defined(HAVE_SYS_SOCKET_H)
32 # include <sys/socket.h>
34 #if defined(HAVE_NETINET_IN_H)
35 # include <netinet/in.h>
37 #if defined(HAVE_NETINET_IN_SYSTM_H)
38 # include <netinet/in_systm.h>
40 #if defined(HAVE_NETINET_IP_H)
41 # include <netinet/ip.h>
43 #if defined(HAVE_NETDB_H)
44 # if HAVE_DECL_AI_NUMERICHOST
46 # else /* !HAVE_DECL_AI_NUMERICHOST */
47 # define getaddrinfo non_rfc2553_getaddrinfo
50 # endif /* !HAVE_DECL_AI_NUMERICHOST */
52 #if defined(HAVE_ARPA_INET_H)
53 # include <arpa/inet.h>
55 #if defined(HAVE_DIRENT_H)
58 # define dirent direct
59 # if defined(HAVE_SYS_NDIR_H)
60 # include <sys/ndir.h>
62 # if defined(HAVE_SYS_DIR_H)
65 # if defined(HAVE_NDIR_H)
70 #if defined(HAVE_SYS_IOCTL_H)
71 # include <sys/ioctl.h>
73 #if defined(HAVE_SYS_PARAM_H)
74 # include <sys/param.h>
76 #if defined(HAVE_SYS_STAT_H)
77 # include <sys/stat.h>
79 #if defined(HAVE_SYS_SYSLIMITS_H)
80 # include <sys/syslimits.h>
82 #if defined(HAVE_SYS_WAIT_H)
83 # include <sys/wait.h>
86 #if defined(HAVE_ARPA_FTP_H)
87 # include <arpa/ftp.h>
90 #if defined(HAVE_FCNTL_H)
93 #if defined(HAVE_LIMITS_H)
96 #if defined(HAVE_PWD_H)
99 #if defined(HAVE_SETJMP_H)
102 #if defined(HAVE_SIGNAL_H)
105 #if defined(HAVE_STDDEF_H)
108 #if defined(HAVE_TERMIOS_H)
109 # include <termios.h>
112 #if defined(HAVE_POLL)
114 #elif defined(HAVE_SELECT)
116 #else /* !defined(HAVE_POLL) && !defined(HAVE_SELECT) */
117 # error "no poll() or select() found"
120 # define POLLIN 0x0001
122 #if !defined(POLLOUT)
123 # define POLLOUT 0x0004
125 #if !defined(POLLRDNORM)
126 # define POLLRDNORM 0x0040
128 #if !defined(POLLWRNORM)
129 # define POLLWRNORM POLLOUT
131 #if !defined(POLLRDBAND)
132 # define POLLRDBAND 0x0080
137 #if !defined(HAVE_STRUCT_POLLFD)
145 #if defined(TIME_WITH_SYS_TIME)
146 # include <sys/time.h>
149 # if defined(HAVE_SYS_TIME_H)
150 # include <sys/time.h>
156 #if defined(HAVE_ERR_H)
160 #if defined(USE_GLOB_H) /* not set by configure; used by other build systems */
163 # include "ftpglob.h"
166 #if defined(HAVE_PATHS_H)
169 #if !defined(_PATH_BSHELL)
170 # define _PATH_BSHELL "/bin/sh"
172 #if !defined(_PATH_TMP)
173 # define _PATH_TMP "/tmp/"
176 typedef struct _stringlist {
182 StringList *sl_init(void);
183 int sl_add(StringList *, char *);
184 void sl_free(StringList *, int);
185 char *sl_find(StringList *, char *);
187 #if defined(HAVE_TERMCAP_H)
188 # include <termcap.h>
190 int tgetent(char *, const char *);
191 char *tgetstr(const char *, char **);
192 int tgetflag(const char *);
193 int tgetnum(const char *);
194 char *tgoto(const char *, int, int);
195 void tputs(const char *, int, int (*)(int));
196 #endif /* !HAVE_TERMCAP_H */
198 #if defined(HAVE_VIS_H) && defined(HAVE_STRVIS) && defined(HAVE_STRUNVIS)
204 #if !defined(HAVE_IN_PORT_T)
205 typedef unsigned short in_port_t;
208 #if !defined(HAVE_SA_FAMILY_T)
209 typedef unsigned short sa_family_t;
212 #if !defined(HAVE_SOCKLEN_T)
213 typedef unsigned int socklen_t;
216 #if defined(USE_INET6)
220 #if !HAVE_DECL_AI_NUMERICHOST
223 #undef EAI_ADDRFAMILY
224 #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
226 #define EAI_AGAIN 2 /* temporary failure in name resolution */
228 #define EAI_BADFLAGS 3 /* invalid value for ai_flags */
230 #define EAI_FAIL 4 /* non-recoverable failure in name resolution */
232 #define EAI_FAMILY 5 /* ai_family not supported */
234 #define EAI_MEMORY 6 /* memory allocation failure */
236 #define EAI_NODATA 7 /* no address associated with hostname */
238 #define EAI_NONAME 8 /* hostname nor servname provided, or not known */
240 #define EAI_SERVICE 9 /* servname not supported for ai_socktype */
242 #define EAI_SOCKTYPE 10 /* ai_socktype not supported */
244 #define EAI_SYSTEM 11 /* system error returned in errno */
246 /* KAME extensions? */
248 #define EAI_BADHINTS 12
250 #define EAI_PROTOCOL 13
256 #define NI_MAXHOST 1025
258 #define NI_MAXSERV 32
261 #define NI_NOFQDN 0x00000001
262 #undef NI_NUMERICHOST
263 #define NI_NUMERICHOST 0x00000002
265 #define NI_NAMEREQD 0x00000004
266 #undef NI_NUMERICSERV
267 #define NI_NUMERICSERV 0x00000008
269 #define NI_DGRAM 0x00000010
273 #define AI_PASSIVE 0x00000001 /* get address to use bind() */
275 #define AI_CANONNAME 0x00000002 /* fill ai_canonname */
277 /* KAME extensions ? */
278 #undef AI_NUMERICHOST
279 #define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
281 #define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
285 #define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
286 #undef AI_V4MAPPED_CFG
287 #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
289 #define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
291 #define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
293 #endif /* !HAVE_DECL_AI_NUMERICHOST */
296 #if !HAVE_DECL_AI_NUMERICHOST && !defined(HAVE_STRUCT_ADDRINFO) \
297 && !defined(USE_SOCKS)
300 int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
301 int ai_family; /* PF_xxx */
302 int ai_socktype; /* SOCK_xxx */
303 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
304 socklen_t ai_addrlen; /* length of ai_addr */
305 char *ai_canonname; /* canonical name for hostname */
306 struct sockaddr *ai_addr; /* binary address */
307 struct addrinfo *ai_next; /* next structure in linked list */
310 int getaddrinfo(const char *, const char *,
311 const struct addrinfo *, struct addrinfo **);
312 int getnameinfo(const struct sockaddr *, socklen_t,
313 char *, size_t, char *, size_t, int);
314 void freeaddrinfo(struct addrinfo *);
315 const char *gai_strerror(int);
317 #endif /* !HAVE_DECL_AI_NUMERICHOST && !defined(HAVE_STRUCT_ADDRINFO) \
318 && !defined(USE_SOCKS) */
320 #if !defined(HAVE_STRUCT_DIRENT_D_NAMLEN)
321 # define DIRENT_MISSING_D_NAMLEN
324 #if !HAVE_DECL_H_ERRNO
327 #define HAVE_H_ERRNO 1 /* XXX: an assumption for now... */
329 #if !HAVE_DECL_FCLOSE
333 #if !HAVE_DECL_GETPASS
334 char *getpass(const char *);
337 #if !HAVE_DECL_OPTARG
341 #if !HAVE_DECL_OPTIND
345 #if !HAVE_DECL_PCLOSE
349 #if !HAVE_DECL_DIRNAME
350 char *dirname(char *);
353 #if !defined(HAVE_ERR)
354 void err(int, const char *, ...);
355 void errx(int, const char *, ...);
356 void warn(const char *, ...);
357 void warnx(const char *, ...);
360 #if !defined(HAVE_FGETLN)
361 char *fgetln(FILE *, size_t *);
364 #if !defined(HAVE_FSEEKO)
365 int fseeko(FILE *, off_t, int);
368 #if !defined(HAVE_INET_NTOP)
369 const char *inet_ntop(int, const void *, char *, socklen_t);
372 #if !defined(HAVE_INET_PTON)
373 int inet_pton(int, const char *, void *);
376 #if !defined(HAVE_MKSTEMP)
380 #if !defined(HAVE_SETPROGNAME)
381 const char *getprogname(void);
382 void setprogname(const char *);
385 #if !defined(HAVE_SNPRINTF)
386 int snprintf(char *, size_t, const char *, ...);
389 #if !defined(HAVE_STRDUP)
390 char *strdup(const char *);
393 #if !defined(HAVE_STRERROR)
397 #if !defined(HAVE_STRPTIME) || !HAVE_DECL_STRPTIME
398 char *strptime(const char *, const char *, struct tm *);
401 #if defined(HAVE_PRINTF_LONG_LONG) && defined(HAVE_LONG_LONG_INT)
402 # if !defined(HAVE_STRTOLL)
403 long long strtoll(const char *, char **, int);
405 # if !defined(LLONG_MIN)
406 # define LLONG_MIN (-0x7fffffffffffffffLL-1)
408 # if !defined(LLONG_MAX)
409 # define LLONG_MAX (0x7fffffffffffffffLL)
411 #else /* !(defined(HAVE_PRINTF_LONG_LONG) && defined(HAVE_LONG_LONG_INT)) */
412 # define NO_LONG_LONG 1
413 #endif /* !(defined(HAVE_PRINTF_LONG_LONG) && defined(HAVE_LONG_LONG_INT)) */
415 #if !defined(HAVE_TIMEGM)
416 time_t timegm(struct tm *);
419 #if !defined(HAVE_STRLCAT)
420 size_t strlcat(char *, const char *, size_t);
423 #if !defined(HAVE_STRLCPY)
424 size_t strlcpy(char *, const char *, size_t);
427 #if !defined(HAVE_STRSEP)
428 char *strsep(char **stringp, const char *delim);
431 #if !defined(HAVE_UTIMES)
432 int utimes(const char *, const struct timeval *);
435 #if !defined(HAVE_MEMMOVE)
436 # define memmove(a,b,c) bcopy((b),(a),(c))
437 /* XXX: add others #defines for borken systems? */
440 #if defined(HAVE_GETPASSPHRASE)
441 # define getpass getpassphrase
445 # define MIN(a, b) ((a) < (b) ? (a) : (b))
448 # define MAX(a, b) ((a) < (b) ? (b) : (a))
451 #if !defined(timersub)
452 # define timersub(tvp, uvp, vvp) \
454 (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
455 (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
456 if ((vvp)->tv_usec < 0) { \
458 (vvp)->tv_usec += 1000000; \
463 #if !defined(S_ISLNK)
464 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
467 #define EPOCH_YEAR 1970
468 #define SECSPERHOUR 3600
469 #define SECSPERDAY 86400
470 #define TM_YEAR_BASE 1900
472 #if defined(USE_SOCKS) /* (Dante) SOCKS5 */
473 #define connect Rconnect
475 #define getsockname Rgetsockname
476 #define getpeername Rgetpeername
477 #define accept Raccept
478 #define rresvport Rrresvport
479 #define bindresvport Rbindresvport
480 #define gethostbyname Rgethostbyname
481 #define gethostbyname2 Rgethostbyname2
482 #define sendto Rsendto
483 #define recvfrom Rrecvfrom
484 #define recvfrom Rrecvfrom
486 #define writev Rwritev
488 #define sendmsg Rsendmsg
492 #define recvmsg Rrecvmsg
493 #define getaddrinfo Rgetaddrinfo
494 #define getipnodebyname Rgetipnodebyname
495 #endif /* defined(USE_SOCKS) */