reload_table[table].res_table = save_config_resources();
Dmsg1(100, "Saved old config in table %d\n", table);
- ok = parse_config(configfile, 0); /* no exit on error */
+ ok = parse_config(configfile, 0, M_ERROR); /* no exit on error */
Dmsg0(100, "Reloaded config file\n");
if (!ok || !check_resources()) {
bvsnprintf(buf, sizeof(buf), msg, arg_ptr);
va_end(arg_ptr);
+ if (lc->err_type == 0) { /* M_ERROR_TERM by default */
+ lc->err_type = M_ERROR_TERM;
+ }
+
if (lc->line_no > lc->begin_line_no) {
bsnprintf(more, sizeof(more),
_("Problem probably begins at line %d.\n"), lc->begin_line_no);
more[0] = 0;
}
if (lc->line_no > 0) {
- e_msg(file, line, M_ERROR_TERM, 0, _("Config error: %s\n"
+ e_msg(file, line, lc->err_type, 0, _("Config error: %s\n"
" : line %d, col %d of file %s\n%s\n%s"),
buf, lc->line_no, lc->col_no, lc->fname, lc->line, more);
} else {
- e_msg(file, line, M_ERROR_TERM, 0, _("Config error: %s\n"), buf);
+ e_msg(file, line, lc->err_type, 0, _("Config error: %s\n"), buf);
}
}
lf->scan_error = s_err;
}
+/*
+ * Set err_type used in error_handler
+ * return the old value
+ */
+int lex_set_error_handler_error_type(LEX *lf, int err_type)
+{
+ int old = lf->err_type;
+ lf->err_type = err_type;
+ return old;
+}
/*
* Free the current file, and retrieve the contents
} else {
lf = nf; /* start new packet */
memset(lf, 0, sizeof(LEX));
+ lex_set_error_handler_error_type(lf, M_ERROR_TERM);
}
if (scan_error) {
lf->scan_error = scan_error;
int32_t int32_val;
int64_t int64_val;
void (*scan_error)(const char *file, int line, struct s_lex_context *lc, const char *msg, ...);
+ int err_type; /* message level for scan_error (M_..) */
void *caller_ctx; /* caller private data */
} LEX;
* scan_error handler is to die on an error.
*/
int
-parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error)
+parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error, int err_type)
{
LEX *lc = NULL;
int token, i, pass;
} else {
lex_set_default_error_handler(lc);
}
+ lex_set_error_handler_error_type(lc, err_type) ;
bstrncpy(lc->str, cf, sizeof(lc->str));
lc->fname = lc->str;
scan_err2(lc, _("Cannot open config file \"%s\": %s\n"),
free(lc);
return 0;
}
+ lex_set_error_handler_error_type(lc, err_type) ;
while ((token=lex_get_token(lc, T_ALL)) != T_EOF) {
Dmsg1(900, "parse got token=%s\n", lex_tok_to_str(token));
switch (state) {
/* Configuration routines */
-int parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error = NULL);
+int parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error = NULL, int err_type=M_ERROR_TERM);
void free_config_resources(void);
RES **save_config_resources(void);
RES **new_res_head();
const char * lex_tok_to_str (int token);
int lex_get_token (LEX *lf, int expect);
void lex_set_default_error_handler (LEX *lf);
+int lex_set_error_handler_error_type (LEX *lf, int err_type);
/* message.c */
void my_name_is (int argc, char *argv[], const char *name);