2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 18:19:42 +00:00
bind/lib/dns/callbacks.c

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

103 lines
2.2 KiB
C
Raw Normal View History

1999-02-10 05:22:02 +00:00
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
1999-02-10 05:22:02 +00:00
*
* SPDX-License-Identifier: MPL-2.0
*
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/.
*
1999-02-10 05:22:02 +00:00
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
/*! \file */
1999-02-10 05:22:02 +00:00
#include <isc/util.h>
1999-02-10 05:22:02 +00:00
#include <dns/callbacks.h>
#include <dns/log.h>
1999-02-10 05:22:02 +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
/*
* Private
1999-02-10 05:22:02 +00:00
*/
static void
stdio_error_warn_callback(dns_rdatacallbacks_t *callbacks, const char *fmt,
...) {
va_list ap;
UNUSED(callbacks);
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
fprintf(stderr, "\n");
}
static void
isclog_error_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...) {
va_list ap;
UNUSED(callbacks);
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
isclog_warn_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...) {
va_list ap;
UNUSED(callbacks);
va_start(ap, fmt);
1999-02-10 05:22:02 +00:00
isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_GENERAL,
DNS_LOGMODULE_MASTER, /* XXX */
ISC_LOG_WARNING, fmt, ap);
va_end(ap);
}
static void
dns_rdatacallbacks_initcommon(dns_rdatacallbacks_t *callbacks) {
1999-02-10 05:22:02 +00:00
REQUIRE(callbacks != NULL);
*callbacks = (dns_rdatacallbacks_t){
.magic = DNS_CALLBACK_MAGIC,
};
1999-02-10 05:22:02 +00:00
}
/*
* Public.
1999-02-10 05:22:02 +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
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
}