summaryrefslogtreecommitdiffstats
path: root/man3/inet_pton.3
diff options
context:
space:
mode:
Diffstat (limited to 'man3/inet_pton.3')
-rw-r--r--man3/inet_pton.314
1 files changed, 7 insertions, 7 deletions
diff --git a/man3/inet_pton.3 b/man3/inet_pton.3
index d51f838fd..54295f648 100644
--- a/man3/inet_pton.3
+++ b/man3/inet_pton.3
@@ -184,22 +184,22 @@ Here are some example runs:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
+\&
int
main(int argc, char *argv[])
{
unsigned char buf[sizeof(struct in6_addr)];
int domain, s;
char str[INET6_ADDRSTRLEN];
-
+\&
if (argc != 3) {
fprintf(stderr, "Usage: %s {i4|i6|<num>} string\en", argv[0]);
exit(EXIT_FAILURE);
}
-
+\&
domain = (strcmp(argv[1], "i4") == 0) ? AF_INET :
(strcmp(argv[1], "i6") == 0) ? AF_INET6 : atoi(argv[1]);
-
+\&
s = inet_pton(domain, argv[2], buf);
if (s <= 0) {
if (s == 0)
@@ -208,14 +208,14 @@ main(int argc, char *argv[])
perror("inet_pton");
exit(EXIT_FAILURE);
}
-
+\&
if (inet_ntop(domain, buf, str, INET6_ADDRSTRLEN) == NULL) {
perror("inet_ntop");
exit(EXIT_FAILURE);
}
-
+\&
printf("%s\en", str);
-
+\&
exit(EXIT_SUCCESS);
}
.EE