1 /*	$NetBSD: callbacks.h,v 1.5 2014/12/10 04:37:58 christos Exp $	*/
2 
3 /*
4  * Copyright (C) 2004-2007, 2011-2013  Internet Systems Consortium, Inc. ("ISC")
5  * Copyright (C) 1999-2002  Internet Software Consortium.
6  *
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.
10  *
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.
18  */
19 
20 /* Id: callbacks.h,v 1.26.40.1 2012/02/07 00:44:16 each Exp  */
21 
22 #ifndef DNS_CALLBACKS_H
23 #define DNS_CALLBACKS_H 1
24 
25 /*! \file dns/callbacks.h */
26 
27 /***
28  ***	Imports
29  ***/
30 
31 #include <isc/lang.h>
32 #include <isc/magic.h>
33 
34 #include <dns/types.h>
35 
36 ISC_LANG_BEGINDECLS
37 
38 /***
39  ***	Types
40  ***/
41 
42 #define DNS_CALLBACK_MAGIC	ISC_MAGIC('C','L','L','B')
43 #define DNS_CALLBACK_VALID(cb)	ISC_MAGIC_VALID(cb, DNS_CALLBACK_MAGIC)
44 
45 struct dns_rdatacallbacks {
46 	unsigned int magic;
47 
48 	/*%
49 	 * dns_load_master calls this when it has rdatasets to commit.
50 	 */
51 	dns_addrdatasetfunc_t add;
52 
53 	/*%
54 	 * This is called when reading in a database image from a 'map'
55 	 * format zone file.
56 	 */
57 	dns_deserializefunc_t deserialize;
58 
59 	/*%
60 	 * dns_master_load*() call this when loading a raw zonefile,
61 	 * to pass back information obtained from the file header
62 	 */
63 	dns_rawdatafunc_t rawdata;
64 	dns_zone_t *zone;
65 
66 	/*%
67 	 * dns_load_master / dns_rdata_fromtext call this to issue a error.
68 	 */
69 	void	(*error)(struct dns_rdatacallbacks *, const char *, ...);
70 	/*%
71 	 * dns_load_master / dns_rdata_fromtext call this to issue a warning.
72 	 */
73 	void	(*warn)(struct dns_rdatacallbacks *, const char *, ...);
74 	/*%
75 	 * Private data handles for use by the above callback functions.
76 	 */
77 	void	*add_private;
78 	void	*deserialize_private;
79 	void	*error_private;
80 	void	*warn_private;
81 };
82 
83 /***
84  ***	Initialization
85  ***/
86 
87 void
88 dns_rdatacallbacks_init(dns_rdatacallbacks_t *callbacks);
89 /*%<
90  * Initialize 'callbacks'.
91  *
92  * \li	'magic' is set to DNS_CALLBACK_MAGIC
93  *
94  * \li	'error' and 'warn' are set to default callbacks that print the
95  *	error message through the DNS library log context.
96  *
97  *\li	All other elements are initialized to NULL.
98  *
99  * Requires:
100  *  \li    'callbacks' is a valid dns_rdatacallbacks_t,
101  */
102 
103 void
104 dns_rdatacallbacks_init_stdio(dns_rdatacallbacks_t *callbacks);
105 /*%<
106  * Like dns_rdatacallbacks_init, but logs to stdio.
107  */
108 
109 ISC_LANG_ENDDECLS
110 
111 #endif /* DNS_CALLBACKS_H */
112