xref: /openbsd-src/lib/libc/asr/res_init.c (revision 8082e013b3e34cd58819c630b3b36d768ac74f45)
1 /*	$OpenBSD: res_init.c,v 1.1 2012/09/08 11:08:21 eric Exp $	*/
2 /*
3  * Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #include <sys/types.h>
19 #include <netinet/in.h>
20 
21 #include <resolv.h>
22 
23 #include "asr.h"
24 
25 /*
26  * XXX these function is actually internal to asr, but we use it here to force
27  * the creation a default resolver context in res_init().
28  */
29 struct asr_ctx *asr_use_resolver(struct asr *);
30 void asr_ctx_unref(struct asr_ctx *);
31 
32 struct __res_state _res;
33 struct __res_state_ext _res_ext;
34 
35 int h_errno;
36 
37 int
38 res_init(void)
39 {
40 	async_resolver_done(NULL);
41 	asr_ctx_unref(asr_use_resolver(NULL));
42 
43 	return (0);
44 }
45