* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: master.h,v 1.34 2001/12/11 20:52:41 marka Exp $ */
+/* $Id: master.h,v 1.35 2002/02/21 00:45:11 bwelling Exp $ */
#ifndef DNS_MASTER_H
#define DNS_MASTER_H 1
dns_rdatacallbacks_t *callbacks,
isc_mem_t *mctx);
+isc_result_t
+dns_master_loadlexer(isc_lex_t *lex,
+ dns_name_t *top,
+ dns_name_t *origin,
+ dns_rdataclass_t zclass,
+ unsigned int options,
+ dns_rdatacallbacks_t *callbacks,
+ isc_mem_t *mctx);
+
isc_result_t
dns_master_loadfileinc(const char *master_file,
dns_name_t *top,
dns_loaddonefunc_t done, void *done_arg,
dns_loadctx_t **ctxp, isc_mem_t *mctx);
+isc_result_t
+dns_master_loadlexerinc(isc_lex_t *lex,
+ dns_name_t *top,
+ dns_name_t *origin,
+ dns_rdataclass_t zclass,
+ unsigned int options,
+ dns_rdatacallbacks_t *callbacks,
+ isc_task_t *task,
+ dns_loaddonefunc_t done, void *done_arg,
+ dns_loadctx_t **ctxp, isc_mem_t *mctx);
+
/*
- * Loads a RFC 1305 master file from a file, stream, or buffer into rdatasets
- * and then calls 'callbacks->commit' to commit the rdatasets. Rdata memory
- * belongs to dns_master_load and will be reused / released when the callback
- * completes. dns_load_master will abort if callbacks->commit returns
- * any value other than ISC_R_SUCCESS.
+ * Loads a RFC 1305 master file from a file, stream, buffer, or existing
+ * lexer into rdatasets and then calls 'callbacks->commit' to commit the
+ * rdatasets. Rdata memory belongs to dns_master_load and will be
+ * reused / released when the callback completes. dns_load_master will
+ * abort if callbacks->commit returns any value other than ISC_R_SUCCESS.
*
* If 'DNS_MASTER_AGETTL' is set and the master file contains one or more
* $DATE directives, the TTLs of the data will be aged accordingly.
*
* Requires:
* 'master_file' points to a valid string.
+ * 'lexer' points to a valid lexer.
* 'top' points to a valid name.
* 'origin' points to a valid name.
* 'callbacks->commit' points to a valid function.
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: master.c,v 1.135 2002/02/20 03:34:12 marka Exp $ */
+/* $Id: master.c,v 1.136 2002/02/21 00:45:09 bwelling Exp $ */
#include <config.h>
unsigned int magic;
isc_mem_t *mctx;
isc_lex_t *lex;
+ isc_boolean_t keep_lex;
dns_rdatacallbacks_t *callbacks;
isc_task_t *task;
dns_loaddonefunc_t done;
incctx_destroy(lctx->mctx, lctx->inc);
/* isc_lex_destroy() will close all open streams */
- if (lctx->lex != NULL)
+ if (lctx->lex != NULL && !lctx->keep_lex)
isc_lex_destroy(&lctx->lex);
if (lctx->task != NULL)
loadctx_create(isc_mem_t *mctx, unsigned int options, dns_name_t *top,
dns_rdataclass_t zclass, dns_name_t *origin,
dns_rdatacallbacks_t *callbacks, isc_task_t *task,
- dns_loaddonefunc_t done, void *done_arg,
+ dns_loaddonefunc_t done, void *done_arg, isc_lex_t *lex,
dns_loadctx_t **lctxp)
{
dns_loadctx_t *lctx;
if (result != ISC_R_SUCCESS)
goto cleanup_ctx;
- lctx->lex = NULL;
- result = isc_lex_create(mctx, TOKENSIZ, &lctx->lex);
- if (result != ISC_R_SUCCESS)
- goto cleanup_inc;
- memset(specials, 0, sizeof(specials));
- specials['('] = 1;
- specials[')'] = 1;
- specials['"'] = 1;
- isc_lex_setspecials(lctx->lex, specials);
- isc_lex_setcomments(lctx->lex, ISC_LEXCOMMENT_DNSMASTERFILE);
+ if (lex != NULL)
+ lctx->lex = lex;
+ else {
+ lctx->lex = NULL;
+ result = isc_lex_create(mctx, TOKENSIZ, &lctx->lex);
+ if (result != ISC_R_SUCCESS)
+ goto cleanup_inc;
+ memset(specials, 0, sizeof(specials));
+ specials['('] = 1;
+ specials[')'] = 1;
+ specials['"'] = 1;
+ isc_lex_setspecials(lctx->lex, specials);
+ isc_lex_setcomments(lctx->lex, ISC_LEXCOMMENT_DNSMASTERFILE);
+ }
lctx->ttl_known = ISC_FALSE;
lctx->ttl = 0;
isc_result_t result;
result = loadctx_create(mctx, options, top, zclass, origin,
- callbacks, NULL, NULL, NULL, &lctx);
+ callbacks, NULL, NULL, NULL, NULL, &lctx);
if (result != ISC_R_SUCCESS)
return (result);
REQUIRE(done != NULL);
result = loadctx_create(mctx, options, top, zclass, origin,
- callbacks, task, done, done_arg, &lctx);
+ callbacks, task, done, done_arg, NULL, &lctx);
if (result != ISC_R_SUCCESS)
return (result);
REQUIRE(stream != NULL);
result = loadctx_create(mctx, options, top, zclass, origin,
- callbacks, NULL, NULL, NULL, &lctx);
+ callbacks, NULL, NULL, NULL, NULL, &lctx);
if (result != ISC_R_SUCCESS)
goto cleanup;
REQUIRE(done != NULL);
result = loadctx_create(mctx, options, top, zclass, origin,
- callbacks, task, done, done_arg, &lctx);
+ callbacks, task, done, done_arg, NULL, &lctx);
if (result != ISC_R_SUCCESS)
goto cleanup;
REQUIRE(buffer != NULL);
result = loadctx_create(mctx, options, top, zclass, origin,
- callbacks, NULL, NULL, NULL, &lctx);
+ callbacks, NULL, NULL, NULL, NULL, &lctx);
if (result != ISC_R_SUCCESS)
return (result);
REQUIRE(done != NULL);
result = loadctx_create(mctx, options, top, zclass, origin,
- callbacks, task, done, done_arg, &lctx);
+ callbacks, task, done, done_arg, NULL, &lctx);
if (result != ISC_R_SUCCESS)
return (result);
return (result);
}
+isc_result_t
+dns_master_loadlexer(isc_lex_t *lex, dns_name_t *top,
+ dns_name_t *origin, dns_rdataclass_t zclass,
+ unsigned int options,
+ dns_rdatacallbacks_t *callbacks, isc_mem_t *mctx)
+{
+ isc_result_t result;
+ dns_loadctx_t *lctx = NULL;
+
+ REQUIRE(lex != NULL);
+
+ result = loadctx_create(mctx, options, top, zclass, origin,
+ callbacks, NULL, NULL, NULL, lex, &lctx);
+ if (result != ISC_R_SUCCESS)
+ return (result);
+
+ result = load(lctx);
+ INSIST(result != DNS_R_CONTINUE);
+
+ dns_loadctx_detach(&lctx);
+ return (result);
+}
+
+isc_result_t
+dns_master_loadlexerinc(isc_lex_t *lex, dns_name_t *top,
+ dns_name_t *origin, dns_rdataclass_t zclass,
+ unsigned int options,
+ dns_rdatacallbacks_t *callbacks, isc_task_t *task,
+ dns_loaddonefunc_t done, void *done_arg,
+ dns_loadctx_t **lctxp, isc_mem_t *mctx)
+{
+ isc_result_t result;
+ dns_loadctx_t *lctx = NULL;
+
+ REQUIRE(lex != NULL);
+ REQUIRE(task != NULL);
+ REQUIRE(done != NULL);
+
+ result = loadctx_create(mctx, options, top, zclass, origin,
+ callbacks, task, done, done_arg, lex, &lctx);
+ if (result != ISC_R_SUCCESS)
+ return (result);
+
+ result = task_send(lctx);
+ if (result == ISC_R_SUCCESS) {
+ dns_loadctx_attach(lctx, lctxp);
+ return (DNS_R_CONTINUE);
+ }
+
+ dns_loadctx_detach(&lctx);
+ return (result);
+}
+
/*
* Grow the slab of dns_rdatalist_t structures.
* Re-link glue and current list.