Fixes with gethostbyname occured after win32 porting ...

v0.5.xx
Alexander Vdolainen 10 years ago
parent f3073beccd
commit ecc8275674

@ -2166,7 +2166,11 @@ int connection_initiate(conn_t *co, const char *host, int port,
}
//r=__resolvehost(host, buf, __TMPBUFLEN, &host_);
host_=gethostbyname(host);
#ifdef WIN32
host_ = gethostbyname(host);
#else
r=__resolvehost(host, buf, __TMPBUFLEN, &host_);
#endif
if(errno) {
r = ENOENT;

@ -47,8 +47,8 @@
#ifdef uuid_t
#undef uuid_t
#endif
#ifdef WIN32
#ifdef WIN32
typedef unsigned char uuid_t[16];
void uuid_generate_random(uuid_t out){
@ -107,45 +107,26 @@ char *__generate_uuid(void)
}
/* networking helpers */
#ifndef WIN32
int __resolvehost(const char *hostname, char *buf, int buf_len,
struct hostent **rhp)
{
#ifndef WIN32
return 0;
#else
return 0;
#endif
// #ifndef WIN32
// struct hostent *hostbuf ;//= malloc(sizeof(struct hostent));
// // #endif
// struct hostent *hp = *rhp = NULL;
// int herr = 0, hres = 0;
// printf("__resolvehost hn %s buf %s\n", hostname,buf);
struct hostent *hostbuf ;//= malloc(sizeof(struct hostent));
struct hostent *hp = *rhp = NULL;
int herr = 0, hres = 0;
// #ifdef WIN32
// *rhp=gethostbyname(hostname);
// printf("__resolvehost hn err %s \n", strerror(errno));
// #else
// hostbuf = malloc(sizeof(struct hostent));
// if(!hostbuf) return NO_ADDRESS;
// hres = gethostbyname_r(hostname, hostbuf,
// buf, buf_len, &hp, &herr);
hostbuf = malloc(sizeof(struct hostent));
if(!hostbuf) return NO_ADDRESS;
hres = gethostbyname_r(hostname, hostbuf,
buf, buf_len, &hp, &herr);
if(hres) return NO_ADDRESS;
*rhp = hp;
// if(hres) return NO_ADDRESS;
// #endif
// *rhp = hp;
// #ifdef WIN32
// if (!*rhp) return NO_ADDRESS;
// else
// return 0;
// #else
// return NETDB_SUCCESS;
// #endif
return NETDB_SUCCESS;
}
#endif
/* sexp helpers */
int sexp_list_car(sexp_t *expr, sexp_t **sx)

Loading…
Cancel
Save