Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / dns / callbacks.c
blobc98eedcbdeb3ebdb6a0c628bdc4070c4e9b770e9
1 /* $NetBSD: callbacks.c,v 1.5 2014/12/10 04:37:58 christos Exp $ */
3 /*
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 */
22 /*! \file */
24 #include <config.h>
26 #include <isc/util.h>
28 #include <dns/callbacks.h>
29 #include <dns/log.h>
31 static void
32 stdio_error_warn_callback(dns_rdatacallbacks_t *, const char *, ...)
33 ISC_FORMAT_PRINTF(2, 3);
35 static void
36 isclog_error_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...)
37 ISC_FORMAT_PRINTF(2, 3);
39 static void
40 isclog_warn_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...)
41 ISC_FORMAT_PRINTF(2, 3);
44 * Private
47 static void
48 stdio_error_warn_callback(dns_rdatacallbacks_t *callbacks,
49 const char *fmt, ...)
51 va_list ap;
53 UNUSED(callbacks);
55 va_start(ap, fmt);
56 vfprintf(stderr, fmt, ap);
57 va_end(ap);
58 fprintf(stderr, "\n");
61 static void
62 isclog_error_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...) {
63 va_list ap;
65 UNUSED(callbacks);
67 va_start(ap, fmt);
68 isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_GENERAL,
69 DNS_LOGMODULE_MASTER, /* XXX */
70 ISC_LOG_ERROR, fmt, ap);
71 va_end(ap);
74 static void
75 isclog_warn_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...) {
76 va_list ap;
78 UNUSED(callbacks);
80 va_start(ap, fmt);
82 isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_GENERAL,
83 DNS_LOGMODULE_MASTER, /* XXX */
84 ISC_LOG_WARNING, fmt, ap);
85 va_end(ap);
88 static void
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;
102 * Public.
105 void
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;
112 void
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;