diff options
Diffstat (limited to 'contrib/libucl/ucl_parser.c')
-rw-r--r-- | contrib/libucl/ucl_parser.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/contrib/libucl/ucl_parser.c b/contrib/libucl/ucl_parser.c index 339b93dff..631bc7412 100644 --- a/contrib/libucl/ucl_parser.c +++ b/contrib/libucl/ucl_parser.c @@ -2726,6 +2726,7 @@ ucl_parser_add_chunk_full (struct ucl_parser *parser, const unsigned char *data, enum ucl_parse_type parse_type) { struct ucl_chunk *chunk; + struct ucl_parser_special_handler *special_handler; if (parser == NULL) { return false; @@ -2743,6 +2744,28 @@ ucl_parser_add_chunk_full (struct ucl_parser *parser, const unsigned char *data, return false; } + memset (chunk, 0, sizeof (*chunk)); + + LL_FOREACH (parser->special_handlers, special_handler) { + if (len >= special_handler->magic_len && + memcmp (data, special_handler->magic, special_handler->magic_len) == 0) { + unsigned char *ndata = NULL; + size_t nlen = 0; + + if (!special_handler->handler (parser, data, len, &ndata, &nlen, + special_handler->user_data)) { + ucl_create_err (&parser->err, "call for external handler failed"); + return false; + } + + data = ndata; + len = nlen; + chunk->special_handler = special_handler; + + break; + } + } + if (parse_type == UCL_PARSE_AUTO && len > 0) { /* We need to detect parse type by the first symbol */ if ((*data & 0x80) == 0x80 && (*data >= 0xdc && *data <= 0xdf)) { @@ -2832,7 +2855,7 @@ ucl_parser_add_chunk (struct ucl_parser *parser, const unsigned char *data, bool ucl_parser_insert_chunk (struct ucl_parser *parser, const unsigned char *data, - size_t len) + size_t len) { if (parser == NULL || parser->top_obj == NULL) { return false; @@ -2854,7 +2877,7 @@ ucl_parser_insert_chunk (struct ucl_parser *parser, const unsigned char *data, chunk = parser->chunks; if (chunk != NULL) { parser->chunks = chunk->next; - UCL_FREE (sizeof (struct ucl_chunk), chunk); + ucl_chunk_free (chunk); parser->recursion --; } @@ -2936,7 +2959,8 @@ bool ucl_parser_chunk_skip (struct ucl_parser *parser) return false; } -ucl_object_t* ucl_parser_get_current_stack_object (struct ucl_parser *parser, unsigned int depth) +ucl_object_t* +ucl_parser_get_current_stack_object (struct ucl_parser *parser, unsigned int depth) { ucl_object_t *obj; |