1 /* $NetBSD: tnftp.h,v 1.36 2014/10/31 07:22:03 lukem Exp $ */
3 #define FTP_PRODUCT PACKAGE_NAME
4 #define FTP_VERSION PACKAGE_VERSION
6 #include "tnftp_config.h"
13 #if defined(HAVE_SYS_TYPES_H)
14 # include <sys/types.h>
16 #if defined(STDC_HEADERS)
21 #if defined(HAVE_LIBGEN_H)
24 #if defined(HAVE_UNISTD_H)
27 #if defined(HAVE_POLL_H)
29 #elif defined(HAVE_SYS_POLL_H)
30 # include <sys/poll.h>
32 #if defined(HAVE_SYS_SOCKET_H)
33 # include <sys/socket.h>
35 #if defined(HAVE_NETINET_IN_H)
36 # include <netinet/in.h>
38 #if defined(HAVE_NETINET_IN_SYSTM_H)
39 # include <netinet/in_systm.h>
41 #if defined(HAVE_NETINET_IP_H)
42 # include <netinet/ip.h>
44 #if defined(HAVE_NETINET_TCP_H)
45 # include <netinet/tcp.h>
47 #if defined(HAVE_NETDB_H)
48 # if HAVE_DECL_AI_NUMERICHOST
50 # else /* !HAVE_DECL_AI_NUMERICHOST */
51 # define getaddrinfo non_rfc2553_getaddrinfo
54 # endif /* !HAVE_DECL_AI_NUMERICHOST */
56 #if defined(HAVE_ARPA_INET_H)
57 # include <arpa/inet.h>
59 #if defined(HAVE_DIRENT_H)
62 # define dirent direct
63 # if defined(HAVE_SYS_NDIR_H)
64 # include <sys/ndir.h>
66 # if defined(HAVE_SYS_DIR_H)
69 # if defined(HAVE_NDIR_H)
73 #if defined(HAVE_SYS_UIO_H)
77 #if defined(HAVE_SYS_IOCTL_H)
78 # include <sys/ioctl.h>
80 #if defined(HAVE_SYS_PARAM_H)
81 # include <sys/param.h>
83 #if defined(HAVE_SYS_STAT_H)
84 # include <sys/stat.h>
86 #if defined(HAVE_SYS_SYSLIMITS_H)
87 # include <sys/syslimits.h>
89 #if defined(HAVE_SYS_WAIT_H)
90 # include <sys/wait.h>
93 #if defined(HAVE_ARPA_FTP_H)
94 # include <arpa/ftp.h>
97 #if defined(HAVE_FCNTL_H)
100 #if defined(HAVE_LIMITS_H)
103 #if defined(HAVE_LOCALE_H)
106 #if defined(HAVE_PWD_H)
109 #if defined(HAVE_SETJMP_H)
112 #if defined(HAVE_SIGNAL_H)
115 #if defined(HAVE_STDDEF_H)
118 #if defined(HAVE_TERMIOS_H)
119 # include <termios.h>
122 #if defined(HAVE_POLL)
124 #elif defined(HAVE_SELECT)
126 #else /* !defined(HAVE_POLL) && !defined(HAVE_SELECT) */
127 # error "no poll() or select() found"
130 # define POLLIN 0x0001
132 #if !defined(POLLOUT)
133 # define POLLOUT 0x0004
135 #if !defined(POLLRDNORM)
136 # define POLLRDNORM 0x0040
138 #if !defined(POLLWRNORM)
139 # define POLLWRNORM POLLOUT
141 #if !defined(POLLRDBAND)
142 # define POLLRDBAND 0x0080
147 #if !defined(HAVE_STRUCT_POLLFD)
155 #if defined(TIME_WITH_SYS_TIME)
156 # include <sys/time.h>
159 # if defined(HAVE_SYS_TIME_H)
160 # include <sys/time.h>
166 #if defined(HAVE_ERR_H)
170 #if defined(USE_GLOB_H) /* not set by configure; used by other build systems */
173 # include "ftpglob.h"
176 #if defined(HAVE_PATHS_H)
179 #if !defined(_PATH_BSHELL)
180 # define _PATH_BSHELL "/bin/sh"
182 #if !defined(_PATH_TMP)
183 # define _PATH_TMP "/tmp/"
186 typedef struct _stringlist
{
192 StringList
*sl_init(void);
193 int sl_add(StringList
*, char *);
194 void sl_free(StringList
*, int);
195 char *sl_find(StringList
*, char *);
197 #if defined(HAVE_TERMCAP_H)
198 # include <termcap.h>
200 int tgetent(char *, const char *);
201 char *tgetstr(const char *, char **);
202 int tgetflag(const char *);
203 int tgetnum(const char *);
204 char *tgoto(const char *, int, int);
205 void tputs(const char *, int, int (*)(int));
206 #endif /* !HAVE_TERMCAP_H */
208 #if defined(HAVE_VIS_H) && defined(HAVE_STRVIS) && defined(HAVE_STRUNVIS)
214 #if !defined(HAVE_IN_PORT_T)
215 typedef unsigned short in_port_t
;
218 #if !defined(HAVE_SA_FAMILY_T)
219 typedef unsigned short sa_family_t
;
222 #if !defined(HAVE_SOCKLEN_T)
223 typedef unsigned int socklen_t
;
226 #if defined(USE_INET6)
230 #if !HAVE_DECL_AI_NUMERICHOST
233 #undef EAI_ADDRFAMILY
234 #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
236 #define EAI_AGAIN 2 /* temporary failure in name resolution */
238 #define EAI_BADFLAGS 3 /* invalid value for ai_flags */
240 #define EAI_FAIL 4 /* non-recoverable failure in name resolution */
242 #define EAI_FAMILY 5 /* ai_family not supported */
244 #define EAI_MEMORY 6 /* memory allocation failure */
246 #define EAI_NODATA 7 /* no address associated with hostname */
248 #define EAI_NONAME 8 /* hostname nor servname provided, or not known */
250 #define EAI_SERVICE 9 /* servname not supported for ai_socktype */
252 #define EAI_SOCKTYPE 10 /* ai_socktype not supported */
254 #define EAI_SYSTEM 11 /* system error returned in errno */
256 /* KAME extensions? */
258 #define EAI_BADHINTS 12
260 #define EAI_PROTOCOL 13
266 #define NI_MAXHOST 1025
268 #define NI_MAXSERV 32
271 #define NI_NOFQDN 0x00000001
272 #undef NI_NUMERICHOST
273 #define NI_NUMERICHOST 0x00000002
275 #define NI_NAMEREQD 0x00000004
276 #undef NI_NUMERICSERV
277 #define NI_NUMERICSERV 0x00000008
279 #define NI_DGRAM 0x00000010
283 #define AI_PASSIVE 0x00000001 /* get address to use bind() */
285 #define AI_CANONNAME 0x00000002 /* fill ai_canonname */
287 /* KAME extensions ? */
288 #undef AI_NUMERICHOST
289 #define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
291 #define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
295 #define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
296 #undef AI_V4MAPPED_CFG
297 #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
299 #define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
301 #define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
303 #endif /* !HAVE_DECL_AI_NUMERICHOST */
306 #if !HAVE_DECL_AI_NUMERICHOST && !defined(HAVE_STRUCT_ADDRINFO) \
307 && !defined(USE_SOCKS)
310 int ai_flags
; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
311 int ai_family
; /* PF_xxx */
312 int ai_socktype
; /* SOCK_xxx */
313 int ai_protocol
; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
314 socklen_t ai_addrlen
; /* length of ai_addr */
315 char *ai_canonname
; /* canonical name for hostname */
316 struct sockaddr
*ai_addr
; /* binary address */
317 struct addrinfo
*ai_next
; /* next structure in linked list */
320 int getaddrinfo(const char *, const char *,
321 const struct addrinfo
*, struct addrinfo
**);
322 int getnameinfo(const struct sockaddr
*, socklen_t
,
323 char *, size_t, char *, size_t, int);
324 void freeaddrinfo(struct addrinfo
*);
325 const char *gai_strerror(int);
327 #endif /* !HAVE_DECL_AI_NUMERICHOST && !defined(HAVE_STRUCT_ADDRINFO) \
328 && !defined(USE_SOCKS) */
330 #if !defined(HAVE_STRUCT_DIRENT_D_NAMLEN)
331 # define DIRENT_MISSING_D_NAMLEN
334 #if !HAVE_DECL_H_ERRNO
337 #define HAVE_H_ERRNO 1 /* XXX: an assumption for now... */
339 #if !HAVE_DECL_FCLOSE
343 #if !HAVE_DECL_GETPASS
344 char *getpass(const char *);
347 #if !HAVE_DECL_OPTARG
351 #if !HAVE_DECL_OPTIND
355 #if !HAVE_DECL_PCLOSE
359 #if !HAVE_DECL_DIRNAME
360 char *dirname(char *);
363 #if !defined(HAVE_ERR)
364 void err(int, const char *, ...);
365 void errx(int, const char *, ...);
366 void warn(const char *, ...);
367 void warnx(const char *, ...);
370 #if !defined(HAVE_FGETLN)
371 char *fgetln(FILE *, size_t *);
374 #if !defined(HAVE_FSEEKO)
375 int fseeko(FILE *, off_t
, int);
378 #if !defined(HAVE_INET_NTOP)
379 const char *inet_ntop(int, const void *, char *, socklen_t
);
382 #if !defined(HAVE_INET_PTON)
383 int inet_pton(int, const char *, void *);
386 #if !defined(HAVE_MKSTEMP)
390 #if !defined(HAVE_SETPROGNAME)
391 const char *getprogname(void);
392 void setprogname(const char *);
395 #if !defined(HAVE_SNPRINTF)
396 int snprintf(char *, size_t, const char *, ...);
399 #if !defined(HAVE_STRDUP)
400 char *strdup(const char *);
403 #if !defined(HAVE_STRERROR)
407 #if !defined(HAVE_STRPTIME) || !HAVE_DECL_STRPTIME
408 char *strptime(const char *, const char *, struct tm
*);
411 #if defined(HAVE_PRINTF_LONG_LONG) && defined(HAVE_LONG_LONG_INT)
412 # if !defined(HAVE_STRTOLL)
413 long long strtoll(const char *, char **, int);
415 # if !defined(LLONG_MIN)
416 # define LLONG_MIN (-0x7fffffffffffffffLL-1)
418 # if !defined(LLONG_MAX)
419 # define LLONG_MAX (0x7fffffffffffffffLL)
421 #else /* !(defined(HAVE_PRINTF_LONG_LONG) && defined(HAVE_LONG_LONG_INT)) */
422 # define NO_LONG_LONG 1
423 #endif /* !(defined(HAVE_PRINTF_LONG_LONG) && defined(HAVE_LONG_LONG_INT)) */
425 #if !defined(HAVE_TIMEGM)
426 time_t timegm(struct tm
*);
429 #if !defined(HAVE_STRLCAT)
430 size_t strlcat(char *, const char *, size_t);
433 #if !defined(HAVE_STRLCPY)
434 size_t strlcpy(char *, const char *, size_t);
437 #if !defined(HAVE_STRSEP)
438 char *strsep(char **stringp
, const char *delim
);
441 #if !defined(HAVE_UTIMES)
442 int utimes(const char *, const struct timeval
*);
445 #if !defined(HAVE_MEMMOVE)
446 # define memmove(a,b,c) bcopy((b),(a),(c))
447 /* XXX: add others #defines for borken systems? */
450 #if defined(HAVE_GETPASSPHRASE)
451 # define getpass getpassphrase
455 # define MIN(a, b) ((a) < (b) ? (a) : (b))
458 # define MAX(a, b) ((a) < (b) ? (b) : (a))
461 #if !defined(timersub)
462 # define timersub(tvp, uvp, vvp) \
464 (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
465 (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
466 if ((vvp)->tv_usec < 0) { \
468 (vvp)->tv_usec += 1000000; \
473 #if !defined(S_ISLNK)
474 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
477 #define EPOCH_YEAR 1970
478 #define SECSPERHOUR 3600
479 #define SECSPERDAY 86400
480 #define TM_YEAR_BASE 1900
482 #if defined(USE_SOCKS) /* (Dante) SOCKS5 */
483 #define connect Rconnect
485 #define getsockname Rgetsockname
486 #define getpeername Rgetpeername
487 #define accept Raccept
488 #define rresvport Rrresvport
489 #define bindresvport Rbindresvport
490 #define gethostbyname Rgethostbyname
491 #define gethostbyname2 Rgethostbyname2
492 #define sendto Rsendto
493 #define recvfrom Rrecvfrom
494 #define recvfrom Rrecvfrom
496 #define writev Rwritev
498 #define sendmsg Rsendmsg
502 #define recvmsg Rrecvmsg
503 #define getaddrinfo Rgetaddrinfo
504 #define getipnodebyname Rgetipnodebyname
505 #endif /* defined(USE_SOCKS) */
509 * Compatibility for stuff in NetBSD <sys/cdefs.h>
517 #define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))