1999-02-10 05:22:02 +00:00
|
|
|
/*
|
2011-12-09 23:47:05 +00:00
|
|
|
* Copyright (C) 2004, 2005, 2007, 2011 Internet Systems Consortium, Inc. ("ISC")
|
2001-01-09 22:01:04 +00:00
|
|
|
* Copyright (C) 1999-2001 Internet Software Consortium.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2007-06-18 23:47:57 +00:00
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
1999-02-10 05:22:02 +00:00
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2004-03-05 05:14:21 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
|
|
|
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
* AND FITNESS. IN NO EVENT SHALL ISC 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.
|
1999-02-10 05:22:02 +00:00
|
|
|
*/
|
|
|
|
|
2011-12-09 23:47:05 +00:00
|
|
|
/* $Id: callbacks.c,v 1.19 2011/12/09 23:47:05 tbox Exp $ */
|
2005-04-27 04:57:32 +00:00
|
|
|
|
|
|
|
/*! \file */
|
1999-02-10 05:22:02 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2000-01-22 01:38:58 +00:00
|
|
|
#include <isc/util.h>
|
|
|
|
|
1999-02-10 05:22:02 +00:00
|
|
|
#include <dns/callbacks.h>
|
2000-01-22 01:38:58 +00:00
|
|
|
#include <dns/log.h>
|
1999-02-10 05:22:02 +00:00
|
|
|
|
2000-06-01 18:26:56 +00:00
|
|
|
static void
|
2001-08-08 22:54:55 +00:00
|
|
|
stdio_error_warn_callback(dns_rdatacallbacks_t *, const char *, ...)
|
|
|
|
ISC_FORMAT_PRINTF(2, 3);
|
|
|
|
|
|
|
|
static void
|
|
|
|
isclog_error_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...)
|
|
|
|
ISC_FORMAT_PRINTF(2, 3);
|
|
|
|
|
|
|
|
static void
|
|
|
|
isclog_warn_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...)
|
|
|
|
ISC_FORMAT_PRINTF(2, 3);
|
1999-02-10 05:22:02 +00:00
|
|
|
|
|
|
|
/*
|
2000-01-22 01:38:58 +00:00
|
|
|
* Private
|
1999-02-10 05:22:02 +00:00
|
|
|
*/
|
|
|
|
|
2000-01-22 01:38:58 +00:00
|
|
|
static void
|
2000-06-01 18:26:56 +00:00
|
|
|
stdio_error_warn_callback(dns_rdatacallbacks_t *callbacks,
|
|
|
|
const char *fmt, ...)
|
|
|
|
{
|
2000-01-22 01:38:58 +00:00
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
UNUSED(callbacks);
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vfprintf(stderr, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-06-01 18:26:56 +00:00
|
|
|
isclog_error_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...) {
|
2000-01-22 01:38:58 +00:00
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
UNUSED(callbacks);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-01-22 01:38:58 +00:00
|
|
|
va_start(ap, fmt);
|
|
|
|
isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
|
|
|
DNS_LOGMODULE_MASTER, /* XXX */
|
|
|
|
ISC_LOG_ERROR, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-06-01 18:26:56 +00:00
|
|
|
isclog_warn_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...) {
|
2000-01-22 01:38:58 +00:00
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
UNUSED(callbacks);
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
1999-02-10 05:22:02 +00:00
|
|
|
|
2000-01-22 01:38:58 +00:00
|
|
|
isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
|
|
|
DNS_LOGMODULE_MASTER, /* XXX */
|
|
|
|
ISC_LOG_WARNING, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-05-08 14:38:29 +00:00
|
|
|
dns_rdatacallbacks_initcommon(dns_rdatacallbacks_t *callbacks) {
|
1999-02-10 05:22:02 +00:00
|
|
|
REQUIRE(callbacks != NULL);
|
|
|
|
|
1999-07-30 23:33:15 +00:00
|
|
|
callbacks->add = NULL;
|
2011-12-08 16:07:22 +00:00
|
|
|
callbacks->rawdata = NULL;
|
|
|
|
callbacks->zone = NULL;
|
1999-07-30 23:33:15 +00:00
|
|
|
callbacks->add_private = NULL;
|
1999-02-10 05:22:02 +00:00
|
|
|
callbacks->error_private = NULL;
|
|
|
|
callbacks->warn_private = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-01-22 01:38:58 +00:00
|
|
|
* Public.
|
1999-02-10 05:22:02 +00:00
|
|
|
*/
|
|
|
|
|
2000-01-22 01:38:58 +00:00
|
|
|
void
|
|
|
|
dns_rdatacallbacks_init(dns_rdatacallbacks_t *callbacks) {
|
|
|
|
dns_rdatacallbacks_initcommon(callbacks);
|
|
|
|
callbacks->error = isclog_error_callback;
|
|
|
|
callbacks->warn = isclog_warn_callback;
|
|
|
|
}
|
1999-02-10 05:22:02 +00:00
|
|
|
|
2000-01-22 01:38:58 +00:00
|
|
|
void
|
|
|
|
dns_rdatacallbacks_init_stdio(dns_rdatacallbacks_t *callbacks) {
|
|
|
|
dns_rdatacallbacks_initcommon(callbacks);
|
|
|
|
callbacks->error = stdio_error_warn_callback;
|
|
|
|
callbacks->warn = stdio_error_warn_callback;
|
1999-02-10 05:22:02 +00:00
|
|
|
}
|
2000-01-22 01:38:58 +00:00
|
|
|
|