2 * Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000, 2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or 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 WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: named-journalprint.c,v 1.2 2009/12/04 21:59:23 marka Exp $ */
27 #include <dns/journal.h>
29 #include <dns/result.h>
30 #include <dns/types.h>
35 * Setup logging to use stderr.
38 setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp) {
39 isc_logdestination_t destination;
40 isc_logconfig_t *logconfig = NULL;
41 isc_log_t *log = NULL;
43 RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) == ISC_R_SUCCESS);
44 isc_log_setcontext(log);
46 dns_log_setcontext(log);
48 destination.file.stream = errout;
49 destination.file.name = NULL;
50 destination.file.versions = ISC_LOG_ROLLNEVER;
51 destination.file.maximum_size = 0;
52 RUNTIME_CHECK(isc_log_createchannel(logconfig, "stderr",
55 &destination, 0) == ISC_R_SUCCESS);
56 RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr",
57 NULL, NULL) == ISC_R_SUCCESS);
60 return (ISC_R_SUCCESS);
64 main(int argc, char **argv) {
66 isc_mem_t *mctx = NULL;
68 isc_log_t *lctx = NULL;
71 printf("usage: %s journal\n", argv[0]);
77 RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
78 RUNTIME_CHECK(setup_logging(mctx, stderr, &lctx) == ISC_R_SUCCESS);
80 result = dns_journal_print(mctx, file, stdout);
81 if (result == DNS_R_NOJOURNAL)
82 fprintf(stderr, "%s\n", dns_result_totext(result));
83 isc_log_destroy(&lctx);
84 isc_mem_detach(&mctx);
85 return(result != ISC_R_SUCCESS ? 1 : 0);