xref: /freebsd/lib/libc/resolv/h_errno.c (revision 25462e6589bbe9f71686bcd7a67bb596b7915eec)
1ab96eeabSHajimu UMEMOTO /*-
2ab96eeabSHajimu UMEMOTO  * Copyright (c) 2006 The FreeBSD Project. All rights reserved.
3ab96eeabSHajimu UMEMOTO  *
4ab96eeabSHajimu UMEMOTO  * Redistribution and use in source and binary forms, with or without
5ab96eeabSHajimu UMEMOTO  * modification, are permitted provided that the following conditions
6ab96eeabSHajimu UMEMOTO  * are met:
7ab96eeabSHajimu UMEMOTO  * 1. Redistributions of source code must retain the above copyright
8ab96eeabSHajimu UMEMOTO  *    notice, this list of conditions and the following disclaimer.
9ab96eeabSHajimu UMEMOTO  * 2. Redistributions in binary form must reproduce the above copyright
10ab96eeabSHajimu UMEMOTO  *    notice, this list of conditions and the following disclaimer in the
11ab96eeabSHajimu UMEMOTO  *    documentation and/or other materials provided with the distribution.
12ab96eeabSHajimu UMEMOTO  *
13ab96eeabSHajimu UMEMOTO  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14ab96eeabSHajimu UMEMOTO  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15ab96eeabSHajimu UMEMOTO  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16ab96eeabSHajimu UMEMOTO  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17ab96eeabSHajimu UMEMOTO  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18ab96eeabSHajimu UMEMOTO  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19ab96eeabSHajimu UMEMOTO  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20ab96eeabSHajimu UMEMOTO  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21ab96eeabSHajimu UMEMOTO  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22ab96eeabSHajimu UMEMOTO  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23ab96eeabSHajimu UMEMOTO  * SUCH DAMAGE.
24ab96eeabSHajimu UMEMOTO  *
25ab96eeabSHajimu UMEMOTO  * $FreeBSD$
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 
36*25462e65SCraig Rodrigues int *__h_errno(void);
37*25462e65SCraig Rodrigues void __h_errno_set(res_state res, int err);
38*25462e65SCraig Rodrigues 
39ab96eeabSHajimu UMEMOTO int *
40ab96eeabSHajimu UMEMOTO __h_errno(void)
41ab96eeabSHajimu UMEMOTO {
42ab96eeabSHajimu UMEMOTO 	return (&__res_state()->res_h_errno);
43ab96eeabSHajimu UMEMOTO }
44ab96eeabSHajimu UMEMOTO 
45ab96eeabSHajimu UMEMOTO void
46ab96eeabSHajimu UMEMOTO __h_errno_set(res_state res, int err)
47ab96eeabSHajimu UMEMOTO {
48ab96eeabSHajimu UMEMOTO 	h_errno = res->res_h_errno = err;
49ab96eeabSHajimu UMEMOTO }
50