1*25c6d8b7Smbalmer /* $NetBSD: res_compat.c,v 1.3 2009/11/22 18:04:37 mbalmer Exp $ */
24b05f4b5Schristos
34b05f4b5Schristos /*-
44b05f4b5Schristos * Copyright (c) 2004 The NetBSD Foundation, Inc.
54b05f4b5Schristos * All rights reserved.
64b05f4b5Schristos *
74b05f4b5Schristos * This code is derived from software contributed to The NetBSD Foundation
84b05f4b5Schristos * by Christos Zoulas.
94b05f4b5Schristos *
104b05f4b5Schristos * Redistribution and use in source and binary forms, with or without
114b05f4b5Schristos * modification, are permitted provided that the following conditions
124b05f4b5Schristos * are met:
134b05f4b5Schristos * 1. Redistributions of source code must retain the above copyright
144b05f4b5Schristos * notice, this list of conditions and the following disclaimer.
154b05f4b5Schristos * 2. Redistributions in binary form must reproduce the above copyright
164b05f4b5Schristos * notice, this list of conditions and the following disclaimer in the
174b05f4b5Schristos * documentation and/or other materials provided with the distribution.
184b05f4b5Schristos *
194b05f4b5Schristos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
204b05f4b5Schristos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
214b05f4b5Schristos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
224b05f4b5Schristos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
234b05f4b5Schristos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
244b05f4b5Schristos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
254b05f4b5Schristos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
264b05f4b5Schristos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
274b05f4b5Schristos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
284b05f4b5Schristos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
294b05f4b5Schristos * POSSIBILITY OF SUCH DAMAGE.
304b05f4b5Schristos */
314b05f4b5Schristos
324b05f4b5Schristos #include <sys/cdefs.h>
334b05f4b5Schristos #if defined(LIBC_SCCS) && !defined(lint)
34*25c6d8b7Smbalmer __RCSID("$NetBSD: res_compat.c,v 1.3 2009/11/22 18:04:37 mbalmer Exp $");
354b05f4b5Schristos #endif
364b05f4b5Schristos
374b05f4b5Schristos #include <sys/types.h>
384b05f4b5Schristos #include <arpa/inet.h>
394b05f4b5Schristos #include <arpa/nameser.h>
404b05f4b5Schristos #include <netdb.h>
414b05f4b5Schristos #include <string.h>
424b05f4b5Schristos #define __OLD_RES_STATE
434b05f4b5Schristos #include <resolv.h>
444b05f4b5Schristos
454b05f4b5Schristos #undef _res
464b05f4b5Schristos
474b05f4b5Schristos /*
484b05f4b5Schristos * Binary Compatibility; this symbol does not appear in a header file
494b05f4b5Schristos * Most userland programs use this to set res_options before res_init()
504b05f4b5Schristos * is called. There are hooks to res_init() to consult the data in this
514b05f4b5Schristos * structure. The hooks are provided indirectly by the two functions below.
52*25c6d8b7Smbalmer * We depend on the fact the first 440 [32 bit machines] bytes are
534b05f4b5Schristos * shared between the two structures.
544b05f4b5Schristos */
554b05f4b5Schristos #ifndef __BIND_NOSTATIC
564b05f4b5Schristos struct __res_state _res
574b05f4b5Schristos #if defined(__BIND_RES_TEXT)
584b05f4b5Schristos = { RES_TIMEOUT, } /* Motorola, et al. */
594b05f4b5Schristos # endif
604b05f4b5Schristos ;
614b05f4b5Schristos
624b05f4b5Schristos void *__res_get_old_state(void);
634b05f4b5Schristos void __res_put_old_state(void *);
644b05f4b5Schristos
654b05f4b5Schristos void *
__res_get_old_state(void)664b05f4b5Schristos __res_get_old_state(void)
674b05f4b5Schristos {
684b05f4b5Schristos return &_res;
694b05f4b5Schristos }
704b05f4b5Schristos
714b05f4b5Schristos void
__res_put_old_state(void * res)724b05f4b5Schristos __res_put_old_state(void *res)
734b05f4b5Schristos {
744b05f4b5Schristos (void)memcpy(&_res, res, sizeof(_res));
754b05f4b5Schristos }
764b05f4b5Schristos #endif
77