MINOR: global: export function and permits to not resolve DNS names
exports the commonly used function str2ip. The function str2ip2 is
created and permits to not resolve DNS names.
diff --git a/src/standard.c b/src/standard.c
index f28825f..79158ff 100644
--- a/src/standard.c
+++ b/src/standard.c
@@ -567,9 +567,11 @@
* indicate INADDR_ANY. NULL is returned if the host part cannot be resolved.
* The return address will only have the address family and the address set,
* all other fields remain zero. The string is not supposed to be modified.
- * The IPv6 '::' address is IN6ADDR_ANY.
+ * The IPv6 '::' address is IN6ADDR_ANY. If <resolve> is non-zero, the hostname
+ * is resolved, otherwise only IP addresses are resolved, and anything else
+ * returns NULL.
*/
-static struct sockaddr_storage *str2ip(const char *str, struct sockaddr_storage *sa)
+struct sockaddr_storage *str2ip2(const char *str, struct sockaddr_storage *sa, int resolve)
{
struct hostent *he;
@@ -603,6 +605,9 @@
return sa;
}
+ if (!resolve)
+ return NULL;
+
#ifdef USE_GETADDRINFO
if (global.tune.options & GTUNE_USE_GAI) {
struct addrinfo hints, *result;