27 |
#include "util.h" |
#include "util.h" |
28 |
|
|
29 |
int xgethostbyname(const char * host, struct in_addr * a) { |
int xgethostbyname(const char * host, struct in_addr * a) { |
30 |
|
#ifdef __CYGWIN__ |
31 |
|
/* cygwin's gethostbyname is thread-safe */ |
32 |
|
struct hostent * p = gethostbyname(host); |
33 |
|
if (p == NULL || p->h_addrtype != AF_INET) { |
34 |
|
return -1; |
35 |
|
} |
36 |
|
*a = *((struct in_addr *) p->h_addr); |
37 |
|
return 0; |
38 |
|
#else |
39 |
struct hostent h; |
struct hostent h; |
40 |
struct hostent * p; |
struct hostent * p; |
41 |
char * buffer; |
char * buffer; |
56 |
*a = *((struct in_addr *) p->h_addr); |
*a = *((struct in_addr *) p->h_addr); |
57 |
free(buffer); |
free(buffer); |
58 |
return 0; |
return 0; |
59 |
|
#endif |
60 |
} |
} |