1 /* $NetBSD: callbacks.h,v 1.1 2024/02/18 20:57:35 christos Exp $ */ 2 3 /* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * SPDX-License-Identifier: MPL-2.0 7 * 8 * This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 11 * 12 * See the COPYRIGHT file distributed with this work for additional 13 * information regarding copyright ownership. 14 */ 15 16 #ifndef DNS_CALLBACKS_H 17 #define DNS_CALLBACKS_H 1 18 19 /*! \file dns/callbacks.h */ 20 21 /*** 22 *** Imports 23 ***/ 24 25 #include <isc/lang.h> 26 #include <isc/magic.h> 27 28 #include <dns/types.h> 29 30 ISC_LANG_BEGINDECLS 31 32 /*** 33 *** Types 34 ***/ 35 36 #define DNS_CALLBACK_MAGIC ISC_MAGIC('C', 'L', 'L', 'B') 37 #define DNS_CALLBACK_VALID(cb) ISC_MAGIC_VALID(cb, DNS_CALLBACK_MAGIC) 38 39 struct dns_rdatacallbacks { 40 unsigned int magic; 41 42 /*% 43 * dns_load_master calls this when it has rdatasets to commit. 44 */ 45 dns_addrdatasetfunc_t add; 46 47 /*% 48 * This is called when reading in a database image from a 'map' 49 * format zone file. 50 */ 51 dns_deserializefunc_t deserialize; 52 53 /*% 54 * dns_master_load*() call this when loading a raw zonefile, 55 * to pass back information obtained from the file header 56 */ 57 dns_rawdatafunc_t rawdata; 58 dns_zone_t *zone; 59 60 /*% 61 * dns_load_master / dns_rdata_fromtext call this to issue a error. 62 */ 63 void (*error)(struct dns_rdatacallbacks *, const char *, ...); 64 /*% 65 * dns_load_master / dns_rdata_fromtext call this to issue a warning. 66 */ 67 void (*warn)(struct dns_rdatacallbacks *, const char *, ...); 68 /*% 69 * Private data handles for use by the above callback functions. 70 */ 71 void *add_private; 72 void *deserialize_private; 73 void *error_private; 74 void *warn_private; 75 }; 76 77 /*** 78 *** Initialization 79 ***/ 80 81 void 82 dns_rdatacallbacks_init(dns_rdatacallbacks_t *callbacks); 83 /*%< 84 * Initialize 'callbacks'. 85 * 86 * \li 'magic' is set to DNS_CALLBACK_MAGIC 87 * 88 * \li 'error' and 'warn' are set to default callbacks that print the 89 * error message through the DNS library log context. 90 * 91 *\li All other elements are initialized to NULL. 92 * 93 * Requires: 94 * \li 'callbacks' is a valid dns_rdatacallbacks_t, 95 */ 96 97 void 98 dns_rdatacallbacks_init_stdio(dns_rdatacallbacks_t *callbacks); 99 /*%< 100 * Like dns_rdatacallbacks_init, but logs to stdio. 101 */ 102 103 ISC_LANG_ENDDECLS 104 105 #endif /* DNS_CALLBACKS_H */ 106