Merge branch 'vendor/GCC'
[dragonfly.git] / contrib / bind-9.3 / lib / dns / include / dns / master.h
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2002  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.3.2.7 2004/03/08 09:04:36 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_HINT         0x00000010      /* Loading a hint master file. */
41 #define DNS_MASTER_SLAVE        0x00000020      /* Loading a slave master file. */
42 #define DNS_MASTER_CHECKNS      0x00000040      /* Check NS records to see if
43                                                  * they are an address */
44 #define DNS_MASTER_FATALNS      0x00000080      /* Treat DNS_MASTER_CHECKNS
45                                                  * matches as fatal */
46 #define DNS_MASTER_CHECKNAMES   0x00000100
47 #define DNS_MASTER_CHECKNAMESFAIL 0x00000200
48
49 ISC_LANG_BEGINDECLS
50
51 /***
52  ***    Function
53  ***/
54
55 isc_result_t
56 dns_master_loadfile(const char *master_file,
57                     dns_name_t *top,
58                     dns_name_t *origin,
59                     dns_rdataclass_t zclass,
60                     unsigned int options,
61                     dns_rdatacallbacks_t *callbacks,
62                     isc_mem_t *mctx);
63
64 isc_result_t
65 dns_master_loadstream(FILE *stream,
66                       dns_name_t *top,
67                       dns_name_t *origin,
68                       dns_rdataclass_t zclass,
69                       unsigned int options,
70                       dns_rdatacallbacks_t *callbacks,
71                       isc_mem_t *mctx);
72
73 isc_result_t
74 dns_master_loadbuffer(isc_buffer_t *buffer,
75                       dns_name_t *top,
76                       dns_name_t *origin,
77                       dns_rdataclass_t zclass,
78                       unsigned int options,
79                       dns_rdatacallbacks_t *callbacks,
80                       isc_mem_t *mctx);
81
82 isc_result_t
83 dns_master_loadlexer(isc_lex_t *lex,
84                      dns_name_t *top,
85                      dns_name_t *origin,
86                      dns_rdataclass_t zclass,
87                      unsigned int options,
88                      dns_rdatacallbacks_t *callbacks,
89                      isc_mem_t *mctx);
90
91 isc_result_t
92 dns_master_loadfileinc(const char *master_file,
93                        dns_name_t *top,
94                        dns_name_t *origin,
95                        dns_rdataclass_t zclass,
96                        unsigned int options,
97                        dns_rdatacallbacks_t *callbacks,
98                        isc_task_t *task,
99                        dns_loaddonefunc_t done, void *done_arg,
100                        dns_loadctx_t **ctxp, isc_mem_t *mctx);
101
102 isc_result_t
103 dns_master_loadstreaminc(FILE *stream,
104                          dns_name_t *top,
105                          dns_name_t *origin,
106                          dns_rdataclass_t zclass,
107                          unsigned int options,
108                          dns_rdatacallbacks_t *callbacks,
109                          isc_task_t *task,
110                          dns_loaddonefunc_t done, void *done_arg,
111                          dns_loadctx_t **ctxp, isc_mem_t *mctx);
112
113 isc_result_t
114 dns_master_loadbufferinc(isc_buffer_t *buffer,
115                          dns_name_t *top,
116                          dns_name_t *origin,
117                          dns_rdataclass_t zclass,
118                          unsigned int options,
119                          dns_rdatacallbacks_t *callbacks,
120                          isc_task_t *task,
121                          dns_loaddonefunc_t done, void *done_arg,
122                          dns_loadctx_t **ctxp, isc_mem_t *mctx);
123
124 isc_result_t
125 dns_master_loadlexerinc(isc_lex_t *lex,
126                         dns_name_t *top,
127                         dns_name_t *origin,
128                         dns_rdataclass_t zclass,
129                         unsigned int options,
130                         dns_rdatacallbacks_t *callbacks,
131                         isc_task_t *task,
132                         dns_loaddonefunc_t done, void *done_arg,
133                         dns_loadctx_t **ctxp, isc_mem_t *mctx);
134
135 /*
136  * Loads a RFC 1305 master file from a file, stream, buffer, or existing
137  * lexer into rdatasets and then calls 'callbacks->commit' to commit the
138  * rdatasets.  Rdata memory belongs to dns_master_load and will be
139  * reused / released when the callback completes.  dns_load_master will
140  * abort if callbacks->commit returns any value other than ISC_R_SUCCESS.
141  *
142  * If 'DNS_MASTER_AGETTL' is set and the master file contains one or more
143  * $DATE directives, the TTLs of the data will be aged accordingly.
144  *
145  * 'callbacks->commit' is assumed to call 'callbacks->error' or
146  * 'callbacks->warn' to generate any error messages required.
147  *
148  * 'done' is called with 'done_arg' and a result code when the loading
149  * is completed or has failed.  If the initial setup fails 'done' is
150  * not called.
151  *
152  * Requires:
153  *      'master_file' points to a valid string.
154  *      'lexer' points to a valid lexer.
155  *      'top' points to a valid name.
156  *      'origin' points to a valid name.
157  *      'callbacks->commit' points to a valid function.
158  *      'callbacks->error' points to a valid function.
159  *      'callbacks->warn' points to a valid function.
160  *      'mctx' points to a valid memory context.
161  *      'task' and 'done' to be valid.
162  *      'lmgr' to be valid.
163  *      'ctxp != NULL && ctxp == NULL'.
164  *
165  * Returns:
166  *      ISC_R_SUCCESS upon successfully loading the master file.
167  *      ISC_R_SEENINCLUDE upon successfully loading the master file with
168  *              a $INCLUDE statement.
169  *      ISC_R_NOMEMORY out of memory.
170  *      ISC_R_UNEXPECTEDEND expected to be able to read a input token and
171  *              there was not one.
172  *      ISC_R_UNEXPECTED
173  *      DNS_R_NOOWNER failed to specify a ownername.
174  *      DNS_R_NOTTL failed to specify a ttl.
175  *      DNS_R_BADCLASS record class did not match zone class.
176  *      DNS_R_CONTINUE load still in progress (dns_master_load*inc() only).
177  *      Any dns_rdata_fromtext() error code.
178  *      Any error code from callbacks->commit().
179  */
180
181 void
182 dns_loadctx_detach(dns_loadctx_t **ctxp);
183 /*
184  * Detach from the load context.
185  *
186  * Requires:
187  *      '*ctxp' to be valid.
188  *
189  * Ensures:
190  *      '*ctxp == NULL'
191  */
192
193 void
194 dns_loadctx_attach(dns_loadctx_t *source, dns_loadctx_t **target);
195 /*
196  * Attach to the load context.
197  *
198  * Requires:
199  *      'source' to be valid.
200  *      'target != NULL && *target == NULL'.
201  */
202
203 void
204 dns_loadctx_cancel(dns_loadctx_t *ctx);
205 /*
206  * Cancel loading the zone file associated with this load context.
207  *
208  * Requires:
209  *      'ctx' to be valid
210  */
211
212 ISC_LANG_ENDDECLS
213
214 #endif /* DNS_MASTER_H */