diff --git a/share/isinetaddr/examples/isinetaddr6.c b/share/isinetaddr/examples/isinetaddr6.c new file mode 100644 index 0000000..4a1873f --- /dev/null +++ b/share/isinetaddr/examples/isinetaddr6.c @@ -0,0 +1,31 @@ +#include +#include +#include + +const char *strings[] = { + /* valid */ + "::", + "::1", + "0000:0000:0000:0000:0000:0000:0000:0000", + + /* invalid */ + "foobar", + NULL, + "00:::0", +}; + +int +main(void) +{ + const char *str; + const int i = sizeof(strings) / sizeof(strings[0]); + for (int j = 0; j < i; j++) { + str = strings[j]; + if (isinetaddr6(str)) { + printf("%s is a valid IPv6 address\n", str); + } else { + printf("%s is an invalid IPv6 address\n", str); + } + } + return EXIT_SUCCESS; +}