diff --git a/lib/connection.c b/lib/connection.c index b3ca7fb..0ee6816 100644 --- a/lib/connection.c +++ b/lib/connection.c @@ -162,25 +162,8 @@ static long __cmp_ulong(const void *a, const void *b) return *(ulong_t *)a - *(ulong_t *)b; } -static int __resolvehost(const char *hostname, char *buf, int buf_len, - struct hostent **rhp) -{ - struct hostent *hostbuf = malloc(sizeof(struct hostent)); - struct hostent *hp = *rhp = NULL; - int herr = 0, hres = 0; - - if(!hostbuf) return NO_ADDRESS; - - hres = gethostbyname_r(hostname, hostbuf, - buf, buf_len, &hp, &herr); - - if (!hp) return NO_ADDRESS; - if(hres) return NO_ADDRESS; - - *rhp = hp; - - return NETDB_SUCCESS; -} +extern int __resolvehost(const char *hostname, char *buf, int buf_len, + struct hostent **rhp); static void __destroy_rpc_list_tree(usrtc_t *tree) { diff --git a/lib/support.c b/lib/support.c index 5fc7082..a035b78 100644 --- a/lib/support.c +++ b/lib/support.c @@ -46,6 +46,27 @@ char *__generate_uuid(void) return uuidc; } +/* networking helpers */ +int __resolvehost(const char *hostname, char *buf, int buf_len, + struct hostent **rhp) +{ + struct hostent *hostbuf = malloc(sizeof(struct hostent)); + struct hostent *hp = *rhp = NULL; + int herr = 0, hres = 0; + + if(!hostbuf) return NO_ADDRESS; + + hres = gethostbyname_r(hostname, hostbuf, + buf, buf_len, &hp, &herr); + + if (!hp) return NO_ADDRESS; + if(hres) return NO_ADDRESS; + + *rhp = hp; + + return NETDB_SUCCESS; +} + /* sexp helpers */ int sexp_list_car(sexp_t *expr, sexp_t **sx) {