"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/lib/dns/callbacks.c" (7 Sep 2020, 2439 Bytes) of package /linux/misc/dns/bind9/9.11.23/bind-9.11.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "callbacks.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3  *
    4  * This Source Code Form is subject to the terms of the Mozilla Public
    5  * License, v. 2.0. If a copy of the MPL was not distributed with this
    6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7  *
    8  * See the COPYRIGHT file distributed with this work for additional
    9  * information regarding copyright ownership.
   10  */
   11 
   12 
   13 /*! \file */
   14 
   15 #include <config.h>
   16 
   17 #include <isc/print.h>
   18 #include <isc/util.h>
   19 
   20 #include <dns/callbacks.h>
   21 #include <dns/log.h>
   22 
   23 static void
   24 stdio_error_warn_callback(dns_rdatacallbacks_t *, const char *, ...)
   25      ISC_FORMAT_PRINTF(2, 3);
   26 
   27 static void
   28 isclog_error_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...)
   29      ISC_FORMAT_PRINTF(2, 3);
   30 
   31 static void
   32 isclog_warn_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...)
   33      ISC_FORMAT_PRINTF(2, 3);
   34 
   35 /*
   36  * Private
   37  */
   38 
   39 static void
   40 stdio_error_warn_callback(dns_rdatacallbacks_t *callbacks,
   41               const char *fmt, ...)
   42 {
   43     va_list ap;
   44 
   45     UNUSED(callbacks);
   46 
   47     va_start(ap, fmt);
   48     vfprintf(stderr, fmt, ap);
   49     va_end(ap);
   50     fprintf(stderr, "\n");
   51 }
   52 
   53 static void
   54 isclog_error_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...) {
   55     va_list ap;
   56 
   57     UNUSED(callbacks);
   58 
   59     va_start(ap, fmt);
   60     isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_GENERAL,
   61                DNS_LOGMODULE_MASTER, /* XXX */
   62                ISC_LOG_ERROR, fmt, ap);
   63     va_end(ap);
   64 }
   65 
   66 static void
   67 isclog_warn_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, ...) {
   68     va_list ap;
   69 
   70     UNUSED(callbacks);
   71 
   72     va_start(ap, fmt);
   73 
   74     isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_GENERAL,
   75                DNS_LOGMODULE_MASTER, /* XXX */
   76                ISC_LOG_WARNING, fmt, ap);
   77     va_end(ap);
   78 }
   79 
   80 static void
   81 dns_rdatacallbacks_initcommon(dns_rdatacallbacks_t *callbacks) {
   82     REQUIRE(callbacks != NULL);
   83 
   84     callbacks->magic = DNS_CALLBACK_MAGIC;
   85     callbacks->add = NULL;
   86     callbacks->rawdata = NULL;
   87     callbacks->zone = NULL;
   88     callbacks->add_private = NULL;
   89     callbacks->error_private = NULL;
   90     callbacks->warn_private = NULL;
   91 }
   92 
   93 /*
   94  * Public.
   95  */
   96 
   97 void
   98 dns_rdatacallbacks_init(dns_rdatacallbacks_t *callbacks) {
   99     dns_rdatacallbacks_initcommon(callbacks);
  100     callbacks->error = isclog_error_callback;
  101     callbacks->warn = isclog_warn_callback;
  102 }
  103 
  104 void
  105 dns_rdatacallbacks_init_stdio(dns_rdatacallbacks_t *callbacks) {
  106     dns_rdatacallbacks_initcommon(callbacks);
  107     callbacks->error = stdio_error_warn_callback;
  108     callbacks->warn = stdio_error_warn_callback;
  109 }
  110