improve gethostbyname2_r using new resolver backend
[musl] / src / network / res_query.c
1 #define _GNU_SOURCE
2 #include <resolv.h>
3 #include <netdb.h>
4 #include "__dns.h"
5 #include "libc.h"
6
7 int res_query(const char *name, int class, int type, unsigned char *dest, int len)
8 {
9         if (class != 1 || len < 512)
10                 return -1;
11         switch(__dns_doqueries(dest, name, &type, 1)) {
12         case EAI_NONAME:
13                 h_errno = HOST_NOT_FOUND;
14                 return -1;
15         case EAI_AGAIN:
16                 h_errno = TRY_AGAIN;
17                 return -1;
18         case EAI_FAIL:
19                 h_errno = NO_RECOVERY;
20                 return -1;
21         }
22         return 512;
23 }
24
25 weak_alias(res_query, res_search);