1 /* $NetBSD: lwresconf_test.c,v 1.6 2014/12/10 04:37:53 christos Exp $ */
4 * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 2000, 2001 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: lwresconf_test.c,v 1.13 2007/06/19 23:46:59 tbox Exp */
29 #include <lwres/lwres.h>
34 CHECK(int val
, const char *msg
) {
36 fprintf(stderr
, "%s returned %d\n", msg
, val
);
43 * Wrappers around our memory management stuff, for the lwres functions.
46 mem_alloc(void *arg
, size_t size
) {
47 return (isc_mem_get(arg
, size
));
51 mem_free(void *arg
, void *mem
, size_t size
) {
52 isc_mem_put(arg
, mem
, size
);
57 main(int argc
, char *argv
[]) {
59 const char *file
= "/etc/resolv.conf";
72 result
= isc_mem_create(0, 0, &mem
);
73 INSIST(result
== ISC_R_SUCCESS
);
78 ret
= lwres_context_create(&ctx
, mem
, mem_alloc
, mem_free
, 0);
80 ret
= lwres_context_create(&ctx
, NULL
, NULL
, NULL
, 0);
82 CHECK(ret
, "lwres_context_create");
85 if (lwres_conf_parse(ctx
, file
) == 0) {
86 lwres_conf_print(ctx
, stderr
);
88 perror("lwres_conf_parse");
91 lwres_conf_clear(ctx
);
92 lwres_context_destroy(&ctx
);
95 isc_mem_stats(mem
, stdout
);
96 isc_mem_destroy(&mem
);