00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <config.h>
00023
00024 #include <isc/util.h>
00025
00026 #include <dns/callbacks.h>
00027 #include <dns/log.h>
00028
00029 static void
00030 stdio_error_warn_callback(dns_rdatacallbacks_t *, const char *, ...)
00031 ISC_FORMAT_PRINTF(2, 3);
00032
00033 static void
00034 isclog_error_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...)
00035 ISC_FORMAT_PRINTF(2, 3);
00036
00037 static void
00038 isclog_warn_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...)
00039 ISC_FORMAT_PRINTF(2, 3);
00040
00041
00042
00043
00044
00045 static void
00046 stdio_error_warn_callback(dns_rdatacallbacks_t *callbacks,
00047 const char *fmt, ...)
00048 {
00049 va_list ap;
00050
00051 UNUSED(callbacks);
00052
00053 va_start(ap, fmt);
00054 vfprintf(stderr, fmt, ap);
00055 va_end(ap);
00056 fprintf(stderr, "\n");
00057 }
00058
00059 static void
00060 isclog_error_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...) {
00061 va_list ap;
00062
00063 UNUSED(callbacks);
00064
00065 va_start(ap, fmt);
00066 isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_GENERAL,
00067 DNS_LOGMODULE_MASTER,
00068 ISC_LOG_ERROR, fmt, ap);
00069 va_end(ap);
00070 }
00071
00072 static void
00073 isclog_warn_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...) {
00074 va_list ap;
00075
00076 UNUSED(callbacks);
00077
00078 va_start(ap, fmt);
00079
00080 isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_GENERAL,
00081 DNS_LOGMODULE_MASTER,
00082 ISC_LOG_WARNING, fmt, ap);
00083 va_end(ap);
00084 }
00085
00086 static void
00087 dns_rdatacallbacks_initcommon(dns_rdatacallbacks_t *callbacks) {
00088 REQUIRE(callbacks != NULL);
00089
00090 callbacks->magic = DNS_CALLBACK_MAGIC;
00091 callbacks->add = NULL;
00092 callbacks->rawdata = NULL;
00093 callbacks->zone = NULL;
00094 callbacks->add_private = NULL;
00095 callbacks->error_private = NULL;
00096 callbacks->warn_private = NULL;
00097 }
00098
00099
00100
00101
00102
00103 void
00104 dns_rdatacallbacks_init(dns_rdatacallbacks_t *callbacks) {
00105 dns_rdatacallbacks_initcommon(callbacks);
00106 callbacks->error = isclog_error_callback;
00107 callbacks->warn = isclog_warn_callback;
00108 }
00109
00110 void
00111 dns_rdatacallbacks_init_stdio(dns_rdatacallbacks_t *callbacks) {
00112 dns_rdatacallbacks_initcommon(callbacks);
00113 callbacks->error = stdio_error_warn_callback;
00114 callbacks->warn = stdio_error_warn_callback;
00115 }
00116