2000-02-16 17:46:18 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2000 Internet Software Consortium.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
2000-07-27 09:55:03 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
|
|
|
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
|
|
|
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
|
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
|
|
|
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
|
|
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2000-02-16 17:46:18 +00:00
|
|
|
*/
|
|
|
|
|
2000-07-27 09:55:03 +00:00
|
|
|
/* $Id: lwresconf_test.c,v 1.8 2000/07/27 09:38:07 tale Exp $ */
|
2000-06-22 22:00:42 +00:00
|
|
|
|
2000-02-16 17:46:18 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <isc/mem.h>
|
2000-04-28 02:12:16 +00:00
|
|
|
#include <isc/util.h>
|
2000-02-16 17:46:18 +00:00
|
|
|
|
|
|
|
#include <lwres/lwres.h>
|
|
|
|
|
|
|
|
#define USE_ISC_MEM
|
|
|
|
|
|
|
|
static inline void
|
2000-06-01 19:11:07 +00:00
|
|
|
CHECK(int val, const char *msg) {
|
2000-02-16 17:46:18 +00:00
|
|
|
if (val != 0) {
|
|
|
|
fprintf(stderr, "%s returned %d\n", msg, val);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef USE_ISC_MEM
|
|
|
|
/*
|
|
|
|
* Wrappers around our memory management stuff, for the lwres functions.
|
|
|
|
*/
|
|
|
|
static void *
|
2000-05-08 14:38:29 +00:00
|
|
|
mem_alloc(void *arg, size_t size) {
|
2000-02-16 17:46:18 +00:00
|
|
|
return (isc_mem_get(arg, size));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-05-08 14:38:29 +00:00
|
|
|
mem_free(void *arg, void *mem, size_t size) {
|
2000-02-16 17:46:18 +00:00
|
|
|
isc_mem_put(arg, mem, size);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int
|
2000-05-08 14:38:29 +00:00
|
|
|
main(int argc, char *argv[]) {
|
2000-02-16 17:46:18 +00:00
|
|
|
lwres_context_t *ctx;
|
|
|
|
const char *file = "/etc/resolv.conf";
|
|
|
|
int ret;
|
|
|
|
#ifdef USE_ISC_MEM
|
|
|
|
isc_mem_t *mem;
|
|
|
|
isc_result_t result;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (argc > 1) {
|
|
|
|
file = argv[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef USE_ISC_MEM
|
|
|
|
mem = NULL;
|
|
|
|
result = isc_mem_create(0, 0, &mem);
|
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ctx = NULL;
|
|
|
|
#ifdef USE_ISC_MEM
|
2000-06-15 23:48:11 +00:00
|
|
|
ret = lwres_context_create(&ctx, mem, mem_alloc, mem_free, 0);
|
2000-02-16 17:46:18 +00:00
|
|
|
#else
|
2000-06-15 23:48:11 +00:00
|
|
|
ret = lwres_context_create(&ctx, NULL, NULL, NULL, 0);
|
2000-02-16 17:46:18 +00:00
|
|
|
#endif
|
|
|
|
CHECK(ret, "lwres_context_create");
|
|
|
|
|
2000-04-17 19:22:44 +00:00
|
|
|
lwres_conf_init(ctx);
|
|
|
|
if (lwres_conf_parse(ctx, file) == 0) {
|
|
|
|
lwres_conf_print(ctx, stderr);
|
2000-02-16 17:46:18 +00:00
|
|
|
} else {
|
|
|
|
perror("lwres_conf_parse");
|
|
|
|
}
|
|
|
|
|
2000-04-17 19:22:44 +00:00
|
|
|
lwres_conf_clear(ctx);
|
2000-02-16 17:46:18 +00:00
|
|
|
lwres_context_destroy(&ctx);
|
|
|
|
|
|
|
|
#ifdef USE_ISC_MEM
|
|
|
|
isc_mem_stats(mem, stdout);
|
|
|
|
isc_mem_destroy(&mem);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|