aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libucl/ucl_util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-05 14:58:37 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-05 14:58:37 +0100
commita3191bd7b34d3373d151827a6e6592ea82084747 (patch)
treeab4ecb6c138e1a21cb76aeaf4503d04a253568ae /contrib/libucl/ucl_util.c
parent91154ccc0114f1dca3b803a9c9bcfd065297c329 (diff)
downloadrspamd-a3191bd7b34d3373d151827a6e6592ea82084747.tar.gz
rspamd-a3191bd7b34d3373d151827a6e6592ea82084747.zip
[Feture] Allow external preprocessors in libucl
Diffstat (limited to 'contrib/libucl/ucl_util.c')
-rw-r--r--contrib/libucl/ucl_util.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/contrib/libucl/ucl_util.c b/contrib/libucl/ucl_util.c
index c6c07ba87..95878109b 100644
--- a/contrib/libucl/ucl_util.c
+++ b/contrib/libucl/ucl_util.c
@@ -516,6 +516,26 @@ ucl_copy_key_trash (const ucl_object_t *obj)
return obj->trash_stack[UCL_TRASH_KEY];
}
+void
+ucl_chunk_free (struct ucl_chunk *chunk)
+{
+ if (chunk) {
+ if (chunk->special_handler) {
+ if (chunk->special_handler->free_function) {
+ chunk->special_handler->free_function (
+ (unsigned char *) chunk->begin,
+ chunk->end - chunk->begin,
+ chunk->special_handler->user_data);
+ } else {
+ UCL_FREE (chunk->end - chunk->begin,
+ (unsigned char *) chunk->begin);
+ }
+ }
+
+ UCL_FREE (sizeof (*chunk), chunk);
+ }
+}
+
char *
ucl_copy_value_trash (const ucl_object_t *obj)
{
@@ -601,7 +621,7 @@ ucl_parser_free (struct ucl_parser *parser)
UCL_FREE (sizeof (struct ucl_macro), macro);
}
LL_FOREACH_SAFE (parser->chunks, chunk, ctmp) {
- UCL_FREE (sizeof (struct ucl_chunk), chunk);
+ ucl_chunk_free (chunk);
}
LL_FOREACH_SAFE (parser->keys, key, ktmp) {
UCL_FREE (sizeof (struct ucl_pubkey), key);
@@ -718,6 +738,12 @@ ucl_pubkey_add (struct ucl_parser *parser, const unsigned char *key, size_t len)
return true;
}
+void ucl_parser_add_special_handler (struct ucl_parser *parser,
+ struct ucl_parser_special_handler *handler)
+{
+ LL_APPEND (parser->special_handlers, handler);
+}
+
#ifdef CURL_FOUND
struct ucl_curl_cbdata {
unsigned char *buf;
@@ -1017,7 +1043,7 @@ ucl_include_url (const unsigned char *data, size_t len,
chunk = parser->chunks;
if (chunk != NULL) {
parser->chunks = chunk->next;
- UCL_FREE (sizeof (struct ucl_chunk), chunk);
+ ucl_chunk_free (chunk);
}
}
@@ -1319,7 +1345,7 @@ ucl_include_file_single (const unsigned char *data, size_t len,
chunk = parser->chunks;
if (chunk != NULL) {
parser->chunks = chunk->next;
- UCL_FREE (sizeof (struct ucl_chunk), chunk);
+ ucl_chunk_free (chunk);
parser->recursion --;
}