/**
* cf_lex_init - initialize the lexer
- * @is_cli: true if we're going to parse CLI command, false for configuration
+ * @cli_main_config: main configuration structure if we're going to parse CLI command, NULL for new configuration
* @c: configuration structure
*
* cf_lex_init() initializes the lexical analyzer and prepares it for
* parsing of a new input.
*/
void
-cf_lex_init(int is_cli, struct config *c)
+cf_lex_init(struct config *cli_main_config, struct config *c)
{
if (!global_root_scope.readonly)
{
}
ifs_head = ifs = push_ifs(NULL);
- if (!is_cli)
+ if (!cli_main_config)
{
ifs->file_name = c->file_name;
ifs->fd = c->file_fd;
yyrestart(NULL);
ifs->buffer = YY_CURRENT_BUFFER;
- if (is_cli)
+ if (cli_main_config)
BEGIN(CLI);
else
BEGIN(INITIAL);
c->root_scope = c->current_scope = cfg_allocz(sizeof(struct sym_scope));
- if (is_cli)
- c->current_scope->next = config->root_scope;
+ if (cli_main_config)
+ c->current_scope->next = cli_main_config->root_scope;
else
c->current_scope->next = &global_filter_scope;
}
if (setjmp(conf_jmpbuf))
goto cleanup;
- cf_lex_init(0, c);
+ cf_lex_init(NULL, c);
sysdep_preconfig(c);
protos_preconfig(c);
mpls_preconfig(c);
* it parses a CLI command. See the CLI module for more information.
*/
int
-cli_parse(struct config *c)
+cli_parse(struct config *main_config, struct config *c)
{
int done = 0;
new_config = c;
if (setjmp(conf_jmpbuf))
goto cleanup;
- cf_lex_init(1, c);
+ cf_lex_init(main_config, c);
cf_parse();
done = 1;
struct config *config_alloc(const char *name);
int config_parse(struct config *);
-int cli_parse(struct config *);
+int cli_parse(struct config *, struct config *);
void config_free(struct config *);
void config_free_old(void);
int config_commit(struct config *, int type, uint timeout);
extern struct include_file_stack *ifs;
int cf_lex(void);
-void cf_lex_init(int is_cli, struct config *c);
+void cf_lex_init(struct config *cli_main, struct config *c);
void cf_lex_unwind(void);
struct symbol *cf_find_symbol_scope(const struct sym_scope *scope, const byte *c);
cli_rh_len = strlen(c->rx_buf);
cli_rh_trick_flag = 0;
this_cli = c;
+ this_cli->main_config = config;
lp_flush(c->parser_pool);
- res = cli_parse(&f);
+ res = cli_parse(config, &f);
if (!res)
cli_printf(c, 9001, f.err_msg);
+ this_cli->main_config = NULL;
config_free(&f);
}
void (*cont)(struct cli *c);
void (*cleanup)(struct cli *c); /* The CLI has closed prematurely */
void *rover; /* Private to continuation routine */
+ struct config *main_config; /* Main config currently in use */
int last_reply;
int restricted; /* CLI is restricted to read-only commands */
struct linpool *parser_pool; /* Pool used during parsing */