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