From f956bbce0775c4ff311881d5b4a4112714949793 Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Wed, 4 Sep 2002 20:55:20 +0000 Subject: [PATCH] use res_nsearch if we have it (from Larry Greenfield) git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11382 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/roken/resolve.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/roken/resolve.c b/lib/roken/resolve.c index 9cf1332d5..903a6c982 100644 --- a/lib/roken/resolve.c +++ b/lib/roken/resolve.c @@ -369,26 +369,43 @@ dns_lookup_int(const char *domain, int rr_class, int rr_type) { unsigned char reply[1024]; int len; -#ifdef HAVE__RES +#if defined(HAVE__RES) || defined(HAVE_RES_NSEARCH) u_long old_options = 0; #endif +#ifdef HAVE_RES_NSEARCH + res_state statp; + if(res_ninit(statp)) + return NULL; /* is this the best we can do? */ +#endif if (_resolve_debug) { -#ifdef HAVE__RES +#ifdef HAVE_RES_NSEARCH + old_options = statp.options; + statp.options |= RES_DEBUG; +#elif defined(HAVE__RES) old_options = _res.options; _res.options |= RES_DEBUG; #endif fprintf(stderr, "dns_lookup(%s, %d, %s)\n", domain, rr_class, dns_type_to_string(rr_type)); } +#ifdef HAVE_RES_NSEARCH + len = res_nsearch(statp, domain, rr_class, rr_type, reply, sizeof(reply)); +#else len = res_search(domain, rr_class, rr_type, reply, sizeof(reply)); +#endif if (_resolve_debug) { -#ifdef HAVE__RES +#ifdef HAVE_RES_NSEARCH + statp.options = old_options; +#elif defined(HAVE__RES) _res.options = old_options; #endif fprintf(stderr, "dns_lookup(%s, %d, %s) --> %d\n", domain, rr_class, dns_type_to_string(rr_type), len); } +#ifdef HAVE_RES_NSEARCH + res_nclose(statp); +#endif if(len < 0) { return NULL; } else {