2 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (c) 1996-1999 by Internet Software Consortium.
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.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC 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
15 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #if !defined(LINT) && !defined(CODECENTER)
19 static const char rcsid
[] = "$Id: lcl.c,v 1.1.2.2 2004/03/17 00:40:13 marka Exp $";
24 #include "port_before.h"
30 #include <sys/types.h>
31 #include <netinet/in.h>
32 #include <arpa/nameser.h>
35 #include <isc/memcluster.h>
39 #include "port_after.h"
46 static void lcl_close(struct irs_acc
*);
47 static struct __res_state
* lcl_res_get(struct irs_acc
*);
48 static void lcl_res_set(struct irs_acc
*, struct __res_state
*,
54 irs_lcl_acc(const char *options
) {
60 if (!(acc
= memget(sizeof *acc
))) {
64 memset(acc
, 0x5e, sizeof *acc
);
65 if (!(lcl
= memget(sizeof *lcl
))) {
70 memset(lcl
, 0x5e, sizeof *lcl
);
75 acc
->gr_map
= irs_lcl_gr
;
80 acc
->pw_map
= irs_lcl_pw
;
84 acc
->sv_map
= irs_lcl_sv
;
85 acc
->pr_map
= irs_lcl_pr
;
86 acc
->ho_map
= irs_lcl_ho
;
87 acc
->nw_map
= irs_lcl_nw
;
88 acc
->ng_map
= irs_lcl_ng
;
89 acc
->res_get
= lcl_res_get
;
90 acc
->res_set
= lcl_res_set
;
91 acc
->close
= lcl_close
;
96 static struct __res_state
*
97 lcl_res_get(struct irs_acc
*this) {
98 struct lcl_p
*lcl
= (struct lcl_p
*)this->private;
100 if (lcl
->res
== NULL
) {
101 struct __res_state
*res
;
102 res
= (struct __res_state
*)malloc(sizeof *res
);
105 memset(res
, 0, sizeof *res
);
106 lcl_res_set(this, res
, free
);
109 if ((lcl
->res
->options
& RES_INIT
) == 0U &&
110 res_ninit(lcl
->res
) < 0)
117 lcl_res_set(struct irs_acc
*this, struct __res_state
*res
,
118 void (*free_res
)(void *)) {
119 struct lcl_p
*lcl
= (struct lcl_p
*)this->private;
121 if (lcl
->res
&& lcl
->free_res
) {
122 res_nclose(lcl
->res
);
123 (*lcl
->free_res
)(lcl
->res
);
127 lcl
->free_res
= free_res
;
131 lcl_close(struct irs_acc
*this) {
132 struct lcl_p
*lcl
= (struct lcl_p
*)this->private;
136 (*lcl
->free_res
)(lcl
->res
);
137 memput(lcl
, sizeof *lcl
);
139 memput(this, sizeof *this);