h_errno.c revision 158792
1173147Srwatson/*-
2156287Srwatson * Copyright (c) 2006 The FreeBSD Project. All rights reserved.
3156287Srwatson *
4156287Srwatson * Redistribution and use in source and binary forms, with or without
5156287Srwatson * modification, are permitted provided that the following conditions
6156287Srwatson * are met:
7156287Srwatson * 1. Redistributions of source code must retain the above copyright
8195740Srwatson *    notice, this list of conditions and the following disclaimer.
9156287Srwatson * 2. Redistributions in binary form must reproduce the above copyright
10186648Srwatson *    notice, this list of conditions and the following disclaimer in the
11195740Srwatson *    documentation and/or other materials provided with the distribution.
12186648Srwatson *
13156287Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14156287Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15156287Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16156287Srwatson * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17156287Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18156287Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19161634Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20161634Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21161634Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22156287Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23156287Srwatson * SUCH DAMAGE.
24156287Srwatson *
25156287Srwatson * $FreeBSD: head/lib/libc/resolv/h_errno.c 158792 2006-05-21 11:29:26Z ume $
26156287Srwatson */
27156287Srwatson
28156287Srwatson#include <sys/types.h>
29156287Srwatson#include <netinet/in.h>
30156287Srwatson#include <arpa/nameser.h>
31156287Srwatson#include <resolv.h>
32156287Srwatson
33156287Srwatson#undef	h_errno
34156287Srwatsonextern int h_errno;
35195740Srwatson
36156287Srwatsonint *
37156287Srwatson__h_errno(void)
38156287Srwatson{
39156287Srwatson	return (&__res_state()->res_h_errno);
40156287Srwatson}
41156287Srwatson
42156287Srwatsonvoid
43156287Srwatson__h_errno_set(res_state res, int err)
44156287Srwatson{
45156287Srwatson	h_errno = res->res_h_errno = err;
46185573Srwatson}
47185573Srwatson