Blame gnulib/netdb.in.h

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