xref: /netbsd-src/lib/libc/resolv/res_state.c (revision 461a86f9bdbf4658bc4b37796e978427095f94a7)
1*461a86f9Schristos /*	$NetBSD: res_state.c,v 1.8 2009/01/11 02:46:29 christos Exp $	*/
2fa406da8Schristos 
3fa406da8Schristos /*-
4fa406da8Schristos  * Copyright (c) 2004 The NetBSD Foundation, Inc.
5fa406da8Schristos  * All rights reserved.
6fa406da8Schristos  *
7fa406da8Schristos  * This code is derived from software contributed to The NetBSD Foundation
8fa406da8Schristos  * by Christos Zoulas.
9fa406da8Schristos  *
10fa406da8Schristos  * Redistribution and use in source and binary forms, with or without
11fa406da8Schristos  * modification, are permitted provided that the following conditions
12fa406da8Schristos  * are met:
13fa406da8Schristos  * 1. Redistributions of source code must retain the above copyright
14fa406da8Schristos  *    notice, this list of conditions and the following disclaimer.
15fa406da8Schristos  * 2. Redistributions in binary form must reproduce the above copyright
16fa406da8Schristos  *    notice, this list of conditions and the following disclaimer in the
17fa406da8Schristos  *    documentation and/or other materials provided with the distribution.
18fa406da8Schristos  *
19fa406da8Schristos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20fa406da8Schristos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21fa406da8Schristos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22fa406da8Schristos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23fa406da8Schristos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24fa406da8Schristos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25fa406da8Schristos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26fa406da8Schristos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27fa406da8Schristos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28fa406da8Schristos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29fa406da8Schristos  * POSSIBILITY OF SUCH DAMAGE.
30fa406da8Schristos  */
31fa406da8Schristos 
32fa406da8Schristos #include <sys/cdefs.h>
33fa406da8Schristos #if defined(LIBC_SCCS) && !defined(lint)
34*461a86f9Schristos __RCSID("$NetBSD: res_state.c,v 1.8 2009/01/11 02:46:29 christos Exp $");
35fa406da8Schristos #endif
36fa406da8Schristos 
37fa406da8Schristos #include <sys/types.h>
38fa406da8Schristos #include <arpa/inet.h>
39fa406da8Schristos #include <arpa/nameser.h>
403c2635eaSchristos #include <netdb.h>
41fa406da8Schristos #include <resolv.h>
42fa406da8Schristos 
43d73eb73dSchristos struct __res_state _nres
44d73eb73dSchristos # if defined(__BIND_RES_TEXT)
45d73eb73dSchristos 	= { .retrans = RES_TIMEOUT, }	/*%< Motorola, et al. */
46d73eb73dSchristos # endif
47d73eb73dSchristos 	;
48fa406da8Schristos 
49fa406da8Schristos res_state __res_get_state_nothread(void);
50fa406da8Schristos void __res_put_state_nothread(res_state);
51fa406da8Schristos 
52729d8bb9Schristos #ifdef __weak_alias
__weak_alias(__res_get_state,__res_get_state_nothread)53fa406da8Schristos __weak_alias(__res_get_state, __res_get_state_nothread)
54fa406da8Schristos __weak_alias(__res_put_state, __res_put_state_nothread)
557168861fSchristos /* Source compatibility; only for single threaded programs */
567168861fSchristos __weak_alias(__res_state, __res_get_state_nothread)
57729d8bb9Schristos #endif
58fa406da8Schristos 
59fa406da8Schristos res_state
60fa406da8Schristos __res_get_state_nothread(void)
61fa406da8Schristos {
624b05f4b5Schristos 	if ((_nres.options & RES_INIT) == 0 && res_ninit(&_nres) == -1) {
633c2635eaSchristos 		h_errno = NETDB_INTERNAL;
643c2635eaSchristos 		return NULL;
653c2635eaSchristos 	}
664b05f4b5Schristos 	return &_nres;
67fa406da8Schristos }
68fa406da8Schristos 
69fa406da8Schristos void
70fa406da8Schristos /*ARGSUSED*/
__res_put_state_nothread(res_state res)71fa406da8Schristos __res_put_state_nothread(res_state res)
72fa406da8Schristos {
73fa406da8Schristos }
74