4 * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1999-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: master_test.c,v 1.32 2009/09/02 23:48:01 tbox Exp */
27 #include <isc/buffer.h>
31 #include <dns/callbacks.h>
32 #include <dns/master.h>
34 #include <dns/rdataset.h>
35 #include <dns/result.h>
40 print_dataset(void *arg
, dns_name_t
*owner
, dns_rdataset_t
*dataset
) {
47 isc_buffer_init(&target
, buf
, 64*1024);
48 result
= dns_rdataset_totext(dataset
, owner
, ISC_FALSE
, ISC_FALSE
,
50 if (result
== ISC_R_SUCCESS
)
51 fprintf(stdout
, "%.*s\n", (int)target
.used
,
54 fprintf(stdout
, "dns_rdataset_totext: %s\n",
55 dns_result_totext(result
));
57 return (ISC_R_SUCCESS
);
61 main(int argc
, char *argv
[]) {
66 unsigned char name_buf
[255];
67 dns_rdatacallbacks_t callbacks
;
71 RUNTIME_CHECK(isc_mem_create(0, 0, &mctx
) == ISC_R_SUCCESS
);
74 isc_buffer_init(&source
, argv
[1], strlen(argv
[1]));
75 isc_buffer_add(&source
, strlen(argv
[1]));
76 isc_buffer_setactive(&source
, strlen(argv
[1]));
77 isc_buffer_init(&target
, name_buf
, 255);
78 dns_name_init(&origin
, NULL
);
79 result
= dns_name_fromtext(&origin
, &source
, dns_rootname
,
81 if (result
!= ISC_R_SUCCESS
) {
82 fprintf(stdout
, "dns_name_fromtext: %s\n",
83 dns_result_totext(result
));
87 dns_rdatacallbacks_init_stdio(&callbacks
);
88 callbacks
.add
= print_dataset
;
90 result
= dns_master_loadfile(argv
[1], &origin
, &origin
,
93 fprintf(stdout
, "dns_master_loadfile: %s\n",
94 dns_result_totext(result
));