mirror of
https://github.com/isc-projects/bind9.git
synced 2026-04-23 07:07:00 -04:00
new function cfg_parse_buffer()
This commit is contained in:
parent
40c1177517
commit
b8d0eef0fc
2 changed files with 47 additions and 14 deletions
|
|
@ -15,7 +15,7 @@
|
|||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: cfg.h,v 1.4 2001/02/15 23:22:27 bwelling Exp $ */
|
||||
/* $Id: cfg.h,v 1.5 2001/02/17 00:15:22 gson Exp $ */
|
||||
|
||||
#ifndef DNS_CFG_H
|
||||
#define DNS_CFG_H 1
|
||||
|
|
@ -84,9 +84,17 @@ cfg_parser_create(isc_mem_t *mctx, isc_log_t *lctx, cfg_parser_t **ret);
|
|||
isc_result_t
|
||||
cfg_parse_file(cfg_parser_t *pctx, const char *filename,
|
||||
cfg_type_t *type, cfg_obj_t **ret);
|
||||
isc_result_t
|
||||
cfg_parse_buffer(cfg_parser_t *pctx, isc_buffer_t *buffer,
|
||||
cfg_type_t *type, cfg_obj_t **ret);
|
||||
/*
|
||||
* Read in a configuration file containing data of type 'type'
|
||||
* Read a configuration containing data of type 'type'
|
||||
* and make '*ret' point to its parse tree.
|
||||
*
|
||||
* The configuration is read from the file 'filename'
|
||||
* (isc_parse_file()) or the buffer 'buffer'
|
||||
* (isc_parse_buffer()).
|
||||
*
|
||||
* Returns an error if the file does not parse correctly.
|
||||
*
|
||||
* Requires:
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: parser.c,v 1.7 2001/02/16 02:57:40 gson Exp $ */
|
||||
/* $Id: parser.c,v 1.8 2001/02/17 00:15:19 gson Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
|
@ -1227,7 +1227,7 @@ cfg_parser_create(isc_mem_t *mctx, isc_log_t *lctx, cfg_parser_t **ret)
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
cfg_parser_openfile(cfg_parser_t *pctx, const char *filename) {
|
||||
parser_openfile(cfg_parser_t *pctx, const char *filename) {
|
||||
isc_result_t result;
|
||||
cfg_listelt_t *elt = NULL;
|
||||
cfg_obj_t *stringobj = NULL;
|
||||
|
|
@ -1250,17 +1250,15 @@ cfg_parser_openfile(cfg_parser_t *pctx, const char *filename) {
|
|||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
cfg_parse_file(cfg_parser_t *pctx, const char *filename,
|
||||
cfg_type_t *type, cfg_obj_t **ret)
|
||||
{
|
||||
/*
|
||||
* Parse a configuration using a pctx where a lexer has already
|
||||
* been set up with a source.
|
||||
*/
|
||||
static isc_result_t
|
||||
parse2(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret) {
|
||||
isc_result_t result;
|
||||
cfg_obj_t *obj = NULL;
|
||||
|
||||
REQUIRE(filename != NULL);
|
||||
|
||||
CHECK(cfg_parser_openfile(pctx, filename));
|
||||
|
||||
result = parse(pctx, type, &obj);
|
||||
|
||||
if (pctx->errors != 0) {
|
||||
|
|
@ -1286,6 +1284,33 @@ cfg_parse_file(cfg_parser_t *pctx, const char *filename,
|
|||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
cfg_parse_file(cfg_parser_t *pctx, const char *filename,
|
||||
cfg_type_t *type, cfg_obj_t **ret)
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(filename != NULL);
|
||||
|
||||
CHECK(parser_openfile(pctx, filename));
|
||||
CHECK(parse2(pctx, type, ret));
|
||||
cleanup:
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
isc_result_t
|
||||
cfg_parse_buffer(cfg_parser_t *pctx, isc_buffer_t *buffer,
|
||||
cfg_type_t *type, cfg_obj_t **ret)
|
||||
{
|
||||
isc_result_t result;
|
||||
REQUIRE(buffer != NULL);
|
||||
CHECK(isc_lex_openbuffer(pctx->lexer, buffer));
|
||||
CHECK(parse2(pctx, type, ret));
|
||||
cleanup:
|
||||
return (result);
|
||||
}
|
||||
|
||||
void
|
||||
cfg_parser_destroy(cfg_parser_t **pctxp) {
|
||||
cfg_parser_t *pctx = *pctxp;
|
||||
|
|
@ -2695,8 +2720,8 @@ parse_mapbody(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **ret)
|
|||
*/
|
||||
CHECK(parse(pctx, &cfg_type_qstring, &includename));
|
||||
CHECK(parse_semicolon(pctx));
|
||||
CHECK(cfg_parser_openfile(pctx, includename->
|
||||
value.string.base));
|
||||
CHECK(parser_openfile(pctx, includename->
|
||||
value.string.base));
|
||||
cfg_obj_destroy(pctx, &includename);
|
||||
goto redo;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue