xref: /netbsd-src/external/gpl3/gdb/dist/gnulib/import/arpa_inet.in.h (revision 4b169a6ba595ae283ca507b26b15fdff40495b1c)
18dffb485Schristos /* A GNU-like <arpa/inet.h>.
28dffb485Schristos 
3*4b169a6bSchristos    Copyright (C) 2005-2006, 2008-2022 Free Software Foundation, Inc.
48dffb485Schristos 
5*4b169a6bSchristos    This file is free software: you can redistribute it and/or modify
6*4b169a6bSchristos    it under the terms of the GNU Lesser General Public License as
7*4b169a6bSchristos    published by the Free Software Foundation; either version 2.1 of the
8*4b169a6bSchristos    License, or (at your option) any later version.
98dffb485Schristos 
10*4b169a6bSchristos    This file is distributed in the hope that it will be useful,
118dffb485Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
128dffb485Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*4b169a6bSchristos    GNU Lesser General Public License for more details.
148dffb485Schristos 
15*4b169a6bSchristos    You should have received a copy of the GNU Lesser General Public License
16*4b169a6bSchristos    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
178dffb485Schristos 
188dffb485Schristos #ifndef _@GUARD_PREFIX@_ARPA_INET_H
198dffb485Schristos 
208dffb485Schristos #if __GNUC__ >= 3
218dffb485Schristos @PRAGMA_SYSTEM_HEADER@
228dffb485Schristos #endif
238dffb485Schristos @PRAGMA_COLUMNS@
248dffb485Schristos 
258dffb485Schristos #if @HAVE_FEATURES_H@
268dffb485Schristos # include <features.h> /* for __GLIBC__ */
278dffb485Schristos #endif
288dffb485Schristos 
298dffb485Schristos /* Gnulib's sys/socket.h is responsible for defining socklen_t (used below) and
308dffb485Schristos    for pulling in winsock2.h etc. under MinGW.
318dffb485Schristos    But avoid namespace pollution on glibc systems.  */
328dffb485Schristos #ifndef __GLIBC__
338dffb485Schristos # include <sys/socket.h>
348dffb485Schristos #endif
358dffb485Schristos 
368dffb485Schristos /* On NonStop Kernel, inet_ntop and inet_pton are declared in <netdb.h>.
378dffb485Schristos    But avoid namespace pollution on glibc systems.  */
388dffb485Schristos #if defined __TANDEM && !defined __GLIBC__
398dffb485Schristos # include <netdb.h>
408dffb485Schristos #endif
418dffb485Schristos 
428dffb485Schristos #if @HAVE_ARPA_INET_H@
438dffb485Schristos 
448dffb485Schristos /* The include_next requires a split double-inclusion guard.  */
458dffb485Schristos # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@
468dffb485Schristos 
478dffb485Schristos #endif
488dffb485Schristos 
498dffb485Schristos #ifndef _@GUARD_PREFIX@_ARPA_INET_H
508dffb485Schristos #define _@GUARD_PREFIX@_ARPA_INET_H
518dffb485Schristos 
528dffb485Schristos /* Get all possible declarations of inet_ntop() and inet_pton().  */
538dffb485Schristos #if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \
548dffb485Schristos     && @HAVE_WS2TCPIP_H@
558dffb485Schristos # include <ws2tcpip.h>
568dffb485Schristos #endif
578dffb485Schristos 
588dffb485Schristos /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
598dffb485Schristos 
608dffb485Schristos /* The definition of _GL_ARG_NONNULL is copied here.  */
618dffb485Schristos 
628dffb485Schristos /* The definition of _GL_WARN_ON_USE is copied here.  */
638dffb485Schristos 
648dffb485Schristos 
658dffb485Schristos #if @GNULIB_INET_NTOP@
668dffb485Schristos /* Converts an internet address from internal format to a printable,
678dffb485Schristos    presentable format.
688dffb485Schristos    AF is an internet address family, such as AF_INET or AF_INET6.
698dffb485Schristos    SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr'
708dffb485Schristos    (for AF_INET6).
718dffb485Schristos    DST points to a buffer having room for CNT bytes.
728dffb485Schristos    The printable representation of the address (in numeric form, not
738dffb485Schristos    surrounded by [...], no reverse DNS is done) is placed in DST, and
748dffb485Schristos    DST is returned.  If an error occurs, the return value is NULL and
758dffb485Schristos    errno is set.  If CNT bytes are not sufficient to hold the result,
768dffb485Schristos    the return value is NULL and errno is set to ENOSPC.  A good value
778dffb485Schristos    for CNT is 46.
788dffb485Schristos 
798dffb485Schristos    For more details, see the POSIX:2008 specification
808dffb485Schristos    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_ntop.html>.  */
818dffb485Schristos # if @REPLACE_INET_NTOP@
828dffb485Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
838dffb485Schristos #   undef inet_ntop
848dffb485Schristos #   define inet_ntop rpl_inet_ntop
858dffb485Schristos #  endif
868dffb485Schristos _GL_FUNCDECL_RPL (inet_ntop, const char *,
878dffb485Schristos                   (int af, const void *restrict src,
888dffb485Schristos                    char *restrict dst, socklen_t cnt)
898dffb485Schristos                   _GL_ARG_NONNULL ((2, 3)));
908dffb485Schristos _GL_CXXALIAS_RPL (inet_ntop, const char *,
918dffb485Schristos                   (int af, const void *restrict src,
928dffb485Schristos                    char *restrict dst, socklen_t cnt));
938dffb485Schristos # else
948dffb485Schristos #  if !@HAVE_DECL_INET_NTOP@
958dffb485Schristos _GL_FUNCDECL_SYS (inet_ntop, const char *,
968dffb485Schristos                   (int af, const void *restrict src,
978dffb485Schristos                    char *restrict dst, socklen_t cnt)
988dffb485Schristos                   _GL_ARG_NONNULL ((2, 3)));
998dffb485Schristos #  endif
1008dffb485Schristos /* Need to cast, because on NonStop Kernel, the fourth parameter is
1018dffb485Schristos                                             size_t cnt.  */
1028dffb485Schristos _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *,
1038dffb485Schristos                        (int af, const void *restrict src,
1048dffb485Schristos                         char *restrict dst, socklen_t cnt));
1058dffb485Schristos # endif
1068dffb485Schristos # if __GLIBC__ >= 2
1078dffb485Schristos _GL_CXXALIASWARN (inet_ntop);
1088dffb485Schristos # endif
1098dffb485Schristos #elif defined GNULIB_POSIXCHECK
1108dffb485Schristos # undef inet_ntop
1118dffb485Schristos # if HAVE_RAW_DECL_INET_NTOP
1128dffb485Schristos _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - "
1138dffb485Schristos                  "use gnulib module inet_ntop for portability");
1148dffb485Schristos # endif
1158dffb485Schristos #endif
1168dffb485Schristos 
1178dffb485Schristos #if @GNULIB_INET_PTON@
1188dffb485Schristos # if @REPLACE_INET_PTON@
1198dffb485Schristos #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1208dffb485Schristos #   undef inet_pton
1218dffb485Schristos #   define inet_pton rpl_inet_pton
1228dffb485Schristos #  endif
1238dffb485Schristos _GL_FUNCDECL_RPL (inet_pton, int,
1248dffb485Schristos                   (int af, const char *restrict src, void *restrict dst)
1258dffb485Schristos                   _GL_ARG_NONNULL ((2, 3)));
1268dffb485Schristos _GL_CXXALIAS_RPL (inet_pton, int,
1278dffb485Schristos                   (int af, const char *restrict src, void *restrict dst));
1288dffb485Schristos # else
1298dffb485Schristos #  if !@HAVE_DECL_INET_PTON@
1308dffb485Schristos _GL_FUNCDECL_SYS (inet_pton, int,
1318dffb485Schristos                   (int af, const char *restrict src, void *restrict dst)
1328dffb485Schristos                   _GL_ARG_NONNULL ((2, 3)));
1338dffb485Schristos #  endif
1348dffb485Schristos _GL_CXXALIAS_SYS (inet_pton, int,
1358dffb485Schristos                   (int af, const char *restrict src, void *restrict dst));
1368dffb485Schristos # endif
1378dffb485Schristos # if __GLIBC__ >= 2
1388dffb485Schristos _GL_CXXALIASWARN (inet_pton);
1398dffb485Schristos # endif
1408dffb485Schristos #elif defined GNULIB_POSIXCHECK
1418dffb485Schristos # undef inet_pton
1428dffb485Schristos # if HAVE_RAW_DECL_INET_PTON
1438dffb485Schristos _GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - "
1448dffb485Schristos                  "use gnulib module inet_pton for portability");
1458dffb485Schristos # endif
1468dffb485Schristos #endif
1478dffb485Schristos 
1488dffb485Schristos 
1498dffb485Schristos #endif /* _@GUARD_PREFIX@_ARPA_INET_H */
1508dffb485Schristos #endif /* _@GUARD_PREFIX@_ARPA_INET_H */
151