From: Simon Josefsson Date: Wed, 15 Oct 2008 12:48:59 +0000 (+0200) Subject: Add netdb.h replacement module. X-Git-Tag: v0.1~6841 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=ceb82aa30f0b017db4ffa03801dc29b7c82cbde0;p=gnulib.git Add netdb.h replacement module. Currently empty and unused, but that will change soon. --- diff --git a/ChangeLog b/ChangeLog index 64b95e5d0..721d69ec2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2008-10-15 Simon Josefsson + * 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 + * doc/gnulib.texi (Getaddrinfo and WINVER): Sync documentation with code. diff --git a/MODULES.html.sh b/MODULES.html.sh index abecc2610..9597f0987 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 8d33ba88a..165401388 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 +@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 diff --git a/lib/netdb.in.h b/lib/netdb.in.h new file mode 100644 index 000000000..0aa0691d5 --- /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 . + 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 . */ + +#else + +/* Declarations for a platform that has . */ + +#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 000000000..d6d729fbc --- /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 is self-contained], + [gl_cv_header_netdb_h_selfcontained], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[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 000000000..21e4ff41b --- /dev/null +++ b/modules/netdb @@ -0,0 +1,38 @@ +Description: +A 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 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 + +License: +LGPLv2+ + +Maintainer: +Simon Josefsson diff --git a/modules/netdb-tests b/modules/netdb-tests new file mode 100644 index 000000000..d1ef7e140 --- /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 000000000..cde9105fd --- /dev/null +++ b/tests/test-netdb.c @@ -0,0 +1,29 @@ +/* Test of 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 . */ + +/* Written by Simon Josefsson , 2008. */ + +#include +#include + +/* Check that the 'struct hostent' type is defined. */ +struct hostent t1; + +int +main (void) +{ + return 0; +}