bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

netdb.h


From: Simon Josefsson
Subject: netdb.h
Date: Wed, 15 Oct 2008 14:52:16 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (gnu/linux)

I noticed that I have some HAVE_NETDB_H checks to cover mingw32 in
gsasl.  The declarations in getaddrinfo.h should really be defined in
netdb.h, as far as I can tell, too.

This is a first patch that merely create a small dummy netdb.h
replacement file.  Pushed, but I do appreciate review and testing of
it.  In particular, if anyone has access to a BeOS system, testing
whether it does the right thing there would be useful.

Thanks,
/Simon

>From ceb82aa30f0b017db4ffa03801dc29b7c82cbde0 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <address@hidden>
Date: Wed, 15 Oct 2008 14:48:59 +0200
Subject: [PATCH] Add netdb.h replacement module.
 Currently empty and unused, but that will change soon.

---
 ChangeLog                    |   12 ++++++++++
 MODULES.html.sh              |    1 +
 doc/posix-headers/netdb.texi |    6 ++--
 lib/netdb.in.h               |   48 ++++++++++++++++++++++++++++++++++++++++++
 m4/netdb_h.m4                |   43 +++++++++++++++++++++++++++++++++++++
 modules/netdb                |   38 +++++++++++++++++++++++++++++++++
 modules/netdb-tests          |   13 +++++++++++
 tests/test-netdb.c           |   29 +++++++++++++++++++++++++
 8 files changed, 187 insertions(+), 3 deletions(-)
 create mode 100644 lib/netdb.in.h
 create mode 100644 m4/netdb_h.m4
 create mode 100644 modules/netdb
 create mode 100644 modules/netdb-tests
 create mode 100644 tests/test-netdb.c

diff --git a/ChangeLog b/ChangeLog
index 64b95e5..721d69e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2008-10-15  Simon Josefsson  <address@hidden>
 
+       * 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  <address@hidden>
+
        * doc/gnulib.texi (Getaddrinfo and WINVER): Sync documentation
        with code.
 
diff --git a/MODULES.html.sh b/MODULES.html.sh
index abecc26..9597f09 100755
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -2134,6 +2134,7 @@ func_all_modules ()
   func_module mkdir
   func_module mkdtemp
   func_module mkstemp
+  func_module netdb
   func_module netinet_in
   func_module open
   func_module perror
diff --git a/doc/posix-headers/netdb.texi b/doc/posix-headers/netdb.texi
index 8d33ba8..1654013 100644
--- a/doc/posix-headers/netdb.texi
+++ b/doc/posix-headers/netdb.texi
@@ -7,11 +7,11 @@ Gnulib module: ---
 
 Portability problems fixed by Gnulib:
 @itemize
address@hidden
+This header file is missing on some platforms:
+mingw, BeOS.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
address@hidden
-This header file is missing on some platforms:
-mingw, BeOS.
 @end itemize
diff --git a/lib/netdb.in.h b/lib/netdb.in.h
new file mode 100644
index 0000000..0aa0691
--- /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@
+
address@hidden@
+
+/* 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 */
diff --git a/m4/netdb_h.m4 b/m4/netdb_h.m4
new file mode 100644
index 0000000..d6d729f
--- /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],
+[
+  :
+])
diff --git a/modules/netdb b/modules/netdb
new file mode 100644
index 0000000..21e4ff4
--- /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 address@hidden $@
+       { 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; \
+       } > address@hidden
+       mv address@hidden $@
+MOSTLYCLEANFILES += netdb.h netdb.h-t
+
+Include:
+#include <netdb.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Simon Josefsson
diff --git a/modules/netdb-tests b/modules/netdb-tests
new file mode 100644
index 0000000..d1ef7e1
--- /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
diff --git a/tests/test-netdb.c b/tests/test-netdb.c
new file mode 100644
index 0000000..cde9105
--- /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 <address@hidden>, 2008.  */
+
+#include <config.h>
+#include <netdb.h>
+
+/* Check that the 'struct hostent' type is defined.  */
+struct hostent t1;
+
+int
+main (void)
+{
+  return 0;
+}
-- 
1.5.6.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]