1999-02-10 05:22:02 +00:00
|
|
|
/*
|
2015-05-23 14:21:51 +02:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
1999-02-10 05:22:02 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
2021-06-03 08:37:05 +02:00
|
|
|
*
|
1999-02-10 05:22:02 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
1999-02-10 05:22:02 +00:00
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
|
|
|
*/
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*! \file */
|
1999-02-10 05:22:02 +00:00
|
|
|
|
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
|
|
|
|
2001-08-08 22:54:55 +00:00
|
|
|
static void
|
|
|
|
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);
|
2024-08-13 18:20:26 +02:00
|
|
|
isc_log_vwrite(DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_MASTER, /* XXX */
|
2000-01-22 01:38:58 +00:00
|
|
|
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
|
|
|
|
2024-08-13 18:20:26 +02:00
|
|
|
isc_log_vwrite(DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_MASTER, /* XXX */
|
2000-01-22 01:38:58 +00:00
|
|
|
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);
|
|
|
|
|
2024-02-05 16:11:16 -08:00
|
|
|
*callbacks = (dns_rdatacallbacks_t){
|
|
|
|
.magic = DNS_CALLBACK_MAGIC,
|
|
|
|
};
|
1999-02-10 05:22:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
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
|
|
|
}
|