(root)/
grep-3.11/
gnulib-tests/
arpa_inet.in.h
       1  /* A GNU-like <arpa/inet.h>.
       2  
       3     Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
       4  
       5     This file is free software: you can redistribute it and/or modify
       6     it under the terms of the GNU Lesser General Public License as
       7     published by the Free Software Foundation; either version 2.1 of the
       8     License, or (at your option) any later version.
       9  
      10     This file is distributed in the hope that it will be useful,
      11     but WITHOUT ANY WARRANTY; without even the implied warranty of
      12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13     GNU Lesser General Public License for more details.
      14  
      15     You should have received a copy of the GNU Lesser General Public License
      16     along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
      17  
      18  #ifndef _@GUARD_PREFIX@_ARPA_INET_H
      19  
      20  #if __GNUC__ >= 3
      21  @PRAGMA_SYSTEM_HEADER@
      22  #endif
      23  @PRAGMA_COLUMNS@
      24  
      25  #if @HAVE_FEATURES_H@
      26  # include <features.h> /* for __GLIBC__ */
      27  #endif
      28  
      29  /* Gnulib's sys/socket.h is responsible for defining socklen_t (used below) and
      30     for pulling in winsock2.h etc. under MinGW.
      31     But avoid namespace pollution on glibc systems.  */
      32  #ifndef __GLIBC__
      33  # include <sys/socket.h>
      34  #endif
      35  
      36  /* On NonStop Kernel, inet_ntop and inet_pton are declared in <netdb.h>.
      37     But avoid namespace pollution on glibc systems.  */
      38  #if defined __TANDEM && !defined __GLIBC__
      39  # include <netdb.h>
      40  #endif
      41  
      42  #if @HAVE_ARPA_INET_H@
      43  
      44  /* The include_next requires a split double-inclusion guard.  */
      45  # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@
      46  
      47  #endif
      48  
      49  #ifndef _@GUARD_PREFIX@_ARPA_INET_H
      50  #define _@GUARD_PREFIX@_ARPA_INET_H
      51  
      52  /* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*.  */
      53  #if !_GL_CONFIG_H_INCLUDED
      54   #error "Please include config.h first."
      55  #endif
      56  
      57  /* Get all possible declarations of inet_ntop() and inet_pton().  */
      58  #if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \
      59      && @HAVE_WS2TCPIP_H@
      60  # include <ws2tcpip.h>
      61  #endif
      62  
      63  /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
      64  
      65  /* The definition of _GL_ARG_NONNULL is copied here.  */
      66  
      67  /* The definition of _GL_WARN_ON_USE is copied here.  */
      68  
      69  
      70  #if @GNULIB_INET_NTOP@
      71  /* Converts an internet address from internal format to a printable,
      72     presentable format.
      73     AF is an internet address family, such as AF_INET or AF_INET6.
      74     SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr'
      75     (for AF_INET6).
      76     DST points to a buffer having room for CNT bytes.
      77     The printable representation of the address (in numeric form, not
      78     surrounded by [...], no reverse DNS is done) is placed in DST, and
      79     DST is returned.  If an error occurs, the return value is NULL and
      80     errno is set.  If CNT bytes are not sufficient to hold the result,
      81     the return value is NULL and errno is set to ENOSPC.  A good value
      82     for CNT is 46.
      83  
      84     For more details, see the POSIX:2008 specification
      85     <https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_ntop.html>.  */
      86  # if @REPLACE_INET_NTOP@
      87  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
      88  #   undef inet_ntop
      89  #   define inet_ntop rpl_inet_ntop
      90  #  endif
      91  _GL_FUNCDECL_RPL (inet_ntop, const char *,
      92                    (int af, const void *restrict src,
      93                     char *restrict dst, socklen_t cnt)
      94                    _GL_ARG_NONNULL ((2, 3)));
      95  _GL_CXXALIAS_RPL (inet_ntop, const char *,
      96                    (int af, const void *restrict src,
      97                     char *restrict dst, socklen_t cnt));
      98  # else
      99  #  if !@HAVE_DECL_INET_NTOP@
     100  _GL_FUNCDECL_SYS (inet_ntop, const char *,
     101                    (int af, const void *restrict src,
     102                     char *restrict dst, socklen_t cnt)
     103                    _GL_ARG_NONNULL ((2, 3)));
     104  #  endif
     105  /* Need to cast, because on NonStop Kernel, the fourth parameter is
     106                                              size_t cnt.  */
     107  _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *,
     108                         (int af, const void *restrict src,
     109                          char *restrict dst, socklen_t cnt));
     110  # endif
     111  # if __GLIBC__ >= 2
     112  _GL_CXXALIASWARN (inet_ntop);
     113  # endif
     114  #elif defined GNULIB_POSIXCHECK
     115  # undef inet_ntop
     116  # if HAVE_RAW_DECL_INET_NTOP
     117  _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - "
     118                   "use gnulib module inet_ntop for portability");
     119  # endif
     120  #endif
     121  
     122  #if @GNULIB_INET_PTON@
     123  # if @REPLACE_INET_PTON@
     124  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     125  #   undef inet_pton
     126  #   define inet_pton rpl_inet_pton
     127  #  endif
     128  _GL_FUNCDECL_RPL (inet_pton, int,
     129                    (int af, const char *restrict src, void *restrict dst)
     130                    _GL_ARG_NONNULL ((2, 3)));
     131  _GL_CXXALIAS_RPL (inet_pton, int,
     132                    (int af, const char *restrict src, void *restrict dst));
     133  # else
     134  #  if !@HAVE_DECL_INET_PTON@
     135  _GL_FUNCDECL_SYS (inet_pton, int,
     136                    (int af, const char *restrict src, void *restrict dst)
     137                    _GL_ARG_NONNULL ((2, 3)));
     138  #  endif
     139  _GL_CXXALIAS_SYS (inet_pton, int,
     140                    (int af, const char *restrict src, void *restrict dst));
     141  # endif
     142  # if __GLIBC__ >= 2
     143  _GL_CXXALIASWARN (inet_pton);
     144  # endif
     145  #elif defined GNULIB_POSIXCHECK
     146  # undef inet_pton
     147  # if HAVE_RAW_DECL_INET_PTON
     148  _GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - "
     149                   "use gnulib module inet_pton for portability");
     150  # endif
     151  #endif
     152  
     153  
     154  #endif /* _@GUARD_PREFIX@_ARPA_INET_H */
     155  #endif /* _@GUARD_PREFIX@_ARPA_INET_H */