@@ -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 */ |
@@ -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 |
@@ -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); | |||
} | |||
@@ -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; | |||
} |
@@ -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 *)); | |||
} | |||
@@ -470,16 +470,16 @@ rspamc_symbol_output (FILE *out, const ucl_object_t *obj) | |||
gboolean first = TRUE; | |||
rspamd_fprintf (out, "Symbol: %s ", ucl_object_key (obj)); | |||
val = ucl_object_find_key (obj, "score"); | |||
val = ucl_object_lookup (obj, "score"); | |||
if (val != NULL) { | |||
rspamd_fprintf (out, "(%.2f)", ucl_object_todouble (val)); | |||
} | |||
val = ucl_object_find_key (obj, "options"); | |||
val = ucl_object_lookup (obj, "options"); | |||
if (val != NULL && val->type == UCL_ARRAY) { | |||
rspamd_fprintf (out, "["); | |||
while ((cur = ucl_iterate_object (val, &it, TRUE)) != NULL) { | |||
while ((cur = ucl_object_iterate (val, &it, TRUE)) != NULL) { | |||
if (first) { | |||
rspamd_fprintf (out, "%s", ucl_object_tostring (cur)); | |||
first = FALSE; | |||
@@ -514,7 +514,7 @@ rspamc_metric_output (FILE *out, const ucl_object_t *obj) | |||
sym_ptr = g_ptr_array_new (); | |||
rspamd_fprintf (out, "[Metric: %s]\n", ucl_object_key (obj)); | |||
while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) { | |||
if (g_ascii_strcasecmp (ucl_object_key (cur), "is_spam") == 0) { | |||
rspamd_fprintf (out, "Spam: %s\n", ucl_object_toboolean (cur) ? | |||
"true" : "false"); | |||
@@ -560,7 +560,7 @@ rspamc_symbols_output (FILE *out, ucl_object_t *obj) | |||
const ucl_object_t *cur, *cmesg; | |||
gchar *emitted; | |||
while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) { | |||
if (g_ascii_strcasecmp (ucl_object_key (cur), "message-id") == 0) { | |||
rspamd_fprintf (out, "Message-ID: %s\n", ucl_object_tostring ( | |||
cur)); | |||
@@ -591,7 +591,7 @@ rspamc_symbols_output (FILE *out, ucl_object_t *obj) | |||
else if (g_ascii_strcasecmp (ucl_object_key (cur), "messages") == 0) { | |||
if (cur->type == UCL_ARRAY) { | |||
mit = NULL; | |||
while ((cmesg = ucl_iterate_object (cur, &mit, true)) != NULL) { | |||
while ((cmesg = ucl_object_iterate (cur, &mit, true)) != NULL) { | |||
rspamd_fprintf (out, "Message: %s\n", | |||
ucl_object_tostring (cmesg)); | |||
} | |||
@@ -610,13 +610,13 @@ rspamc_uptime_output (FILE *out, ucl_object_t *obj) | |||
const ucl_object_t *elt; | |||
int64_t seconds, days, hours, minutes; | |||
elt = ucl_object_find_key (obj, "version"); | |||
elt = ucl_object_lookup (obj, "version"); | |||
if (elt != NULL) { | |||
rspamd_fprintf (out, "Rspamd version: %s\n", ucl_object_tostring ( | |||
elt)); | |||
} | |||
elt = ucl_object_find_key (obj, "uptime"); | |||
elt = ucl_object_lookup (obj, "uptime"); | |||
if (elt != NULL) { | |||
rspamd_printf ("Uptime: "); | |||
seconds = ucl_object_toint (elt); | |||
@@ -661,8 +661,8 @@ rspamc_counters_sort (const ucl_object_t **o1, const ucl_object_t **o2) | |||
} | |||
if (g_ascii_strcasecmp (args[0], "name") == 0) { | |||
elt1 = ucl_object_find_key (*o1, "symbol"); | |||
elt2 = ucl_object_find_key (*o2, "symbol"); | |||
elt1 = ucl_object_lookup (*o1, "symbol"); | |||
elt2 = ucl_object_lookup (*o2, "symbol"); | |||
if (elt1 && elt2) { | |||
c = strcmp (ucl_object_tostring (elt1), | |||
@@ -673,8 +673,8 @@ rspamc_counters_sort (const ucl_object_t **o1, const ucl_object_t **o2) | |||
} | |||
} | |||
else if (g_ascii_strcasecmp (args[0], "weight") == 0) { | |||
elt1 = ucl_object_find_key (*o1, "weight"); | |||
elt2 = ucl_object_find_key (*o2, "weight"); | |||
elt1 = ucl_object_lookup (*o1, "weight"); | |||
elt2 = ucl_object_lookup (*o2, "weight"); | |||
if (elt1 && elt2) { | |||
order1 = ucl_object_todouble (elt1) * 1000.0; | |||
@@ -682,8 +682,8 @@ rspamc_counters_sort (const ucl_object_t **o1, const ucl_object_t **o2) | |||
} | |||
} | |||
else if (g_ascii_strcasecmp (args[0], "frequency") == 0) { | |||
elt1 = ucl_object_find_key (*o1, "frequency"); | |||
elt2 = ucl_object_find_key (*o2, "frequency"); | |||
elt1 = ucl_object_lookup (*o1, "frequency"); | |||
elt2 = ucl_object_lookup (*o2, "frequency"); | |||
if (elt1 && elt2) { | |||
order1 = ucl_object_toint (elt1); | |||
@@ -691,8 +691,8 @@ rspamc_counters_sort (const ucl_object_t **o1, const ucl_object_t **o2) | |||
} | |||
} | |||
else if (g_ascii_strcasecmp (args[0], "time") == 0) { | |||
elt1 = ucl_object_find_key (*o1, "time"); | |||
elt2 = ucl_object_find_key (*o2, "time"); | |||
elt1 = ucl_object_lookup (*o1, "time"); | |||
elt2 = ucl_object_lookup (*o2, "time"); | |||
if (elt1 && elt2) { | |||
order1 = ucl_object_todouble (elt1) * 1000000; | |||
@@ -726,8 +726,8 @@ rspamc_counters_output (FILE *out, ucl_object_t *obj) | |||
} | |||
/* Find maximum width of symbol's name */ | |||
while ((cur = ucl_iterate_object (obj, &iter, true)) != NULL) { | |||
sym = ucl_object_find_key (cur, "symbol"); | |||
while ((cur = ucl_object_iterate (obj, &iter, true)) != NULL) { | |||
sym = ucl_object_lookup (cur, "symbol"); | |||
if (sym != NULL) { | |||
l = sym->len; | |||
if (l > max_len) { | |||
@@ -755,12 +755,12 @@ rspamc_counters_output (FILE *out, ucl_object_t *obj) | |||
iter = NULL; | |||
i = 0; | |||
while ((cur = ucl_iterate_object (obj, &iter, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (obj, &iter, true)) != NULL) { | |||
printf (" %s \n", dash_buf); | |||
sym = ucl_object_find_key (cur, "symbol"); | |||
weight = ucl_object_find_key (cur, "weight"); | |||
freq = ucl_object_find_key (cur, "frequency"); | |||
tim = ucl_object_find_key (cur, "time"); | |||
sym = ucl_object_lookup (cur, "symbol"); | |||
weight = ucl_object_lookup (cur, "weight"); | |||
freq = ucl_object_lookup (cur, "frequency"); | |||
tim = ucl_object_lookup (cur, "time"); | |||
if (sym && weight && freq && tim) { | |||
printf (fmt_buf, i, | |||
ucl_object_tostring (sym), | |||
@@ -776,12 +776,12 @@ rspamc_counters_output (FILE *out, ucl_object_t *obj) | |||
static void | |||
rspamc_stat_actions (ucl_object_t *obj, GString *out, gint64 scanned) | |||
{ | |||
const ucl_object_t *actions = ucl_object_find_key (obj, "actions"), *cur; | |||
const ucl_object_t *actions = ucl_object_lookup (obj, "actions"), *cur; | |||
ucl_object_iter_t iter = NULL; | |||
gint64 spam, ham; | |||
if (actions && ucl_object_type (actions) == UCL_OBJECT) { | |||
while ((cur = ucl_iterate_object (actions, &iter, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (actions, &iter, true)) != NULL) { | |||
gint64 cnt = ucl_object_toint (cur); | |||
rspamd_printf_gstring (out, "Messages with action %s: %L" | |||
", %.2f%%\n", ucl_object_key (cur), cnt, | |||
@@ -789,8 +789,8 @@ rspamc_stat_actions (ucl_object_t *obj, GString *out, gint64 scanned) | |||
} | |||
} | |||
spam = ucl_object_toint (ucl_object_find_key (obj, "spam_count")); | |||
ham = ucl_object_toint (ucl_object_find_key (obj, "ham_count")); | |||
spam = ucl_object_toint (ucl_object_lookup (obj, "spam_count")); | |||
ham = ucl_object_toint (ucl_object_lookup (obj, "ham_count")); | |||
rspamd_printf_gstring (out, "Messages treated as spam: %L, %.2f%%\n", spam, | |||
((gdouble)spam / (gdouble)scanned) * 100.); | |||
rspamd_printf_gstring (out, "Messages treated as ham: %L, %.2f%%\n", ham, | |||
@@ -803,15 +803,15 @@ rspamc_stat_statfile (const ucl_object_t *obj, GString *out) | |||
gint64 version, size, blocks, used_blocks, nlanguages, nusers; | |||
const gchar *label, *symbol, *type; | |||
version = ucl_object_toint (ucl_object_find_key (obj, "revision")); | |||
size = ucl_object_toint (ucl_object_find_key (obj, "size")); | |||
blocks = ucl_object_toint (ucl_object_find_key (obj, "total")); | |||
used_blocks = ucl_object_toint (ucl_object_find_key (obj, "used")); | |||
label = ucl_object_tostring (ucl_object_find_key (obj, "label")); | |||
symbol = ucl_object_tostring (ucl_object_find_key (obj, "symbol")); | |||
type = ucl_object_tostring (ucl_object_find_key (obj, "type")); | |||
nlanguages = ucl_object_toint (ucl_object_find_key (obj, "languages")); | |||
nusers = ucl_object_toint (ucl_object_find_key (obj, "users")); | |||
version = ucl_object_toint (ucl_object_lookup (obj, "revision")); | |||
size = ucl_object_toint (ucl_object_lookup (obj, "size")); | |||
blocks = ucl_object_toint (ucl_object_lookup (obj, "total")); | |||
used_blocks = ucl_object_toint (ucl_object_lookup (obj, "used")); | |||
label = ucl_object_tostring (ucl_object_lookup (obj, "label")); | |||
symbol = ucl_object_tostring (ucl_object_lookup (obj, "symbol")); | |||
type = ucl_object_tostring (ucl_object_lookup (obj, "type")); | |||
nlanguages = ucl_object_toint (ucl_object_lookup (obj, "languages")); | |||
nusers = ucl_object_toint (ucl_object_lookup (obj, "users")); | |||
if (label) { | |||
rspamd_printf_gstring (out, "Statfile: %s <%s> type: %s; ", symbol, | |||
@@ -839,7 +839,7 @@ rspamc_stat_output (FILE *out, ucl_object_t *obj) | |||
out_str = g_string_sized_new (BUFSIZ); | |||
scanned = ucl_object_toint (ucl_object_find_key (obj, "scanned")); | |||
scanned = ucl_object_toint (ucl_object_lookup (obj, "scanned")); | |||
rspamd_printf_gstring (out_str, "Messages scanned: %L\n", | |||
scanned); | |||
@@ -848,66 +848,66 @@ rspamc_stat_output (FILE *out, ucl_object_t *obj) | |||
} | |||
rspamd_printf_gstring (out_str, "Messages learned: %L\n", | |||
ucl_object_toint (ucl_object_find_key (obj, "learned"))); | |||
ucl_object_toint (ucl_object_lookup (obj, "learned"))); | |||
rspamd_printf_gstring (out_str, "Connections count: %L\n", | |||
ucl_object_toint (ucl_object_find_key (obj, "connections"))); | |||
ucl_object_toint (ucl_object_lookup (obj, "connections"))); | |||
rspamd_printf_gstring (out_str, "Control connections count: %L\n", | |||
ucl_object_toint (ucl_object_find_key (obj, "control_connections"))); | |||
ucl_object_toint (ucl_object_lookup (obj, "control_connections"))); | |||
/* Pools */ | |||
rspamd_printf_gstring (out_str, "Pools allocated: %L\n", | |||
ucl_object_toint (ucl_object_find_key (obj, "pools_allocated"))); | |||
ucl_object_toint (ucl_object_lookup (obj, "pools_allocated"))); | |||
rspamd_printf_gstring (out_str, "Pools freed: %L\n", | |||
ucl_object_toint (ucl_object_find_key (obj, "pools_freed"))); | |||
ucl_object_toint (ucl_object_lookup (obj, "pools_freed"))); | |||
rspamd_printf_gstring (out_str, "Bytes allocated: %HL\n", | |||
ucl_object_toint (ucl_object_find_key (obj, "bytes_allocated"))); | |||
ucl_object_toint (ucl_object_lookup (obj, "bytes_allocated"))); | |||
rspamd_printf_gstring (out_str, "Memory chunks allocated: %L\n", | |||
ucl_object_toint (ucl_object_find_key (obj, "chunks_allocated"))); | |||
ucl_object_toint (ucl_object_lookup (obj, "chunks_allocated"))); | |||
rspamd_printf_gstring (out_str, "Shared chunks allocated: %L\n", | |||
ucl_object_toint (ucl_object_find_key (obj, "shared_chunks_allocated"))); | |||
ucl_object_toint (ucl_object_lookup (obj, "shared_chunks_allocated"))); | |||
rspamd_printf_gstring (out_str, "Chunks freed: %L\n", | |||
ucl_object_toint (ucl_object_find_key (obj, "chunks_freed"))); | |||
ucl_object_toint (ucl_object_lookup (obj, "chunks_freed"))); | |||
rspamd_printf_gstring (out_str, "Oversized chunks: %L\n", | |||
ucl_object_toint (ucl_object_find_key (obj, "chunks_oversized"))); | |||
ucl_object_toint (ucl_object_lookup (obj, "chunks_oversized"))); | |||
/* Fuzzy */ | |||
rspamd_printf_gstring (out_str, "Fuzzy hashes stored: %L\n", | |||
ucl_object_toint (ucl_object_find_key (obj, "fuzzy_stored"))); | |||
ucl_object_toint (ucl_object_lookup (obj, "fuzzy_stored"))); | |||
rspamd_printf_gstring (out_str, "Fuzzy hashes expired: %L\n", | |||
ucl_object_toint (ucl_object_find_key (obj, "fuzzy_expired"))); | |||
ucl_object_toint (ucl_object_lookup (obj, "fuzzy_expired"))); | |||
st = ucl_object_find_key (obj, "fuzzy_checked"); | |||
st = ucl_object_lookup (obj, "fuzzy_checked"); | |||
if (st != NULL && ucl_object_type (st) == UCL_ARRAY) { | |||
rspamd_printf_gstring (out_str, "Fuzzy hashes checked: "); | |||
iter = NULL; | |||
while ((cur = ucl_iterate_object (st, &iter, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (st, &iter, true)) != NULL) { | |||
rspamd_printf_gstring (out_str, "%hL ", ucl_object_toint (cur)); | |||
} | |||
rspamd_printf_gstring (out_str, "\n"); | |||
} | |||
st = ucl_object_find_key (obj, "fuzzy_found"); | |||
st = ucl_object_lookup (obj, "fuzzy_found"); | |||
if (st != NULL && ucl_object_type (st) == UCL_ARRAY) { | |||
rspamd_printf_gstring (out_str, "Fuzzy hashes found: "); | |||
iter = NULL; | |||
while ((cur = ucl_iterate_object (st, &iter, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (st, &iter, true)) != NULL) { | |||
rspamd_printf_gstring (out_str, "%hL ", ucl_object_toint (cur)); | |||
} | |||
rspamd_printf_gstring (out_str, "\n"); | |||
} | |||
st = ucl_object_find_key (obj, "statfiles"); | |||
st = ucl_object_lookup (obj, "statfiles"); | |||
if (st != NULL && ucl_object_type (st) == UCL_ARRAY) { | |||
iter = NULL; | |||
while ((cur = ucl_iterate_object (st, &iter, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (st, &iter, true)) != NULL) { | |||
rspamc_stat_statfile (cur, out_str); | |||
} | |||
} | |||
rspamd_printf_gstring (out_str, "Total learns: %L\n", | |||
ucl_object_toint (ucl_object_find_key (obj, "total_learns"))); | |||
ucl_object_toint (ucl_object_lookup (obj, "total_learns"))); | |||
rspamd_fprintf (out, "%v", out_str); | |||
} | |||
@@ -997,21 +997,21 @@ rspamc_mime_output (FILE *out, ucl_object_t *result, GString *input, | |||
added_headers = g_string_sized_new (127); | |||
if (result) { | |||
metric = ucl_object_find_key (result, "default"); | |||
metric = ucl_object_lookup (result, "default"); | |||
if (metric != NULL) { | |||
res = ucl_object_find_key (metric, "action"); | |||
res = ucl_object_lookup (metric, "action"); | |||
if (res) { | |||
action = ucl_object_tostring (res); | |||
} | |||
res = ucl_object_find_key (metric, "score"); | |||
res = ucl_object_lookup (metric, "score"); | |||
if (res) { | |||
score = ucl_object_todouble (res); | |||
} | |||
res = ucl_object_find_key (metric, "required_score"); | |||
res = ucl_object_lookup (metric, "required_score"); | |||
if (res) { | |||
required_score = ucl_object_todouble (res); | |||
} | |||
@@ -1050,7 +1050,7 @@ rspamc_mime_output (FILE *out, ucl_object_t *result, GString *input, | |||
/* Short description of all symbols */ | |||
symbuf = g_string_sized_new (64); | |||
while ((cur = ucl_iterate_object (metric, &it, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (metric, &it, true)) != NULL) { | |||
if (ucl_object_type (cur) == UCL_OBJECT) { | |||
rspamd_printf_gstring (symbuf, "%s,", ucl_object_key (cur)); |
@@ -1592,7 +1592,7 @@ rspamd_controller_handle_saveactions ( | |||
} | |||
for (i = 0; i < 3; i++) { | |||
cur = ucl_iterate_object (obj, &it, TRUE); | |||
cur = ucl_object_iterate (obj, &it, TRUE); | |||
if (cur == NULL) { | |||
break; | |||
} | |||
@@ -1705,15 +1705,15 @@ rspamd_controller_handle_savesymbols ( | |||
return 0; | |||
} | |||
while ((cur = ucl_iterate_object (obj, &iter, true))) { | |||
while ((cur = ucl_object_iterate (obj, &iter, true))) { | |||
if (cur->type != UCL_OBJECT) { | |||
msg_err_session ("json array data error"); | |||
rspamd_controller_send_error (conn_ent, 400, "Cannot parse input"); | |||
ucl_object_unref (obj); | |||
return 0; | |||
} | |||
jname = ucl_object_find_key (cur, "name"); | |||
jvalue = ucl_object_find_key (cur, "value"); | |||
jname = ucl_object_lookup (cur, "name"); | |||
jvalue = ucl_object_lookup (cur, "value"); | |||
val = ucl_object_todouble (jvalue); | |||
sym = | |||
g_hash_table_lookup (metric->symbols, ucl_object_tostring (jname)); | |||
@@ -2257,23 +2257,23 @@ rspamd_controller_load_saved_stats (struct rspamd_controller_worker_ctx *ctx) | |||
stat = ctx->srv->stat; | |||
memcpy (&stat_copy, stat, sizeof (stat_copy)); | |||
elt = ucl_object_find_key (obj, "scanned"); | |||
elt = ucl_object_lookup (obj, "scanned"); | |||
if (elt != NULL && ucl_object_type (elt) == UCL_INT) { | |||
stat_copy.messages_scanned = ucl_object_toint (elt); | |||
} | |||
elt = ucl_object_find_key (obj, "learned"); | |||
elt = ucl_object_lookup (obj, "learned"); | |||
if (elt != NULL && ucl_object_type (elt) == UCL_INT) { | |||
stat_copy.messages_learned = ucl_object_toint (elt); | |||
} | |||
elt = ucl_object_find_key (obj, "actions"); | |||
elt = ucl_object_lookup (obj, "actions"); | |||
if (elt != NULL) { | |||
for (i = METRIC_ACTION_REJECT; i <= METRIC_ACTION_NOACTION; i++) { | |||
subelt = ucl_object_find_key (elt, rspamd_action_to_str (i)); | |||
subelt = ucl_object_lookup (elt, rspamd_action_to_str (i)); | |||
if (subelt && ucl_object_type (subelt) == UCL_INT) { | |||
stat_copy.actions_stat[i] = ucl_object_toint (subelt); | |||
@@ -2281,13 +2281,13 @@ rspamd_controller_load_saved_stats (struct rspamd_controller_worker_ctx *ctx) | |||
} | |||
} | |||
elt = ucl_object_find_key (obj, "connections_count"); | |||
elt = ucl_object_lookup (obj, "connections_count"); | |||
if (elt != NULL && ucl_object_type (elt) == UCL_INT) { | |||
stat_copy.connections_count = ucl_object_toint (elt); | |||
} | |||
elt = ucl_object_find_key (obj, "control_connections_count"); | |||
elt = ucl_object_lookup (obj, "control_connections_count"); | |||
if (elt != NULL && ucl_object_type (elt) == UCL_INT) { | |||
stat_copy.control_connections_count = ucl_object_toint (elt); |
@@ -1128,7 +1128,7 @@ fuzzy_parse_keypair (rspamd_mempool_t *pool, | |||
msg_info_pool ("loaded keypair %*xs", 8, pk); | |||
} | |||
else if (ucl_object_type (obj) == UCL_ARRAY) { | |||
while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) { | |||
if (!fuzzy_parse_keypair (pool, cur, pd, section, err)) { | |||
return FALSE; | |||
} |
@@ -116,7 +116,7 @@ http_proxy_parse_upstream (rspamd_mempool_t *pool, | |||
return FALSE; | |||
} | |||
elt = ucl_object_find_key (obj, "name"); | |||
elt = ucl_object_lookup (obj, "name"); | |||
if (elt == NULL) { | |||
g_set_error (err, http_proxy_quark (), 100, | |||
"upstream option must have some name definition"); | |||
@@ -127,7 +127,7 @@ http_proxy_parse_upstream (rspamd_mempool_t *pool, | |||
up = g_slice_alloc0 (sizeof (*up)); | |||
up->name = g_strdup (ucl_object_tostring (elt)); | |||
elt = ucl_object_find_key (obj, "key"); | |||
elt = ucl_object_lookup (obj, "key"); | |||
if (elt != NULL) { | |||
up->key = rspamd_pubkey_from_base32 (ucl_object_tostring (elt), 0, | |||
RSPAMD_KEYPAIR_KEX, RSPAMD_CRYPTOBOX_MODE_25519); | |||
@@ -140,7 +140,7 @@ http_proxy_parse_upstream (rspamd_mempool_t *pool, | |||
} | |||
} | |||
elt = ucl_object_find_key (obj, "hosts"); | |||
elt = ucl_object_lookup (obj, "hosts"); | |||
if (elt == NULL) { | |||
g_set_error (err, http_proxy_quark (), 100, | |||
@@ -157,7 +157,7 @@ http_proxy_parse_upstream (rspamd_mempool_t *pool, | |||
goto err; | |||
} | |||
elt = ucl_object_find_key (obj, "default"); | |||
elt = ucl_object_lookup (obj, "default"); | |||
if (elt && ucl_object_toboolean (elt)) { | |||
ctx->default_upstream = up; | |||
} |
@@ -644,25 +644,25 @@ rspamd_keypair_from_ucl (const ucl_object_t *obj) | |||
return NULL; | |||
} | |||
elt = ucl_object_find_key (obj, "keypair"); | |||
elt = ucl_object_lookup (obj, "keypair"); | |||
if (elt != NULL) { | |||
obj = elt; | |||
} | |||
pubkey = ucl_object_find_any_key (obj, "pubkey", "public", "public_key", | |||
pubkey = ucl_object_lookup_any (obj, "pubkey", "public", "public_key", | |||
NULL); | |||
if (pubkey == NULL || ucl_object_type (pubkey) != UCL_STRING) { | |||
return NULL; | |||
} | |||
privkey = ucl_object_find_any_key (obj, "privkey", "private", "private_key", | |||
privkey = ucl_object_lookup_any (obj, "privkey", "private", "private_key", | |||
"secret", "secret_key", NULL); | |||
if (privkey == NULL || ucl_object_type (privkey) != UCL_STRING) { | |||
return NULL; | |||
} | |||
/* Optional fields */ | |||
elt = ucl_object_find_key (obj, "type"); | |||
elt = ucl_object_lookup (obj, "type"); | |||
if (elt && ucl_object_type (elt) == UCL_STRING) { | |||
str = ucl_object_tostring (elt); | |||
@@ -675,7 +675,7 @@ rspamd_keypair_from_ucl (const ucl_object_t *obj) | |||
/* TODO: handle errors */ | |||
} | |||
elt = ucl_object_find_key (obj, "algorithm"); | |||
elt = ucl_object_lookup (obj, "algorithm"); | |||
if (elt && ucl_object_type (elt) == UCL_STRING) { | |||
str = ucl_object_tostring (elt); | |||
@@ -688,7 +688,7 @@ rspamd_keypair_from_ucl (const ucl_object_t *obj) | |||
/* TODO: handle errors */ | |||
} | |||
elt = ucl_object_find_key (obj, "encoding"); | |||
elt = ucl_object_lookup (obj, "encoding"); | |||
if (elt && ucl_object_type (elt) == UCL_STRING) { | |||
str = ucl_object_tostring (elt); | |||
@@ -101,11 +101,11 @@ insert_metric_result (struct rspamd_task *task, | |||
} | |||
if (task->settings) { | |||
mobj = ucl_object_find_key (task->settings, metric->name); | |||
mobj = ucl_object_lookup (task->settings, metric->name); | |||
if (mobj) { | |||
gdouble corr; | |||
sobj = ucl_object_find_key (mobj, symbol); | |||
sobj = ucl_object_lookup (mobj, symbol); | |||
if (sobj != NULL && ucl_object_todouble_safe (sobj, &corr)) { | |||
msg_debug ("settings: changed weight of symbol %s from %.2f to %.2f", | |||
symbol, w, corr); | |||
@@ -349,10 +349,10 @@ get_specific_action_score (struct rspamd_task *task, | |||
double score; | |||
if (metric) { | |||
act = ucl_object_find_key (metric, "actions"); | |||
act = ucl_object_lookup (metric, "actions"); | |||
if (act) { | |||
act_name = rspamd_action_to_str (action->action); | |||
sact = ucl_object_find_key (act, act_name); | |||
sact = ucl_object_lookup (act, act_name); | |||
if (sact != NULL && ucl_object_todouble_safe (sact, &score)) { | |||
msg_debug_task ("found override score %.2f for action %s in settings", | |||
score, act_name); | |||
@@ -374,7 +374,7 @@ rspamd_check_action_metric (struct rspamd_task *task, | |||
int i; | |||
if (task->settings) { | |||
ms = ucl_object_find_key (task->settings, metric->name); | |||
ms = ucl_object_lookup (task->settings, metric->name); | |||
} | |||
for (i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i++) { |
@@ -92,11 +92,11 @@ rspamd_rcl_logging_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
const gchar *facility, *log_type, *log_level; | |||
struct rspamd_config *cfg = ud; | |||
val = ucl_object_find_key (obj, "type"); | |||
val = ucl_object_lookup (obj, "type"); | |||
if (val != NULL && ucl_object_tostring_safe (val, &log_type)) { | |||
if (g_ascii_strcasecmp (log_type, "file") == 0) { | |||
/* Need to get filename */ | |||
val = ucl_object_find_key (obj, "filename"); | |||
val = ucl_object_lookup (obj, "filename"); | |||
if (val == NULL || val->type != UCL_STRING) { | |||
g_set_error (err, | |||
CFG_RCL_ERROR, | |||
@@ -113,7 +113,7 @@ rspamd_rcl_logging_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
#ifdef HAVE_SYSLOG_H | |||
cfg->log_facility = LOG_DAEMON; | |||
cfg->log_type = RSPAMD_LOG_SYSLOG; | |||
val = ucl_object_find_key (obj, "facility"); | |||
val = ucl_object_lookup (obj, "facility"); | |||
if (val != NULL && ucl_object_tostring_safe (val, &facility)) { | |||
if (g_ascii_strcasecmp (facility, "LOG_AUTH") == 0 || | |||
g_ascii_strcasecmp (facility, "auth") == 0 ) { | |||
@@ -198,7 +198,7 @@ rspamd_rcl_logging_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
} | |||
/* Handle log level */ | |||
val = ucl_object_find_key (obj, "level"); | |||
val = ucl_object_lookup (obj, "level"); | |||
if (val != NULL && ucl_object_tostring_safe (val, &log_level)) { | |||
if (g_ascii_strcasecmp (log_level, "error") == 0) { | |||
cfg->log_level = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL; | |||
@@ -237,7 +237,7 @@ rspamd_rcl_options_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
HASH_FIND_STR (section->subsections, "dns", dns_section); | |||
dns = ucl_object_find_key (obj, "dns"); | |||
dns = ucl_object_lookup (obj, "dns"); | |||
if (dns_section != NULL && dns != NULL) { | |||
if (!rspamd_rcl_section_parse_defaults (dns_section, cfg->cfg_pool, dns, | |||
cfg, err)) { | |||
@@ -247,7 +247,7 @@ rspamd_rcl_options_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
HASH_FIND_STR (section->subsections, "upstream", upstream_section); | |||
upstream = ucl_object_find_key (obj, "upstream"); | |||
upstream = ucl_object_lookup (obj, "upstream"); | |||
if (upstream_section != NULL && upstream != NULL) { | |||
if (!rspamd_rcl_section_parse_defaults (upstream_section, cfg->cfg_pool, | |||
upstream, cfg, err)) { | |||
@@ -294,7 +294,7 @@ rspamd_rcl_group_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
sd->gr = gr; | |||
/* Handle symbols */ | |||
val = ucl_object_find_key (obj, "symbol"); | |||
val = ucl_object_lookup (obj, "symbol"); | |||
if (val != NULL && ucl_object_type (val) == UCL_OBJECT) { | |||
HASH_FIND_STR (section->subsections, "symbol", subsection); | |||
g_assert (subsection != NULL); | |||
@@ -358,13 +358,13 @@ rspamd_rcl_symbol_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
msg_warn_config ("redefining symbol '%s' in metric '%s'", key, metric->name); | |||
} | |||
if ((elt = ucl_object_find_key (obj, "one_shot")) != NULL) { | |||
if ((elt = ucl_object_lookup (obj, "one_shot")) != NULL) { | |||
if (ucl_object_toboolean (elt)) { | |||
sym_def->flags |= RSPAMD_SYMBOL_FLAG_ONESHOT; | |||
} | |||
} | |||
if ((elt = ucl_object_find_key (obj, "ignore")) != NULL) { | |||
if ((elt = ucl_object_lookup (obj, "ignore")) != NULL) { | |||
if (ucl_object_toboolean (elt)) { | |||
sym_def->flags |= RSPAMD_SYMBOL_FLAG_IGNORE; | |||
} | |||
@@ -375,7 +375,7 @@ rspamd_rcl_symbol_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
return FALSE; | |||
} | |||
if (ucl_object_find_any_key (obj, "score", "weight", NULL) != NULL) { | |||
if (ucl_object_lookup_any (obj, "score", "weight", NULL) != NULL) { | |||
*sym_def->weight_ptr = sym_def->score; | |||
} | |||
@@ -394,7 +394,7 @@ rspamd_rcl_actions_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
const ucl_object_t *cur; | |||
ucl_object_iter_t it = NULL; | |||
while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) { | |||
if (!rspamd_action_from_str (ucl_object_key (cur), &action_value) || | |||
!ucl_object_todouble_safe (cur, &action_score)) { | |||
g_set_error (err, | |||
@@ -444,7 +444,7 @@ rspamd_rcl_metric_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
} | |||
/* Handle actions */ | |||
val = ucl_object_find_key (obj, "actions"); | |||
val = ucl_object_lookup (obj, "actions"); | |||
if (val != NULL) { | |||
if (val->type != UCL_OBJECT) { | |||
g_set_error (err, CFG_RCL_ERROR, EINVAL, | |||
@@ -463,7 +463,7 @@ rspamd_rcl_metric_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
/* No more legacy mode */ | |||
/* Handle grouped symbols */ | |||
val = ucl_object_find_key (obj, "group"); | |||
val = ucl_object_lookup (obj, "group"); | |||
if (val != NULL && ucl_object_type (val) == UCL_OBJECT) { | |||
HASH_FIND_STR (section->subsections, "group", subsection); | |||
g_assert (subsection != NULL); | |||
@@ -480,7 +480,7 @@ rspamd_rcl_metric_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
} | |||
/* Handle symbols */ | |||
val = ucl_object_find_key (obj, "symbol"); | |||
val = ucl_object_lookup (obj, "symbol"); | |||
if (val != NULL && ucl_object_type (val) == UCL_OBJECT) { | |||
HASH_FIND_STR (section->subsections, "symbol", subsection); | |||
g_assert (subsection != NULL); | |||
@@ -497,12 +497,12 @@ rspamd_rcl_metric_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
} | |||
/* Handle ignored symbols */ | |||
val = ucl_object_find_key (obj, "ignore"); | |||
val = ucl_object_lookup (obj, "ignore"); | |||
if (val != NULL && ucl_object_type (val) == UCL_ARRAY) { | |||
LL_FOREACH (val, cur) { | |||
it = NULL; | |||
while ((elt = ucl_iterate_object (cur, &it, true)) != NULL) { | |||
while ((elt = ucl_object_iterate (cur, &it, true)) != NULL) { | |||
if (ucl_object_type (elt) == UCL_STRING) { | |||
sym_def = g_hash_table_lookup (metric->symbols, | |||
ucl_object_tostring (elt)); | |||
@@ -543,7 +543,7 @@ rspamd_rcl_worker_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
g_assert (key != NULL); | |||
worker_type = key; | |||
val = ucl_object_find_any_key (obj, "module", "load", NULL); | |||
val = ucl_object_lookup_any (obj, "module", "load", NULL); | |||
if (val != NULL && ucl_object_tostring_safe (val, &lib_path)) { | |||
@@ -608,7 +608,7 @@ rspamd_rcl_worker_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
return TRUE; | |||
} | |||
val = ucl_object_find_any_key (obj, "bind_socket", "listen", "bind", NULL); | |||
val = ucl_object_lookup_any (obj, "bind_socket", "listen", "bind", NULL); | |||
/* This name is more logical */ | |||
if (val != NULL) { | |||
it = ucl_object_iterate_new (val); | |||
@@ -641,7 +641,7 @@ rspamd_rcl_worker_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
if (wparser != NULL && obj->type == UCL_OBJECT) { | |||
it = NULL; | |||
while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) { | |||
srch.name = ucl_object_key (cur); | |||
srch.ptr = wrk->ctx; /* XXX: is it valid? */ | |||
whandler = g_hash_table_lookup (wparser->parsers, &srch); | |||
@@ -952,7 +952,7 @@ rspamd_rcl_modules_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
const gchar *data; | |||
if (obj->type == UCL_OBJECT) { | |||
val = ucl_object_find_key (obj, "path"); | |||
val = ucl_object_lookup (obj, "path"); | |||
LL_FOREACH (val, cur) | |||
{ | |||
@@ -1032,7 +1032,7 @@ rspamd_rcl_statfile_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, | |||
st->opts = (ucl_object_t *)obj; | |||
st->clcf = ccf; | |||
val = ucl_object_find_key (obj, "spam"); | |||
val = ucl_object_lookup (obj, "spam"); | |||
if (val == NULL) { | |||
msg_info_config ( | |||
"statfile %s has no explicit 'spam' setting, trying to guess by symbol", | |||
@@ -1100,7 +1100,7 @@ rspamd_rcl_classifier_handler (rspamd_mempool_t *pool, | |||
ccf->name = ccf->classifier; | |||
} | |||
while ((val = ucl_iterate_object (obj, &it, true)) != NULL && res) { | |||
while ((val = ucl_object_iterate (obj, &it, true)) != NULL && res) { | |||
st_key = ucl_object_key (val); | |||
if (st_key != NULL) { | |||
if (g_ascii_strcasecmp (st_key, "statfile") == 0) { | |||
@@ -1122,13 +1122,13 @@ rspamd_rcl_classifier_handler (rspamd_mempool_t *pool, | |||
tkcf->name = ucl_object_tostring (val); | |||
} | |||
else if (ucl_object_type (val) == UCL_OBJECT) { | |||
cur = ucl_object_find_key (val, "name"); | |||
cur = ucl_object_lookup (val, "name"); | |||
if (cur != NULL) { | |||
tkcf->name = ucl_object_tostring (cur); | |||
tkcf->opts = val; | |||
} | |||
else { | |||
cur = ucl_object_find_key (val, "type"); | |||
cur = ucl_object_lookup (val, "type"); | |||
if (cur != NULL) { | |||
tkcf->name = ucl_object_tostring (cur); | |||
tkcf->opts = val; | |||
@@ -1183,7 +1183,7 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool, | |||
new = FALSE; | |||
} | |||
val = ucl_object_find_key (obj, "expression"); | |||
val = ucl_object_lookup (obj, "expression"); | |||
if (val == NULL || !ucl_object_tostring_safe (val, &composite_expression)) { | |||
g_set_error (err, | |||
CFG_RCL_ERROR, | |||
@@ -1219,11 +1219,11 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool, | |||
NULL, NULL, SYMBOL_TYPE_COMPOSITE, -1); | |||
} | |||
val = ucl_object_find_key (obj, "score"); | |||
val = ucl_object_lookup (obj, "score"); | |||
if (val != NULL && ucl_object_todouble_safe (val, &score)) { | |||
/* Also set score in the metric */ | |||
val = ucl_object_find_key (obj, "group"); | |||
val = ucl_object_lookup (obj, "group"); | |||
if (val != NULL) { | |||
group = ucl_object_tostring (val); | |||
} | |||
@@ -1231,7 +1231,7 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool, | |||
group = "composite"; | |||
} | |||
val = ucl_object_find_key (obj, "metric"); | |||
val = ucl_object_lookup (obj, "metric"); | |||
if (val != NULL) { | |||
metric = ucl_object_tostring (val); | |||
} | |||
@@ -1239,7 +1239,7 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool, | |||
metric = DEFAULT_METRIC; | |||
} | |||
val = ucl_object_find_key (obj, "description"); | |||
val = ucl_object_lookup (obj, "description"); | |||
if (val != NULL) { | |||
description = ucl_object_tostring (val); | |||
} | |||
@@ -2057,7 +2057,7 @@ rspamd_rcl_process_section (struct rspamd_rcl_section *sec, | |||
it = NULL; | |||
if (sec->key_attr != NULL) { | |||
while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) { | |||
if (ucl_object_type (cur) != UCL_OBJECT) { | |||
is_nested = FALSE; | |||
break; | |||
@@ -2072,7 +2072,7 @@ rspamd_rcl_process_section (struct rspamd_rcl_section *sec, | |||
/* Just reiterate on all subobjects */ | |||
it = NULL; | |||
while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) { | |||
if (!sec->handler (pool, cur, ucl_object_key (cur), ptr, sec, err)) { | |||
return FALSE; | |||
} | |||
@@ -2083,7 +2083,7 @@ rspamd_rcl_process_section (struct rspamd_rcl_section *sec, | |||
else { | |||
if (sec->key_attr != NULL) { | |||
/* First of all search for required attribute and use it as a key */ | |||
cur = ucl_object_find_key (obj, sec->key_attr); | |||
cur = ucl_object_lookup (obj, sec->key_attr); | |||
if (cur == NULL) { | |||
if (sec->default_key == NULL) { | |||
@@ -2156,7 +2156,7 @@ rspamd_rcl_parse (struct rspamd_rcl_section *top, | |||
} | |||
} | |||
else { | |||
found = ucl_object_find_key (obj, cur->name); | |||
found = ucl_object_lookup (obj, cur->name); | |||
if (found == NULL) { | |||
if (cur->required) { | |||
g_set_error (err, CFG_RCL_ERROR, ENOENT, | |||
@@ -2217,7 +2217,7 @@ rspamd_rcl_section_parse_defaults (struct rspamd_rcl_section *section, | |||
HASH_ITER (hh, section->default_parser, cur, tmp) | |||
{ | |||
found = ucl_object_find_key (obj, cur->key); | |||
found = ucl_object_lookup (obj, cur->key); | |||
if (found != NULL) { | |||
cur->pd.user_struct = ptr; | |||
@@ -2817,7 +2817,7 @@ rspamd_rcl_register_worker_option (struct rspamd_config *cfg, | |||
g_hash_table_insert (nparser->parsers, &nhandler->key, nhandler); | |||
doc_workers = ucl_object_find_key (cfg->doc_strings, "workers"); | |||
doc_workers = ucl_object_lookup (cfg->doc_strings, "workers"); | |||
if (doc_workers == NULL) { | |||
doc_obj = ucl_object_typed_new (UCL_OBJECT); | |||
@@ -2825,7 +2825,7 @@ rspamd_rcl_register_worker_option (struct rspamd_config *cfg, | |||
doc_workers = doc_obj; | |||
} | |||
doc_target = ucl_object_find_key (doc_workers, g_quark_to_string (type)); | |||
doc_target = ucl_object_lookup (doc_workers, g_quark_to_string (type)); | |||
if (doc_target == NULL) { | |||
doc_obj = ucl_object_typed_new (UCL_OBJECT); | |||
@@ -2952,11 +2952,11 @@ rspamd_rcl_doc_obj_from_handler (ucl_object_t *doc_obj, | |||
gboolean has_example = FALSE, has_type = FALSE; | |||
const gchar *type = NULL; | |||
if (ucl_object_find_key (doc_obj, "example") != NULL) { | |||
if (ucl_object_lookup (doc_obj, "example") != NULL) { | |||
has_example = TRUE; | |||
} | |||
if (ucl_object_find_key (doc_obj, "type") != NULL) { | |||
if (ucl_object_lookup (doc_obj, "type") != NULL) { | |||
has_type = TRUE; | |||
} | |||
@@ -3145,7 +3145,7 @@ rspamd_rcl_add_doc_by_path (struct rspamd_config *cfg, | |||
required); | |||
} | |||
else { | |||
found = ucl_lookup_path (cfg->doc_strings, doc_path); | |||
found = ucl_object_lookup_path (cfg->doc_strings, doc_path); | |||
if (found != NULL) { | |||
return rspamd_rcl_add_doc_obj ((ucl_object_t *) found, | |||
@@ -3169,7 +3169,7 @@ rspamd_rcl_add_doc_by_path (struct rspamd_config *cfg, | |||
return NULL; | |||
} | |||
found = ucl_object_find_key (cur, *comp); | |||
found = ucl_object_lookup (cur, *comp); | |||
if (found == NULL) { | |||
obj = ucl_object_typed_new (UCL_OBJECT); |
@@ -1144,7 +1144,7 @@ rspamd_ucl_fin_cb (rspamd_mempool_t * pool, struct map_cb_data *data) | |||
ucl_parser_free (parser); | |||
it = NULL; | |||
while ((cur = ucl_iterate_object (obj, &it, true))) { | |||
while ((cur = ucl_object_iterate (obj, &it, true))) { | |||
ucl_object_replace_key (cbdata->cfg->rcl_obj, (ucl_object_t *)cur, | |||
cur->key, cur->keylen, false); | |||
} | |||
@@ -1427,7 +1427,7 @@ rspamd_config_is_module_enabled (struct rspamd_config *cfg, | |||
} | |||
} | |||
conf = ucl_object_find_key (cfg->rcl_obj, module_name); | |||
conf = ucl_object_lookup (cfg->rcl_obj, module_name); | |||
if (conf == NULL) { | |||
msg_info_config ("%s module %s is enabled but has not been configured", | |||
@@ -1439,7 +1439,7 @@ rspamd_config_is_module_enabled (struct rspamd_config *cfg, | |||
} | |||
} | |||
else { | |||
enabled = ucl_object_find_key (conf, "enabled"); | |||
enabled = ucl_object_lookup (conf, "enabled"); | |||
if (enabled && ucl_object_type (enabled) == UCL_BOOLEAN) { | |||
if (!ucl_object_toboolean (enabled)) { |
@@ -40,13 +40,13 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg) | |||
struct metric_action *cur_action; | |||
struct rspamd_symbol_def *s; | |||
while ((cur_elt = ucl_iterate_object (top, &it, true))) { | |||
while ((cur_elt = ucl_object_iterate (top, &it, true))) { | |||
if (ucl_object_type (cur_elt) != UCL_OBJECT) { | |||
msg_err ("loaded json array element is not an object"); | |||
continue; | |||
} | |||
cur_nm = ucl_object_find_key (cur_elt, "metric"); | |||
cur_nm = ucl_object_lookup (cur_elt, "metric"); | |||
if (!cur_nm || ucl_object_type (cur_nm) != UCL_STRING) { | |||
msg_err ( | |||
"loaded json metric object element has no 'metric' attribute"); | |||
@@ -59,18 +59,18 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg) | |||
continue; | |||
} | |||
cur_nm = ucl_object_find_key (cur_elt, "symbols"); | |||
cur_nm = ucl_object_lookup (cur_elt, "symbols"); | |||
/* Parse symbols */ | |||
if (cur_nm && ucl_object_type (cur_nm) == UCL_ARRAY) { | |||
ucl_object_iter_t nit = NULL; | |||
while ((it_val = ucl_iterate_object (cur_nm, &nit, true))) { | |||
if (ucl_object_find_key (it_val, "name") && | |||
ucl_object_find_key (it_val, "value")) { | |||
while ((it_val = ucl_object_iterate (cur_nm, &nit, true))) { | |||
if (ucl_object_lookup (it_val, "name") && | |||
ucl_object_lookup (it_val, "value")) { | |||
const ucl_object_t *n = | |||
ucl_object_find_key (it_val, "name"); | |||
ucl_object_lookup (it_val, "name"); | |||
const ucl_object_t *v = | |||
ucl_object_find_key (it_val, "value"); | |||
ucl_object_lookup (it_val, "value"); | |||
if((s = g_hash_table_lookup (real_metric->symbols, | |||
ucl_object_tostring (n))) != NULL) { | |||
@@ -90,25 +90,25 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg) | |||
ucl_object_insert_key ((ucl_object_t *)cur_elt, arr, "symbols", | |||
sizeof ("symbols") - 1, false); | |||
} | |||
cur_nm = ucl_object_find_key (cur_elt, "actions"); | |||
cur_nm = ucl_object_lookup (cur_elt, "actions"); | |||
/* Parse actions */ | |||
if (cur_nm && ucl_object_type (cur_nm) == UCL_ARRAY) { | |||
ucl_object_iter_t nit = NULL; | |||
while ((it_val = ucl_iterate_object (cur_nm, &nit, true))) { | |||
if (ucl_object_find_key (it_val, "name") && | |||
ucl_object_find_key (it_val, "value")) { | |||
while ((it_val = ucl_object_iterate (cur_nm, &nit, true))) { | |||
if (ucl_object_lookup (it_val, "name") && | |||
ucl_object_lookup (it_val, "value")) { | |||
if (!rspamd_action_from_str (ucl_object_tostring ( | |||
ucl_object_find_key (it_val, "name")), &test_act)) { | |||
ucl_object_lookup (it_val, "name")), &test_act)) { | |||
msg_err ("unknown action: %s", | |||
ucl_object_tostring (ucl_object_find_key (it_val, | |||
ucl_object_tostring (ucl_object_lookup (it_val, | |||
"name"))); | |||
continue; | |||
} | |||
cur_action = &real_metric->actions[test_act]; | |||
cur_action->action = test_act; | |||
cur_action->score = | |||
ucl_object_todouble (ucl_object_find_key (it_val, | |||
ucl_object_todouble (ucl_object_lookup (it_val, | |||
"value")); | |||
} | |||
else { | |||
@@ -340,12 +340,12 @@ dynamic_metric_find_elt (const ucl_object_t *arr, const gchar *name) | |||
ucl_object_iter_t it = NULL; | |||
const ucl_object_t *cur, *n; | |||
while ((cur = ucl_iterate_object (arr, &it, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (arr, &it, true)) != NULL) { | |||
if (cur->type == UCL_OBJECT) { | |||
n = ucl_object_find_key (cur, "name"); | |||
n = ucl_object_lookup (cur, "name"); | |||
if (n && n->type == UCL_STRING && | |||
strcmp (name, ucl_object_tostring (n)) == 0) { | |||
return (ucl_object_t *)ucl_object_find_key (cur, "value"); | |||
return (ucl_object_t *)ucl_object_lookup (cur, "value"); | |||
} | |||
} | |||
} | |||
@@ -359,9 +359,9 @@ dynamic_metric_find_metric (const ucl_object_t *arr, const gchar *metric) | |||
ucl_object_iter_t it = NULL; | |||
const ucl_object_t *cur, *n; | |||
while ((cur = ucl_iterate_object (arr, &it, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (arr, &it, true)) != NULL) { | |||
if (cur->type == UCL_OBJECT) { | |||
n = ucl_object_find_key (cur, "metric"); | |||
n = ucl_object_lookup (cur, "metric"); | |||
if (n && n->type == UCL_STRING && | |||
strcmp (metric, ucl_object_tostring (n)) == 0) { | |||
return (ucl_object_t *)cur; | |||
@@ -415,7 +415,7 @@ add_dynamic_symbol (struct rspamd_config *cfg, | |||
metric = new_dynamic_metric (metric_name, cfg->current_dynamic_conf); | |||
} | |||
syms = (ucl_object_t *)ucl_object_find_key (metric, "symbols"); | |||
syms = (ucl_object_t *)ucl_object_lookup (metric, "symbols"); | |||
if (syms != NULL) { | |||
ucl_object_t *sym; | |||
@@ -462,7 +462,7 @@ add_dynamic_action (struct rspamd_config *cfg, | |||
metric = new_dynamic_metric (metric_name, cfg->current_dynamic_conf); | |||
} | |||
acts = (ucl_object_t *)ucl_object_find_key (metric, "actions"); | |||
acts = (ucl_object_t *)ucl_object_lookup (metric, "actions"); | |||
if (acts != NULL) { | |||
ucl_object_t *act; | |||
@@ -862,44 +862,44 @@ rspamd_ucl_torspamc_output (struct rspamd_task *task, | |||
*required_score, *is_spam, *elt, *cur; | |||
ucl_object_iter_t iter = NULL; | |||
metric = ucl_object_find_key (top, DEFAULT_METRIC); | |||
metric = ucl_object_lookup (top, DEFAULT_METRIC); | |||
if (metric != NULL) { | |||
score = ucl_object_find_key (metric, "score"); | |||
required_score = ucl_object_find_key (metric, "required_score"); | |||
is_spam = ucl_object_find_key (metric, "is_spam"); | |||
score = ucl_object_lookup (metric, "score"); | |||
required_score = ucl_object_lookup (metric, "required_score"); | |||
is_spam = ucl_object_lookup (metric, "is_spam"); | |||
rspamd_printf_fstring (out, | |||
"Metric: default; %s; %.2f / %.2f / 0.0\r\n", | |||
ucl_object_toboolean (is_spam) ? "True" : "False", | |||
ucl_object_todouble (score), | |||
ucl_object_todouble (required_score)); | |||
elt = ucl_object_find_key (metric, "action"); | |||
elt = ucl_object_lookup (metric, "action"); | |||
if (elt != NULL) { | |||
rspamd_printf_fstring (out, "Action: %s\r\n", | |||
ucl_object_tostring (elt)); | |||
} | |||
iter = NULL; | |||
while ((elt = ucl_iterate_object (metric, &iter, true)) != NULL) { | |||
while ((elt = ucl_object_iterate (metric, &iter, true)) != NULL) { | |||
if (elt->type == UCL_OBJECT) { | |||
const ucl_object_t *sym_score; | |||
sym_score = ucl_object_find_key (elt, "score"); | |||
sym_score = ucl_object_lookup (elt, "score"); | |||
rspamd_printf_fstring (out, "Symbol: %s(%.2f)\r\n", | |||
ucl_object_key (elt), | |||
ucl_object_todouble (sym_score)); | |||
} | |||
} | |||
elt = ucl_object_find_key (metric, "subject"); | |||
elt = ucl_object_lookup (metric, "subject"); | |||
if (elt != NULL) { | |||
rspamd_printf_fstring (out, "Subject: %s\r\n", | |||
ucl_object_tostring (elt)); | |||
} | |||
} | |||
elt = ucl_object_find_key (top, "messages"); | |||
elt = ucl_object_lookup (top, "messages"); | |||
if (elt != NULL) { | |||
iter = NULL; | |||
while ((cur = ucl_iterate_object (elt, &iter, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (elt, &iter, true)) != NULL) { | |||
if (cur->type == UCL_STRING) { | |||
rspamd_printf_fstring (out, "Message: %s\r\n", | |||
ucl_object_tostring (cur)); | |||
@@ -920,18 +920,18 @@ rspamd_ucl_tospamc_output (struct rspamd_task *task, | |||
ucl_object_iter_t iter = NULL; | |||
rspamd_fstring_t *f; | |||
metric = ucl_object_find_key (top, DEFAULT_METRIC); | |||
metric = ucl_object_lookup (top, DEFAULT_METRIC); | |||
if (metric != NULL) { | |||
score = ucl_object_find_key (metric, "score"); | |||
required_score = ucl_object_find_key (metric, "required_score"); | |||
is_spam = ucl_object_find_key (metric, "is_spam"); | |||
score = ucl_object_lookup (metric, "score"); | |||
required_score = ucl_object_lookup (metric, "required_score"); | |||
is_spam = ucl_object_lookup (metric, "is_spam"); | |||
rspamd_printf_fstring (out, | |||
"Spam: %s ; %.2f / %.2f\r\n\r\n", | |||
ucl_object_toboolean (is_spam) ? "True" : "False", | |||
ucl_object_todouble (score), | |||
ucl_object_todouble (required_score)); | |||
while ((elt = ucl_iterate_object (metric, &iter, true)) != NULL) { | |||
while ((elt = ucl_object_iterate (metric, &iter, true)) != NULL) { | |||
if (elt->type == UCL_OBJECT) { | |||
rspamd_printf_fstring (out, "%s,", | |||
ucl_object_key (elt)); |
@@ -239,65 +239,65 @@ rspamd_roll_history_load (struct roll_history *history, const gchar *filename) | |||
row = &history->rows[i]; | |||
memset (row, 0, sizeof (*row)); | |||
elt = ucl_object_find_key (cur, "time"); | |||
elt = ucl_object_lookup (cur, "time"); | |||
if (elt && ucl_object_type (elt) == UCL_FLOAT) { | |||
double_to_tv (ucl_object_todouble (elt), &row->tv); | |||
} | |||
elt = ucl_object_find_key (cur, "id"); | |||
elt = ucl_object_lookup (cur, "id"); | |||
if (elt && ucl_object_type (elt) == UCL_STRING) { | |||
rspamd_strlcpy (row->message_id, ucl_object_tostring (elt), | |||
sizeof (row->message_id)); | |||
} | |||
elt = ucl_object_find_key (cur, "symbols"); | |||
elt = ucl_object_lookup (cur, "symbols"); | |||
if (elt && ucl_object_type (elt) == UCL_STRING) { | |||
rspamd_strlcpy (row->symbols, ucl_object_tostring (elt), | |||
sizeof (row->symbols)); | |||
} | |||
elt = ucl_object_find_key (cur, "user"); | |||
elt = ucl_object_lookup (cur, "user"); | |||
if (elt && ucl_object_type (elt) == UCL_STRING) { | |||
rspamd_strlcpy (row->user, ucl_object_tostring (elt), | |||
sizeof (row->user)); | |||
} | |||
elt = ucl_object_find_key (cur, "from"); | |||
elt = ucl_object_lookup (cur, "from"); | |||
if (elt && ucl_object_type (elt) == UCL_STRING) { | |||
rspamd_strlcpy (row->from_addr, ucl_object_tostring (elt), | |||
sizeof (row->from_addr)); | |||
} | |||
elt = ucl_object_find_key (cur, "len"); | |||
elt = ucl_object_lookup (cur, "len"); | |||
if (elt && ucl_object_type (elt) == UCL_INT) { | |||
row->len = ucl_object_toint (elt); | |||
} | |||
elt = ucl_object_find_key (cur, "scan_time"); | |||
elt = ucl_object_lookup (cur, "scan_time"); | |||
if (elt && ucl_object_type (elt) == UCL_FLOAT) { | |||
row->scan_time = ucl_object_todouble (elt); | |||
} | |||
elt = ucl_object_find_key (cur, "score"); | |||
elt = ucl_object_lookup (cur, "score"); | |||
if (elt && ucl_object_type (elt) == UCL_FLOAT) { | |||
row->score = ucl_object_todouble (elt); | |||
} | |||
elt = ucl_object_find_key (cur, "required_score"); | |||
elt = ucl_object_lookup (cur, "required_score"); | |||
if (elt && ucl_object_type (elt) == UCL_FLOAT) { | |||
row->required_score = ucl_object_todouble (elt); | |||
} | |||
elt = ucl_object_find_key (cur, "action"); | |||
elt = ucl_object_lookup (cur, "action"); | |||
if (elt && ucl_object_type (elt) == UCL_INT) { | |||
row->action = ucl_object_toint (elt); |
@@ -391,7 +391,7 @@ rspamd_symbols_cache_load_items (struct symbols_cache *cache, const gchar *name) | |||
* metric | |||
*/ | |||
#if 0 | |||
elt = ucl_object_find_key (cur, "weight"); | |||
elt = ucl_object_lookup (cur, "weight"); | |||
if (elt) { | |||
w = ucl_object_todouble (elt); | |||
@@ -400,17 +400,17 @@ rspamd_symbols_cache_load_items (struct symbols_cache *cache, const gchar *name) | |||
} | |||
} | |||
#endif | |||
elt = ucl_object_find_key (cur, "time"); | |||
elt = ucl_object_lookup (cur, "time"); | |||
if (elt) { | |||
item->avg_time = ucl_object_todouble (elt); | |||
} | |||
elt = ucl_object_find_key (cur, "count"); | |||
elt = ucl_object_lookup (cur, "count"); | |||
if (elt) { | |||
item->avg_counter = ucl_object_toint (elt); | |||
} | |||
elt = ucl_object_find_key (cur, "frequency"); | |||
elt = ucl_object_lookup (cur, "frequency"); | |||
if (elt) { | |||
item->frequency = ucl_object_toint (elt); | |||
} | |||
@@ -914,11 +914,11 @@ check_metric_settings (struct rspamd_task *task, struct metric *metric, | |||
return FALSE; | |||
} | |||
mobj = ucl_object_find_key (task->settings, metric->name); | |||
mobj = ucl_object_lookup (task->settings, metric->name); | |||
if (mobj != NULL) { | |||
act = ucl_object_find_key (mobj, "actions"); | |||
act = ucl_object_lookup (mobj, "actions"); | |||
if (act != NULL) { | |||
reject = ucl_object_find_key (act, | |||
reject = ucl_object_lookup (act, | |||
rspamd_action_to_str (METRIC_ACTION_REJECT)); | |||
if (reject != NULL && ucl_object_todouble_safe (reject, &val)) { | |||
*score = val; | |||
@@ -1198,7 +1198,7 @@ rspamd_symbols_cache_process_symbols (struct rspamd_task * task, | |||
if (task->settings) { | |||
const ucl_object_t *wl; | |||
wl = ucl_object_find_key (task->settings, "whitelist"); | |||
wl = ucl_object_lookup (task->settings, "whitelist"); | |||
if (wl != NULL) { | |||
msg_info_task ("<%s> is whitelisted", task->message_id); | |||
task->flags |= RSPAMD_TASK_FLAG_SKIP; |
@@ -799,10 +799,10 @@ rspamd_mmaped_file_init (struct rspamd_stat_ctx *ctx, | |||
const gchar *filename; | |||
gsize size; | |||
filenameo = ucl_object_find_key (stf->opts, "filename"); | |||
filenameo = ucl_object_lookup (stf->opts, "filename"); | |||
if (filenameo == NULL || ucl_object_type (filenameo) != UCL_STRING) { | |||
filenameo = ucl_object_find_key (stf->opts, "path"); | |||
filenameo = ucl_object_lookup (stf->opts, "path"); | |||
if (filenameo == NULL || ucl_object_type (filenameo) != UCL_STRING) { | |||
msg_err_config ("statfile %s has no filename defined", stf->symbol); | |||
@@ -812,7 +812,7 @@ rspamd_mmaped_file_init (struct rspamd_stat_ctx *ctx, | |||
filename = ucl_object_tostring (filenameo); | |||
sizeo = ucl_object_find_key (stf->opts, "size"); | |||
sizeo = ucl_object_lookup (stf->opts, "size"); | |||
if (sizeo == NULL || ucl_object_type (sizeo) != UCL_INT) { | |||
msg_err_config ("statfile %s has no size defined", stf->symbol); |
@@ -465,7 +465,7 @@ rspamd_redis_stat_learns (redisAsyncContext *c, gpointer r, gpointer priv) | |||
rspamd_strtoul (reply->str, reply->len, &num); | |||
} | |||
obj = (ucl_object_t *)ucl_object_find_key (cbdata->cur, "revision"); | |||
obj = (ucl_object_t *)ucl_object_lookup (cbdata->cur, "revision"); | |||
if (obj) { | |||
obj->value.iv += num; | |||
} | |||
@@ -500,17 +500,17 @@ rspamd_redis_stat_key (redisAsyncContext *c, gpointer r, gpointer priv) | |||
num = 0; | |||
} | |||
obj = (ucl_object_t *)ucl_object_find_key (cbdata->cur, "used"); | |||
obj = (ucl_object_t *)ucl_object_lookup (cbdata->cur, "used"); | |||
if (obj) { | |||
obj->value.iv += num; | |||
} | |||
obj = (ucl_object_t *)ucl_object_find_key (cbdata->cur, "total"); | |||
obj = (ucl_object_t *)ucl_object_lookup (cbdata->cur, "total"); | |||
if (obj) { | |||
obj->value.iv += num; | |||
} | |||
obj = (ucl_object_t *)ucl_object_find_key (cbdata->cur, "size"); | |||
obj = (ucl_object_t *)ucl_object_lookup (cbdata->cur, "size"); | |||
if (obj) { | |||
/* Size of key + size of int64_t */ | |||
obj->value.iv += num * (sizeof (G_STRINGIFY (G_MAXINT64)) + | |||
@@ -856,11 +856,11 @@ rspamd_redis_init (struct rspamd_stat_ctx *ctx, | |||
backend = g_slice_alloc0 (sizeof (*backend)); | |||
elt = ucl_object_find_any_key (stf->opts, "read_servers", "servers", NULL); | |||
elt = ucl_object_lookup_any (stf->opts, "read_servers", "servers", NULL); | |||
if (elt == NULL) { | |||
if (st->classifier->cfg->opts) { | |||
elt = ucl_object_find_any_key (st->classifier->cfg->opts, | |||
elt = ucl_object_lookup_any (st->classifier->cfg->opts, | |||
"read_servers", "servers", NULL); | |||
} | |||
@@ -880,7 +880,7 @@ rspamd_redis_init (struct rspamd_stat_ctx *ctx, | |||
return NULL; | |||
} | |||
elt = ucl_object_find_key (stf->opts, "write_servers"); | |||
elt = ucl_object_lookup (stf->opts, "write_servers"); | |||
if (elt == NULL) { | |||
/* Use read servers as write ones */ | |||
g_assert (relt != NULL); | |||
@@ -903,7 +903,7 @@ rspamd_redis_init (struct rspamd_stat_ctx *ctx, | |||
} | |||
} | |||
elt = ucl_object_find_key (stf->opts, "prefix"); | |||
elt = ucl_object_lookup (stf->opts, "prefix"); | |||
if (elt == NULL || ucl_object_type (elt) != UCL_STRING) { | |||
/* Default non-users statistics */ | |||
backend->redis_object = REDIS_DEFAULT_OBJECT; | |||
@@ -911,7 +911,7 @@ rspamd_redis_init (struct rspamd_stat_ctx *ctx, | |||
/* | |||
* Make redis backend compatible with sqlite3 backend in users settings | |||
*/ | |||
users_enabled = ucl_object_find_any_key (stf->clcf->opts, "per_user", | |||
users_enabled = ucl_object_lookup_any (stf->clcf->opts, "per_user", | |||
"users_enabled", NULL); | |||
if (users_enabled != NULL) { | |||
@@ -954,7 +954,7 @@ rspamd_redis_init (struct rspamd_stat_ctx *ctx, | |||
backend->redis_object = ucl_object_tostring (elt); | |||
} | |||
elt = ucl_object_find_key (stf->opts, "timeout"); | |||
elt = ucl_object_lookup (stf->opts, "timeout"); | |||
if (elt) { | |||
backend->timeout = ucl_object_todouble (elt); | |||
} |
@@ -523,9 +523,9 @@ rspamd_sqlite3_init (struct rspamd_stat_ctx *ctx, | |||
struct rspamd_stat_sqlite3_db *bk; | |||
GError *err = NULL; | |||
filenameo = ucl_object_find_key (stf->opts, "filename"); | |||
filenameo = ucl_object_lookup (stf->opts, "filename"); | |||
if (filenameo == NULL || ucl_object_type (filenameo) != UCL_STRING) { | |||
filenameo = ucl_object_find_key (stf->opts, "path"); | |||
filenameo = ucl_object_lookup (stf->opts, "path"); | |||
if (filenameo == NULL || ucl_object_type (filenameo) != UCL_STRING) { | |||
msg_err_config ("statfile %s has no filename defined", stf->symbol); | |||
return NULL; | |||
@@ -543,7 +543,7 @@ rspamd_sqlite3_init (struct rspamd_stat_ctx *ctx, | |||
bk->L = cfg->lua_state; | |||
users_enabled = ucl_object_find_any_key (clf->opts, "per_user", | |||
users_enabled = ucl_object_lookup_any (clf->opts, "per_user", | |||
"users_enabled", NULL); | |||
if (users_enabled != NULL) { | |||
if (ucl_object_type (users_enabled) == UCL_BOOLEAN) { | |||
@@ -576,7 +576,7 @@ rspamd_sqlite3_init (struct rspamd_stat_ctx *ctx, | |||
bk->enable_users = FALSE; | |||
} | |||
lang_enabled = ucl_object_find_any_key (clf->opts, | |||
lang_enabled = ucl_object_lookup_any (clf->opts, | |||
"per_language", "languages_enabled", NULL); | |||
if (lang_enabled != NULL) { |
@@ -185,11 +185,11 @@ rspamd_stat_cache_redis_init (struct rspamd_stat_ctx *ctx, | |||
cache_ctx = g_slice_alloc0 (sizeof (*cache_ctx)); | |||
elt = ucl_object_find_any_key (stf->opts, "read_servers", "servers", NULL); | |||
elt = ucl_object_lookup_any (stf->opts, "read_servers", "servers", NULL); | |||
if (elt == NULL) { | |||
if (st->classifier->cfg->opts) { | |||
elt = ucl_object_find_any_key (st->classifier->cfg->opts, | |||
elt = ucl_object_lookup_any (st->classifier->cfg->opts, | |||
"read_servers", "servers", NULL); | |||
} | |||
@@ -209,7 +209,7 @@ rspamd_stat_cache_redis_init (struct rspamd_stat_ctx *ctx, | |||
return NULL; | |||
} | |||
elt = ucl_object_find_key (stf->opts, "write_servers"); | |||
elt = ucl_object_lookup (stf->opts, "write_servers"); | |||
if (elt == NULL) { | |||
/* Use read servers as write ones */ | |||
g_assert (relt != NULL); | |||
@@ -232,7 +232,7 @@ rspamd_stat_cache_redis_init (struct rspamd_stat_ctx *ctx, | |||
} | |||
} | |||
elt = ucl_object_find_key (stf->opts, "key"); | |||
elt = ucl_object_lookup (stf->opts, "key"); | |||
if (elt == NULL || ucl_object_type (elt) != UCL_STRING) { | |||
cache_ctx->redis_object = DEFAULT_REDIS_KEY; | |||
} | |||
@@ -240,7 +240,7 @@ rspamd_stat_cache_redis_init (struct rspamd_stat_ctx *ctx, | |||
cache_ctx->redis_object = ucl_object_tostring (elt); | |||
} | |||
elt = ucl_object_find_key (stf->opts, "timeout"); | |||
elt = ucl_object_lookup (stf->opts, "timeout"); | |||
if (elt) { | |||
cache_ctx->timeout = ucl_object_todouble (elt); | |||
} |
@@ -125,7 +125,7 @@ rspamd_stat_cache_sqlite3_init (struct rspamd_stat_ctx *ctx, | |||
GError *err = NULL; | |||
if (cf) { | |||
elt = ucl_object_find_any_key (cf, "path", "file", NULL); | |||
elt = ucl_object_lookup_any (cf, "path", "file", NULL); | |||
if (elt != NULL) { | |||
path = ucl_object_tostring (elt); |
@@ -152,11 +152,11 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base) | |||
cache_name = NULL; | |||
if (clf->opts) { | |||
cache_obj = ucl_object_find_key (clf->opts, "cache"); | |||
cache_obj = ucl_object_lookup (clf->opts, "cache"); | |||
cache_name_obj = NULL; | |||
if (cache_obj) { | |||
cache_name_obj = ucl_object_find_any_key (cache_obj, | |||
cache_name_obj = ucl_object_lookup_any (cache_obj, | |||
"name", "type", NULL); | |||
} | |||
@@ -702,7 +702,7 @@ rspamd_stat_check_autolearn (struct rspamd_task *task) | |||
ret = FALSE; | |||
if (cl->cfg->opts) { | |||
obj = ucl_object_find_key (cl->cfg->opts, "autolearn"); | |||
obj = ucl_object_lookup (cl->cfg->opts, "autolearn"); | |||
if (ucl_object_type (obj) == UCL_BOOLEAN) { | |||
if (ucl_object_toboolean (obj)) { |
@@ -97,12 +97,12 @@ rspamd_tokenizer_osb_config_from_ucl (rspamd_mempool_t * pool, | |||
def = rspamd_tokenizer_osb_default_config (); | |||
memcpy (cf, def, sizeof (*cf)); | |||
elt = ucl_object_find_key (obj, "hash"); | |||
elt = ucl_object_lookup (obj, "hash"); | |||
if (elt != NULL && ucl_object_type (elt) == UCL_STRING) { | |||
if (g_ascii_strncasecmp (ucl_object_tostring (elt), "xxh", 3) | |||
== 0) { | |||
cf->ht = RSPAMD_OSB_HASH_XXHASH; | |||
elt = ucl_object_find_key (obj, "seed"); | |||
elt = ucl_object_lookup (obj, "seed"); | |||
if (elt != NULL && ucl_object_type (elt) == UCL_INT) { | |||
cf->seed = ucl_object_toint (elt); | |||
} | |||
@@ -110,7 +110,7 @@ rspamd_tokenizer_osb_config_from_ucl (rspamd_mempool_t * pool, | |||
else if (g_ascii_strncasecmp (ucl_object_tostring (elt), "sip", 3) | |||
== 0) { | |||
cf->ht = RSPAMD_OSB_HASH_SIPHASH; | |||
elt = ucl_object_find_key (obj, "key"); | |||
elt = ucl_object_lookup (obj, "key"); | |||
if (elt != NULL && ucl_object_type (elt) == UCL_STRING) { | |||
key = rspamd_decode_base32 (ucl_object_tostring (elt), | |||
@@ -131,13 +131,13 @@ rspamd_tokenizer_osb_config_from_ucl (rspamd_mempool_t * pool, | |||
} | |||
} | |||
else { | |||
elt = ucl_object_find_key (obj, "compat"); | |||
elt = ucl_object_lookup (obj, "compat"); | |||
if (elt != NULL && ucl_object_toboolean (elt)) { | |||
cf->ht = RSPAMD_OSB_HASH_COMPAT; | |||
} | |||
} | |||
elt = ucl_object_find_key (obj, "window"); | |||
elt = ucl_object_lookup (obj, "window"); | |||
if (elt != NULL && ucl_object_type (elt) == UCL_INT) { | |||
cf->window_size = ucl_object_toint (elt); | |||
if (cf->window_size > DEFAULT_FEATURE_WINDOW_SIZE * 4) { |
@@ -643,7 +643,7 @@ rspamd_upstreams_from_ucl (struct upstream_list *ups, | |||
ucl_object_iter_t it = NULL; | |||
if (ucl_object_type (in) == UCL_ARRAY) { | |||
while ((cur = ucl_iterate_object (in, &it, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (in, &it, true)) != NULL) { | |||
if (rspamd_upstreams_from_ucl (ups, cur, def_port, data)) { | |||
ret = TRUE; | |||
} |
@@ -364,7 +364,7 @@ lua_statfile_get_param (lua_State *L) | |||
param = luaL_checkstring (L, 2); | |||
if (st != NULL && param != NULL) { | |||
value = ucl_object_find_key (st->opts, param); | |||
value = ucl_object_lookup (st->opts, param); | |||
if (value != NULL) { | |||
lua_pushstring (L, ucl_object_tostring_forced (value)); | |||
return 1; |
@@ -173,9 +173,9 @@ rspamd_lua_set_path (lua_State *L, struct rspamd_config *cfg) | |||
return; | |||
} | |||
opts = ucl_object_find_key (cfg->rcl_obj, "options"); | |||
opts = ucl_object_lookup (cfg->rcl_obj, "options"); | |||
if (opts != NULL) { | |||
opts = ucl_object_find_key (opts, "lua_path"); | |||
opts = ucl_object_lookup (opts, "lua_path"); | |||
if (opts != NULL && ucl_object_type (opts) == UCL_STRING) { | |||
additional_path = ucl_object_tostring (opts); | |||
} |
@@ -900,7 +900,7 @@ lua_config_get_key (lua_State *L) | |||
name = luaL_checklstring(L, 2, &namelen); | |||
if (name && cfg) { | |||
val = ucl_object_find_keyl(cfg->rcl_obj, name, namelen); | |||
val = ucl_object_lookup_len(cfg->rcl_obj, name, namelen); | |||
if (val != NULL) { | |||
ucl_object_push_lua (L, val, val->type != UCL_ARRAY); | |||
} |
@@ -192,7 +192,7 @@ lua_worker_get_option (lua_State *L) | |||
lua_pushnil (L); | |||
} | |||
else { | |||
val = ucl_object_find_key (ctx->opts, name); | |||
val = ucl_object_lookup (ctx->opts, name); | |||
if (val == NULL) { | |||
lua_pushnil (L); | |||
} |
@@ -170,7 +170,7 @@ parse_flags (struct fuzzy_rule *rule, | |||
"string mappings are deprecated and no longer supported, use new style configuration"); | |||
} | |||
else if (val->type == UCL_OBJECT) { | |||
elt = ucl_object_find_key (val, "symbol"); | |||
elt = ucl_object_lookup (val, "symbol"); | |||
if (elt == NULL || !ucl_object_tostring_safe (elt, &sym)) { | |||
sym = ucl_object_key (val); | |||
} | |||
@@ -179,11 +179,11 @@ parse_flags (struct fuzzy_rule *rule, | |||
rspamd_mempool_alloc (fuzzy_module_ctx->fuzzy_pool, | |||
sizeof (struct fuzzy_mapping)); | |||
map->symbol = sym; | |||
elt = ucl_object_find_key (val, "flag"); | |||
elt = ucl_object_lookup (val, "flag"); | |||
if (elt != NULL) { | |||
map->fuzzy_flag = ucl_obj_toint (elt); | |||
elt = ucl_object_find_key (val, "max_score"); | |||
elt = ucl_object_lookup (val, "max_score"); | |||
if (elt != NULL) { | |||
map->weight = ucl_obj_todouble (elt); | |||
@@ -361,9 +361,9 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id | |||
fuzzy_module_ctx->fuzzy_pool); | |||
rule->learn_condition_cb = -1; | |||
if ((value = ucl_object_find_key (obj, "mime_types")) != NULL) { | |||
if ((value = ucl_object_lookup (obj, "mime_types")) != NULL) { | |||
it = NULL; | |||
while ((cur = ucl_iterate_object (value, &it, value->type == UCL_ARRAY)) | |||
while ((cur = ucl_object_iterate (value, &it, value->type == UCL_ARRAY)) | |||
!= NULL) { | |||
rule->mime_types = g_list_concat (rule->mime_types, | |||
parse_mime_types (ucl_obj_tostring (cur))); | |||
@@ -375,9 +375,9 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id | |||
(rspamd_mempool_destruct_t)g_list_free, rule->mime_types); | |||
} | |||
if ((value = ucl_object_find_key (obj, "headers")) != NULL) { | |||
if ((value = ucl_object_lookup (obj, "headers")) != NULL) { | |||
it = NULL; | |||
while ((cur = ucl_iterate_object (value, &it, value->type == UCL_ARRAY)) | |||
while ((cur = ucl_object_iterate (value, &it, value->type == UCL_ARRAY)) | |||
!= NULL) { | |||
rule->fuzzy_headers = g_list_concat (rule->fuzzy_headers, | |||
parse_fuzzy_headers (ucl_obj_tostring (cur))); | |||
@@ -394,20 +394,20 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id | |||
} | |||
if ((value = ucl_object_find_key (obj, "max_score")) != NULL) { | |||
if ((value = ucl_object_lookup (obj, "max_score")) != NULL) { | |||
rule->max_score = ucl_obj_todouble (value); | |||
} | |||
if ((value = ucl_object_find_key (obj, "symbol")) != NULL) { | |||
if ((value = ucl_object_lookup (obj, "symbol")) != NULL) { | |||
rule->symbol = ucl_obj_tostring (value); | |||
} | |||
if ((value = ucl_object_find_key (obj, "read_only")) != NULL) { | |||
if ((value = ucl_object_lookup (obj, "read_only")) != NULL) { | |||
rule->read_only = ucl_obj_toboolean (value); | |||
} | |||
if ((value = ucl_object_find_key (obj, "skip_unknown")) != NULL) { | |||
if ((value = ucl_object_lookup (obj, "skip_unknown")) != NULL) { | |||
rule->skip_unknown = ucl_obj_toboolean (value); | |||
} | |||
if ((value = ucl_object_find_key (obj, "servers")) != NULL) { | |||
if ((value = ucl_object_lookup (obj, "servers")) != NULL) { | |||
rule->servers = rspamd_upstreams_create (cfg->ups_ctx); | |||
rspamd_mempool_add_destructor (fuzzy_module_ctx->fuzzy_pool, | |||
@@ -418,14 +418,14 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id | |||
return -1; | |||
} | |||
} | |||
if ((value = ucl_object_find_key (obj, "fuzzy_map")) != NULL) { | |||
if ((value = ucl_object_lookup (obj, "fuzzy_map")) != NULL) { | |||
it = NULL; | |||
while ((cur = ucl_iterate_object (value, &it, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (value, &it, true)) != NULL) { | |||
parse_flags (rule, cfg, cur, cb_id); | |||
} | |||
} | |||
if ((value = ucl_object_find_key (obj, "encryption_key")) != NULL) { | |||
if ((value = ucl_object_lookup (obj, "encryption_key")) != NULL) { | |||
/* Create key from user's input */ | |||
k = ucl_object_tostring (value); | |||
@@ -441,7 +441,7 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id | |||
RSPAMD_CRYPTOBOX_MODE_25519); | |||
} | |||
if ((value = ucl_object_find_key (obj, "learn_condition")) != NULL) { | |||
if ((value = ucl_object_lookup (obj, "learn_condition")) != NULL) { | |||
lua_script = ucl_object_tostring (value); | |||
if (lua_script) { | |||
@@ -466,7 +466,7 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id | |||
} | |||
} | |||
if ((value = ucl_object_find_key (obj, "fuzzy_key")) != NULL) { | |||
if ((value = ucl_object_lookup (obj, "fuzzy_key")) != NULL) { | |||
/* Create key from user's input */ | |||
k = ucl_object_tostring (value); | |||
} | |||
@@ -481,7 +481,7 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id | |||
rspamd_cryptobox_hash (rule->hash_key->str, k, strlen (k), NULL, 0); | |||
rule->hash_key->len = rspamd_cryptobox_HASHKEYBYTES; | |||
if ((value = ucl_object_find_key (obj, "fuzzy_shingles_key")) != NULL) { | |||
if ((value = ucl_object_lookup (obj, "fuzzy_shingles_key")) != NULL) { | |||
k = ucl_object_tostring (value); | |||
} | |||
if (k == NULL) { |
@@ -129,7 +129,7 @@ regexp_module_config (struct rspamd_config *cfg) | |||
return TRUE; | |||
} | |||
sec = ucl_object_find_key (cfg->rcl_obj, "regexp"); | |||
sec = ucl_object_lookup (cfg->rcl_obj, "regexp"); | |||
if (sec == NULL) { | |||
msg_err_config ("regexp module enabled, but no rules are defined"); | |||
return TRUE; | |||
@@ -137,7 +137,7 @@ regexp_module_config (struct rspamd_config *cfg) | |||
regexp_module_ctx->max_size = 0; | |||
while ((value = ucl_iterate_object (sec, &it, true)) != NULL) { | |||
while ((value = ucl_object_iterate (sec, &it, true)) != NULL) { | |||
if (g_ascii_strncasecmp (ucl_object_key (value), "max_size", | |||
sizeof ("max_size") - 1) == 0) { | |||
regexp_module_ctx->max_size = ucl_obj_toint (value); | |||
@@ -187,12 +187,12 @@ regexp_module_config (struct rspamd_config *cfg) | |||
gboolean one_shot = FALSE, is_lua = FALSE, valid_expression = TRUE; | |||
/* We have some lua table, extract its arguments */ | |||
elt = ucl_object_find_key (value, "callback"); | |||
elt = ucl_object_lookup (value, "callback"); | |||
if (elt == NULL || elt->type != UCL_USERDATA) { | |||
/* Try plain regexp expression */ | |||
elt = ucl_object_find_any_key (value, "regexp", "re", NULL); | |||
elt = ucl_object_lookup_any (value, "regexp", "re", NULL); | |||
if (elt != NULL && ucl_object_type (elt) == UCL_STRING) { | |||
cur_item = rspamd_mempool_alloc0 (regexp_module_ctx->regexp_pool, | |||
@@ -232,7 +232,7 @@ regexp_module_config (struct rspamd_config *cfg) | |||
cur_item, | |||
SYMBOL_TYPE_NORMAL, -1); | |||
elt = ucl_object_find_key (value, "condition"); | |||
elt = ucl_object_lookup (value, "condition"); | |||
if (elt != NULL && ucl_object_type (elt) == UCL_USERDATA) { | |||
struct ucl_lua_funcdata *conddata; | |||
@@ -242,31 +242,31 @@ regexp_module_config (struct rspamd_config *cfg) | |||
conddata->L, conddata->idx); | |||
} | |||
elt = ucl_object_find_key (value, "metric"); | |||
elt = ucl_object_lookup (value, "metric"); | |||
if (elt) { | |||
metric = ucl_object_tostring (elt); | |||
} | |||
elt = ucl_object_find_key (value, "description"); | |||
elt = ucl_object_lookup (value, "description"); | |||
if (elt) { | |||
description = ucl_object_tostring (elt); | |||
} | |||
elt = ucl_object_find_key (value, "group"); | |||
elt = ucl_object_lookup (value, "group"); | |||
if (elt) { | |||
group = ucl_object_tostring (elt); | |||
} | |||
elt = ucl_object_find_key (value, "score"); | |||
elt = ucl_object_lookup (value, "score"); | |||
if (elt) { | |||
score = ucl_object_todouble (elt); | |||
} | |||
elt = ucl_object_find_key (value, "one_shot"); | |||
elt = ucl_object_lookup (value, "one_shot"); | |||
if (elt) { | |||
one_shot = ucl_object_toboolean (elt); |
@@ -671,7 +671,7 @@ surbl_module_config (struct rspamd_config *cfg) | |||
if (cur != NULL && cur->type == UCL_OBJECT) { | |||
it = NULL; | |||
while ((cur_bit = | |||
ucl_iterate_object (cur, &it, true)) != NULL) { | |||
ucl_object_iterate (cur, &it, true)) != NULL) { | |||
if (ucl_object_key (cur_bit) != NULL && cur_bit->type == | |||
UCL_INT) { | |||
gchar *p; | |||
@@ -708,7 +708,7 @@ surbl_module_config (struct rspamd_config *cfg) | |||
new_suffix->ips); | |||
while ((cur_bit = | |||
ucl_iterate_object (cur, &it, true)) != NULL) { | |||
ucl_object_iterate (cur, &it, true)) != NULL) { | |||
if (ucl_object_key (cur_bit) != NULL) { | |||
gchar *p; | |||
@@ -109,7 +109,7 @@ rspamadm_add_doc_elt (const ucl_object_t *obj, const ucl_object_t *doc_obj, | |||
} | |||
/* We create comments as a list of parts */ | |||
elt = ucl_object_find_key (doc_obj, "data"); | |||
elt = ucl_object_lookup (doc_obj, "data"); | |||
if (elt) { | |||
rspamd_printf_fstring (&comment, " * %s", ucl_object_tostring (elt)); | |||
cur_comment = ucl_object_fromstring_common (comment->str, comment->len, 0); | |||
@@ -117,7 +117,7 @@ rspamadm_add_doc_elt (const ucl_object_t *obj, const ucl_object_t *doc_obj, | |||
DL_APPEND (nobj, cur_comment); | |||
} | |||
elt = ucl_object_find_key (doc_obj, "type"); | |||
elt = ucl_object_lookup (doc_obj, "type"); | |||
if (elt) { | |||
rspamd_printf_fstring (&comment, " * Type: %s", ucl_object_tostring (elt)); | |||
cur_comment = ucl_object_fromstring_common (comment->str, comment->len, 0); | |||
@@ -125,7 +125,7 @@ rspamadm_add_doc_elt (const ucl_object_t *obj, const ucl_object_t *doc_obj, | |||
DL_APPEND (nobj, cur_comment); | |||
} | |||
elt = ucl_object_find_key (doc_obj, "required"); | |||
elt = ucl_object_lookup (doc_obj, "required"); | |||
if (elt) { | |||
rspamd_printf_fstring (&comment, " * Required: %B", | |||
ucl_object_toboolean (elt)); | |||
@@ -161,13 +161,13 @@ rspamadm_gen_comments (const ucl_object_t *obj, const ucl_object_t *doc_obj, | |||
} | |||
if (ucl_object_type (obj) == UCL_OBJECT) { | |||
while ((cur_obj = ucl_iterate_object (obj, &it, true))) { | |||
cur_doc = ucl_object_find_keyl (doc_obj, cur_obj->key, | |||
while ((cur_obj = ucl_object_iterate (obj, &it, true))) { | |||
cur_doc = ucl_object_lookup_len (doc_obj, cur_obj->key, | |||
cur_obj->keylen); | |||
if (cur_doc != NULL) { | |||
LL_FOREACH (cur_obj, cur_elt) { | |||
if (ucl_object_find_keyl (comments, (const char *)&cur_elt, | |||
if (ucl_object_lookup_len (comments, (const char *)&cur_elt, | |||
sizeof (void *)) == NULL) { | |||
rspamadm_gen_comments (cur_elt, cur_doc, comments); | |||
} | |||
@@ -281,8 +281,8 @@ rspamadm_configdump (gint argc, gchar **argv) | |||
} | |||
else { | |||
for (i = 1; i < argc; i ++) { | |||
obj = ucl_lookup_path (cfg->rcl_obj, argv[i]); | |||
doc_obj = ucl_lookup_path (cfg->doc_strings, argv[i]); | |||
obj = ucl_object_lookup_path (cfg->rcl_obj, argv[i]); | |||
doc_obj = ucl_object_lookup_path (cfg->doc_strings, argv[i]); | |||
if (!obj) { | |||
rspamd_printf ("Section %s NOT FOUND\n", argv[i]); |
@@ -126,7 +126,7 @@ rspamadm_confighelp_search_word_step (const ucl_object_t *obj, | |||
const ucl_object_t *cur, *elt; | |||
const gchar *dot_pos; | |||
while ((cur = ucl_iterate_object (obj, &it, true)) != NULL) { | |||
while ((cur = ucl_object_iterate (obj, &it, true)) != NULL) { | |||
if (cur->keylen > 0) { | |||
rspamd_printf_gstring (path, ".%*s", (int) cur->keylen, cur->key); | |||
@@ -141,7 +141,7 @@ rspamadm_confighelp_search_word_step (const ucl_object_t *obj, | |||
} | |||
if (ucl_object_type (cur) == UCL_OBJECT) { | |||
elt = ucl_object_find_key (cur, "data"); | |||
elt = ucl_object_lookup (cur, "data"); | |||
if (elt != NULL && ucl_object_type (elt) == UCL_STRING) { | |||
if (rspamd_substring_search_caseless (elt->value.sv, | |||
@@ -252,7 +252,7 @@ rspamadm_confighelp (gint argc, gchar **argv) | |||
} | |||
else { | |||
doc_obj = ucl_object_typed_new (UCL_OBJECT); | |||
elt = ucl_lookup_path (cfg->doc_strings, argv[i]); | |||
elt = ucl_object_lookup_path (cfg->doc_strings, argv[i]); | |||
if (elt) { | |||
ucl_object_insert_key (doc_obj, ucl_object_ref (elt), |