--- trunk/http-host.c 2008/05/31 21:42:36 116 +++ trunk/http-host.c 2008/06/02 17:52:38 125 @@ -22,11 +22,19 @@ #include "http-server.h" #include -#include #include "util.h" int xgethostbyname(const char * host, struct in_addr * a) { +#if defined(__CYGWIN__) || defined(__MINGW32__) + /* gethostbyname is thread-safe */ + struct hostent * p = gethostbyname(host); + if (p == NULL || p->h_addrtype != AF_INET) { + return -1; + } + *a = *((struct in_addr *) p->h_addr); + return 0; +#else struct hostent h; struct hostent * p; char * buffer; @@ -47,4 +55,18 @@ *a = *((struct in_addr *) p->h_addr); free(buffer); return 0; +#endif +} + +#ifndef HAVE_INET_ATON +int inet_aton(const char * name, struct in_addr * a) { + unsigned long result = inet_addr(name); + if (result == INADDR_NONE) { + return 0; + } + else { + a->s_addr = result; + return 1; + } } +#endif