cfg_obj_attach(zoneconf, &cfg->nzf_config);
} else {
cfg_obj_t *z = UNCONST(zoneobj);
- CHECK(cfg_parser_mapadd(cfg->nzf_config, z, "zone"));
+ CHECK(cfg_map_add(cfg->nzf_config, z, "zone"));
}
cleanup_config = true;
#endif /* HAVE_LMDB */
#ifndef HAVE_LMDB
/* Store the new zone configuration; also in NZF if applicable */
z = UNCONST(zoneobj);
- CHECK(cfg_parser_mapadd(cfg->nzf_config, z, "zone"));
+ CHECK(cfg_map_add(cfg->nzf_config, z, "zone"));
#endif /* HAVE_LMDB */
if (added) {
*** Functions
***/
-void
-cfg_parser_attach(cfg_parser_t *src, cfg_parser_t **dest);
-/*%<
- * Reference a parser object.
- */
-
-isc_result_t
-cfg_parser_create(isc_mem_t *mctx, cfg_parser_t **ret);
-/*%<
- * Create a configuration file parser. Any warning and error
- * messages will be logged.
- *
- * The parser object returned can be used for a single call
- * to cfg_parse_file() or cfg_parse_buffer(). It must not
- * be reused for parsing multiple files or buffers.
- */
-
-void
-cfg_parser_setflags(cfg_parser_t *pctx, unsigned int flags, bool turn_on);
-/*%<
- * Set parser context flags. The flags are not checked for sensibility.
- * If 'turn_on' is 'true' the flags will be set, otherwise the flags will
- * be cleared.
- *
- * Requires:
- *\li "pctx" is not NULL.
- */
-
isc_result_t
cfg_parse_file(isc_mem_t *mctx, const char *file, const cfg_type_t *type,
unsigned int flags, cfg_obj_t **ret);
*\li others - file contains errors
*/
-isc_result_t
-cfg_parser_mapadd(cfg_obj_t *mapobj, cfg_obj_t *obj, const char *clause);
-/*%<
- * Add the object 'obj' to the specified clause in mapbody 'mapobj'.
- * Used for adding new zones.
- *
- * Require:
- * \li 'obj' is a valid cfg_obj_t.
- * \li 'mapobj' is a valid cfg_obj_t of type map.
- */
-
-void
-cfg_parser_reset(cfg_parser_t *pctx);
-/*%<
- * Reset an existing parser so it can be re-used for a new file or
- * buffer.
- */
-
-void
-cfg_parser_destroy(cfg_parser_t **pctxp);
-/*%<
- * Remove a reference to a configuration parser; destroy it if there are no
- * more references.
- */
-
cfg_obj_t *
cfg_parser_currentfile(cfg_parser_t *pctx);
/*%<
* \li #ISC_R_NOTFOUND - name not found in map
*/
+isc_result_t
+cfg_map_add(cfg_obj_t *mapobj, cfg_obj_t *obj, const char *clause);
+/*%<
+ * Add the object 'obj' to the specified clause in mapbody 'mapobj'.
+ * Used for adding new zones.
+ *
+ * Require:
+ * \li 'obj' is a valid cfg_obj_t.
+ * \li 'mapobj' is a valid cfg_obj_t of type map.
+ */
+
const cfg_obj_t *
cfg_map_getname(const cfg_obj_t *mapobj);
/*%<
print_list, NULL,
&cfg_rep_list, &cfg_type_qstring };
-isc_result_t
-cfg_parser_create(isc_mem_t *mctx, cfg_parser_t **ret) {
+static isc_result_t
+parser_create(isc_mem_t *mctx, cfg_parser_t **ret) {
isc_result_t result;
cfg_parser_t *pctx;
isc_lexspecials_t specials;
return result;
}
-void
-cfg_parser_setflags(cfg_parser_t *pctx, unsigned int flags, bool turn_on) {
- REQUIRE(pctx != NULL);
+static void
+parser_destroy(cfg_parser_t **pctxp) {
+ cfg_parser_t *pctx;
- if (turn_on) {
- pctx->flags |= flags;
- } else {
- pctx->flags &= ~flags;
+ REQUIRE(pctxp != NULL && *pctxp != NULL);
+ pctx = *pctxp;
+ *pctxp = NULL;
+
+ if (isc_refcount_decrement(&pctx->references) == 1) {
+ isc_lex_destroy(&pctx->lexer);
+ /*
+ * Cleaning up open_files does not
+ * close the files; that was already done
+ * by closing the lexer.
+ */
+ CLEANUP_OBJ(pctx->open_files);
+ CLEANUP_OBJ(pctx->closed_files);
+ isc_mem_putanddetach(&pctx->mctx, pctx, sizeof(*pctx));
}
}
return result;
}
-void
-cfg_parser_reset(cfg_parser_t *pctx) {
- REQUIRE(pctx != NULL);
-
- if (pctx->lexer != NULL) {
- isc_lex_close(pctx->lexer);
- }
-
- pctx->seen_eof = false;
- pctx->ungotten = false;
- pctx->errors = 0;
- pctx->warnings = 0;
- pctx->line = 0;
-}
-
/*
* Parse a configuration using a pctx where a lexer has already
* been set up with a source.
REQUIRE(ret != NULL && *ret == NULL);
REQUIRE_PCTX_FLAGS(flags);
- CHECK(cfg_parser_create(mctx, &pctx));
+ CHECK(parser_create(mctx, &pctx));
pctx->flags = flags;
CHECK(parser_openfile(pctx, filename));
cleanup:
if (pctx != NULL) {
- cfg_parser_destroy(&pctx);
+ parser_destroy(&pctx);
}
return result;
REQUIRE(ret != NULL && *ret == NULL);
REQUIRE_PCTX_FLAGS(flags);
- CHECK(cfg_parser_create(mctx, &pctx));
+ CHECK(parser_create(mctx, &pctx));
CHECK(isc_lex_openbuffer(pctx->lexer, buffer));
pctx->buf_name = file;
cleanup:
if (pctx != NULL) {
- cfg_parser_destroy(&pctx);
+ parser_destroy(&pctx);
}
return result;
}
-void
-cfg_parser_attach(cfg_parser_t *src, cfg_parser_t **dest) {
- REQUIRE(src != NULL);
- REQUIRE(dest != NULL && *dest == NULL);
-
- isc_refcount_increment(&src->references);
- *dest = src;
-}
-
-void
-cfg_parser_destroy(cfg_parser_t **pctxp) {
- cfg_parser_t *pctx;
-
- REQUIRE(pctxp != NULL && *pctxp != NULL);
- pctx = *pctxp;
- *pctxp = NULL;
-
- if (isc_refcount_decrement(&pctx->references) == 1) {
- isc_lex_destroy(&pctx->lexer);
- /*
- * Cleaning up open_files does not
- * close the files; that was already done
- * by closing the lexer.
- */
- CLEANUP_OBJ(pctx->open_files);
- CLEANUP_OBJ(pctx->closed_files);
- isc_mem_putanddetach(&pctx->mctx, pctx, sizeof(*pctx));
- }
-}
-
/*
* void
*/
}
isc_result_t
-cfg_parser_mapadd(cfg_obj_t *mapobj, cfg_obj_t *obj, const char *clausename) {
+cfg_map_add(cfg_obj_t *mapobj, cfg_obj_t *obj, const char *clausename) {
isc_result_t result = ISC_R_SUCCESS;
const cfg_map_t *map = NULL;
isc_symvalue_t symval;