1 /* $NetBSD: callbacks.c,v 1.5 2014/12/10 04:37:58 christos Exp $ */
4 * Copyright (C) 2004, 2005, 2007, 2011, 2012 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: callbacks.c,v 1.19.40.1 2012/02/07 00:44:13 each Exp */
28 #include <dns/callbacks.h>
32 stdio_error_warn_callback(dns_rdatacallbacks_t
*, const char *, ...)
33 ISC_FORMAT_PRINTF(2, 3);
36 isclog_error_callback(dns_rdatacallbacks_t
*callbacks
, const char *fmt
, ...)
37 ISC_FORMAT_PRINTF(2, 3);
40 isclog_warn_callback(dns_rdatacallbacks_t
*callbacks
, const char *fmt
, ...)
41 ISC_FORMAT_PRINTF(2, 3);
48 stdio_error_warn_callback(dns_rdatacallbacks_t
*callbacks
,
56 vfprintf(stderr
, fmt
, ap
);
58 fprintf(stderr
, "\n");
62 isclog_error_callback(dns_rdatacallbacks_t
*callbacks
, const char *fmt
, ...) {
68 isc_log_vwrite(dns_lctx
, DNS_LOGCATEGORY_GENERAL
,
69 DNS_LOGMODULE_MASTER
, /* XXX */
70 ISC_LOG_ERROR
, fmt
, ap
);
75 isclog_warn_callback(dns_rdatacallbacks_t
*callbacks
, const char *fmt
, ...) {
82 isc_log_vwrite(dns_lctx
, DNS_LOGCATEGORY_GENERAL
,
83 DNS_LOGMODULE_MASTER
, /* XXX */
84 ISC_LOG_WARNING
, fmt
, ap
);
89 dns_rdatacallbacks_initcommon(dns_rdatacallbacks_t
*callbacks
) {
90 REQUIRE(callbacks
!= NULL
);
92 callbacks
->magic
= DNS_CALLBACK_MAGIC
;
93 callbacks
->add
= NULL
;
94 callbacks
->rawdata
= NULL
;
95 callbacks
->zone
= NULL
;
96 callbacks
->add_private
= NULL
;
97 callbacks
->error_private
= NULL
;
98 callbacks
->warn_private
= NULL
;
106 dns_rdatacallbacks_init(dns_rdatacallbacks_t
*callbacks
) {
107 dns_rdatacallbacks_initcommon(callbacks
);
108 callbacks
->error
= isclog_error_callback
;
109 callbacks
->warn
= isclog_warn_callback
;
113 dns_rdatacallbacks_init_stdio(dns_rdatacallbacks_t
*callbacks
) {
114 dns_rdatacallbacks_initcommon(callbacks
);
115 callbacks
->error
= stdio_error_warn_callback
;
116 callbacks
->warn
= stdio_error_warn_callback
;