xref: /netbsd-src/lib/libc/resolv/h_errno.c (revision 3873655b27106b47bd1677dcc9631ec9c164fd6a)
1*3873655bSchristos /*	$NetBSD: h_errno.c,v 1.3 2008/06/21 20:41:48 christos Exp $	*/
278991785Schristos 
378991785Schristos /*-
478991785Schristos  * Copyright (c) 2004 The NetBSD Foundation, Inc.
578991785Schristos  * All rights reserved.
678991785Schristos  *
778991785Schristos  * This code is derived from software contributed to The NetBSD Foundation
878991785Schristos  * by Christos Zoulas.
978991785Schristos  *
1078991785Schristos  * Redistribution and use in source and binary forms, with or without
1178991785Schristos  * modification, are permitted provided that the following conditions
1278991785Schristos  * are met:
1378991785Schristos  * 1. Redistributions of source code must retain the above copyright
1478991785Schristos  *    notice, this list of conditions and the following disclaimer.
1578991785Schristos  * 2. Redistributions in binary form must reproduce the above copyright
1678991785Schristos  *    notice, this list of conditions and the following disclaimer in the
1778991785Schristos  *    documentation and/or other materials provided with the distribution.
1878991785Schristos  *
1978991785Schristos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2078991785Schristos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2178991785Schristos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2278991785Schristos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2378991785Schristos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2478991785Schristos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2578991785Schristos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2678991785Schristos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2778991785Schristos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2878991785Schristos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2978991785Schristos  * POSSIBILITY OF SUCH DAMAGE.
3078991785Schristos  */
3178991785Schristos 
3278991785Schristos #include <sys/cdefs.h>
3378991785Schristos #if defined(LIBC_SCCS) && !defined(lint)
34*3873655bSchristos __RCSID("$NetBSD: h_errno.c,v 1.3 2008/06/21 20:41:48 christos Exp $");
3578991785Schristos #endif
3678991785Schristos 
3778991785Schristos #include <sys/types.h>
3878991785Schristos #include <arpa/inet.h>
3978991785Schristos #include <arpa/nameser.h>
4078991785Schristos #include <resolv.h>
4178991785Schristos #include <netdb.h>
4278991785Schristos 
4378991785Schristos #undef h_errno
4478991785Schristos 
4578991785Schristos extern int h_errno;
46*3873655bSchristos extern struct __res_state _nres;
47*3873655bSchristos 
48*3873655bSchristos int *
__h_errno(void)49*3873655bSchristos __h_errno(void)
50*3873655bSchristos {
51*3873655bSchristos 	return &_nres.res_h_errno;
52*3873655bSchristos }
5378991785Schristos 
5478991785Schristos void
__h_errno_set(res_state res,int err)5578991785Schristos __h_errno_set(res_state res, int err)
5678991785Schristos {
5778991785Schristos 	h_errno = res->res_h_errno = err;
5878991785Schristos }
59