Browse Source

[config] fix bugs in new config handling

personal/stbuehler/wip
Stefan Bühler 9 years ago
parent
commit
875995dae5
  1. 11
      src/main/config_parser.rl
  2. 4
      src/main/plugin.c
  3. 3
      src/main/plugin_core.c

11
src/main/config_parser.rl

@ -1051,7 +1051,13 @@ static gboolean p_setup(GString *name, liConfigTokenizerContext *ctx, GError **e
if (!p_parameter_values(&parameters, ctx, error)) return FALSE;
if (!li_plugin_config_setup(ctx->srv, name->str, parameters)) {
if (g_str_equal(name->str, "__print")) {
GString *s = li_value_to_string(parameters);
DEBUG(ctx->srv, "config __print: %s", s->str);
g_string_free(s, TRUE);
li_value_free(parameters);
return TRUE;
} else if (!li_plugin_config_setup(ctx->srv, name->str, parameters)) {
return parse_error(ctx, error, "setup '%s' failed", name->str);
}
@ -1114,6 +1120,7 @@ error:
GString *s = li_value_to_string(parameters);
DEBUG(ctx->srv, "config __print: %s", s->str);
g_string_free(s, TRUE);
li_value_free(parameters);
return TRUE;
} else if (NULL == (a = li_plugin_config_action(ctx->srv, ctx->wrk, name->str, parameters))) {
return parse_error(ctx, error, "action '%s' failed", name->str);
@ -1611,7 +1618,7 @@ static gboolean p_condition_value(liConditionTree **tree, liConfigTokenizerConte
if (TK_STRING != token) return parse_error(ctx, error, "expected a string as key to condition variable");
lvalue = li_condition_lvalue_new(lval, g_string_new_len(GSTR_LEN(ctx->token_string)));
NEXT(token);
if (TK_SQUARE_OPEN != token) {
if (TK_SQUARE_CLOSE != token) {
parse_error(ctx, error, "expected ']'");
goto error;
}

4
src/main/plugin.c

@ -363,6 +363,10 @@ static liServerOption* find_option(liServer *srv, const char *name) {
static gboolean li_parse_option(liServer *srv, liWorker *wrk, liServerOption *sopt, const char *name, liValue *val, liOptionSet *mark) {
assert(NULL != srv && NULL != wrk && NULL != sopt && NULL != name && NULL != mark);
if (NULL != val && LI_VALUE_LIST == sopt->type && val->type != LI_VALUE_LIST) {
li_value_wrap_in_list(val);
}
if (NULL != val && sopt->type != val->type && sopt->type != LI_VALUE_NONE) {
ERROR(srv, "Unexpected value type '%s', expected '%s' for option %s",
li_value_type_string(val), li_valuetype_string(sopt->type), name);

3
src/main/plugin_core.c

@ -1879,12 +1879,13 @@ static gboolean core_register_fetch_files_static(liServer *srv, liPlugin* p, liV
liFetchDatabase *db = NULL;
UNUSED(p); UNUSED(userdata);
val = li_value_get_single_argument(val);
val = li_value_get_single_argument(val);
if (!li_value_list_has_len(val, 2)
|| LI_VALUE_STRING != li_value_list_type_at(val, 0)
|| LI_VALUE_STRING != li_value_list_type_at(val, 1)) {
ERROR(srv, "%s", "fetch.files_static expects a two strings as parameter: \"<name>\" => \"/path/abc_*.d/file\"");
ERROR(srv, "%s", "fetch.files_static expects two strings as parameter: \"<name>\" => \"/path/abc_*.d/file\"");
goto out;
}

Loading…
Cancel
Save