1ab96eeabSHajimu UMEMOTO /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
3d915a14eSPedro F. Giffuni *
4ab96eeabSHajimu UMEMOTO * Copyright (c) 2006 The FreeBSD Project. All rights reserved.
5ab96eeabSHajimu UMEMOTO *
6ab96eeabSHajimu UMEMOTO * Redistribution and use in source and binary forms, with or without
7ab96eeabSHajimu UMEMOTO * modification, are permitted provided that the following conditions
8ab96eeabSHajimu UMEMOTO * are met:
9ab96eeabSHajimu UMEMOTO * 1. Redistributions of source code must retain the above copyright
10ab96eeabSHajimu UMEMOTO * notice, this list of conditions and the following disclaimer.
11ab96eeabSHajimu UMEMOTO * 2. Redistributions in binary form must reproduce the above copyright
12ab96eeabSHajimu UMEMOTO * notice, this list of conditions and the following disclaimer in the
13ab96eeabSHajimu UMEMOTO * documentation and/or other materials provided with the distribution.
14ab96eeabSHajimu UMEMOTO *
15ab96eeabSHajimu UMEMOTO * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16ab96eeabSHajimu UMEMOTO * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17ab96eeabSHajimu UMEMOTO * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ab96eeabSHajimu UMEMOTO * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19ab96eeabSHajimu UMEMOTO * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20ab96eeabSHajimu UMEMOTO * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21ab96eeabSHajimu UMEMOTO * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22ab96eeabSHajimu UMEMOTO * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23ab96eeabSHajimu UMEMOTO * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24ab96eeabSHajimu UMEMOTO * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25ab96eeabSHajimu UMEMOTO * SUCH DAMAGE.
26ab96eeabSHajimu UMEMOTO */
27ab96eeabSHajimu UMEMOTO
28ab96eeabSHajimu UMEMOTO #include <sys/types.h>
29ab96eeabSHajimu UMEMOTO #include <netinet/in.h>
30ab96eeabSHajimu UMEMOTO #include <arpa/nameser.h>
31ab96eeabSHajimu UMEMOTO #include <resolv.h>
32ab96eeabSHajimu UMEMOTO
33ab96eeabSHajimu UMEMOTO #undef h_errno
34ab96eeabSHajimu UMEMOTO extern int h_errno;
35ab96eeabSHajimu UMEMOTO
3625462e65SCraig Rodrigues int *__h_errno(void);
3725462e65SCraig Rodrigues void __h_errno_set(res_state res, int err);
3825462e65SCraig Rodrigues
39ab96eeabSHajimu UMEMOTO int *
__h_errno(void)40ab96eeabSHajimu UMEMOTO __h_errno(void)
41ab96eeabSHajimu UMEMOTO {
42ab96eeabSHajimu UMEMOTO return (&__res_state()->res_h_errno);
43ab96eeabSHajimu UMEMOTO }
44ab96eeabSHajimu UMEMOTO
45ab96eeabSHajimu UMEMOTO void
__h_errno_set(res_state res,int err)46ab96eeabSHajimu UMEMOTO __h_errno_set(res_state res, int err)
47ab96eeabSHajimu UMEMOTO {
48ab96eeabSHajimu UMEMOTO h_errno = res->res_h_errno = err;
49ab96eeabSHajimu UMEMOTO }
50