summaryrefslogtreecommitdiffstats
path: root/man3/inet_net_pton.3
diff options
context:
space:
mode:
Diffstat (limited to 'man3/inet_net_pton.3')
-rw-r--r--man3/inet_net_pton.338
1 files changed, 17 insertions, 21 deletions
diff --git a/man3/inet_net_pton.3 b/man3/inet_net_pton.3
index bffa27b71..2a744419b 100644
--- a/man3/inet_net_pton.3
+++ b/man3/inet_net_pton.3
@@ -2,7 +2,7 @@
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
-.TH inet_net_pton 3 2023-02-05 "Linux man-pages 6.03"
+.TH inet_net_pton 3 2023-05-03 "Linux man-pages 6.05.01"
.SH NAME
inet_net_pton, inet_net_ntop \- Internet network number conversion
.SH LIBRARY
@@ -132,11 +132,7 @@ The size of the output buffer was insufficient.
.I pres
was not in correct presentation format.
.SH STANDARDS
-The
-.BR inet_net_pton ()
-and
-.BR inet_net_ntop ()
-functions are nonstandard, but widely available.
+None.
.SH NOTES
.SS Input presentation format for inet_net_pton()
The network number may be specified either
@@ -311,59 +307,59 @@ Raw address: c1a80180
.\" SRC BEGIN (inet_net_pton.c)
.EX
/* Link with "\-lresolv" */
-
+\&
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
-
+\&
#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \e
} while (0)
-
+\&
int
main(int argc, char *argv[])
{
char buf[100];
struct in_addr addr;
int bits;
-
+\&
if (argc < 2) {
fprintf(stderr,
"Usage: %s presentation\-form [addr\-init\-value]\en",
argv[0]);
exit(EXIT_FAILURE);
}
-
+\&
/* If argv[2] is supplied (a numeric value), use it to initialize
the output buffer given to inet_net_pton(), so that we can see
that inet_net_pton() initializes only those bytes needed for
the network number. If argv[2] is not supplied, then initialize
the buffer to zero (as is recommended practice). */
-
+\&
addr.s_addr = (argc > 2) ? strtod(argv[2], NULL) : 0;
-
+\&
/* Convert presentation network number in argv[1] to binary. */
-
+\&
bits = inet_net_pton(AF_INET, argv[1], &addr, sizeof(addr));
if (bits == \-1)
errExit("inet_net_ntop");
-
+\&
printf("inet_net_pton() returned: %d\en", bits);
-
+\&
/* Convert binary format back to presentation, using \[aq]bits\[aq]
returned by inet_net_pton(). */
-
+\&
if (inet_net_ntop(AF_INET, &addr, bits, buf, sizeof(buf)) == NULL)
errExit("inet_net_ntop");
-
+\&
printf("inet_net_ntop() yielded: %s\en", buf);
-
+\&
/* Display \[aq]addr\[aq] in raw form (in network byte order), so we can
see bytes not displayed by inet_net_ntop(); some of those bytes
may not have been touched by inet_net_ntop(), and so will still
have any initial value that was specified in argv[2]. */
-
+\&
printf("Raw address: %x\en", htonl(addr.s_addr));
-
+\&
exit(EXIT_SUCCESS);
}
.EE