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