diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-02-16 09:59:52 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-02-16 09:59:52 +0000 |
commit | 6bc5286496c43a0ee9f1a616507c7aa03e28450c (patch) | |
tree | 9a6ed4374aaf129777560ba58f608368fb8754df /contrib | |
parent | 153e64677902c1acc7a1e8ee21d5b634d8a65885 (diff) | |
download | rspamd-6bc5286496c43a0ee9f1a616507c7aa03e28450c.tar.gz rspamd-6bc5286496c43a0ee9f1a616507c7aa03e28450c.zip |
Refactor UCL API
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/libucl/lua_ucl.c | 6 | ||||
-rw-r--r-- | contrib/libucl/ucl.h | 31 | ||||
-rw-r--r-- | contrib/libucl/ucl_emitter.c | 8 | ||||
-rw-r--r-- | contrib/libucl/ucl_schema.c | 80 | ||||
-rw-r--r-- | contrib/libucl/ucl_util.c | 54 |
5 files changed, 93 insertions, 86 deletions
diff --git a/contrib/libucl/lua_ucl.c b/contrib/libucl/lua_ucl.c index 3c42adbfe..bf80810d3 100644 --- a/contrib/libucl/lua_ucl.c +++ b/contrib/libucl/lua_ucl.c @@ -150,14 +150,14 @@ ucl_object_lua_push_object (lua_State *L, const ucl_object_t *obj, } /* Optimize allocation by preallocation of table */ - while (ucl_iterate_object (obj, &it, true) != NULL) { + while (ucl_object_iterate (obj, &it, true) != NULL) { nelt ++; } lua_createtable (L, 0, nelt); it = NULL; - while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) { + while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) { ucl_object_lua_push_element (L, ucl_object_key (cur), cur); } @@ -860,7 +860,7 @@ lua_ucl_object_validate (lua_State *L) } if (path) { - schema_elt = ucl_lookup_path_char (schema, path, '/'); + schema_elt = ucl_object_lookup_path_char (schema, path, '/'); } else { /* Use the top object */ diff --git a/contrib/libucl/ucl.h b/contrib/libucl/ucl.h index ba18380a9..bcc8049ac 100644 --- a/contrib/libucl/ucl.h +++ b/contrib/libucl/ucl.h @@ -661,8 +661,9 @@ UCL_EXTERN const char* ucl_object_tolstring (const ucl_object_t *obj, size_t *tl * @param key key to search * @return object matching the specified key or NULL if key was not found */ -UCL_EXTERN const ucl_object_t* ucl_object_find_key (const ucl_object_t *obj, +UCL_EXTERN const ucl_object_t* ucl_object_lookup (const ucl_object_t *obj, const char *key); +#define ucl_object_find_key ucl_object_lookup /** * Return object identified by a key in the specified object, if the first key is @@ -674,8 +675,9 @@ UCL_EXTERN const ucl_object_t* ucl_object_find_key (const ucl_object_t *obj, * @param ... list of alternative keys to search (NULL terminated) * @return object matching the specified key or NULL if key was not found */ -UCL_EXTERN const ucl_object_t* ucl_object_find_any_key (const ucl_object_t *obj, +UCL_EXTERN const ucl_object_t* ucl_object_lookup_any (const ucl_object_t *obj, const char *key, ...); +#define ucl_object_find_any_key ucl_object_lookup_any /** * Return object identified by a fixed size key in the specified object @@ -684,8 +686,9 @@ UCL_EXTERN const ucl_object_t* ucl_object_find_any_key (const ucl_object_t *obj, * @param klen length of a key * @return object matching the specified key or NULL if key was not found */ -UCL_EXTERN const ucl_object_t* ucl_object_find_keyl (const ucl_object_t *obj, +UCL_EXTERN const ucl_object_t* ucl_object_lookup_len (const ucl_object_t *obj, const char *key, size_t klen); +#define ucl_object_find_keyl ucl_object_lookup_len /** * Return object identified by dot notation string @@ -693,8 +696,9 @@ UCL_EXTERN const ucl_object_t* ucl_object_find_keyl (const ucl_object_t *obj, * @param path dot.notation.path to the path to lookup. May use numeric .index on arrays * @return object matched the specified path or NULL if path is not found */ -UCL_EXTERN const ucl_object_t *ucl_lookup_path (const ucl_object_t *obj, +UCL_EXTERN const ucl_object_t *ucl_object_lookup_path (const ucl_object_t *obj, const char *path); +#define ucl_lookup_path ucl_object_lookup_path /** * Return object identified by object notation string using arbitrary delimiter @@ -703,8 +707,9 @@ UCL_EXTERN const ucl_object_t *ucl_lookup_path (const ucl_object_t *obj, * @param sep the sepatorator to use in place of . (incase keys have . in them) * @return object matched the specified path or NULL if path is not found */ -UCL_EXTERN const ucl_object_t *ucl_lookup_path_char (const ucl_object_t *obj, +UCL_EXTERN const ucl_object_t *ucl_object_lookup_path_char (const ucl_object_t *obj, const char *path, char sep); +#define ucl_lookup_path_char ucl_object_lookup_path_char /** * Returns a key of an object as a NULL terminated string @@ -802,8 +807,9 @@ typedef void* ucl_object_iter_t; * while ((cur = ucl_iterate_object (obj, &it)) != NULL) ... * @return the next object or NULL */ -UCL_EXTERN const ucl_object_t* ucl_iterate_object (const ucl_object_t *obj, +UCL_EXTERN const ucl_object_t* ucl_object_iterate (const ucl_object_t *obj, ucl_object_iter_t *iter, bool expand_values); +#define ucl_iterate_object ucl_object_iterate /** * Create new safe iterator for the specified object @@ -1072,34 +1078,34 @@ UCL_EXTERN ucl_object_t* ucl_parser_get_object (struct ucl_parser *parser); * @param parser parser object * @return error description */ -UCL_EXTERN const char *ucl_parser_get_error(struct ucl_parser *parser); +UCL_EXTERN const char *ucl_parser_get_error (struct ucl_parser *parser); /** * Get the code of the last error * @param parser parser object * @return error code */ -UCL_EXTERN int ucl_parser_get_error_code(struct ucl_parser *parser); +UCL_EXTERN int ucl_parser_get_error_code (struct ucl_parser *parser); /** * Get the current column number within parser * @param parser parser object * @return current column number */ -UCL_EXTERN unsigned ucl_parser_get_column(struct ucl_parser *parser); +UCL_EXTERN unsigned ucl_parser_get_column (struct ucl_parser *parser); /** * Get the current line number within parser * @param parser parser object * @return current line number */ -UCL_EXTERN unsigned ucl_parser_get_linenum(struct ucl_parser *parser); +UCL_EXTERN unsigned ucl_parser_get_linenum (struct ucl_parser *parser); /** * Clear the error in the parser * @param parser parser object */ -UCL_EXTERN void ucl_parser_clear_error(struct ucl_parser *parser); +UCL_EXTERN void ucl_parser_clear_error (struct ucl_parser *parser); /** * Free ucl parser object @@ -1132,7 +1138,8 @@ UCL_EXTERN const ucl_object_t * ucl_comments_find (const ucl_object_t *comments, * @param err if *err is NULL it is set to parser error * @return true if a key has been successfully added */ -UCL_EXTERN bool ucl_pubkey_add (struct ucl_parser *parser, const unsigned char *key, size_t len); +UCL_EXTERN bool ucl_parser_pubkey_add (struct ucl_parser *parser, + const unsigned char *key, size_t len); /** * Set FILENAME and CURDIR variables in parser diff --git a/contrib/libucl/ucl_emitter.c b/contrib/libucl/ucl_emitter.c index 84108e21d..a15cd08cf 100644 --- a/contrib/libucl/ucl_emitter.c +++ b/contrib/libucl/ucl_emitter.c @@ -268,7 +268,7 @@ ucl_emitter_common_start_array (struct ucl_emitter_context *ctx, if (obj->type == UCL_ARRAY) { /* explicit array */ - while ((cur = ucl_iterate_object (obj, &iter, true)) != NULL) { + while ((cur = ucl_object_iterate (obj, &iter, true)) != NULL) { ucl_emitter_common_elt (ctx, cur, first, false, compact); first = false; } @@ -381,7 +381,7 @@ ucl_emitter_common_elt (struct ucl_emitter_context *ctx, ucl_add_tabs (func, ctx->indent, compact); if (ctx->comments && ctx->id == UCL_EMIT_CONFIG) { - comment = ucl_object_find_keyl (ctx->comments, (const char *)&obj, + comment = ucl_object_lookup_len (ctx->comments, (const char *)&obj, sizeof (void *)); if (comment) { @@ -551,7 +551,7 @@ ucl_emit_msgpack_elt (struct ucl_emitter_context *ctx, ucl_emit_msgpack_start_obj (ctx, obj, print_key); it = NULL; - while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) { + while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) { LL_FOREACH (cur, celt) { ucl_emit_msgpack_elt (ctx, celt, false, true); /* XXX: @@ -570,7 +570,7 @@ ucl_emit_msgpack_elt (struct ucl_emitter_context *ctx, ucl_emit_msgpack_start_array (ctx, obj, print_key); it = NULL; - while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) { + while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) { ucl_emit_msgpack_elt (ctx, cur, false, false); } diff --git a/contrib/libucl/ucl_schema.c b/contrib/libucl/ucl_schema.c index 531cf848c..4d7c871ff 100644 --- a/contrib/libucl/ucl_schema.c +++ b/contrib/libucl/ucl_schema.c @@ -78,7 +78,7 @@ ucl_schema_test_pattern (const ucl_object_t *obj, const char *pattern) ucl_object_iter_t iter = NULL; if (regcomp (®, pattern, REG_EXTENDED | REG_NOSUB) == 0) { - while ((elt = ucl_iterate_object (obj, &iter, true)) != NULL) { + while ((elt = ucl_object_iterate (obj, &iter, true)) != NULL) { if (regexec (®, ucl_object_key (elt), 0, NULL, 0) == 0) { res = elt; break; @@ -103,14 +103,14 @@ ucl_schema_validate_dependencies (const ucl_object_t *deps, ucl_object_iter_t iter = NULL, piter; bool ret = true; - while (ret && (cur = ucl_iterate_object (deps, &iter, true)) != NULL) { - elt = ucl_object_find_key (obj, ucl_object_key (cur)); + while (ret && (cur = ucl_object_iterate (deps, &iter, true)) != NULL) { + elt = ucl_object_lookup (obj, ucl_object_key (cur)); if (elt != NULL) { /* Need to check dependencies */ if (cur->type == UCL_ARRAY) { piter = NULL; - while (ret && (cur_dep = ucl_iterate_object (cur, &piter, true)) != NULL) { - if (ucl_object_find_key (obj, ucl_object_tostring (cur_dep)) == NULL) { + while (ret && (cur_dep = ucl_object_iterate (cur, &piter, true)) != NULL) { + if (ucl_object_lookup (obj, ucl_object_tostring (cur_dep)) == NULL) { ucl_schema_create_error (err, UCL_SCHEMA_MISSING_DEPENDENCY, elt, "dependency %s is missing for key %s", ucl_object_tostring (cur_dep), ucl_object_key (cur)); @@ -143,12 +143,12 @@ ucl_schema_validate_object (const ucl_object_t *schema, bool ret = true, allow_additional = true; int64_t minmax; - while (ret && (elt = ucl_iterate_object (schema, &iter, true)) != NULL) { + while (ret && (elt = ucl_object_iterate (schema, &iter, true)) != NULL) { if (elt->type == UCL_OBJECT && strcmp (ucl_object_key (elt), "properties") == 0) { piter = NULL; - while (ret && (prop = ucl_iterate_object (elt, &piter, true)) != NULL) { - found = ucl_object_find_key (obj, ucl_object_key (prop)); + while (ret && (prop = ucl_object_iterate (elt, &piter, true)) != NULL) { + found = ucl_object_lookup (obj, ucl_object_key (prop)); if (found) { ret = ucl_schema_validate (prop, found, true, err, root, ext_ref); @@ -206,7 +206,7 @@ ucl_schema_validate_object (const ucl_object_t *schema, } else if (strcmp (ucl_object_key (elt), "patternProperties") == 0) { piter = NULL; - while (ret && (prop = ucl_iterate_object (elt, &piter, true)) != NULL) { + while (ret && (prop = ucl_object_iterate (elt, &piter, true)) != NULL) { found = ucl_schema_test_pattern (obj, ucl_object_key (prop)); if (found) { ret = ucl_schema_validate (prop, found, true, err, root, @@ -226,14 +226,14 @@ ucl_schema_validate_object (const ucl_object_t *schema, if (!allow_additional || additional_schema != NULL) { /* Check if we have exactly the same properties in schema and object */ iter = NULL; - prop = ucl_object_find_key (schema, "properties"); - while ((elt = ucl_iterate_object (obj, &iter, true)) != NULL) { - found = ucl_object_find_key (prop, ucl_object_key (elt)); + prop = ucl_object_lookup (schema, "properties"); + while ((elt = ucl_object_iterate (obj, &iter, true)) != NULL) { + found = ucl_object_lookup (prop, ucl_object_key (elt)); if (found == NULL) { /* Try patternProperties */ piter = NULL; - pat = ucl_object_find_key (schema, "patternProperties"); - while ((pelt = ucl_iterate_object (pat, &piter, true)) != NULL) { + pat = ucl_object_lookup (schema, "patternProperties"); + while ((pelt = ucl_object_iterate (pat, &piter, true)) != NULL) { found = ucl_schema_test_pattern (obj, ucl_object_key (pelt)); if (found != NULL) { break; @@ -261,8 +261,8 @@ ucl_schema_validate_object (const ucl_object_t *schema, /* Required properties */ if (required != NULL) { iter = NULL; - while ((elt = ucl_iterate_object (required, &iter, true)) != NULL) { - if (ucl_object_find_key (obj, ucl_object_tostring (elt)) == NULL) { + while ((elt = ucl_object_iterate (required, &iter, true)) != NULL) { + if (ucl_object_lookup (obj, ucl_object_tostring (elt)) == NULL) { ucl_schema_create_error (err, UCL_SCHEMA_MISSING_PROPERTY, obj, "object has missing property %s", ucl_object_tostring (elt)); @@ -287,7 +287,7 @@ ucl_schema_validate_number (const ucl_object_t *schema, double constraint, val; const double alpha = 1e-16; - while (ret && (elt = ucl_iterate_object (schema, &iter, true)) != NULL) { + while (ret && (elt = ucl_object_iterate (schema, &iter, true)) != NULL) { if ((elt->type == UCL_FLOAT || elt->type == UCL_INT) && strcmp (ucl_object_key (elt), "multipleOf") == 0) { constraint = ucl_object_todouble (elt); @@ -309,7 +309,7 @@ ucl_schema_validate_number (const ucl_object_t *schema, else if ((elt->type == UCL_FLOAT || elt->type == UCL_INT) && strcmp (ucl_object_key (elt), "maximum") == 0) { constraint = ucl_object_todouble (elt); - test = ucl_object_find_key (schema, "exclusiveMaximum"); + test = ucl_object_lookup (schema, "exclusiveMaximum"); if (test && test->type == UCL_BOOLEAN) { exclusive = ucl_object_toboolean (test); } @@ -325,7 +325,7 @@ ucl_schema_validate_number (const ucl_object_t *schema, else if ((elt->type == UCL_FLOAT || elt->type == UCL_INT) && strcmp (ucl_object_key (elt), "minimum") == 0) { constraint = ucl_object_todouble (elt); - test = ucl_object_find_key (schema, "exclusiveMinimum"); + test = ucl_object_lookup (schema, "exclusiveMinimum"); if (test && test->type == UCL_BOOLEAN) { exclusive = ucl_object_toboolean (test); } @@ -355,7 +355,7 @@ ucl_schema_validate_string (const ucl_object_t *schema, regex_t re; #endif - while (ret && (elt = ucl_iterate_object (schema, &iter, true)) != NULL) { + while (ret && (elt = ucl_object_iterate (schema, &iter, true)) != NULL) { if (elt->type == UCL_INT && strcmp (ucl_object_key (elt), "maxLength") == 0) { constraint = ucl_object_toint (elt); @@ -429,7 +429,7 @@ ucl_schema_array_is_unique (const ucl_object_t *obj, struct ucl_schema_error *er struct ucl_compare_node *node, test, *nodes = NULL, *tmp; bool ret = true; - while ((elt = ucl_iterate_object (obj, &iter, true)) != NULL) { + while ((elt = ucl_object_iterate (obj, &iter, true)) != NULL) { test.obj = elt; node = TREE_FIND (&tree, ucl_compare_node, link, &test); if (node != NULL) { @@ -470,11 +470,11 @@ ucl_schema_validate_array (const ucl_object_t *schema, int64_t minmax; unsigned int idx = 0; - while (ret && (elt = ucl_iterate_object (schema, &iter, true)) != NULL) { + while (ret && (elt = ucl_object_iterate (schema, &iter, true)) != NULL) { if (strcmp (ucl_object_key (elt), "items") == 0) { if (elt->type == UCL_ARRAY) { found = ucl_array_head (obj); - while (ret && (it = ucl_iterate_object (elt, &piter, true)) != NULL) { + while (ret && (it = ucl_object_iterate (elt, &piter, true)) != NULL) { if (found) { ret = ucl_schema_validate (it, found, false, err, root, ext_ref); @@ -488,7 +488,7 @@ ucl_schema_validate_array (const ucl_object_t *schema, } else if (elt->type == UCL_OBJECT) { /* Validate all items using the specified schema */ - while (ret && (it = ucl_iterate_object (obj, &piter, true)) != NULL) { + while (ret && (it = ucl_object_iterate (obj, &piter, true)) != NULL) { ret = ucl_schema_validate (elt, it, false, err, root, ext_ref); } @@ -594,7 +594,7 @@ ucl_schema_type_is_allowed (const ucl_object_t *type, const ucl_object_t *obj, if (type->type == UCL_ARRAY) { /* One of allowed types */ - while ((elt = ucl_iterate_object (type, &iter, true)) != NULL) { + while ((elt = ucl_object_iterate (type, &iter, true)) != NULL) { if (ucl_schema_type_is_allowed (elt, obj, err)) { return true; } @@ -642,7 +642,7 @@ ucl_schema_validate_enum (const ucl_object_t *en, const ucl_object_t *obj, const ucl_object_t *elt; bool ret = false; - while ((elt = ucl_iterate_object (en, &iter, true)) != NULL) { + while ((elt = ucl_object_iterate (en, &iter, true)) != NULL) { if (ucl_object_compare (elt, obj) == 0) { ret = true; break; @@ -672,7 +672,7 @@ ucl_schema_resolve_ref_component (const ucl_object_t *cur, if (cur->type == UCL_OBJECT) { /* Find a key inside an object */ - res = ucl_object_find_keyl (cur, refc, len); + res = ucl_object_lookup_len (cur, refc, len); if (res == NULL) { ucl_schema_create_error (err, UCL_SCHEMA_INVALID_SCHEMA, cur, "reference %s is invalid, missing path component", refc); @@ -748,7 +748,7 @@ ucl_schema_resolve_ref (const ucl_object_t *root, const char *ref, p = ref; } - ext_obj = ucl_object_find_key (ext_ref, p); + ext_obj = ucl_object_lookup (ext_ref, p); if (ext_obj == NULL) { if (ucl_strnstr (p, "://", strlen (p)) != NULL) { @@ -863,7 +863,7 @@ ucl_schema_validate_values (const ucl_object_t *schema, const ucl_object_t *obj, const ucl_object_t *elt, *cur; int64_t constraint, i; - elt = ucl_object_find_key (schema, "maxValues"); + elt = ucl_object_lookup (schema, "maxValues"); if (elt != NULL && elt->type == UCL_INT) { constraint = ucl_object_toint (elt); cur = obj; @@ -879,7 +879,7 @@ ucl_schema_validate_values (const ucl_object_t *schema, const ucl_object_t *obj, cur = cur->next; } } - elt = ucl_object_find_key (schema, "minValues"); + elt = ucl_object_lookup (schema, "minValues"); if (elt != NULL && elt->type == UCL_INT) { constraint = ucl_object_toint (elt); cur = obj; @@ -935,17 +935,17 @@ ucl_schema_validate (const ucl_object_t *schema, return true; } - elt = ucl_object_find_key (schema, "enum"); + elt = ucl_object_lookup (schema, "enum"); if (elt != NULL && elt->type == UCL_ARRAY) { if (!ucl_schema_validate_enum (elt, obj, err)) { return false; } } - elt = ucl_object_find_key (schema, "allOf"); + elt = ucl_object_lookup (schema, "allOf"); if (elt != NULL && elt->type == UCL_ARRAY) { iter = NULL; - while ((cur = ucl_iterate_object (elt, &iter, true)) != NULL) { + while ((cur = ucl_object_iterate (elt, &iter, true)) != NULL) { ret = ucl_schema_validate (cur, obj, true, err, root, external_refs); if (!ret) { return false; @@ -953,10 +953,10 @@ ucl_schema_validate (const ucl_object_t *schema, } } - elt = ucl_object_find_key (schema, "anyOf"); + elt = ucl_object_lookup (schema, "anyOf"); if (elt != NULL && elt->type == UCL_ARRAY) { iter = NULL; - while ((cur = ucl_iterate_object (elt, &iter, true)) != NULL) { + while ((cur = ucl_object_iterate (elt, &iter, true)) != NULL) { ret = ucl_schema_validate (cur, obj, true, err, root, external_refs); if (ret) { break; @@ -971,11 +971,11 @@ ucl_schema_validate (const ucl_object_t *schema, } } - elt = ucl_object_find_key (schema, "oneOf"); + elt = ucl_object_lookup (schema, "oneOf"); if (elt != NULL && elt->type == UCL_ARRAY) { iter = NULL; ret = false; - while ((cur = ucl_iterate_object (elt, &iter, true)) != NULL) { + while ((cur = ucl_object_iterate (elt, &iter, true)) != NULL) { if (!ret) { ret = ucl_schema_validate (cur, obj, true, err, root, external_refs); } @@ -989,7 +989,7 @@ ucl_schema_validate (const ucl_object_t *schema, } } - elt = ucl_object_find_key (schema, "not"); + elt = ucl_object_lookup (schema, "not"); if (elt != NULL && elt->type == UCL_OBJECT) { if (ucl_schema_validate (elt, obj, true, err, root, external_refs)) { return false; @@ -1000,7 +1000,7 @@ ucl_schema_validate (const ucl_object_t *schema, } } - elt = ucl_object_find_key (schema, "$ref"); + elt = ucl_object_lookup (schema, "$ref"); if (elt != NULL) { ref_root = root; cur = ucl_schema_resolve_ref (root, ucl_object_tostring (elt), @@ -1015,7 +1015,7 @@ ucl_schema_validate (const ucl_object_t *schema, } } - elt = ucl_object_find_key (schema, "type"); + elt = ucl_object_lookup (schema, "type"); if (!ucl_schema_type_is_allowed (elt, obj, err)) { return false; } diff --git a/contrib/libucl/ucl_util.c b/contrib/libucl/ucl_util.c index 7626e0996..fae6cdeb9 100644 --- a/contrib/libucl/ucl_util.c +++ b/contrib/libucl/ucl_util.c @@ -1334,7 +1334,7 @@ ucl_include_common (const unsigned char *data, size_t len, /* Process arguments */ if (args != NULL && args->type == UCL_OBJECT) { - while ((param = ucl_iterate_object (args, &it, true)) != NULL) { + while ((param = ucl_object_iterate (args, &it, true)) != NULL) { if (param->type == UCL_BOOLEAN) { if (strncmp (param->key, "try", param->keylen) == 0) { params.must_exist = !ucl_object_toboolean (param); @@ -1509,7 +1509,7 @@ ucl_priority_handler (const unsigned char *data, size_t len, /* Process arguments */ if (args != NULL && args->type == UCL_OBJECT) { - while ((param = ucl_iterate_object (args, &it, true)) != NULL) { + while ((param = ucl_object_iterate (args, &it, true)) != NULL) { if (param->type == UCL_INT) { if (strncmp (param->key, "priority", param->keylen) == 0) { priority = ucl_object_toint (param); @@ -1588,7 +1588,7 @@ ucl_load_handler (const unsigned char *data, size_t len, /* Process arguments */ if (args != NULL && args->type == UCL_OBJECT) { - while ((param = ucl_iterate_object (args, &it, true)) != NULL) { + while ((param = ucl_object_iterate (args, &it, true)) != NULL) { if (param->type == UCL_BOOLEAN) { if (strncmp (param->key, "try", param->keylen) == 0) { try_load = ucl_object_toboolean (param); @@ -1648,7 +1648,7 @@ ucl_load_handler (const unsigned char *data, size_t len, free (load_file); container = parser->stack->obj; - old_obj = __DECONST (ucl_object_t *, ucl_object_find_key (container, + old_obj = __DECONST (ucl_object_t *, ucl_object_lookup (container, prefix)); if (old_obj != NULL) { @@ -1704,7 +1704,7 @@ ucl_inherit_handler (const unsigned char *data, size_t len, bool replace = false; struct ucl_parser *parser = ud; - parent = ucl_object_find_keyl (ctx, data, len); + parent = ucl_object_lookup_len (ctx, data, len); /* Some sanity checks */ if (parent == NULL || ucl_object_type (parent) != UCL_OBJECT) { @@ -1721,13 +1721,13 @@ ucl_inherit_handler (const unsigned char *data, size_t len, target = parser->stack->obj; - if (args && (cur = ucl_object_find_key (args, "replace")) != NULL) { + if (args && (cur = ucl_object_lookup (args, "replace")) != NULL) { replace = ucl_object_toboolean (cur); } - while ((cur = ucl_iterate_object (parent, &it, true))) { + while ((cur = ucl_object_iterate (parent, &it, true))) { /* We do not replace existing keys */ - if (!replace && ucl_object_find_keyl (target, cur->key, cur->keylen)) { + if (!replace && ucl_object_lookup_len (target, cur->key, cur->keylen)) { continue; } @@ -2172,7 +2172,7 @@ ucl_object_insert_key_common (ucl_object_t *top, ucl_object_t *elt, } else if (found->type == UCL_OBJECT && elt->type == UCL_OBJECT) { /* Mix two hashes */ - while ((cur = ucl_iterate_object (elt, &it, true)) != NULL) { + while ((cur = ucl_object_iterate (elt, &it, true)) != NULL) { tmp = ucl_object_ref (cur); ucl_object_insert_key_common (found, tmp, cur->key, cur->keylen, copy_key, false, false); @@ -2201,7 +2201,7 @@ ucl_object_delete_keyl (ucl_object_t *top, const char *key, size_t keylen) return false; } - found = __DECONST (ucl_object_t *, ucl_object_find_keyl (top, key, keylen)); + found = __DECONST (ucl_object_t *, ucl_object_lookup_len (top, key, keylen)); if (found == NULL) { return false; @@ -2228,7 +2228,7 @@ ucl_object_pop_keyl (ucl_object_t *top, const char *key, size_t keylen) if (top == NULL || key == NULL) { return false; } - found = ucl_object_find_keyl (top, key, keylen); + found = ucl_object_lookup_len (top, key, keylen); if (found == NULL) { return NULL; @@ -2301,7 +2301,7 @@ ucl_object_merge (ucl_object_t *top, ucl_object_t *elt, bool copy) } const ucl_object_t * -ucl_object_find_keyl (const ucl_object_t *obj, const char *key, size_t klen) +ucl_object_lookup_len (const ucl_object_t *obj, const char *key, size_t klen) { const ucl_object_t *ret; ucl_object_t srch; @@ -2318,17 +2318,17 @@ ucl_object_find_keyl (const ucl_object_t *obj, const char *key, size_t klen) } const ucl_object_t * -ucl_object_find_key (const ucl_object_t *obj, const char *key) +ucl_object_lookup (const ucl_object_t *obj, const char *key) { if (key == NULL) { return NULL; } - return ucl_object_find_keyl (obj, key, strlen (key)); + return ucl_object_lookup_len (obj, key, strlen (key)); } const ucl_object_t* -ucl_object_find_any_key (const ucl_object_t *obj, +ucl_object_lookup_any (const ucl_object_t *obj, const char *key, ...) { va_list ap; @@ -2339,7 +2339,7 @@ ucl_object_find_any_key (const ucl_object_t *obj, return NULL; } - ret = ucl_object_find_keyl (obj, key, strlen (key)); + ret = ucl_object_lookup_len (obj, key, strlen (key)); if (ret == NULL) { va_start (ap, key); @@ -2351,7 +2351,7 @@ ucl_object_find_any_key (const ucl_object_t *obj, break; } else { - ret = ucl_object_find_keyl (obj, nk, strlen (nk)); + ret = ucl_object_lookup_len (obj, nk, strlen (nk)); } } @@ -2362,7 +2362,7 @@ ucl_object_find_any_key (const ucl_object_t *obj, } const ucl_object_t* -ucl_iterate_object (const ucl_object_t *obj, ucl_object_iter_t *iter, bool expand_values) +ucl_object_iterate (const ucl_object_t *obj, ucl_object_iter_t *iter, bool expand_values) { const ucl_object_t *elt = NULL; @@ -2469,7 +2469,7 @@ ucl_object_iterate_safe (ucl_object_iter_t it, bool expand_values) } if (rit->impl_it->type == UCL_OBJECT || rit->impl_it->type == UCL_ARRAY) { - ret = ucl_iterate_object (rit->impl_it, &rit->expl_it, true); + ret = ucl_object_iterate (rit->impl_it, &rit->expl_it, true); if (ret == NULL) { /* Need to switch to another implicit object in chain */ @@ -2504,13 +2504,13 @@ ucl_object_iterate_free (ucl_object_iter_t it) } const ucl_object_t * -ucl_lookup_path (const ucl_object_t *top, const char *path_in) { - return ucl_lookup_path_char (top, path_in, '.'); +ucl_object_lookup_path (const ucl_object_t *top, const char *path_in) { + return ucl_object_lookup_path_char (top, path_in, '.'); } const ucl_object_t * -ucl_lookup_path_char (const ucl_object_t *top, const char *path_in, const char sep) { +ucl_object_lookup_path_char (const ucl_object_t *top, const char *path_in, const char sep) { const ucl_object_t *o = NULL, *found; const char *p, *c; char *err_str; @@ -2543,7 +2543,7 @@ ucl_lookup_path_char (const ucl_object_t *top, const char *path_in, const char s o = ucl_array_find_index (top, index); break; default: - o = ucl_object_find_keyl (top, c, p - c); + o = ucl_object_lookup_len (top, c, p - c); break; } if (o == NULL) { @@ -3165,7 +3165,7 @@ ucl_object_copy_internal (const ucl_object_t *other, bool allow_array) /* reset old value */ memset (&new->value, 0, sizeof (new->value)); - while ((cur = ucl_iterate_object (other, &it, true)) != NULL) { + while ((cur = ucl_object_iterate (other, &it, true)) != NULL) { if (other->type == UCL_ARRAY) { ucl_array_append (new, ucl_object_copy_internal (cur, false)); } @@ -3271,8 +3271,8 @@ ucl_object_compare (const ucl_object_t *o1, const ucl_object_t *o2) break; case UCL_OBJECT: if (o1->len == o2->len && o1->len > 0) { - while ((it1 = ucl_iterate_object (o1, &iter, true)) != NULL) { - it2 = ucl_object_find_key (o2, ucl_object_key (it1)); + while ((it1 = ucl_object_iterate (o1, &iter, true)) != NULL) { + it2 = ucl_object_lookup (o2, ucl_object_key (it1)); if (it2 == NULL) { ret = 1; break; @@ -3426,7 +3426,7 @@ ucl_comments_find (const ucl_object_t *comments, const ucl_object_t *srch) { if (comments && srch) { - return ucl_object_find_keyl (comments, (const char *)&srch, + return ucl_object_lookup_len (comments, (const char *)&srch, sizeof (void *)); } |