Re: provide inet_?to? declarations in arpa_inet.h

2008-05-02 Thread Simon Josefsson
Bruno Haible <[EMAIL PROTECTED]> writes:

>> The variable are set to 0 in the inet_ntop/inet_pton modules, via a
>> AC_CHECK_DECLS statement.
>
> No, it isn't. AC_CHECK_DECLS([inet_ntop]...) sets the shell variable
> ac_cv_have_decl_inet_ntop to yes or no. It does not set the shell variable
> HAVE_DECL_INET_NTOP to 1 or 0.
>
> Look at the generated configure file to convince yourself:
> $ ./gnulib-tool --create-testdir --dir=/dev/shm/testdir5 inet_ntop
> $ cd /dev/shm/testdir5
> $ grep HAVE_DECL_INET_NTOP configure
> HAVE_DECL_INET_NTOP
> HAVE_DECL_INET_NTOP=1;
> #define HAVE_DECL_INET_NTOP 1
> #define HAVE_DECL_INET_NTOP 0

Ah, sorry.  Thanks for explaining.  Indeed, the following was missing.
Pushed.

Thanks,
/Simon

>From 029a3a28224414fe9495a160febd3431b981e659 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <[EMAIL PROTECTED]>
Date: Sat, 3 May 2008 06:22:26 +0200
Subject: [PATCH] Make sure inet_ntop/inet_pton is declared when needed.

---
 ChangeLog   |7 +++
 m4/inet_ntop.m4 |5 -
 m4/inet_pton.m4 |5 -
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7f2e5f5..f566efa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-05-03  Simon Josefsson  <[EMAIL PROTECTED]>
+
+   * m4/inet_pton.m4: Set HAVE_DECL_INET_PTON to 0 when declarations
+   are needed from arpa/inet.h.
+   * m4/inet_ntop.m4: Likewise, for HAVE_DECL_INET_NTOP.
+   Reported by Bruno Haible.
+
 2008-05-02  Jim Meyering  <[EMAIL PROTECTED]>
 
avoid compilation error on FreeBSD 6
diff --git a/m4/inet_ntop.m4 b/m4/inet_ntop.m4
index 342cd28..25a3ee9 100644
--- a/m4/inet_ntop.m4
+++ b/m4/inet_ntop.m4
@@ -1,4 +1,4 @@
-# inet_ntop.m4 serial 5
+# inet_ntop.m4 serial 6
 dnl Copyright (C) 2005, 2006, 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,
@@ -19,6 +19,9 @@ AC_DEFUN([gl_INET_NTOP],
 # Prerequisites of lib/inet_ntop.c.
 AC_DEFUN([gl_PREREQ_INET_NTOP], [
   AC_CHECK_DECLS([inet_ntop],,,[#include ])
+  if test $ac_cv_have_decl_inet_ntop = no; then
+HAVE_DECL_INET_NTOP=0
+  fi
   AC_REQUIRE([gl_SOCKET_FAMILIES])
   AC_REQUIRE([AC_C_RESTRICT])
 ])
diff --git a/m4/inet_pton.m4 b/m4/inet_pton.m4
index 7d7f993..a57e4c6 100644
--- a/m4/inet_pton.m4
+++ b/m4/inet_pton.m4
@@ -1,4 +1,4 @@
-# inet_pton.m4 serial 4
+# inet_pton.m4 serial 5
 dnl Copyright (C) 2006, 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,
@@ -19,6 +19,9 @@ AC_DEFUN([gl_INET_PTON],
 # Prerequisites of lib/inet_pton.c.
 AC_DEFUN([gl_PREREQ_INET_PTON], [
   AC_CHECK_DECLS([inet_pton],,,[#include ])
+  if test $ac_cv_have_decl_inet_pton = no; then
+HAVE_DECL_INET_PTON=0
+  fi
   AC_REQUIRE([gl_SOCKET_FAMILIES])
   AC_REQUIRE([AC_C_RESTRICT])
 ])
-- 
1.5.5





Re: provide inet_?to? declarations in arpa_inet.h

2008-05-01 Thread Bruno Haible
Simon Josefsson wrote:
> >> +-e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
> >> +-e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
> >>  < $(srcdir)/arpa_inet.in.h; \
> >>} > [EMAIL PROTECTED]
> >>mv [EMAIL PROTECTED] $@
> >
> > This cannot be correct/complete. You are initializing the two variables
> > to 1, never setting them to 0, and then substituting them. You also need to
> > set them to 0 somewhere, conditionally.
> 
> The variable are set to 0 in the inet_ntop/inet_pton modules, via a
> AC_CHECK_DECLS statement.

No, it isn't. AC_CHECK_DECLS([inet_ntop]...) sets the shell variable
ac_cv_have_decl_inet_ntop to yes or no. It does not set the shell variable
HAVE_DECL_INET_NTOP to 1 or 0.

Look at the generated configure file to convince yourself:
$ ./gnulib-tool --create-testdir --dir=/dev/shm/testdir5 inet_ntop
$ cd /dev/shm/testdir5
$ grep HAVE_DECL_INET_NTOP configure
HAVE_DECL_INET_NTOP
HAVE_DECL_INET_NTOP=1;
#define HAVE_DECL_INET_NTOP 1
#define HAVE_DECL_INET_NTOP 0

Bruno





Re: provide inet_?to? declarations in arpa_inet.h

2008-04-30 Thread Simon Josefsson
Bruno Haible <[EMAIL PROTECTED]> writes:

> Simon Josefsson wrote:
>> diff --git a/m4/arpa_inet_h.m4 b/m4/arpa_inet_h.m4
>> index 8f530c5..baddf0d 100644
>> --- a/m4/arpa_inet_h.m4
>> +++ b/m4/arpa_inet_h.m4
>> @@ -32,4 +32,7 @@ AC_DEFUN([gl_ARPA_INET_H_DEFAULTS],
>>  [
>>GNULIB_INET_NTOP=0; AC_SUBST([GNULIB_INET_NTOP])
>>GNULIB_INET_PTON=0; AC_SUBST([GNULIB_INET_PTON])
>> +  dnl Assume proper GNU behavior unless another module says otherwise.
>> +  HAVE_DECL_INET_NTOP=1;  AC_SUBST([HAVE_DECL_INET_NTOP])
>> +  HAVE_DECL_INET_PTON=1;  AC_SUBST([HAVE_DECL_INET_PTON])
>>  ])
>> diff --git a/modules/arpa_inet b/modules/arpa_inet
>> index e5934ac..8c5f3f9 100644
>> --- a/modules/arpa_inet
>> +++ b/modules/arpa_inet
>> @@ -24,6 +24,8 @@ arpa/inet.h:
>>sed \
>>-e 's|@''GNULIB_INET_NTOP''@|$(GNULIB_INET_NTOP)|g' \
>>-e 's|@''GNULIB_INET_PTON''@|$(GNULIB_INET_PTON)|g' \
>> +  -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
>> +  -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
>>< $(srcdir)/arpa_inet.in.h; \
>>  } > [EMAIL PROTECTED]
>>  mv [EMAIL PROTECTED] $@
>
> This cannot be correct/complete. You are initializing the two variables
> to 1, never setting them to 0, and then substituting them. You also need to
> set them to 0 somewhere, conditionally.

The variable are set to 0 in the inet_ntop/inet_pton modules, via a
AC_CHECK_DECLS statement.  This is similar to how the unistd module
works.

(arpa_inet.in.h already used these variables, done in the first patch.)

/Simon




Re: provide inet_?to? declarations in arpa_inet.h

2008-04-29 Thread Bruno Haible
Simon Josefsson wrote:
> diff --git a/m4/arpa_inet_h.m4 b/m4/arpa_inet_h.m4
> index 8f530c5..baddf0d 100644
> --- a/m4/arpa_inet_h.m4
> +++ b/m4/arpa_inet_h.m4
> @@ -32,4 +32,7 @@ AC_DEFUN([gl_ARPA_INET_H_DEFAULTS],
>  [
>GNULIB_INET_NTOP=0; AC_SUBST([GNULIB_INET_NTOP])
>GNULIB_INET_PTON=0; AC_SUBST([GNULIB_INET_PTON])
> +  dnl Assume proper GNU behavior unless another module says otherwise.
> +  HAVE_DECL_INET_NTOP=1;  AC_SUBST([HAVE_DECL_INET_NTOP])
> +  HAVE_DECL_INET_PTON=1;  AC_SUBST([HAVE_DECL_INET_PTON])
>  ])
> diff --git a/modules/arpa_inet b/modules/arpa_inet
> index e5934ac..8c5f3f9 100644
> --- a/modules/arpa_inet
> +++ b/modules/arpa_inet
> @@ -24,6 +24,8 @@ arpa/inet.h:
> sed \
> -e 's|@''GNULIB_INET_NTOP''@|$(GNULIB_INET_NTOP)|g' \
> -e 's|@''GNULIB_INET_PTON''@|$(GNULIB_INET_PTON)|g' \
> +   -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
> +   -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
> < $(srcdir)/arpa_inet.in.h; \
>   } > [EMAIL PROTECTED]
>   mv [EMAIL PROTECTED] $@

This cannot be correct/complete. You are initializing the two variables
to 1, never setting them to 0, and then substituting them. You also need to
set them to 0 somewhere, conditionally.

Bruno





Re: provide inet_?to? declarations in arpa_inet.h

2008-04-29 Thread Bruno Haible
Simon Josefsson wrote:
> Btw, a solaris system I have access to declares the function as follows
> (in system arpa/inet.h):
> 
> #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
> extern int inet_pton(int, const char *_RESTRICT_KYWD, void *_RESTRICT_KYWD);
> extern const char *inet_ntop(int, const void *_RESTRICT_KYWD,
> char *_RESTRICT_KYWD, socklen_t);
> #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
> 
> Would setting any of those defines, to get the system's prototypes, be
> the right thing?

Yes, sure. Well spotted. The flag that you need is __EXTENSIONS__, and
- surprise surprise - it is enabled by gnulib's 'extensions' module.
This is what was missing:


2008-04-29  Bruno Haible  <[EMAIL PROTECTED]>

* m4/inet_ntop.m4 (gl_INET_NTOP): Require gl_USE_SYSTEM_EXTENSIONS.
* m4/inet_pton.m4 (gl_INET_PTON): Likewise.
* modules/inet_ntop (Depends-on): Add extensions.
* modules/inet_pton (Depends-on): Likewise.
Reported by Simon Josefsson.

*** m4/inet_ntop.m4.orig2008-04-30 01:27:13.0 +0200
--- m4/inet_ntop.m4 2008-04-30 01:19:40.0 +0200
***
*** 6,11 
--- 6,14 
  
  AC_DEFUN([gl_INET_NTOP],
  [
+   dnl Persuade Solaris  to declare inet_ntop.
+   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+ 
AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
ARPA_INET_H='arpa/inet.h'
  
*** m4/inet_pton.m4.orig2008-04-30 01:27:13.0 +0200
--- m4/inet_pton.m4 2008-04-30 01:19:40.0 +0200
***
*** 6,11 
--- 6,14 
  
  AC_DEFUN([gl_INET_PTON],
  [
+   dnl Persuade Solaris  to declare inet_ntop.
+   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+ 
AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
ARPA_INET_H='arpa/inet.h'
  
*** modules/inet_ntop.orig  2008-04-30 01:27:13.0 +0200
--- modules/inet_ntop   2008-04-30 01:26:07.0 +0200
***
*** 10,15 
--- 10,16 
  sys_socket
  arpa_inet
  netinet_in
+ extensions
  
  configure.ac:
  gl_INET_NTOP
*** modules/inet_pton.orig  2008-04-30 01:27:13.0 +0200
--- modules/inet_pton   2008-04-30 01:26:12.0 +0200
***
*** 10,15 
--- 10,16 
  sys_socket
  arpa_inet
  netinet_in
+ extensions
  
  configure.ac:
  gl_INET_PTON





Re: provide inet_?to? declarations in arpa_inet.h

2008-04-29 Thread Simon Josefsson
Bruno Haible <[EMAIL PROTECTED]> writes:

> Simon Josefsson wrote:
>> I've tested it better now
>
> It was still apparently tested only on few systems. As you can see
> from doc/posix-functions/inet*.texi, the functions inet_ntop and inet_pton
> need to be declared also on HP-UX 11, OSF/1 4.0, Solaris 2.5.1. So the
> gnulib  must be used in these cases as well (at least). And
> it must include the system's , which the present mingw-only
> replacement didn't do.

> Also, in the GNULIB_POSIXCHECK-conditionalized warnings, it is misleading
> to say "inet_pton doesn't exist on mingw" when in fact it does not exist
> on a couple of Unix systems either. (See doc/posix-functions/inet*.texi for
> reference.) mingw is one of gnulib's target platforms, but not its primary 
> one.
>
> I committed this.

Thanks!

Btw, a solaris system I have access to declares the function as follows
(in system arpa/inet.h):

#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
extern int inet_pton(int, const char *_RESTRICT_KYWD, void *_RESTRICT_KYWD);
extern const char *inet_ntop(int, const void *_RESTRICT_KYWD,
char *_RESTRICT_KYWD, socklen_t);
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */

Would setting any of those defines, to get the system's prototypes, be
the right thing?

/Simon




Re: provide inet_?to? declarations in arpa_inet.h

2008-04-29 Thread Bruno Haible
Simon Josefsson wrote:
> I've tested it better now

It was still apparently tested only on few systems. As you can see
from doc/posix-functions/inet*.texi, the functions inet_ntop and inet_pton
need to be declared also on HP-UX 11, OSF/1 4.0, Solaris 2.5.1. So the
gnulib  must be used in these cases as well (at least). And
it must include the system's , which the present mingw-only
replacement didn't do.

Also, in the GNULIB_POSIXCHECK-conditionalized warnings, it is misleading
to say "inet_pton doesn't exist on mingw" when in fact it does not exist
on a couple of Unix systems either. (See doc/posix-functions/inet*.texi for
reference.) mingw is one of gnulib's target platforms, but not its primary one.

I committed this.

2008-04-29  Bruno Haible  <[EMAIL PROTECTED]>

* lib/arpa_inet.in.h: Include system's  if it exists.
(inet_ntop, inet_pton): Change portability warning's wording.
* m4/arpa_inet_h.m4 (gl_HEADER_ARPA_INET): Set HAVE_ARPA_INET_H.
Invoke gl_CHECK_NEXT_HEADERS.
(gl_ARPA_INET_H_DEFAULTS): Initialize ARPA_INET_H.
* m4/inet_ntop.m4 (gl_INET_NTOP): Require gl_ARPA_INET_H_DEFAULTS and
set ARPA_INET_H.
* m4/inet_pton.m4 (gl_INET_PTON): Likewise.
* modules/arpa_inet (Description): No longer only for systems that
lack it.
(Depends-on): Add include_next.
(Makeile.am): Substitute INCLUDE_NEXT, NEXT_ARPA_INET_H,
HAVE_ARPA_INET_H.

*** lib/arpa_inet.in.h.orig 2008-04-29 13:24:54.0 +0200
--- lib/arpa_inet.in.h  2008-04-29 13:16:51.0 +0200
***
*** 1,5 
! /* Provide a arpa/inet header file for systems lacking it (read: MinGW)
!Copyright (C) 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
--- 1,6 
! /* A GNU-like .
! 
!Copyright (C) 2005-2006, 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
***
*** 16,27 
 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
  
  #ifndef _GL_ARPA_INET_H
- #define _GL_ARPA_INET_H
  
  /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc
 under MinGW. */
  #include 
  
  #if @GNULIB_INET_NTOP@
  # if [EMAIL PROTECTED]@
  /* Converts an internet address from internal format to a printable,
--- 17,37 
 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
  
  #ifndef _GL_ARPA_INET_H
  
  /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc
 under MinGW. */
  #include 
  
+ #if @HAVE_ARPA_INET_H@
+ 
+ /* The include_next requires a split double-inclusion guard.  */
+ # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@
+ 
+ #endif
+ 
+ #ifndef _GL_ARPA_INET_H
+ #define _GL_ARPA_INET_H
+ 
  #if @GNULIB_INET_NTOP@
  # if [EMAIL PROTECTED]@
  /* Converts an internet address from internal format to a printable,
***
*** 44,51 
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef inet_ntop
! # define inet_ntop(af,src,dst,cnt)\
! (GL_LINK_WARNING ("inet_ntop doesn't exist on mingw - " \
"use gnulib module inet_ntop for portability"), \
   inet_ntop (af, src, dst, cnt))
  #endif
--- 54,61 
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef inet_ntop
! # define inet_ntop(af,src,dst,cnt) \
! (GL_LINK_WARNING ("inet_ntop is unportable - " \
"use gnulib module inet_ntop for portability"), \
   inet_ntop (af, src, dst, cnt))
  #endif
***
*** 56,65 
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef inet_pton
! # define inet_pton(af,src,dst)\
!   (GL_LINK_WARNING ("inet_pton doesn't exist on mingw - "   \
!   "use gnulib module inet_pton for portability"),   \
 inet_pton (af, src, dst))
  #endif
  
  #endif /* _GL_ARPA_INET_H */
--- 66,76 
  # endif
  #elif defined GNULIB_POSIXCHECK
  # undef inet_pton
! # define inet_pton(af,src,dst) \
!   (GL_LINK_WARNING ("inet_pton is unportable - " \
!   "use gnulib module inet_pton for portability"), \
 inet_pton (af, src, dst))
  #endif
  
  #endif /* _GL_ARPA_INET_H */
+ #endif /* _GL_ARPA_INET_H */
*** m4/arpa_inet_h.m4.orig  2008-04-29 13:24:54.0 +0200
--- m4/arpa_inet_h.m4   2008-04-29 13:22:28.0 +0200
***
*** 1,10 
! # arpa_inet_h.m4 serial 2
  dnl Copyright (C) 2006, 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.
  
! dnl Written by Simon Josefsson
  
  AC_DEFUN([gl_HEADER_ARPA_INET],
  [
--- 1,10 -

Re: provide inet_?to? declarations in arpa_inet.h

2008-04-29 Thread Simon Josefsson
Simon Josefsson <[EMAIL PROTECTED]> writes:

> Bruno Haible <[EMAIL PROTECTED]> writes:
>
>> Hi Simon,
>>
>>> I would also favor removing both inet_ntop.h and inet_pton.h, and use
>>> arpa/inet.h for the declarations, as you suggested.
>>
>> Me too.
>
> Yoann, Bruno,
> I've pushed the following, please test it.

I've tested it better now, and needed the following.  Pushed.

/Simon

>From aa1d60fec96400b6f0a07bf2701b8bc1ba955077 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <[EMAIL PROTECTED]>
Date: Tue, 29 Apr 2008 11:26:41 +0200
Subject: [PATCH] Make arpa/inet module build under MinGW.

---
 ChangeLog |7 +++
 m4/arpa_inet_h.m4 |3 +++
 modules/arpa_inet |2 ++
 3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6f90e61..7dd2b27 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-04-29  Simon Josefsson  <[EMAIL PROTECTED]>
+
+   * m4/arpa_inet_h.m4 (gl_ARPA_INET_H_DEFAULTS): Set
+   HAVE_DECL_INET_NTOP and HAVE_DECL_INET_PTON.
+
+   * modules/arpa_inet (arpa/inet.h): Use them.
+
 2008-04-28  Eric Blake  <[EMAIL PROTECTED]>
 
Test getndelim2.
diff --git a/m4/arpa_inet_h.m4 b/m4/arpa_inet_h.m4
index 8f530c5..baddf0d 100644
--- a/m4/arpa_inet_h.m4
+++ b/m4/arpa_inet_h.m4
@@ -32,4 +32,7 @@ AC_DEFUN([gl_ARPA_INET_H_DEFAULTS],
 [
   GNULIB_INET_NTOP=0; AC_SUBST([GNULIB_INET_NTOP])
   GNULIB_INET_PTON=0; AC_SUBST([GNULIB_INET_PTON])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_DECL_INET_NTOP=1;  AC_SUBST([HAVE_DECL_INET_NTOP])
+  HAVE_DECL_INET_PTON=1;  AC_SUBST([HAVE_DECL_INET_PTON])
 ])
diff --git a/modules/arpa_inet b/modules/arpa_inet
index e5934ac..8c5f3f9 100644
--- a/modules/arpa_inet
+++ b/modules/arpa_inet
@@ -24,6 +24,8 @@ arpa/inet.h:
  sed \
  -e 's|@''GNULIB_INET_NTOP''@|$(GNULIB_INET_NTOP)|g' \
  -e 's|@''GNULIB_INET_PTON''@|$(GNULIB_INET_PTON)|g' \
+ -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
+ -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
  < $(srcdir)/arpa_inet.in.h; \
} > [EMAIL PROTECTED]
mv [EMAIL PROTECTED] $@
-- 
1.5.5





Re: provide inet_?to? declarations in arpa_inet.h

2008-04-28 Thread Simon Josefsson
Bruno Haible <[EMAIL PROTECTED]> writes:

> Hi Simon,
>
>> I would also favor removing both inet_ntop.h and inet_pton.h, and use
>> arpa/inet.h for the declarations, as you suggested.
>
> Me too.

Yoann, Bruno,
I've pushed the following, please test it.

/Simon

>From 33d11481e0930865b73ae2cf69403fe95223bb9a Mon Sep 17 00:00:00 2001
From: Simon Josefsson <[EMAIL PROTECTED]>
Date: Mon, 28 Apr 2008 17:40:25 +0200
Subject: [PATCH] Move inet_ntop and inet_pton declarations to arpa/inet.h.

---
 ChangeLog  |   16 
 lib/arpa_inet.in.h |   24 ++--
 lib/inet_ntop.c|4 ++--
 lib/inet_ntop.h|   42 --
 lib/inet_pton.c|4 ++--
 lib/inet_pton.h|   24 
 m4/inet_ntop.m4|7 +++
 m4/inet_pton.m4|7 +++
 modules/inet_ntop  |3 +--
 modules/inet_pton  |3 +--
 10 files changed, 50 insertions(+), 84 deletions(-)
 delete mode 100644 lib/inet_ntop.h
 delete mode 100644 lib/inet_pton.h

diff --git a/ChangeLog b/ChangeLog
index 147e944..53fe2a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2008-04-28  Simon Josefsson  <[EMAIL PROTECTED]>
 
+   * lib/inet_ntop.h, lib/inet_pton.h: Remove files.
+
+   * lib/inet_ntop.c: Include arpa/inet.h instead of inet_ntop.h.
+
+   * lib/inet_pton.c: Include arpa/inet.h instead of inet_pton.h.
+
+   * lib/arpa_inet.in.h [EMAIL PROTECTED]@]: Inline inet_ntop.h
+   declarations.
+   [EMAIL PROTECTED]@]: Inline inet_pton.h declarations.
+
+   * m4/inet_pton.m4: Don't check for header files.
+
+   * m4/inet_ntop.m4: Don't check for header files.
+
+2008-04-28  Simon Josefsson  <[EMAIL PROTECTED]>
+
* m4/sys_socket_h.m4: Require AC_C_INLINE when necessary.
* lib/sys_socket.in.h (setsockopt): Use proper win32 tests (don't
trigger for cygwin).
diff --git a/lib/arpa_inet.in.h b/lib/arpa_inet.in.h
index f043e59..900f7f3 100644
--- a/lib/arpa_inet.in.h
+++ b/lib/arpa_inet.in.h
@@ -23,7 +23,25 @@
 #include 
 
 #if @GNULIB_INET_NTOP@
-# include 
+# if [EMAIL PROTECTED]@
+/* Converts an internet address from internal format to a printable,
+   presentable format.
+   AF is an internet address family, such as AF_INET or AF_INET6.
+   SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr'
+   (for AF_INET6).
+   DST points to a buffer having room for CNT bytes.
+   The printable representation of the address (in numeric form, not
+   surrounded by [...], no reverse DNS is done) is placed in DST, and
+   DST is returned.  If an error occurs, the return value is NULL and
+   errno is set.  If CNT bytes are not sufficient to hold the result,
+   the return value is NULL and errno is set to ENOSPC.  A good value
+   for CNT is 46.
+
+   For more details, see the POSIX:2001 specification
+   .  */
+extern const char *inet_ntop (int af, const void *restrict src,
+ char *restrict dst, socklen_t cnt);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef inet_ntop
 # define inet_ntop(af,src,dst,cnt) \
@@ -33,7 +51,9 @@
 #endif
 
 #if @GNULIB_INET_PTON@
-# include 
+# if [EMAIL PROTECTED]@
+extern int inet_pton (int af, const char *restrict src, void *restrict dst);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef inet_pton
 # define inet_pton(af,src,dst) \
diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c
index 537b59f..16eb109 100644
--- a/lib/inet_ntop.c
+++ b/lib/inet_ntop.c
@@ -1,6 +1,6 @@
 /* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
 
-   Copyright (C) 2005, 2006  Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, 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
@@ -36,7 +36,7 @@
 #include 
 
 /* Specification.  */
-#include "inet_ntop.h"
+#include 
 
 #include 
 #include 
diff --git a/lib/inet_ntop.h b/lib/inet_ntop.h
deleted file mode 100644
index bd1e085..000
--- a/lib/inet_ntop.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Convert internet address from internal to printable, presentable format.
-   Copyright (C) 2005, 2006 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 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 Foundat

Re: provide inet_?to? declarations in arpa_inet.h

2008-04-26 Thread Bruno Haible
Hi Simon,

> I would also favor removing both inet_ntop.h and inet_pton.h, and use
> arpa/inet.h for the declarations, as you suggested.

Me too.

Bruno





Re: provide inet_?to? declarations in arpa_inet.h

2008-04-22 Thread Simon Josefsson
Yoann Vandoorselaere <[EMAIL PROTECTED]> writes:

> Hi Simon,
>
> Le mardi 22 avril 2008 à 10:54 +0200, Simon Josefsson a écrit :
>> Gnulib's current (minimal) arpa/inet.h for MinGW doesn't declare
>> inet_ntop and inet_pton, which doesn't exist on MinGW.  However, gnulib
>> has inet_ntop and inet_pton modules with their own header files.  This
>> patch makes sure that arpa/inet.h provides the expected declarations.
>> Comments?
>> 
>> Yoann, ok to commit?  It has minimal consequences for your module
>> inet_ntop, it only adds a gl_ARPA_INET_MODULE_INDICATOR([inet_ntop] to
>> the modules/inet_ntop file.
>> 
>> We could consider dropping the inet_ntop.h and inet_pton.h files
>> instead, and just require that you include arpa/inet.h.  This would be
>> slightly cleaner.  Yoann, what do you think about that?
>
> Look good to me, please commit.

Hi Yoann.  Done, thanks for feedback.

> I would also favor removing both inet_ntop.h and inet_pton.h, and use
> arpa/inet.h for the declarations, as you suggested.

Yes, I'll work on that next.

/Simon




Re: provide inet_?to? declarations in arpa_inet.h

2008-04-22 Thread Yoann Vandoorselaere
Hi Simon,

Le mardi 22 avril 2008 à 10:54 +0200, Simon Josefsson a écrit :
> Gnulib's current (minimal) arpa/inet.h for MinGW doesn't declare
> inet_ntop and inet_pton, which doesn't exist on MinGW.  However, gnulib
> has inet_ntop and inet_pton modules with their own header files.  This
> patch makes sure that arpa/inet.h provides the expected declarations.
> Comments?
> 
> Yoann, ok to commit?  It has minimal consequences for your module
> inet_ntop, it only adds a gl_ARPA_INET_MODULE_INDICATOR([inet_ntop] to
> the modules/inet_ntop file.
> 
> We could consider dropping the inet_ntop.h and inet_pton.h files
> instead, and just require that you include arpa/inet.h.  This would be
> slightly cleaner.  Yoann, what do you think about that?

Look good to me, please commit.

I would also favor removing both inet_ntop.h and inet_pton.h, and use
arpa/inet.h for the declarations, as you suggested.

Thanks!

-- 
Yoann Vandoorselaere | Responsable R&D / CTO | PreludeIDS Technologies
Tel: +33 (0)8 70 70 21 58  Fax: +33(0)4 78 42 21 58
http://www.prelude-ids.com





provide inet_?to? declarations in arpa_inet.h

2008-04-22 Thread Simon Josefsson
Hi,

Gnulib's current (minimal) arpa/inet.h for MinGW doesn't declare
inet_ntop and inet_pton, which doesn't exist on MinGW.  However, gnulib
has inet_ntop and inet_pton modules with their own header files.  This
patch makes sure that arpa/inet.h provides the expected declarations.
Comments?

Yoann, ok to commit?  It has minimal consequences for your module
inet_ntop, it only adds a gl_ARPA_INET_MODULE_INDICATOR([inet_ntop] to
the modules/inet_ntop file.

We could consider dropping the inet_ntop.h and inet_pton.h files
instead, and just require that you include arpa/inet.h.  This would be
slightly cleaner.  Yoann, what do you think about that?

/Simon

diff --git a/m4/arpa_inet_h.m4 b/m4/arpa_inet_h.m4
index d01d098..8f530c5 100644
--- a/m4/arpa_inet_h.m4
+++ b/m4/arpa_inet_h.m4
@@ -1,5 +1,5 @@
-# arpa_inet_h.m4 serial 1
-dnl Copyright (C) 2006 Free Software Foundation, Inc.
+# arpa_inet_h.m4 serial 2
+dnl Copyright (C) 2006, 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.
@@ -8,6 +8,10 @@ dnl Written by Simon Josefsson
 
 AC_DEFUN([gl_HEADER_ARPA_INET],
 [
+  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
+  dnl once only, before all statements that occur in other macros.
+  AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
+
   AC_CHECK_HEADERS_ONCE([arpa/inet.h])
   if test $ac_cv_header_arpa_inet_h = yes; then
 ARPA_INET_H=''
@@ -16,3 +20,16 @@ AC_DEFUN([gl_HEADER_ARPA_INET],
   fi
   AC_SUBST(ARPA_INET_H)
 ])
+
+AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
+  
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_ARPA_INET_H_DEFAULTS],
+[
+  GNULIB_INET_NTOP=0; AC_SUBST([GNULIB_INET_NTOP])
+  GNULIB_INET_PTON=0; AC_SUBST([GNULIB_INET_PTON])
+])
diff --git a/modules/arpa_inet b/modules/arpa_inet
index 5193952..6cdf206 100644
--- a/modules/arpa_inet
+++ b/modules/arpa_inet
@@ -2,6 +2,7 @@ Description:
 A  for systems lacking it (e.g., Mingw).
 
 Files:
+lib/arpa_inet.in.h
 m4/arpa_inet_h.m4
 
 Depends-on:
@@ -18,9 +19,11 @@ BUILT_SOURCES += $(ARPA_INET_H)
 # doesn't have one.
 arpa/inet.h:
@MKDIR_P@ arpa
-   rm -f [EMAIL PROTECTED] $@
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- echo '#include '; \
+ sed \
+ -e 's|@''GNULIB_INET_NTOP''@|$(GNULIB_INET_NTOP)|g' \
+ -e 's|@''GNULIB_INET_PTON''@|$(GNULIB_INET_PTON)|g' \
+ < $(srcdir)/arpa_inet.in.h; \
} > [EMAIL PROTECTED]
mv [EMAIL PROTECTED] $@
 MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t
diff --git a/modules/inet_ntop b/modules/inet_ntop
index 544ab87..1779359 100644
--- a/modules/inet_ntop
+++ b/modules/inet_ntop
@@ -14,6 +14,7 @@ netinet_in
 
 configure.ac:
 gl_INET_NTOP
+gl_ARPA_INET_MODULE_INDICATOR([inet_ntop])
 
 Makefile.am:
 
diff --git a/modules/inet_pton b/modules/inet_pton
index c9a4fac..3b6166d 100644
--- a/modules/inet_pton
+++ b/modules/inet_pton
@@ -14,6 +14,7 @@ netinet_in
 
 configure.ac:
 gl_INET_PTON
+gl_ARPA_INET_MODULE_INDICATOR([inet_pton])
 
 Makefile.am:

lib/arpa_inet.h:
 
/* Provide a arpa/inet header file for systems lacking it (read: MinGW)
   Copyright (C) 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 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.  */

#ifndef _GL_ARPA_INET_H
#define _GL_ARPA_INET_H

/* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc
   under MinGW. */
#include 

#if @GNULIB_INET_NTOP@
# include 
#elif defined GNULIB_POSIXCHECK
# undef inet_ntop
# define inet_ntop(af,src,dst,cnt)  \
(GL_LINK_WARNING ("inet_ntop doesn't exist on mingw - " \
  "use gnulib module inet_ntop for portability"), \
 inet_ntop (af, src, dst, cnt))
#endif

#if @GNULIB_INET_PTON@
# include 
#elif defined GNULIB_POSIXCHECK
# undef inet_pton
# define inet_pton(af,src,dst)  \
  (GL_LINK_WARNING ("inet_pton doesn't exist on mingw - " \
"use gnulib module inet_pton for portability"),   \
   ine