diff options
author | Simon Josefsson <simon@josefsson.org> | 2008-10-22 10:45:00 +0200 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2008-10-22 10:45:00 +0200 |
commit | 9b80e162e33a7f87b6cf1064935544e22352ba98 (patch) | |
tree | 35374559aa9ad8ce5aa93f3a48138cc64902913c /gl | |
parent | ddef7f47dc1ba571345c83c794639d2bf7c0f09c (diff) | |
download | gnutls-9b80e162e33a7f87b6cf1064935544e22352ba98.tar.gz |
Update gnulib files.
Diffstat (limited to 'gl')
-rw-r--r-- | gl/arpa_inet.in.h | 2 | ||||
-rw-r--r-- | gl/gai_strerror.c | 7 | ||||
-rw-r--r-- | gl/getaddrinfo.c | 2 | ||||
-rw-r--r-- | gl/getaddrinfo.h | 163 | ||||
-rw-r--r-- | gl/gnulib.mk | 25 | ||||
-rw-r--r-- | gl/m4/getaddrinfo.m4 | 11 | ||||
-rw-r--r-- | gl/m4/gnulib-common.m4 | 12 | ||||
-rw-r--r-- | gl/m4/gnulib-comp.m4 | 6 | ||||
-rw-r--r-- | gl/m4/netdb_h.m4 | 32 | ||||
-rw-r--r-- | gl/netdb.in.h | 189 | ||||
-rw-r--r-- | gl/netinet_in.in.h | 2 | ||||
-rw-r--r-- | gl/stdarg.in.h | 2 | ||||
-rw-r--r-- | gl/tests/gnulib.mk | 9 | ||||
-rw-r--r-- | gl/tests/test-getaddrinfo.c | 2 | ||||
-rw-r--r-- | gl/tests/test-netdb.c | 29 |
15 files changed, 314 insertions, 179 deletions
diff --git a/gl/arpa_inet.in.h b/gl/arpa_inet.in.h index e782581f65..4b95b944fc 100644 --- a/gl/arpa_inet.in.h +++ b/gl/arpa_inet.in.h @@ -24,7 +24,9 @@ #if @HAVE_ARPA_INET_H@ +# if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ +# endif /* The include_next requires a split double-inclusion guard. */ # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@ diff --git a/gl/gai_strerror.c b/gl/gai_strerror.c index 9e4abbe6db..78a8edfed0 100644 --- a/gl/gai_strerror.c +++ b/gl/gai_strerror.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997. @@ -18,13 +18,10 @@ #ifndef _LIBC # include <config.h> -# include "getaddrinfo.h" #endif #include <stdio.h> -#ifdef HAVE_NETDB_H -# include <netdb.h> -#endif +#include <netdb.h> #ifdef _LIBC # include <libintl.h> diff --git a/gl/getaddrinfo.c b/gl/getaddrinfo.c index 3016c93f20..f09cf9ee64 100644 --- a/gl/getaddrinfo.c +++ b/gl/getaddrinfo.c @@ -19,7 +19,7 @@ #include <config.h> -#include "getaddrinfo.h" +#include <netdb.h> #if HAVE_NETINET_IN_H # include <netinet/in.h> diff --git a/gl/getaddrinfo.h b/gl/getaddrinfo.h deleted file mode 100644 index 14587a2902..0000000000 --- a/gl/getaddrinfo.h +++ /dev/null @@ -1,163 +0,0 @@ -/* Get address information. - Copyright (C) 1996-2002, 2003, 2004, 2005, 2006, 2008 - Free Software Foundation, Inc. - Contributed by Simon Josefsson <simon@josefsson.org>. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifndef GETADDRINFO_H -#define GETADDRINFO_H - -/* sys/socket.h in i386-unknown-freebsd4.10 and - powerpc-apple-darwin5.5 require sys/types.h, so include it first. - Then we'll also get 'socklen_t' and 'struct sockaddr' which are - used below. */ -#include <sys/types.h> -/* Get all getaddrinfo related declarations, if available. */ -#include <sys/socket.h> -#ifdef HAVE_NETDB_H -# include <netdb.h> -#endif - -#ifndef HAVE_STRUCT_ADDRINFO - -/* Structure to contain information about address of a service provider. */ -struct addrinfo -{ - int ai_flags; /* Input flags. */ - int ai_family; /* Protocol family for socket. */ - int ai_socktype; /* Socket type. */ - int ai_protocol; /* Protocol for socket. */ - socklen_t ai_addrlen; /* Length of socket address. */ - struct sockaddr *ai_addr; /* Socket address for socket. */ - char *ai_canonname; /* Canonical name for service location. */ - struct addrinfo *ai_next; /* Pointer to next in list. */ -}; -#endif - -/* Possible values for `ai_flags' field in `addrinfo' structure. */ -#ifndef AI_PASSIVE -# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */ -#endif -#ifndef AI_CANONNAME -# define AI_CANONNAME 0x0002 /* Request for canonical name. */ -#endif -#ifndef AI_NUMERICSERV -# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */ -#endif - -#if 0 -/* The commented out definitions below are not yet implemented in the - GNULIB getaddrinfo() replacement, so are not yet needed and may, in fact, - cause conflicts on systems with a getaddrinfo() function which does not - define them. - - If they are restored, be sure to protect the definitions with #ifndef. */ -#define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */ -#define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */ -#define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */ -#define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose - returned address type.. */ -#endif /* 0 */ - -/* Error values for `getaddrinfo' function. */ -#ifndef EAI_BADFLAGS -# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */ -# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */ -# define EAI_AGAIN -3 /* Temporary failure in name resolution. */ -# define EAI_FAIL -4 /* Non-recoverable failure in name res. */ -# define EAI_NODATA -5 /* No address associated with NAME. */ -# define EAI_FAMILY -6 /* `ai_family' not supported. */ -# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */ -# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */ -# define EAI_MEMORY -10 /* Memory allocation failure. */ -#endif - -/* Since EAI_NODATA is deprecated by RFC3493, some systems (at least - FreeBSD, which does define EAI_BADFLAGS) have removed the definition - in favor of EAI_NONAME. */ -#if !defined EAI_NODATA && defined EAI_NONAME -# define EAI_NODATA EAI_NONAME -#endif - -#ifndef EAI_OVERFLOW -/* Not defined on mingw32. */ -# define EAI_OVERFLOW -12 /* Argument buffer overflow. */ -#endif -#ifndef EAI_ADDRFAMILY -/* Not defined on mingw32. */ -# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */ -#endif -#ifndef EAI_SYSTEM -/* Not defined on mingw32. */ -# define EAI_SYSTEM -11 /* System error returned in `errno'. */ -#endif - -#ifdef __USE_GNU -# ifndef EAI_INPROGRESS -# define EAI_INPROGRESS -100 /* Processing request in progress. */ -# define EAI_CANCELED -101 /* Request canceled. */ -# define EAI_NOTCANCELED -102 /* Request not canceled. */ -# define EAI_ALLDONE -103 /* All requests done. */ -# define EAI_INTR -104 /* Interrupted by a signal. */ -# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */ -# endif -#endif - -#if !HAVE_DECL_GETADDRINFO -/* Translate name of a service location and/or a service name to set of - socket addresses. - For more details, see the POSIX:2001 specification - <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */ -extern int getaddrinfo (const char *restrict nodename, - const char *restrict servname, - const struct addrinfo *restrict hints, - struct addrinfo **restrict res); -#endif - -#if !HAVE_DECL_FREEADDRINFO -/* Free `addrinfo' structure AI including associated storage. - For more details, see the POSIX:2001 specification - <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */ -extern void freeaddrinfo (struct addrinfo *ai); -#endif - -#if !HAVE_DECL_GAI_STRERROR -/* Convert error return from getaddrinfo() to a string. - For more details, see the POSIX:2001 specification - <http://www.opengroup.org/susv3xsh/gai_strerror.html>. */ -extern const char *gai_strerror (int ecode); -#endif - -#if !HAVE_DECL_GETNAMEINFO -/* Convert socket address to printable node and service names. - For more details, see the POSIX:2001 specification - <http://www.opengroup.org/susv3xsh/getnameinfo.html>. */ -extern int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, - char *restrict node, socklen_t nodelen, - char *restrict service, socklen_t servicelen, - int flags); - -#endif - -/* Possible flags for getnameinfo. */ -#ifndef NI_NUMERICHOST -# define NI_NUMERICHOST 1 -#endif -#ifndef NI_NUMERICSERV -# define NI_NUMERICSERV 2 -#endif - -#endif /* GETADDRINFO_H */ diff --git a/gl/gnulib.mk b/gl/gnulib.mk index 7c19a3ff18..046543dd67 100644 --- a/gl/gnulib.mk +++ b/gl/gnulib.mk @@ -76,7 +76,7 @@ EXTRA_DIST += $(top_srcdir)/build-aux/gendocs.sh ## begin gnulib module getaddrinfo -EXTRA_DIST += gai_strerror.c getaddrinfo.c getaddrinfo.h +EXTRA_DIST += gai_strerror.c getaddrinfo.c EXTRA_libgnu_la_SOURCES += gai_strerror.c getaddrinfo.c @@ -172,6 +172,29 @@ EXTRA_DIST += $(top_srcdir)/maint.mk ## end gnulib module maintainer-makefile +## begin gnulib module netdb + +BUILT_SOURCES += $(NETDB_H) + +# We need the following in order to create <netdb.h> when the system +# doesn't have one that works with the given compiler. +netdb.h: netdb.in.h + rm -f $@-t $@ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_NETDB_H''@|$(NEXT_NETDB_H)|g' \ + -e 's|@''HAVE_NETDB_H''@|$(HAVE_NETDB_H)|g' \ + -e 's|@''GNULIB_GETADDRINFO''@|$(GNULIB_GETADDRINFO)|g' \ + < $(srcdir)/netdb.in.h; \ + } > $@-t + mv $@-t $@ +MOSTLYCLEANFILES += netdb.h netdb.h-t + +EXTRA_DIST += netdb.in.h + +## end gnulib module netdb + ## begin gnulib module netinet_in BUILT_SOURCES += $(NETINET_IN_H) diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4 index 52135ba947..c184c6f294 100644 --- a/gl/m4/getaddrinfo.m4 +++ b/gl/m4/getaddrinfo.m4 @@ -1,5 +1,5 @@ -# getaddrinfo.m4 serial 15 -dnl Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +# getaddrinfo.m4 serial 16 +dnl Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -7,10 +7,9 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_GETADDRINFO], [ AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H + AC_REQUIRE([gl_HEADER_NETDB])dnl for HAVE_NETDB_H AC_MSG_NOTICE([checking how to do getaddrinfo, freeaddrinfo and getnameinfo]) - AC_CHECK_HEADERS_ONCE(netdb.h) - AC_SEARCH_LIBS(getaddrinfo, [nsl socket]) AC_CACHE_CHECK([for getaddrinfo], [gl_cv_func_getaddrinfo], [ AC_TRY_LINK([ @@ -72,7 +71,7 @@ AC_DEFUN([gl_GETADDRINFO], gl_PREREQ_GETADDRINFO ]) -# Prerequisites of lib/getaddrinfo.h and lib/getaddrinfo.c. +# Prerequisites of lib/getaddrinfo.c. AC_DEFUN([gl_PREREQ_GETADDRINFO], [ AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H AC_SEARCH_LIBS(gethostbyname, [inet nsl]) @@ -104,7 +103,7 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [ dnl have sa_len so the result is correct anyway. AC_CHECK_MEMBERS([struct sockaddr.sa_len], , , [#include <sys/socket.h>]) - AC_CHECK_HEADERS_ONCE(netinet/in.h netdb.h) + AC_CHECK_HEADERS_ONCE(netinet/in.h) AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror, getnameinfo],,,[ /* sys/types.h is not needed according to POSIX, but the sys/socket.h in i386-unknown-freebsd4.10 and diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4 index 34d91c728f..c73db14cc5 100644 --- a/gl/m4/gnulib-common.m4 +++ b/gl/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 5 +# gnulib-common.m4 serial 6 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -21,6 +21,16 @@ AC_DEFUN([gl_COMMON_BODY], [ #if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ # define __GNUC_STDC_INLINE__ 1 #endif]) + AH_VERBATIM([unused_parameter], +[/* Define as a marker that can be attached to function parameter declarations + for parameters that are not used. This helps to reduce warnings, such as + from GCC -Wunused-parameter. */ +#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _UNUSED_PARAMETER_ __attribute__ ((__unused__)) +#else +# define _UNUSED_PARAMETER_ +#endif +]) ]) # gl_MODULE_INDICATOR([modulename]) diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index cfd30c1330..0153061498 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -55,6 +55,7 @@ AC_DEFUN([gl_INIT], [AM_XGETTEXT_OPTION([--flag=error:3:c-format]) AM_XGETTEXT_OPTION([--flag=error_at_line:5:c-format])]) gl_GETADDRINFO + gl_NETDB_MODULE_INDICATOR([getaddrinfo]) gl_FUNC_GETDELIM gl_STDIO_MODULE_INDICATOR([getdelim]) gl_FUNC_GETLINE @@ -74,6 +75,7 @@ AC_DEFUN([gl_INIT], gl_ARPA_INET_MODULE_INDICATOR([inet_ntop]) gl_INET_PTON gl_ARPA_INET_MODULE_INDICATOR([inet_pton]) + gl_HEADER_NETDB gl_HEADER_NETINET_IN AC_PROG_MKDIR_P gl_FUNC_READLINE @@ -224,7 +226,6 @@ AC_DEFUN([gl_FILE_LIST], [ lib/error.h lib/gai_strerror.c lib/getaddrinfo.c - lib/getaddrinfo.h lib/getdelim.c lib/getline.c lib/getpass.c @@ -232,6 +233,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/inet_ntop.c lib/inet_pton.c lib/intprops.h + lib/netdb.in.h lib/netinet_in.in.h lib/progname.c lib/progname.h @@ -257,6 +259,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/lib-ld.m4 m4/lib-link.m4 m4/lib-prefix.m4 + m4/netdb_h.m4 m4/netinet_in_h.m4 m4/readline.m4 m4/socklen.m4 @@ -267,6 +270,7 @@ AC_DEFUN([gl_FILE_LIST], [ tests/test-getaddrinfo.c tests/test-getdelim.c tests/test-getline.c + tests/test-netdb.c tests/test-netinet_in.c tests/test-strerror.c top/GNUmakefile diff --git a/gl/m4/netdb_h.m4 b/gl/m4/netdb_h.m4 new file mode 100644 index 0000000000..ecb57b4e66 --- /dev/null +++ b/gl/m4/netdb_h.m4 @@ -0,0 +1,32 @@ +# netdb_h.m4 serial 2 +dnl Copyright (C) 2008 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_HEADER_NETDB], +[ + AC_REQUIRE([gl_NETDB_H_DEFAULTS]) + gl_CHECK_NEXT_HEADERS([netdb.h]) + if test $ac_cv_header_netdb_h = yes; then + NETDB_H='' + HAVE_NETDB_H=1 + else + NETDB_H='netdb.h' + HAVE_NETDB_H=0 + fi + AC_SUBST([HAVE_NETDB_H]) + AC_SUBST([NETDB_H]) +]) + +AC_DEFUN([gl_NETDB_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_NETDB_H_DEFAULTS]) + GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 +]) + +AC_DEFUN([gl_NETDB_H_DEFAULTS], +[ + GNULIB_GETADDRINFO=0; AC_SUBST([GNULIB_GETADDRINFO]) +]) diff --git a/gl/netdb.in.h b/gl/netdb.in.h new file mode 100644 index 0000000000..d470a646f3 --- /dev/null +++ b/gl/netdb.in.h @@ -0,0 +1,189 @@ +/* Provide a netdb.h header file for systems lacking it (read: MinGW). + Copyright (C) 2008 Free Software Foundation, Inc. + Written by Simon Josefsson. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* This file is supposed to be used on platforms that lack <netdb.h>. + It is intended to provide definitions and prototypes needed by an + application. */ + +#ifndef _GL_NETDB_H + +#if @HAVE_NETDB_H@ + +# if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +# endif + +/* The include_next requires a split double-inclusion guard. */ +# @INCLUDE_NEXT@ @NEXT_NETDB_H@ + +#endif + +#ifndef _GL_NETDB_H +#define _GL_NETDB_H + +#if @HAVE_NETDB_H@ + +/* Declarations for a platform that has <netdb.h>. */ + +#else + +/* Get netdb.h definitions such as struct hostent for MinGW. */ +#include <sys/socket.h> + +/* Declarations for a platform that lacks <netdb.h>. */ + +#if @GNULIB_GETADDRINFO@ + +# ifndef HAVE_STRUCT_ADDRINFO + +/* Structure to contain information about address of a service provider. */ +struct addrinfo +{ + int ai_flags; /* Input flags. */ + int ai_family; /* Protocol family for socket. */ + int ai_socktype; /* Socket type. */ + int ai_protocol; /* Protocol for socket. */ + socklen_t ai_addrlen; /* Length of socket address. */ + struct sockaddr *ai_addr; /* Socket address for socket. */ + char *ai_canonname; /* Canonical name for service location. */ + struct addrinfo *ai_next; /* Pointer to next in list. */ +}; +# endif + +/* Possible values for `ai_flags' field in `addrinfo' structure. */ +# ifndef AI_PASSIVE +# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */ +# endif +# ifndef AI_CANONNAME +# define AI_CANONNAME 0x0002 /* Request for canonical name. */ +# endif +# ifndef AI_NUMERICSERV +# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */ +# endif + +# if 0 +/* The commented out definitions below are not yet implemented in the + GNULIB getaddrinfo() replacement, so are not yet needed and may, in fact, + cause conflicts on systems with a getaddrinfo() function which does not + define them. + + If they are restored, be sure to protect the definitions with #ifndef. */ +# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */ +# define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */ +# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */ +# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose + returned address type.. */ +# endif /* 0 */ + +/* Error values for `getaddrinfo' function. */ +# ifndef EAI_BADFLAGS +# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */ +# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */ +# define EAI_AGAIN -3 /* Temporary failure in name resolution. */ +# define EAI_FAIL -4 /* Non-recoverable failure in name res. */ +# define EAI_NODATA -5 /* No address associated with NAME. */ +# define EAI_FAMILY -6 /* `ai_family' not supported. */ +# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */ +# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */ +# define EAI_MEMORY -10 /* Memory allocation failure. */ +# endif + +/* Since EAI_NODATA is deprecated by RFC3493, some systems (at least + FreeBSD, which does define EAI_BADFLAGS) have removed the definition + in favor of EAI_NONAME. */ +# if !defined EAI_NODATA && defined EAI_NONAME +# define EAI_NODATA EAI_NONAME +# endif + +# ifndef EAI_OVERFLOW +/* Not defined on mingw32. */ +# define EAI_OVERFLOW -12 /* Argument buffer overflow. */ +# endif +# ifndef EAI_ADDRFAMILY +/* Not defined on mingw32. */ +# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */ +# endif +# ifndef EAI_SYSTEM +/* Not defined on mingw32. */ +# define EAI_SYSTEM -11 /* System error returned in `errno'. */ +# endif + +# if 0 +/* The commented out definitions below are not yet implemented in the + GNULIB getaddrinfo() replacement, so are not yet needed. + + If they are restored, be sure to protect the definitions with #ifndef. */ +# ifndef EAI_INPROGRESS +# define EAI_INPROGRESS -100 /* Processing request in progress. */ +# define EAI_CANCELED -101 /* Request canceled. */ +# define EAI_NOTCANCELED -102 /* Request not canceled. */ +# define EAI_ALLDONE -103 /* All requests done. */ +# define EAI_INTR -104 /* Interrupted by a signal. */ +# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */ +# endif +# endif + +# if !HAVE_DECL_GETADDRINFO +/* Translate name of a service location and/or a service name to set of + socket addresses. + For more details, see the POSIX:2001 specification + <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */ +extern int getaddrinfo (const char *restrict nodename, + const char *restrict servname, + const struct addrinfo *restrict hints, + struct addrinfo **restrict res); +# endif + +# if !HAVE_DECL_FREEADDRINFO +/* Free `addrinfo' structure AI including associated storage. + For more details, see the POSIX:2001 specification + <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */ +extern void freeaddrinfo (struct addrinfo *ai); +# endif + +# if !HAVE_DECL_GAI_STRERROR +/* Convert error return from getaddrinfo() to a string. + For more details, see the POSIX:2001 specification + <http://www.opengroup.org/susv3xsh/gai_strerror.html>. */ +extern const char *gai_strerror (int ecode); +# endif + +# if !HAVE_DECL_GETNAMEINFO +/* Convert socket address to printable node and service names. + For more details, see the POSIX:2001 specification + <http://www.opengroup.org/susv3xsh/getnameinfo.html>. */ +extern int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, + char *restrict node, socklen_t nodelen, + char *restrict service, socklen_t servicelen, + int flags); +# endif + +/* Possible flags for getnameinfo. */ +# ifndef NI_NUMERICHOST +# define NI_NUMERICHOST 1 +# endif +# ifndef NI_NUMERICSERV +# define NI_NUMERICSERV 2 +# endif + +#endif /* @GNULIB_GETADDRINFO@ */ + +#endif /* HAVE_NETDB_H */ + +#endif /* _GL_NETDB_H */ +#endif /* _GL_NETDB_H */ diff --git a/gl/netinet_in.in.h b/gl/netinet_in.in.h index cf5aa81ebe..97e11a7e0b 100644 --- a/gl/netinet_in.in.h +++ b/gl/netinet_in.in.h @@ -19,7 +19,9 @@ #if @HAVE_NETINET_IN_H@ +# if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ +# endif /* On many platforms, <netinet/in.h> assumes prior inclusion of <sys/types.h>. */ diff --git a/gl/stdarg.in.h b/gl/stdarg.in.h index 3597baf5c2..186a495150 100644 --- a/gl/stdarg.in.h +++ b/gl/stdarg.in.h @@ -17,7 +17,9 @@ #ifndef _GL_STDARG_H +#if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ +#endif /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_STDARG_H@ diff --git a/gl/tests/gnulib.mk b/gl/tests/gnulib.mk index 37daafa13d..637debf1a6 100644 --- a/gl/tests/gnulib.mk +++ b/gl/tests/gnulib.mk @@ -81,6 +81,15 @@ EXTRA_DIST += test-getline.c ## end gnulib module getline-tests +## begin gnulib module netdb-tests + +TESTS += test-netdb +check_PROGRAMS += test-netdb + +EXTRA_DIST += test-netdb.c + +## end gnulib module netdb-tests + ## begin gnulib module netinet_in-tests TESTS += test-netinet_in diff --git a/gl/tests/test-getaddrinfo.c b/gl/tests/test-getaddrinfo.c index bfdb9cf0e8..a887cb1a99 100644 --- a/gl/tests/test-getaddrinfo.c +++ b/gl/tests/test-getaddrinfo.c @@ -18,7 +18,7 @@ /* Written by Simon Josefsson. */ #include <config.h> -#include "getaddrinfo.h" +#include <netdb.h> #include <arpa/inet.h> #include <netinet/in.h> #include <stdio.h> diff --git a/gl/tests/test-netdb.c b/gl/tests/test-netdb.c new file mode 100644 index 0000000000..cde9105fde --- /dev/null +++ b/gl/tests/test-netdb.c @@ -0,0 +1,29 @@ +/* Test of <netdb.h> substitute. + Copyright (C) 2007-2008 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* Written by Simon Josefsson <simon@josefsson.org>, 2008. */ + +#include <config.h> +#include <netdb.h> + +/* Check that the 'struct hostent' type is defined. */ +struct hostent t1; + +int +main (void) +{ + return 0; +} |