"Fossies" - the Fresh Open Source Software Archive

Member "tnftp-20200705/tnftp.h" (4 Jul 2020, 11885 Bytes) of package /linux/privat/tnftp-20200705.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "tnftp.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 20151004_vs_20200705.

    1 /*  $NetBSD: tnftp.h,v 1.39 2020/07/04 14:47:35 lukem Exp $ */
    2 
    3 #ifndef TNFTP_H
    4 #define TNFTP_H 1
    5 
    6 #define FTP_PRODUCT PACKAGE_NAME
    7 #define FTP_VERSION PACKAGE_VERSION
    8 
    9 #include "tnftp_config.h"
   10 
   11 #include <assert.h>
   12 #include <stdio.h>
   13 #include <ctype.h>
   14 #include <errno.h>
   15 
   16 #if defined(HAVE_SYS_TYPES_H)
   17 # include <sys/types.h>
   18 #endif
   19 #if defined(STDC_HEADERS)
   20 # include <stdarg.h>
   21 # include <stdlib.h>
   22 # include <string.h>
   23 #endif
   24 #if defined(HAVE_LIBGEN_H)
   25 # include <libgen.h>
   26 #endif
   27 #if defined(HAVE_UNISTD_H)
   28 # include <unistd.h>
   29 #endif
   30 #if defined(HAVE_POLL_H)
   31 # include <poll.h>
   32 #elif defined(HAVE_SYS_POLL_H)
   33 # include <sys/poll.h>
   34 #endif
   35 #if defined(HAVE_SYS_SOCKET_H)
   36 # include <sys/socket.h>
   37 #endif
   38 #if defined(HAVE_NETINET_IN_H)
   39 # include <netinet/in.h>
   40 #endif
   41 #if defined(HAVE_NETINET_IN_SYSTM_H)
   42 # include <netinet/in_systm.h>
   43 #endif
   44 #if defined(HAVE_NETINET_IP_H)
   45 # include <netinet/ip.h>
   46 #endif
   47 #if defined(HAVE_NETINET_TCP_H)
   48 # include <netinet/tcp.h>
   49 #endif
   50 #if defined(HAVE_NETDB_H)
   51 # if HAVE_DECL_AI_NUMERICHOST
   52 #  include <netdb.h>
   53 # else  /* !HAVE_DECL_AI_NUMERICHOST */
   54 #  define getaddrinfo non_rfc2553_getaddrinfo
   55 #  include <netdb.h>
   56 #  undef getaddrinfo
   57 # endif /* !HAVE_DECL_AI_NUMERICHOST */
   58 #endif
   59 #if defined(HAVE_ARPA_INET_H)
   60 # include <arpa/inet.h>
   61 #endif
   62 #if defined(HAVE_DIRENT_H)
   63 # include <dirent.h>
   64 #else
   65 # define dirent direct
   66 # if defined(HAVE_SYS_NDIR_H)
   67 #  include <sys/ndir.h>
   68 # endif
   69 # if defined(HAVE_SYS_DIR_H)
   70 #  include <sys/dir.h>
   71 # endif
   72 # if defined(HAVE_NDIR_H)
   73 #  include <ndir.h>
   74 # endif
   75 #endif
   76 #if defined(HAVE_SYS_UIO_H)
   77 # include <sys/uio.h>
   78 #endif
   79 
   80 #if defined(HAVE_SYS_IOCTL_H)
   81 # include <sys/ioctl.h>
   82 #endif
   83 #if defined(HAVE_SYS_PARAM_H)
   84 # include <sys/param.h>
   85 #endif
   86 #if defined(HAVE_SYS_STAT_H)
   87 # include <sys/stat.h>
   88 #endif
   89 #if defined(HAVE_SYS_SYSLIMITS_H)
   90 # include <sys/syslimits.h>
   91 #endif
   92 #if defined(HAVE_SYS_WAIT_H)
   93 # include <sys/wait.h>
   94 #endif
   95 
   96 #if defined(HAVE_ARPA_FTP_H)
   97 # include <arpa/ftp.h>
   98 #endif
   99 
  100 #if defined(HAVE_FCNTL_H)
  101 # include <fcntl.h>
  102 #endif
  103 #if defined(HAVE_LIMITS_H)
  104 # include <limits.h>
  105 #endif
  106 #if defined(HAVE_LOCALE_H)
  107 # include <locale.h>
  108 #endif
  109 #if defined(HAVE_PWD_H)
  110 # include <pwd.h>
  111 #endif
  112 #if defined(HAVE_SETJMP_H)
  113 # include <setjmp.h>
  114 #endif
  115 #if defined(HAVE_SIGNAL_H)
  116 # include <signal.h>
  117 #endif
  118 #if defined(HAVE_STDDEF_H)
  119 # include <stddef.h>
  120 #endif
  121 #if defined(HAVE_TERMIOS_H)
  122 # include <termios.h>
  123 #endif
  124 
  125 #if defined(HAVE_POLL)
  126 /* we use poll */
  127 #elif defined(HAVE_SELECT)
  128 /* we use select */
  129 #else /* !defined(HAVE_POLL) && !defined(HAVE_SELECT) */
  130 # error "no poll() or select() found"
  131 #endif
  132 #if !defined(POLLIN)
  133 # define POLLIN     0x0001
  134 #endif
  135 #if !defined(POLLOUT)
  136 # define POLLOUT    0x0004
  137 #endif
  138 #if !defined(POLLRDNORM)
  139 # define POLLRDNORM 0x0040
  140 #endif
  141 #if !defined(POLLWRNORM)
  142 # define POLLWRNORM POLLOUT
  143 #endif
  144 #if !defined(POLLRDBAND)
  145 # define POLLRDBAND 0x0080
  146 #endif
  147 #if !defined(INFTIM)
  148 # define INFTIM -1
  149 #endif
  150 #if !defined(HAVE_STRUCT_POLLFD)
  151 struct pollfd {
  152     int fd;
  153     short   events;
  154     short   revents;
  155 };
  156 #endif
  157 
  158 #if defined(TIME_WITH_SYS_TIME)
  159 # include <sys/time.h>
  160 # include <time.h>
  161 #else
  162 # if defined(HAVE_SYS_TIME_H)
  163 #  include <sys/time.h>
  164 # else
  165 #  include <time.h>
  166 # endif
  167 #endif
  168 
  169 #if defined(HAVE_ERR_H)
  170 # include <err.h>
  171 #endif
  172 
  173 #if defined(USE_GLOB_H) /* not set by configure; used by other build systems */
  174 # include <glob.h>
  175 #else
  176 # include "ftpglob.h"
  177 #endif
  178 
  179 #if defined(HAVE_PATHS_H)
  180 # include <paths.h>
  181 #endif
  182 #if !defined(_PATH_BSHELL)
  183 # define _PATH_BSHELL   "/bin/sh"
  184 #endif
  185 #if !defined(_PATH_TMP)
  186 # define _PATH_TMP  "/tmp/"
  187 #endif
  188 
  189 typedef struct _stringlist {
  190     char    **sl_str;
  191     size_t    sl_max;
  192     size_t    sl_cur;
  193 } StringList;
  194 
  195 StringList *sl_init(void);
  196 int  sl_add(StringList *, char *);
  197 void     sl_free(StringList *, int);
  198 char    *sl_find(StringList *, char *);
  199 
  200 #if defined(HAVE_TERMCAP_H)
  201 # include <termcap.h>
  202 #else
  203 int  tgetent(char *, const char *);
  204 char    *tgetstr(const char *, char **);
  205 int  tgetflag(const char *);
  206 int  tgetnum(const char *);
  207 char    *tgoto(const char *, int, int);
  208 void     tputs(const char *, int, int (*)(int));
  209 #endif /* !HAVE_TERMCAP_H */
  210 
  211 #if defined(HAVE_VIS_H) && defined(HAVE_STRVIS) && defined(HAVE_STRUNVIS)
  212 # include <vis.h>
  213 #else
  214 # include "ftpvis.h"
  215 #endif
  216 
  217 #if !defined(HAVE_IN_PORT_T)
  218 typedef unsigned short in_port_t;
  219 #endif
  220 
  221 #if !defined(HAVE_SA_FAMILY_T)
  222 typedef unsigned short sa_family_t;
  223 #endif
  224 
  225 #if !defined(HAVE_SOCKLEN_T)
  226 typedef unsigned int socklen_t;
  227 #endif
  228 
  229 #if defined(USE_INET6)
  230 # define INET6
  231 #endif
  232 
  233 #if !HAVE_DECL_AI_NUMERICHOST
  234 
  235                 /* RFC 2553 */
  236 #undef  EAI_ADDRFAMILY
  237 #define EAI_ADDRFAMILY   1  /* address family for hostname not supported */
  238 #undef  EAI_AGAIN
  239 #define EAI_AGAIN    2  /* temporary failure in name resolution */
  240 #undef  EAI_BADFLAGS
  241 #define EAI_BADFLAGS     3  /* invalid value for ai_flags */
  242 #undef  EAI_FAIL
  243 #define EAI_FAIL     4  /* non-recoverable failure in name resolution */
  244 #undef  EAI_FAMILY
  245 #define EAI_FAMILY   5  /* ai_family not supported */
  246 #undef  EAI_MEMORY
  247 #define EAI_MEMORY   6  /* memory allocation failure */
  248 #undef  EAI_NODATA
  249 #define EAI_NODATA   7  /* no address associated with hostname */
  250 #undef  EAI_NONAME
  251 #define EAI_NONAME   8  /* hostname nor servname provided, or not known */
  252 #undef  EAI_SERVICE
  253 #define EAI_SERVICE  9  /* servname not supported for ai_socktype */
  254 #undef  EAI_SOCKTYPE
  255 #define EAI_SOCKTYPE    10  /* ai_socktype not supported */
  256 #undef  EAI_SYSTEM
  257 #define EAI_SYSTEM  11  /* system error returned in errno */
  258 
  259                 /* KAME extensions? */
  260 #undef  EAI_BADHINTS
  261 #define EAI_BADHINTS    12
  262 #undef  EAI_PROTOCOL
  263 #define EAI_PROTOCOL    13
  264 #undef  EAI_MAX
  265 #define EAI_MAX     14
  266 
  267                 /* RFC 2553 */
  268 #undef  NI_MAXHOST
  269 #define NI_MAXHOST  1025
  270 #undef  NI_MAXSERV
  271 #define NI_MAXSERV  32
  272 
  273 #undef  NI_NOFQDN
  274 #define NI_NOFQDN   0x00000001
  275 #undef  NI_NUMERICHOST
  276 #define NI_NUMERICHOST  0x00000002
  277 #undef  NI_NAMEREQD
  278 #define NI_NAMEREQD 0x00000004
  279 #undef  NI_NUMERICSERV
  280 #define NI_NUMERICSERV  0x00000008
  281 #undef  NI_DGRAM
  282 #define NI_DGRAM    0x00000010
  283 
  284                 /* RFC 2553 */
  285 #undef  AI_PASSIVE
  286 #define AI_PASSIVE  0x00000001 /* get address to use bind() */
  287 #undef  AI_CANONNAME
  288 #define AI_CANONNAME    0x00000002 /* fill ai_canonname */
  289 
  290                 /* KAME extensions ? */
  291 #undef  AI_NUMERICHOST
  292 #define AI_NUMERICHOST  0x00000004 /* prevent name resolution */
  293 #undef  AI_MASK
  294 #define AI_MASK     (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
  295 
  296                 /* RFC 2553 */
  297 #undef  AI_ALL
  298 #define AI_ALL      0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
  299 #undef  AI_V4MAPPED_CFG
  300 #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
  301 #undef  AI_ADDRCONFIG
  302 #define AI_ADDRCONFIG   0x00000400 /* only if any address is assigned */
  303 #undef  AI_V4MAPPED
  304 #define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
  305 
  306 #endif /* !HAVE_DECL_AI_NUMERICHOST */
  307 
  308 
  309 #if !HAVE_DECL_AI_NUMERICHOST && !defined(HAVE_STRUCT_ADDRINFO) \
  310     && !defined(USE_SOCKS)
  311 
  312 struct addrinfo {
  313     int     ai_flags;   /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
  314     int     ai_family;  /* PF_xxx */
  315     int     ai_socktype;    /* SOCK_xxx */
  316     int     ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
  317     socklen_t   ai_addrlen; /* length of ai_addr */
  318     char        *ai_canonname;  /* canonical name for hostname */
  319     struct sockaddr *ai_addr;   /* binary address */
  320     struct addrinfo *ai_next;   /* next structure in linked list */
  321 };
  322 
  323 int getaddrinfo(const char *, const char *,
  324         const struct addrinfo *, struct addrinfo **);
  325 int getnameinfo(const struct sockaddr *, socklen_t,
  326         char *, size_t, char *, size_t, int);
  327 void    freeaddrinfo(struct addrinfo *);
  328 const char *gai_strerror(int);
  329 
  330 #endif /* !HAVE_DECL_AI_NUMERICHOST && !defined(HAVE_STRUCT_ADDRINFO) \
  331     && !defined(USE_SOCKS) */
  332 
  333 #if !defined(HAVE_STRUCT_DIRENT_D_NAMLEN)
  334 # define DIRENT_MISSING_D_NAMLEN
  335 #endif
  336 
  337 #if !HAVE_DECL_H_ERRNO
  338 extern int  h_errno;
  339 #endif
  340 #define HAVE_H_ERRNO    1       /* XXX: an assumption for now... */
  341 
  342 #if !HAVE_DECL_FCLOSE
  343 int fclose(FILE *);
  344 #endif
  345 
  346 #if !HAVE_DECL_GETPASS
  347 char    *getpass(const char *);
  348 #endif
  349 
  350 #if !HAVE_DECL_OPTARG
  351 extern char    *optarg;
  352 #endif
  353 
  354 #if !HAVE_DECL_OPTIND
  355 extern int  optind;
  356 #endif
  357 
  358 #if !HAVE_DECL_PCLOSE
  359 int pclose(FILE *);
  360 #endif
  361 
  362 #if !HAVE_DECL_DIRNAME
  363 char    *dirname(char *);
  364 #endif
  365 
  366 #if !defined(HAVE_ERR)
  367 void    err(int, const char *, ...);
  368 void    errx(int, const char *, ...);
  369 void    warn(const char *, ...);
  370 void    warnx(const char *, ...);
  371 #endif
  372 
  373 #if !defined(HAVE_FGETLN)
  374 char   *fgetln(FILE *, size_t *);
  375 #endif
  376 
  377 #if !defined(HAVE_FSEEKO)
  378 int fseeko(FILE *, off_t, int);
  379 #endif
  380 
  381 #if !defined(HAVE_INET_NTOP)
  382 const char *inet_ntop(int, const void *, char *, socklen_t);
  383 #endif
  384 
  385 #if !defined(HAVE_INET_PTON)
  386 int inet_pton(int, const char *, void *);
  387 #endif
  388 
  389 #if !defined(HAVE_MKSTEMP)
  390 int mkstemp(char *);
  391 #endif
  392 
  393 #if !defined(HAVE_SETPROGNAME)
  394 const char *getprogname(void);
  395 void    setprogname(const char *);
  396 #endif
  397 
  398 #if !defined(HAVE_SNPRINTF)
  399 int snprintf(char *, size_t, const char *, ...);
  400 #endif
  401 
  402 #if !defined(HAVE_STRDUP)
  403 char   *strdup(const char *);
  404 #endif
  405 
  406 #if !defined(HAVE_STRERROR)
  407 char   *strerror(int);
  408 #endif
  409 
  410 #if !defined(HAVE_STRPTIME) || !HAVE_DECL_STRPTIME
  411 char   *strptime(const char *, const char *, struct tm *);
  412 #endif
  413 
  414 #if defined(HAVE_PRINTF_LONG_LONG) && defined(HAVE_LONG_LONG_INT)
  415 # if !defined(HAVE_STRTOLL)
  416 long long strtoll(const char *, char **, int);
  417 # endif
  418 # if !defined(LLONG_MIN)
  419 #  define LLONG_MIN (-0x7fffffffffffffffLL-1)
  420 # endif
  421 # if !defined(LLONG_MAX)
  422 #  define LLONG_MAX (0x7fffffffffffffffLL)
  423 # endif
  424 #else  /* !(defined(HAVE_PRINTF_LONG_LONG) && defined(HAVE_LONG_LONG_INT)) */
  425 # define NO_LONG_LONG   1
  426 #endif /* !(defined(HAVE_PRINTF_LONG_LONG) && defined(HAVE_LONG_LONG_INT)) */
  427 
  428 #if !defined(HAVE_TIMEGM)
  429 time_t  timegm(struct tm *);
  430 #endif
  431 
  432 #if !defined(HAVE_STRLCAT)
  433 size_t  strlcat(char *, const char *, size_t);
  434 #endif
  435 
  436 #if !defined(HAVE_STRLCPY)
  437 size_t  strlcpy(char *, const char *, size_t);
  438 #endif
  439 
  440 #if !defined(HAVE_STRSEP)
  441 char   *strsep(char **stringp, const char *delim);
  442 #endif
  443 
  444 #if !defined(HAVE_UTIMES)
  445 int utimes(const char *, const struct timeval *);
  446 #endif
  447 
  448 #if !defined(HAVE_VASPRINTF)
  449 int vasprintf(char **, const char *, va_list);
  450 #endif
  451 
  452 #if !defined(HAVE_MEMMOVE)
  453 # define memmove(a,b,c) bcopy((b),(a),(c))
  454     /* XXX: add others #defines for borken systems? */
  455 #endif
  456 
  457 #if defined(HAVE_GETPASSPHRASE)
  458 # define getpass getpassphrase
  459 #endif
  460 
  461 #if !defined(MIN)
  462 # define MIN(a, b)  ((a) < (b) ? (a) : (b))
  463 #endif
  464 #if !defined(MAX)
  465 # define MAX(a, b)  ((a) < (b) ? (b) : (a))
  466 #endif
  467 
  468 #if !defined(timersub)
  469 # define timersub(tvp, uvp, vvp)                    \
  470     do {                                \
  471         (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;      \
  472         (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;   \
  473         if ((vvp)->tv_usec < 0) {               \
  474             (vvp)->tv_sec--;                \
  475             (vvp)->tv_usec += 1000000;          \
  476         }                           \
  477     } while (0)
  478 #endif
  479 
  480 #if !defined(S_ISLNK)
  481 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
  482 #endif
  483 
  484 #define EPOCH_YEAR  1970
  485 #define SECSPERHOUR 3600
  486 #define SECSPERDAY  86400
  487 #define TM_YEAR_BASE    1900
  488 
  489 #if defined(USE_SOCKS)      /* (Dante) SOCKS5 */
  490 #define connect     Rconnect
  491 #define bind        Rbind
  492 #define getsockname Rgetsockname
  493 #define getpeername Rgetpeername
  494 #define accept      Raccept
  495 #define rresvport   Rrresvport
  496 #define bindresvport    Rbindresvport
  497 #define gethostbyname   Rgethostbyname
  498 #define gethostbyname2  Rgethostbyname2
  499 #define sendto      Rsendto
  500 #define recvfrom    Rrecvfrom
  501 #define recvfrom    Rrecvfrom
  502 #define write       Rwrite
  503 #define writev      Rwritev
  504 #define send        Rsend
  505 #define sendmsg     Rsendmsg
  506 #define read        Rread
  507 #define readv       Rreadv
  508 #define recv        Rrecv
  509 #define recvmsg     Rrecvmsg
  510 #define getaddrinfo Rgetaddrinfo
  511 #define getipnodebyname Rgetipnodebyname
  512 #endif /* defined(USE_SOCKS) */
  513 
  514 
  515 /*
  516  * Compatibility for stuff in NetBSD <sys/cdefs.h>
  517  */
  518 #undef __dead
  519 #define __dead
  520 
  521 #ifdef __UNCONST
  522 #undef __UNCONST
  523 #endif
  524 #define __UNCONST(a)    ((void *)(unsigned long)(const void *)(a))
  525 
  526 #ifdef __UNVOLATILE
  527 #undef __UNVOLATILE
  528 #endif
  529 #define __UNVOLATILE(a) ((void *)(unsigned long)(volatile void *)(a))
  530 
  531 #endif /* TNFTP_H */