1*aa6411e2SAugustin Cavalier /* $NetBSD: h_errno.c,v 1.3 2008/06/21 20:41:48 christos Exp $ */
2*aa6411e2SAugustin Cavalier
3*aa6411e2SAugustin Cavalier /*-
4*aa6411e2SAugustin Cavalier * Copyright (c) 2004 The NetBSD Foundation, Inc.
5*aa6411e2SAugustin Cavalier * All rights reserved.
6*aa6411e2SAugustin Cavalier *
7*aa6411e2SAugustin Cavalier * This code is derived from software contributed to The NetBSD Foundation
8*aa6411e2SAugustin Cavalier * by Christos Zoulas.
9*aa6411e2SAugustin Cavalier *
10*aa6411e2SAugustin Cavalier * Redistribution and use in source and binary forms, with or without
11*aa6411e2SAugustin Cavalier * modification, are permitted provided that the following conditions
12*aa6411e2SAugustin Cavalier * are met:
13*aa6411e2SAugustin Cavalier * 1. Redistributions of source code must retain the above copyright
14*aa6411e2SAugustin Cavalier * notice, this list of conditions and the following disclaimer.
15*aa6411e2SAugustin Cavalier * 2. Redistributions in binary form must reproduce the above copyright
16*aa6411e2SAugustin Cavalier * notice, this list of conditions and the following disclaimer in the
17*aa6411e2SAugustin Cavalier * documentation and/or other materials provided with the distribution.
18*aa6411e2SAugustin Cavalier *
19*aa6411e2SAugustin Cavalier * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*aa6411e2SAugustin Cavalier * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*aa6411e2SAugustin Cavalier * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*aa6411e2SAugustin Cavalier * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*aa6411e2SAugustin Cavalier * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*aa6411e2SAugustin Cavalier * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*aa6411e2SAugustin Cavalier * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*aa6411e2SAugustin Cavalier * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*aa6411e2SAugustin Cavalier * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*aa6411e2SAugustin Cavalier * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*aa6411e2SAugustin Cavalier * POSSIBILITY OF SUCH DAMAGE.
30*aa6411e2SAugustin Cavalier */
31*aa6411e2SAugustin Cavalier
32*aa6411e2SAugustin Cavalier #include <sys/cdefs.h>
33*aa6411e2SAugustin Cavalier #if defined(LIBC_SCCS) && !defined(lint)
34*aa6411e2SAugustin Cavalier __RCSID("$NetBSD: h_errno.c,v 1.3 2008/06/21 20:41:48 christos Exp $");
35*aa6411e2SAugustin Cavalier #endif
36*aa6411e2SAugustin Cavalier
37*aa6411e2SAugustin Cavalier #include <sys/types.h>
38*aa6411e2SAugustin Cavalier #include <arpa/inet.h>
39*aa6411e2SAugustin Cavalier #include <arpa/nameser.h>
40*aa6411e2SAugustin Cavalier #include <resolv.h>
41*aa6411e2SAugustin Cavalier #include <netdb.h>
42*aa6411e2SAugustin Cavalier
43*aa6411e2SAugustin Cavalier #undef h_errno
44*aa6411e2SAugustin Cavalier
45*aa6411e2SAugustin Cavalier extern int h_errno;
46*aa6411e2SAugustin Cavalier extern struct __res_state _nres;
47*aa6411e2SAugustin Cavalier
48*aa6411e2SAugustin Cavalier int *
__h_errno(void)49*aa6411e2SAugustin Cavalier __h_errno(void)
50*aa6411e2SAugustin Cavalier {
51*aa6411e2SAugustin Cavalier return &_nres.res_h_errno;
52*aa6411e2SAugustin Cavalier }
53*aa6411e2SAugustin Cavalier
54*aa6411e2SAugustin Cavalier void
__h_errno_set(res_state res,int err)55*aa6411e2SAugustin Cavalier __h_errno_set(res_state res, int err)
56*aa6411e2SAugustin Cavalier {
57*aa6411e2SAugustin Cavalier h_errno = res->res_h_errno = err;
58*aa6411e2SAugustin Cavalier }
59