From 6e18271550e09cede11943db639122edee80219c Mon Sep 17 00:00:00 2001 From: Alexander Vdolainen Date: Mon, 2 Feb 2015 14:59:49 +0200 Subject: [PATCH] resolve_host moved to the more appropriate place; --- lib/connection.c | 21 ++------------------- lib/support.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 19 deletions(-) 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) {