2 * Copyright (c) 1995-1999 by Internet Software Consortium.
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
9 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
10 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
11 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
13 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
14 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
18 #include <sys/types.h>
19 #include <netinet/in.h>
20 #include <arpa/nameser.h>
25 /* The resolver state for use by single-threaded programs. */
26 struct __res_state _res
;
28 /* This function is used to access the resolver state in
29 single-threaded programs. */
38 /* The following bit is copied from res_data.c (where it is #ifdef'ed
39 out) since res_init() should go into libc.so but the rest of that
44 extern int __res_vinit(res_state
, int);
47 * These three fields used to be statically initialized. This made
48 * it hard to use this code in a shared library. It is necessary,
49 * now that we're doing dynamic initialization here, that we preserve
50 * the old semantics: if an application modifies one of these three
51 * fields of _res before res_init() is called, res_init() will not
52 * alter them. Of course, if an application is setting them to
53 * _zero_ before calling res_init(), hoping to override what used
54 * to be the static default, we can't detect it and unexpected results
55 * will follow. Zero for any of these fields would make no sense,
56 * so one can safely assume that the applications were already getting
59 * _res.options is tricky since some apps were known to diddle the bits
60 * before res_init() was first called. We can't replicate that semantic
61 * with dynamic initialization (they may have turned bits off that are
62 * set in RES_DEFAULT). Our solution is to declare such applications
63 * "broken". They could fool us by setting RES_INIT but none do (yet).
66 _res
.retrans
= RES_TIMEOUT
;
69 if (!(_res
.options
& RES_INIT
))
70 _res
.options
= RES_DEFAULT
;
73 * This one used to initialize implicitly to zero, so unless the app
74 * has set it to something in particular, we can randomize it now.
77 _res
.id
= res_randomid();
79 return (__res_vinit(&_res
, 1));
83 #include <shlib-compat.h>
85 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2)
87 strong_alias (__res_init
, __res_init_weak
);
88 weak_extern (__res_init_weak
);
89 compat_symbol (libc
, __res_init_weak
, res_init
, GLIBC_2_0
);