22 |
#include "http-server.h" |
#include "http-server.h" |
23 |
|
|
24 |
#include <errno.h> |
#include <errno.h> |
|
#include <netdb.h> |
|
25 |
|
|
26 |
#include "util.h" |
#include "util.h" |
27 |
|
|
28 |
int xgethostbyname(const char * host, struct in_addr * a) { |
int xgethostbyname(const char * host, struct in_addr * a) { |
29 |
#ifdef __CYGWIN__ |
#if defined(__CYGWIN__) || defined(__MINGW32__) |
30 |
/* cygwin's gethostbyname is thread-safe */ |
/* gethostbyname is thread-safe */ |
31 |
struct hostent * p = gethostbyname(host); |
struct hostent * p = gethostbyname(host); |
32 |
if (p == NULL || p->h_addrtype != AF_INET) { |
if (p == NULL || p->h_addrtype != AF_INET) { |
33 |
return -1; |
return -1; |
57 |
return 0; |
return 0; |
58 |
#endif |
#endif |
59 |
} |
} |
60 |
|
|
61 |
|
#ifndef HAVE_INET_ATON |
62 |
|
int inet_aton(const char * name, struct in_addr * a) { |
63 |
|
unsigned long result = inet_addr(name); |
64 |
|
if (result == INADDR_NONE) { |
65 |
|
return 0; |
66 |
|
} |
67 |
|
else { |
68 |
|
a->s_addr = result; |
69 |
|
return 1; |
70 |
|
} |
71 |
|
} |
72 |
|
#endif |