changeset 10644:ba5c6a0c8928

Add netdb.h replacement module. Currently empty and unused, but that will change soon.
author Simon Josefsson <simon@josefsson.org>
date Wed, 15 Oct 2008 14:48:59 +0200
parents e1661469bc9a
children 9b742ec50416
files ChangeLog MODULES.html.sh doc/posix-headers/netdb.texi lib/netdb.in.h m4/netdb_h.m4 modules/netdb modules/netdb-tests tests/test-netdb.c
diffstat 8 files changed, 187 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-10-15  Simon Josefsson  <simon@josefsson.org>
+
+	* modules/netdb, modules/netdb-tests: New file.
+	* m4/netdb_h.m4: New file.
+	* lib/netdb.in.h: Add, currently just an empty file pending
+	definitions.
+	* tests/test-netdb.c: New file.
+	* doc/posix-headers/netdb.texi: Mention that we replace it if
+	needed.
+	* MODULES.html.sh (Support for systems lacking POSIX:2001): Add
+	netdb.
+
 2008-10-15  Simon Josefsson  <simon@josefsson.org>
 
 	* doc/gnulib.texi (Getaddrinfo and WINVER): Sync documentation
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -2134,6 +2134,7 @@
   func_module mkdir
   func_module mkdtemp
   func_module mkstemp
+  func_module netdb
   func_module netinet_in
   func_module open
   func_module perror
--- a/doc/posix-headers/netdb.texi
+++ b/doc/posix-headers/netdb.texi
@@ -7,11 +7,11 @@
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This header file is missing on some platforms:
+mingw, BeOS.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This header file is missing on some platforms:
-mingw, BeOS.
 @end itemize
new file mode 100644
--- /dev/null
+++ b/lib/netdb.in.h
@@ -0,0 +1,48 @@
+/* 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 2, 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@
+
+@PRAGMA_SYSTEM_HEADER@
+
+/* 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
+
+/* Declarations for a platform that has <netdb.h>.  */
+
+#endif /* HAVE_NETDB_H */
+
+#endif /* _GL_NETDB_H */
+#endif /* _GL_NETDB_H */
new file mode 100644
--- /dev/null
+++ b/m4/netdb_h.m4
@@ -0,0 +1,43 @@
+# netdb_h.m4 serial 1
+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])
+  AC_CACHE_CHECK([whether <netdb.h> is self-contained],
+    [gl_cv_header_netdb_h_selfcontained],
+    [
+      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],
+					 [[struct hostent h;]])],
+        [gl_cv_header_netdb_h_selfcontained=yes],
+        [gl_cv_header_netdb_h_selfcontained=no])
+    ])
+  if test $gl_cv_header_netdb_h_selfcontained = yes; then
+    NETDB_H=''
+  else
+    NETDB_H='netdb.h'
+    gl_CHECK_NEXT_HEADERS([netdb.h])
+    if test $ac_cv_header_netdb_h = yes; then
+      HAVE_NETDB_H=1
+    else
+      HAVE_NETDB_H=0
+    fi
+    AC_SUBST([HAVE_NETDB_H])
+  fi
+  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],
+[
+  :
+])
new file mode 100644
--- /dev/null
+++ b/modules/netdb
@@ -0,0 +1,38 @@
+Description:
+A <netdb.h> for systems lacking it.
+
+Files:
+lib/netdb.in.h
+m4/netdb_h.m4
+
+Depends-on:
+include_next
+
+configure.ac:
+gl_HEADER_NETDB
+
+Makefile.am:
+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' \
+	      < $(srcdir)/netdb.in.h; \
+	} > $@-t
+	mv $@-t $@
+MOSTLYCLEANFILES += netdb.h netdb.h-t
+
+Include:
+#include <netdb.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Simon Josefsson
new file mode 100644
--- /dev/null
+++ b/modules/netdb-tests
@@ -0,0 +1,13 @@
+Files:
+tests/test-netdb.c
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-netdb
+check_PROGRAMS += test-netdb
+
+License:
+LGPL
new file mode 100644
--- /dev/null
+++ b/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;
+}