Merge from vendor branch GROFF:
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / dns / include / dns / master.h
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2001, 2003  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: master.h,v 1.31.2.4 2004/03/09 06:11:17 marka Exp $ */
19
20 #ifndef DNS_MASTER_H
21 #define DNS_MASTER_H 1
22
23 /***
24  ***    Imports
25  ***/
26
27 #include <stdio.h>
28
29 #include <isc/lang.h>
30
31 #include <dns/types.h>
32
33 /*
34  * Flags to be passed in the 'options' argument in the functions below.
35  */
36 #define DNS_MASTER_AGETTL       0x00000001      /* Age the ttl based on $DATE. */
37 #define DNS_MASTER_MANYERRORS   0x00000002      /* Continue processing on errors. */
38 #define DNS_MASTER_NOINCLUDE    0x00000004      /* Disallow $INCLUDE directives. */
39 #define DNS_MASTER_ZONE         0x00000008      /* Loading a zone master file. */
40 #define DNS_MASTER_SLAVE        0x00000020      /* Loading a slave master file. */
41
42 ISC_LANG_BEGINDECLS
43
44 /***
45  ***    Function
46  ***/
47
48 isc_result_t
49 dns_master_loadfile(const char *master_file,
50                     dns_name_t *top,
51                     dns_name_t *origin,
52                     dns_rdataclass_t zclass,
53                     unsigned int options,
54                     dns_rdatacallbacks_t *callbacks,
55                     isc_mem_t *mctx);
56
57 isc_result_t
58 dns_master_loadstream(FILE *stream,
59                       dns_name_t *top,
60                       dns_name_t *origin,
61                       dns_rdataclass_t zclass,
62                       unsigned int options,
63                       dns_rdatacallbacks_t *callbacks,
64                       isc_mem_t *mctx);
65
66 isc_result_t
67 dns_master_loadbuffer(isc_buffer_t *buffer,
68                       dns_name_t *top,
69                       dns_name_t *origin,
70                       dns_rdataclass_t zclass,
71                       unsigned int options,
72                       dns_rdatacallbacks_t *callbacks,
73                       isc_mem_t *mctx);
74
75 isc_result_t
76 dns_master_loadfileinc(const char *master_file,
77                        dns_name_t *top,
78                        dns_name_t *origin,
79                        dns_rdataclass_t zclass,
80                        unsigned int options,
81                        dns_rdatacallbacks_t *callbacks,
82                        isc_task_t *task,
83                        dns_loaddonefunc_t done, void *done_arg,
84                        dns_loadctx_t **ctxp, isc_mem_t *mctx);
85
86 isc_result_t
87 dns_master_loadstreaminc(FILE *stream,
88                          dns_name_t *top,
89                          dns_name_t *origin,
90                          dns_rdataclass_t zclass,
91                          unsigned int options,
92                          dns_rdatacallbacks_t *callbacks,
93                          isc_task_t *task,
94                          dns_loaddonefunc_t done, void *done_arg,
95                          dns_loadctx_t **ctxp, isc_mem_t *mctx);
96
97 isc_result_t
98 dns_master_loadbufferinc(isc_buffer_t *buffer,
99                          dns_name_t *top,
100                          dns_name_t *origin,
101                          dns_rdataclass_t zclass,
102                          unsigned int options,
103                          dns_rdatacallbacks_t *callbacks,
104                          isc_task_t *task,
105                          dns_loaddonefunc_t done, void *done_arg,
106                          dns_loadctx_t **ctxp, isc_mem_t *mctx);
107
108 /*
109  * Loads a RFC 1305 master file from a file, stream, or buffer into rdatasets
110  * and then calls 'callbacks->commit' to commit the rdatasets.  Rdata memory
111  * belongs to dns_master_load and will be reused / released when the callback
112  * completes.  dns_load_master will abort if callbacks->commit returns
113  * any value other than ISC_R_SUCCESS.
114  *
115  * If 'DNS_MASTER_AGETTL' is set and the master file contains one or more
116  * $DATE directives, the TTLs of the data will be aged accordingly.
117  *
118  * 'callbacks->commit' is assumed to call 'callbacks->error' or
119  * 'callbacks->warn' to generate any error messages required.
120  *
121  * 'done' is called with 'done_arg' and a result code when the loading
122  * is completed or has failed.  If the initial setup fails 'done' is
123  * not called.
124  *
125  * Requires:
126  *      'master_file' points to a valid string.
127  *      'top' points to a valid name.
128  *      'origin' points to a valid name.
129  *      'callbacks->commit' points to a valid function.
130  *      'callbacks->error' points to a valid function.
131  *      'callbacks->warn' points to a valid function.
132  *      'mctx' points to a valid memory context.
133  *      'task' and 'done' to be valid.
134  *      'lmgr' to be valid.
135  *      'ctxp != NULL && ctxp == NULL'.
136  *
137  * Returns:
138  *      ISC_R_SUCCESS upon successfully loading the master file.
139  *      ISC_R_SEENINCLUDE upon successfully loading the master file with
140  *              a $INCLUDE statement.
141  *      ISC_R_NOMEMORY out of memory.
142  *      ISC_R_UNEXPECTEDEND expected to be able to read a input token and
143  *              there was not one.
144  *      ISC_R_UNEXPECTED
145  *      DNS_R_NOOWNER failed to specify a ownername.
146  *      DNS_R_NOTTL failed to specify a ttl.
147  *      DNS_R_BADCLASS record class did not match zone class.
148  *      DNS_R_CONTINUE load still in progress (dns_master_load*inc() only).
149  *      Any dns_rdata_fromtext() error code.
150  *      Any error code from callbacks->commit().
151  */
152
153 void
154 dns_loadctx_detach(dns_loadctx_t **ctxp);
155 /*
156  * Detach from the load context.
157  *
158  * Requires:
159  *      '*ctxp' to be valid.
160  *
161  * Ensures:
162  *      '*ctxp == NULL'
163  */
164
165 void
166 dns_loadctx_attach(dns_loadctx_t *source, dns_loadctx_t **target);
167 /*
168  * Attach to the load context.
169  *
170  * Requires:
171  *      'source' to be valid.
172  *      'target != NULL && *target == NULL'.
173  */
174
175 void
176 dns_loadctx_cancel(dns_loadctx_t *ctx);
177 /*
178  * Cancel loading the zone file associated with this load context.
179  *
180  * Requires:
181  *      'ctx' to be valid
182  */
183
184 ISC_LANG_ENDDECLS
185
186 #endif /* DNS_MASTER_H */