Try to use best DNS search functions in dnsglue.c

Create macros to declare a DNS search handle, initialize a handle,
perform a search, and destroy a handle.  On OS X, use the native
dns_open, dns_search, and dns_free functions, since using the res_*
interfaces may not contact the correct servers.  On systems with
res_ninit, use res_nclose if we don't have res_ndestroy.

Based on a patch by Nate Rosenblum.