diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-08-18 13:17:16 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-08-18 13:17:16 +0100 |
commit | a22ea751b62b7be2f879a77c71588d1b5aa2f643 (patch) | |
tree | 2d3268b4e3093ba51f3a6e99aff467f7453daa2e /contrib/libucl/ucl_parser.c | |
parent | f4e5deb129c8e9a50175af83966e9c2f63c05cff (diff) | |
download | rspamd-a22ea751b62b7be2f879a77c71588d1b5aa2f643.tar.gz rspamd-a22ea751b62b7be2f879a77c71588d1b5aa2f643.zip |
Update libucl and use UCL_RANDOM_FUNCTION.
Diffstat (limited to 'contrib/libucl/ucl_parser.c')
-rw-r--r-- | contrib/libucl/ucl_parser.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/contrib/libucl/ucl_parser.c b/contrib/libucl/ucl_parser.c index 8f177938c..03935d9d0 100644 --- a/contrib/libucl/ucl_parser.c +++ b/contrib/libucl/ucl_parser.c @@ -1226,6 +1226,12 @@ ucl_parse_key (struct ucl_parser *parser, struct ucl_chunk *chunk, */ unsigned priold = ucl_object_get_priority (tobj), prinew = ucl_object_get_priority (nobj); + + /* Special case for inherited objects */ + if (tobj->flags & UCL_OBJECT_INHERITED) { + prinew = priold + 1; + } + if (priold == prinew) { ucl_parser_append_elt (parser, container, tobj, nobj); } @@ -2066,12 +2072,29 @@ ucl_state_machine (struct ucl_parser *parser) macro_start, macro_len); parser->state = parser->prev_state; if (macro_escaped == NULL) { - ret = macro->handler (macro_start, macro_len, macro_args, - macro->ud); + if (macro->is_context) { + ret = macro->h.context_handler (macro_start, macro_len, + macro_args, + parser->top_obj, + macro->ud); + } + else { + ret = macro->h.handler (macro_start, macro_len, macro_args, + macro->ud); + } } else { - ret = macro->handler (macro_escaped, macro_len, macro_args, + if (macro->is_context) { + ret = macro->h.context_handler (macro_escaped, macro_len, + macro_args, + parser->top_obj, + macro->ud); + } + else { + ret = macro->h.handler (macro_escaped, macro_len, macro_args, macro->ud); + } + UCL_FREE (macro_len + 1, macro_escaped); } @@ -2116,6 +2139,7 @@ ucl_parser_new (int flags) ucl_parser_register_macro (new, "includes", ucl_includes_handler, new); ucl_parser_register_macro (new, "priority", ucl_priority_handler, new); ucl_parser_register_macro (new, "load", ucl_load_handler, new); + ucl_parser_register_context_macro (new, "inherit", ucl_inherit_handler, new); new->flags = flags; new->includepaths = NULL; @@ -2147,14 +2171,39 @@ ucl_parser_register_macro (struct ucl_parser *parser, const char *macro, if (macro == NULL || handler == NULL) { return; } + + new = UCL_ALLOC (sizeof (struct ucl_macro)); + if (new == NULL) { + return; + } + + memset (new, 0, sizeof (struct ucl_macro)); + new->h.handler = handler; + new->name = strdup (macro); + new->ud = ud; + HASH_ADD_KEYPTR (hh, parser->macroes, new->name, strlen (new->name), new); +} + +void +ucl_parser_register_context_macro (struct ucl_parser *parser, const char *macro, + ucl_context_macro_handler handler, void* ud) +{ + struct ucl_macro *new; + + if (macro == NULL || handler == NULL) { + return; + } + new = UCL_ALLOC (sizeof (struct ucl_macro)); if (new == NULL) { return; } + memset (new, 0, sizeof (struct ucl_macro)); - new->handler = handler; + new->h.context_handler = handler; new->name = strdup (macro); new->ud = ud; + new->is_context = true; HASH_ADD_KEYPTR (hh, parser->macroes, new->name, strlen (new->name), new); } |