Merged existing IPv4 and IPv6 Curl_ip2addr functions into a single one

which now also takes a protocol address family argument.
This commit is contained in:
Yang Tse
2008-11-06 17:19:56 +00:00
parent 2903a5c050
commit a0ef686c54
10 changed files with 150 additions and 217 deletions

View File

@@ -70,6 +70,7 @@
#include "strerror.h"
#include "url.h"
#include "multiif.h"
#include "inet_pton.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@@ -665,14 +666,13 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
{
struct hostent *h = NULL;
struct SessionHandle *data = conn->data;
in_addr_t in;
struct in_addr in;
*waitp = 0; /* don't wait, we act synchronously */
in = inet_addr(hostname);
if(in != CURL_INADDR_NONE)
if(Curl_inet_pton(AF_INET, hostname, &in) > 0)
/* This is a dotted IP address 123.123.123.123-style */
return Curl_ip2addr(in, hostname, port);
return Curl_ip2addr(AF_INET, &in, hostname, port);
/* fire up a new resolver thread! */
if(init_resolve_thread(conn, hostname, port, NULL)) {