Blame gl/netdb.in.h

Packit aea12f
/* Provide a netdb.h header file for systems lacking it (read: MinGW).
Packit Service 991b93
   Copyright (C) 2008-2020 Free Software Foundation, Inc.
Packit aea12f
   Written by Simon Josefsson.
Packit aea12f
Packit aea12f
   This program is free software; you can redistribute it and/or modify
Packit Service 991b93
   it under the terms of the GNU Lesser General Public License as published by
Packit Service 991b93
   the Free Software Foundation; either version 2.1, or (at your option)
Packit aea12f
   any later version.
Packit aea12f
Packit aea12f
   This program is distributed in the hope that it will be useful,
Packit aea12f
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit aea12f
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 991b93
   GNU Lesser General Public License for more details.
Packit aea12f
Packit Service 991b93
   You should have received a copy of the GNU Lesser General Public License
Packit aea12f
   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
Packit aea12f
Packit aea12f
/* This file is supposed to be used on platforms that lack <netdb.h>.
Packit aea12f
   It is intended to provide definitions and prototypes needed by an
Packit aea12f
   application.  */
Packit aea12f
Packit aea12f
#ifndef _@GUARD_PREFIX@_NETDB_H
Packit aea12f
Packit aea12f
#if __GNUC__ >= 3
Packit aea12f
@PRAGMA_SYSTEM_HEADER@
Packit aea12f
#endif
Packit aea12f
@PRAGMA_COLUMNS@
Packit aea12f
Packit aea12f
#if @HAVE_NETDB_H@
Packit aea12f
Packit aea12f
/* The include_next requires a split double-inclusion guard.  */
Packit aea12f
# @INCLUDE_NEXT@ @NEXT_NETDB_H@
Packit aea12f
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#ifndef _@GUARD_PREFIX@_NETDB_H
Packit aea12f
#define _@GUARD_PREFIX@_NETDB_H
Packit aea12f
Packit aea12f
/* Get <netdb.h> definitions such as 'socklen_t' on IRIX 6.5 and OSF/1 4.0 and
Packit aea12f
   'struct hostent' on MinGW.  */
Packit aea12f
#include <sys/socket.h>
Packit aea12f
Packit aea12f
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
Packit aea12f
Packit aea12f
/* The definition of _GL_ARG_NONNULL is copied here.  */
Packit aea12f
Packit aea12f
/* The definition of _GL_WARN_ON_USE is copied here.  */
Packit aea12f
Packit aea12f
/* Declarations for a platform that lacks <netdb.h>, or where it is
Packit aea12f
   incomplete.  */
Packit aea12f
Packit aea12f
#if @GNULIB_GETADDRINFO@
Packit aea12f
Packit aea12f
# if !@HAVE_STRUCT_ADDRINFO@
Packit aea12f
Packit aea12f
#  ifdef __cplusplus
Packit aea12f
extern "C" {
Packit aea12f
#  endif
Packit aea12f
Packit aea12f
#  if !GNULIB_defined_struct_addrinfo
Packit aea12f
/* Structure to contain information about address of a service provider.  */
Packit aea12f
struct addrinfo
Packit aea12f
{
Packit aea12f
  int ai_flags;                 /* Input flags.  */
Packit aea12f
  int ai_family;                /* Protocol family for socket.  */
Packit aea12f
  int ai_socktype;              /* Socket type.  */
Packit aea12f
  int ai_protocol;              /* Protocol for socket.  */
Packit aea12f
  socklen_t ai_addrlen;         /* Length of socket address.  */
Packit aea12f
  struct sockaddr *ai_addr;     /* Socket address for socket.  */
Packit aea12f
  char *ai_canonname;           /* Canonical name for service location.  */
Packit aea12f
  struct addrinfo *ai_next;     /* Pointer to next in list.  */
Packit aea12f
};
Packit aea12f
#   define GNULIB_defined_struct_addrinfo 1
Packit aea12f
#  endif
Packit aea12f
Packit aea12f
#  ifdef __cplusplus
Packit aea12f
}
Packit aea12f
#  endif
Packit aea12f
Packit aea12f
# endif
Packit aea12f
Packit aea12f
/* Possible values for 'ai_flags' field in 'addrinfo' structure.  */
Packit aea12f
# ifndef AI_PASSIVE
Packit aea12f
#  define AI_PASSIVE    0x0001  /* Socket address is intended for 'bind'.  */
Packit aea12f
# endif
Packit aea12f
# ifndef AI_CANONNAME
Packit aea12f
#  define AI_CANONNAME  0x0002  /* Request for canonical name.  */
Packit aea12f
# endif
Packit aea12f
# ifndef AI_NUMERICSERV
Packit aea12f
#  define AI_NUMERICSERV        0x0400  /* Don't use name resolution.  */
Packit aea12f
# endif
Packit aea12f
Packit aea12f
# if 0
Packit aea12f
#  define AI_NUMERICHOST        0x0004  /* Don't use name resolution.  */
Packit aea12f
# endif
Packit aea12f
Packit aea12f
/* These symbolic constants are required to be present by POSIX, but
Packit aea12f
   our getaddrinfo replacement doesn't use them (yet).  Setting them
Packit aea12f
   to 0 on systems that doesn't have them avoids causing problems for
Packit aea12f
   system getaddrinfo implementations that would be confused by
Packit aea12f
   unknown values.  */
Packit aea12f
# ifndef AI_V4MAPPED
Packit aea12f
#  define AI_V4MAPPED    0 /* 0x0008: IPv4 mapped addresses are acceptable.  */
Packit aea12f
# endif
Packit aea12f
# ifndef AI_ALL
Packit aea12f
#  define AI_ALL         0 /* 0x0010: Return IPv4 mapped and IPv6 addresses. */
Packit aea12f
# endif
Packit aea12f
# ifndef AI_ADDRCONFIG
Packit aea12f
#  define AI_ADDRCONFIG  0 /* 0x0020: Use configuration of this host to choose
Packit aea12f
                                      returned address type.  */
Packit aea12f
# endif
Packit aea12f
Packit aea12f
/* Error values for 'getaddrinfo' function.  */
Packit aea12f
# ifndef EAI_BADFLAGS
Packit aea12f
#  define EAI_BADFLAGS    -1    /* Invalid value for 'ai_flags' field.  */
Packit aea12f
#  define EAI_NONAME      -2    /* NAME or SERVICE is unknown.  */
Packit aea12f
#  define EAI_AGAIN       -3    /* Temporary failure in name resolution.  */
Packit aea12f
#  define EAI_FAIL        -4    /* Non-recoverable failure in name res.  */
Packit aea12f
#  define EAI_NODATA      -5    /* No address associated with NAME.  */
Packit aea12f
#  define EAI_FAMILY      -6    /* 'ai_family' not supported.  */
Packit aea12f
#  define EAI_SOCKTYPE    -7    /* 'ai_socktype' not supported.  */
Packit aea12f
#  define EAI_SERVICE     -8    /* SERVICE not supported for 'ai_socktype'.  */
Packit aea12f
#  define EAI_MEMORY      -10   /* Memory allocation failure.  */
Packit aea12f
# endif
Packit aea12f
Packit aea12f
/* Since EAI_NODATA is deprecated by RFC3493, some systems (at least
Packit aea12f
   FreeBSD, which does define EAI_BADFLAGS) have removed the definition
Packit aea12f
   in favor of EAI_NONAME.  */
Packit aea12f
# if !defined EAI_NODATA && defined EAI_NONAME
Packit aea12f
#  define EAI_NODATA EAI_NONAME
Packit aea12f
# endif
Packit aea12f
Packit aea12f
# ifndef EAI_OVERFLOW
Packit aea12f
/* Not defined on mingw32 and Haiku. */
Packit aea12f
#  define EAI_OVERFLOW    -12   /* Argument buffer overflow.  */
Packit aea12f
# endif
Packit aea12f
# ifndef EAI_ADDRFAMILY
Packit aea12f
/* Not defined on mingw32. */
Packit aea12f
#  define EAI_ADDRFAMILY  -9    /* Address family for NAME not supported.  */
Packit aea12f
# endif
Packit aea12f
# ifndef EAI_SYSTEM
Packit aea12f
/* Not defined on mingw32. */
Packit aea12f
#  define EAI_SYSTEM      -11   /* System error returned in 'errno'.  */
Packit aea12f
# endif
Packit aea12f
Packit aea12f
# if 0
Packit aea12f
/* The commented out definitions below are not yet implemented in the
Packit aea12f
   GNULIB getaddrinfo() replacement, so are not yet needed.
Packit aea12f
Packit aea12f
   If they are restored, be sure to protect the definitions with #ifndef.  */
Packit aea12f
#  ifndef EAI_INPROGRESS
Packit aea12f
#   define EAI_INPROGRESS       -100    /* Processing request in progress.  */
Packit aea12f
#   define EAI_CANCELED         -101    /* Request canceled.  */
Packit aea12f
#   define EAI_NOTCANCELED      -102    /* Request not canceled.  */
Packit aea12f
#   define EAI_ALLDONE          -103    /* All requests done.  */
Packit aea12f
#   define EAI_INTR             -104    /* Interrupted by a signal.  */
Packit aea12f
#   define EAI_IDN_ENCODE       -105    /* IDN encoding failed.  */
Packit aea12f
#  endif
Packit aea12f
# endif
Packit aea12f
Packit aea12f
/* Translate name of a service location and/or a service name to set of
Packit aea12f
   socket addresses.
Packit Service 991b93
   For more details, see the POSIX:2008 specification
Packit Service 991b93
   <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>.  */
Packit Service 991b93
# if @REPLACE_GETADDRINFO@
Packit Service 991b93
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit Service 991b93
#   undef getaddrinfo
Packit Service 991b93
#   define getaddrinfo rpl_getaddrinfo
Packit Service 991b93
#  endif
Packit Service 991b93
_GL_FUNCDECL_RPL (getaddrinfo, int,
Packit Service 991b93
                  (const char *restrict nodename,
Packit Service 991b93
                   const char *restrict servname,
Packit Service 991b93
                   const struct addrinfo *restrict hints,
Packit Service 991b93
                   struct addrinfo **restrict res)
Packit Service 991b93
                  _GL_ARG_NONNULL ((4)));
Packit Service 991b93
_GL_CXXALIAS_RPL (getaddrinfo, int,
Packit Service 991b93
                  (const char *restrict nodename,
Packit Service 991b93
                   const char *restrict servname,
Packit Service 991b93
                   const struct addrinfo *restrict hints,
Packit Service 991b93
                   struct addrinfo **restrict res));
Packit Service 991b93
# else
Packit Service 991b93
#  if !@HAVE_DECL_GETADDRINFO@
Packit aea12f
_GL_FUNCDECL_SYS (getaddrinfo, int,
Packit aea12f
                  (const char *restrict nodename,
Packit aea12f
                   const char *restrict servname,
Packit aea12f
                   const struct addrinfo *restrict hints,
Packit aea12f
                   struct addrinfo **restrict res)
Packit aea12f
                  _GL_ARG_NONNULL ((4)));
Packit Service 991b93
#  endif
Packit aea12f
_GL_CXXALIAS_SYS (getaddrinfo, int,
Packit aea12f
                  (const char *restrict nodename,
Packit aea12f
                   const char *restrict servname,
Packit aea12f
                   const struct addrinfo *restrict hints,
Packit aea12f
                   struct addrinfo **restrict res));
Packit Service 991b93
# endif
Packit aea12f
_GL_CXXALIASWARN (getaddrinfo);
Packit aea12f
Packit aea12f
/* Free 'addrinfo' structure AI including associated storage.
Packit Service 991b93
   For more details, see the POSIX:2008 specification
Packit Service 991b93
   <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>.  */
Packit Service 991b93
# if @REPLACE_GETADDRINFO@
Packit Service 991b93
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit Service 991b93
#   undef freeaddrinfo
Packit Service 991b93
#   define freeaddrinfo rpl_freeaddrinfo
Packit Service 991b93
#  endif
Packit Service 991b93
_GL_FUNCDECL_RPL (freeaddrinfo, void, (struct addrinfo *ai)
Packit Service 991b93
                                      _GL_ARG_NONNULL ((1)));
Packit Service 991b93
_GL_CXXALIAS_RPL (freeaddrinfo, void, (struct addrinfo *ai));
Packit Service 991b93
# else
Packit Service 991b93
#  if !@HAVE_DECL_FREEADDRINFO@
Packit aea12f
_GL_FUNCDECL_SYS (freeaddrinfo, void, (struct addrinfo *ai)
Packit aea12f
                                      _GL_ARG_NONNULL ((1)));
Packit Service 991b93
#  endif
Packit aea12f
_GL_CXXALIAS_SYS (freeaddrinfo, void, (struct addrinfo *ai));
Packit Service 991b93
# endif
Packit aea12f
_GL_CXXALIASWARN (freeaddrinfo);
Packit aea12f
Packit aea12f
# if @REPLACE_GAI_STRERROR@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef gai_strerror
Packit aea12f
#   define gai_strerror rpl_gai_strerror
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (gai_strerror, const char *, (int ecode));
Packit aea12f
_GL_CXXALIAS_RPL (gai_strerror, const char *, (int ecode));
Packit aea12f
# else
Packit aea12f
#  if !@HAVE_DECL_GAI_STRERROR@
Packit aea12f
/* Convert error return from getaddrinfo() to a string.
Packit Service 991b93
   For more details, see the POSIX:2008 specification
Packit Service 991b93
   <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gai_strerror.html>.  */
Packit aea12f
_GL_FUNCDECL_SYS (gai_strerror, const char *, (int ecode));
Packit aea12f
#  endif
Packit aea12f
_GL_CXXALIAS_SYS (gai_strerror, const char *, (int ecode));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (gai_strerror);
Packit aea12f
Packit aea12f
# if !@HAVE_DECL_GETNAMEINFO@
Packit aea12f
/* Convert socket address to printable node and service names.
Packit Service 991b93
   For more details, see the POSIX:2008 specification
Packit Service 991b93
   <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getnameinfo.html>.  */
Packit aea12f
_GL_FUNCDECL_SYS (getnameinfo, int,
Packit aea12f
                  (const struct sockaddr *restrict sa, socklen_t salen,
Packit aea12f
                   char *restrict node, socklen_t nodelen,
Packit aea12f
                   char *restrict service, socklen_t servicelen,
Packit aea12f
                   int flags)
Packit aea12f
                  _GL_ARG_NONNULL ((1)));
Packit aea12f
# endif
Packit aea12f
/* Need to cast, because on glibc systems, the seventh parameter is
Packit aea12f
                        unsigned int flags.  */
Packit aea12f
_GL_CXXALIAS_SYS_CAST (getnameinfo, int,
Packit aea12f
                       (const struct sockaddr *restrict sa, socklen_t salen,
Packit aea12f
                        char *restrict node, socklen_t nodelen,
Packit aea12f
                        char *restrict service, socklen_t servicelen,
Packit aea12f
                        int flags));
Packit aea12f
_GL_CXXALIASWARN (getnameinfo);
Packit aea12f
Packit aea12f
/* Possible flags for getnameinfo.  */
Packit aea12f
# ifndef NI_NUMERICHOST
Packit aea12f
#  define NI_NUMERICHOST 1
Packit aea12f
# endif
Packit aea12f
# ifndef NI_NUMERICSERV
Packit aea12f
#  define NI_NUMERICSERV 2
Packit aea12f
# endif
Packit aea12f
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
Packit aea12f
# undef getaddrinfo
Packit aea12f
# if HAVE_RAW_DECL_GETADDRINFO
Packit aea12f
_GL_WARN_ON_USE (getaddrinfo, "getaddrinfo is unportable - "
Packit aea12f
                 "use gnulib module getaddrinfo for portability");
Packit aea12f
# endif
Packit aea12f
Packit aea12f
# undef freeaddrinfo
Packit aea12f
# if HAVE_RAW_DECL_FREEADDRINFO
Packit aea12f
_GL_WARN_ON_USE (freeaddrinfo, "freeaddrinfo is unportable - "
Packit aea12f
                 "use gnulib module getaddrinfo for portability");
Packit aea12f
# endif
Packit aea12f
Packit aea12f
# undef gai_strerror
Packit aea12f
# if HAVE_RAW_DECL_GAI_STRERROR
Packit aea12f
_GL_WARN_ON_USE (gai_strerror, "gai_strerror is unportable - "
Packit aea12f
                 "use gnulib module getaddrinfo for portability");
Packit aea12f
# endif
Packit aea12f
Packit aea12f
# undef getnameinfo
Packit aea12f
# if HAVE_RAW_DECL_GETNAMEINFO
Packit aea12f
_GL_WARN_ON_USE (getnameinfo, "getnameinfo is unportable - "
Packit aea12f
                 "use gnulib module getaddrinfo for portability");
Packit aea12f
# endif
Packit aea12f
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#endif /* _@GUARD_PREFIX@_NETDB_H */
Packit aea12f
#endif /* _@GUARD_PREFIX@_NETDB_H */