xref: /freebsd/lib/libc/resolv/h_errno.c (revision d915a14ef094c8dfc1a5aee70e135abfec01d0f1)
1ab96eeabSHajimu UMEMOTO /*-
2*d915a14eSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*d915a14eSPedro 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  * $FreeBSD$
28ab96eeabSHajimu UMEMOTO  */
29ab96eeabSHajimu UMEMOTO 
30ab96eeabSHajimu UMEMOTO #include <sys/types.h>
31ab96eeabSHajimu UMEMOTO #include <netinet/in.h>
32ab96eeabSHajimu UMEMOTO #include <arpa/nameser.h>
33ab96eeabSHajimu UMEMOTO #include <resolv.h>
34ab96eeabSHajimu UMEMOTO 
35ab96eeabSHajimu UMEMOTO #undef	h_errno
36ab96eeabSHajimu UMEMOTO extern int h_errno;
37ab96eeabSHajimu UMEMOTO 
3825462e65SCraig Rodrigues int *__h_errno(void);
3925462e65SCraig Rodrigues void __h_errno_set(res_state res, int err);
4025462e65SCraig Rodrigues 
41ab96eeabSHajimu UMEMOTO int *
42ab96eeabSHajimu UMEMOTO __h_errno(void)
43ab96eeabSHajimu UMEMOTO {
44ab96eeabSHajimu UMEMOTO 	return (&__res_state()->res_h_errno);
45ab96eeabSHajimu UMEMOTO }
46ab96eeabSHajimu UMEMOTO 
47ab96eeabSHajimu UMEMOTO void
48ab96eeabSHajimu UMEMOTO __h_errno_set(res_state res, int err)
49ab96eeabSHajimu UMEMOTO {
50ab96eeabSHajimu UMEMOTO 	h_errno = res->res_h_errno = err;
51ab96eeabSHajimu UMEMOTO }
52