Skip to content
Snippets Groups Projects
Commit 87b7676c authored by Jan Včelák's avatar Jan Včelák :rocket:
Browse files

conf: added cf_warning API

parent 2edf603a
Branches
Tags
No related merge requests found
......@@ -43,6 +43,7 @@
extern int cf_lex (YYSTYPE *lvalp, void *scanner);
extern void cf_error(void *scanner, const char *format, ...);
extern void cf_warning(void *scanner, const char *format, ...);
extern conf_t *new_config;
static conf_iface_t *this_iface = 0;
static conf_iface_t *this_remote = 0;
......
......@@ -60,7 +60,7 @@ conf_t *new_config = NULL; /*!< \brief Currently parsed config. */
static volatile int _parser_res = 0; /*!< \brief Parser result. */
static pthread_mutex_t _parser_lock = PTHREAD_MUTEX_INITIALIZER;
static void cf_print_error(void *scanner, const char *msg)
static void cf_print_error(void *scanner, int priority, const char *msg)
{
conf_extra_t *extra = NULL;
int lineno = -1;
......@@ -85,10 +85,8 @@ static void cf_print_error(void *scanner, const char *msg)
filename = new_config->filename;
}
log_error("config error, file '%s', line %d, token '%s' (%s)",
filename, lineno, text, msg);
_parser_res = KNOT_EPARSEFAIL;
log_msg(priority, "config, file '%s', line %d, token '%s', %s",
filename, lineno, text, msg);
}
/*! \brief Config error report. */
......@@ -101,7 +99,21 @@ void cf_error(void *scanner, const char *format, ...)
vsnprintf(buffer, sizeof(buffer), format, ap);
va_end(ap);
cf_print_error(scanner, buffer);
cf_print_error(scanner, LOG_ERR, buffer);
_parser_res = KNOT_EPARSEFAIL;
}
/*! \brief Config warning report. */
void cf_warning(void *scanner, const char *format, ...)
{
char buffer[ERROR_BUFFER_SIZE];
va_list ap;
va_start(ap, format);
vsnprintf(buffer, sizeof(buffer), format, ap);
va_end(ap);
cf_print_error(scanner, LOG_WARNING, buffer);
}
/*!
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment