2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 10:10:06 +00:00
bind/lib/dns/callbacks.c
Ondřej Surý 58bd26b6cf Update the copyright information in all files in the repository
This commit converts the license handling to adhere to the REUSE
specification.  It specifically:

1. Adds used licnses to LICENSES/ directory

2. Add "isc" template for adding the copyright boilerplate

3. Changes all source files to include copyright and SPDX license
   header, this includes all the C sources, documentation, zone files,
   configuration files.  There are notes in the doc/dev/copyrights file
   on how to add correct headers to the new files.

4. Handle the rest that can't be modified via .reuse/dep5 file.  The
   binary (or otherwise unmodifiable) files could have license places
   next to them in <foo>.license file, but this would lead to cluttered
   repository and most of the files handled in the .reuse/dep5 file are
   system test files.
2022-01-11 09:05:02 +01:00

108 lines
2.4 KiB
C

/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* SPDX-License-Identifier: MPL-2.0
*
* 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/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
/*! \file */
#include <isc/print.h>
#include <isc/util.h>
#include <dns/callbacks.h>
#include <dns/log.h>
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);
/*
* Private
*/
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);
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) {
REQUIRE(callbacks != NULL);
callbacks->magic = DNS_CALLBACK_MAGIC;
callbacks->add = NULL;
callbacks->rawdata = NULL;
callbacks->zone = NULL;
callbacks->add_private = NULL;
callbacks->error_private = NULL;
callbacks->warn_private = NULL;
}
/*
* Public.
*/
void
dns_rdatacallbacks_init(dns_rdatacallbacks_t *callbacks) {
dns_rdatacallbacks_initcommon(callbacks);
callbacks->error = isclog_error_callback;
callbacks->warn = isclog_warn_callback;
}
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;
}