2023-12-09 04:03:03 +00:00
|
|
|
/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│
|
2023-12-13 07:28:11 +00:00
|
|
|
│ vi: set noet ft=c ts=8 sw=8 fenc=utf-8 :vi │
|
2023-12-09 04:03:03 +00:00
|
|
|
╚──────────────────────────────────────────────────────────────────────────────╝
|
|
|
|
│ │
|
|
|
|
│ Musl Libc │
|
|
|
|
│ Copyright © 2005-2014 Rich Felker, et al. │
|
|
|
|
│ │
|
|
|
|
│ Permission is hereby granted, free of charge, to any person obtaining │
|
|
|
|
│ a copy of this software and associated documentation files (the │
|
|
|
|
│ "Software"), to deal in the Software without restriction, including │
|
|
|
|
│ without limitation the rights to use, copy, modify, merge, publish, │
|
|
|
|
│ distribute, sublicense, and/or sell copies of the Software, and to │
|
|
|
|
│ permit persons to whom the Software is furnished to do so, subject to │
|
|
|
|
│ the following conditions: │
|
|
|
|
│ │
|
|
|
|
│ The above copyright notice and this permission notice shall be │
|
|
|
|
│ included in all copies or substantial portions of the Software. │
|
|
|
|
│ │
|
|
|
|
│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │
|
|
|
|
│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │
|
|
|
|
│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │
|
|
|
|
│ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │
|
|
|
|
│ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │
|
|
|
|
│ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │
|
|
|
|
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
|
|
|
│ │
|
|
|
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
|
|
|
#include "third_party/musl/resolv.h"
|
2023-12-29 06:58:17 +00:00
|
|
|
#include "third_party/musl/netdb.h"
|
2023-12-09 04:03:03 +00:00
|
|
|
#include "third_party/musl/resolv.internal.h"
|
|
|
|
|
|
|
|
asm(".ident\t\"\\n\\n\
|
|
|
|
Musl libc (MIT License)\\n\
|
|
|
|
Copyright 2005-2014 Rich Felker, et. al.\"");
|
|
|
|
asm(".include \"libc/disclaimer.inc\"");
|
|
|
|
|
|
|
|
int res_query(const char *name, int class, int type, unsigned char *dest, int len)
|
|
|
|
{
|
|
|
|
unsigned char q[280];
|
|
|
|
int ql = __res_mkquery(0, name, class, type, 0, 0, 0, q, sizeof q);
|
|
|
|
if (ql < 0) return ql;
|
|
|
|
int r = __res_send(q, ql, dest, len);
|
|
|
|
if (r<12) {
|
|
|
|
h_errno = TRY_AGAIN;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if ((dest[3] & 15) == 3) {
|
|
|
|
h_errno = HOST_NOT_FOUND;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if ((dest[3] & 15) == 0 && !dest[6] && !dest[7]) {
|
|
|
|
h_errno = NO_DATA;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
__weak_reference(res_query, res_search);
|