}
/* 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);
}
}
if (path) {
- schema_elt = ucl_lookup_path_char (schema, path, '/');
+ schema_elt = ucl_object_lookup_path_char (schema, path, '/');
}
else {
/* Use the top object */
* @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
* @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
* @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
* @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
* @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
* 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
* @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
* @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
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;
}
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) {
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:
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);
}
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;
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));
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);
}
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,
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;
/* 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));
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);
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);
}
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);
}
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);
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) {
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);
}
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);
}
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;
}
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;
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);
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) {
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;
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;
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;
}
}
- 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;
}
}
- 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);
}
}
}
- 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;
}
}
- 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),
}
}
- elt = ucl_object_find_key (schema, "type");
+ elt = ucl_object_lookup (schema, "type");
if (!ucl_schema_type_is_allowed (elt, obj, err)) {
return false;
}
/* 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);
/* 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);
/* 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);
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) {
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) {
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;
}
}
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);
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;
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;
}
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;
}
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;
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);
break;
}
else {
- ret = ucl_object_find_keyl (obj, nk, strlen (nk));
+ ret = ucl_object_lookup_len (obj, nk, strlen (nk));
}
}
}
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;
}
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 */
}
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;
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) {
/* 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));
}
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;
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 *));
}
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;
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");
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));
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));
}
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);
}
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),
}
}
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;
}
}
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);
}
}
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;
}
/* 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) {
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),
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,
}
}
- 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,
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,
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);
}
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);
}
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);
}
/* 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));
}
for (i = 0; i < 3; i++) {
- cur = ucl_iterate_object (obj, &it, TRUE);
+ cur = ucl_object_iterate (obj, &it, TRUE);
if (cur == NULL) {
break;
}
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));
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);
}
}
- 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);
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;
}
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");
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);
}
}
- elt = ucl_object_find_key (obj, "hosts");
+ elt = ucl_object_lookup (obj, "hosts");
if (elt == NULL) {
g_set_error (err, http_proxy_quark (), 100,
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;
}
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);
/* 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);
/* 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);
}
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);
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);
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++) {
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,
#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 ) {
}
/* 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;
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)) {
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)) {
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);
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;
}
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;
}
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,
}
/* 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,
/* 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);
}
/* 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);
}
/* 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));
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)) {
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);
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);
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)
{
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",
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) {
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;
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,
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);
}
group = "composite";
}
- val = ucl_object_find_key (obj, "metric");
+ val = ucl_object_lookup (obj, "metric");
if (val != NULL) {
metric = ucl_object_tostring (val);
}
metric = DEFAULT_METRIC;
}
- val = ucl_object_find_key (obj, "description");
+ val = ucl_object_lookup (obj, "description");
if (val != NULL) {
description = ucl_object_tostring (val);
}
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;
/* 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;
}
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) {
}
}
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,
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;
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);
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);
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;
}
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,
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);
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);
}
}
}
- 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",
}
}
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)) {
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");
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) {
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 {
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");
}
}
}
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;
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;
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;
*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));
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));
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);
* metric
*/
#if 0
- elt = ucl_object_find_key (cur, "weight");
+ elt = ucl_object_lookup (cur, "weight");
if (elt) {
w = ucl_object_todouble (elt);
}
}
#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);
}
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;
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;
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);
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);
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;
}
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)) +
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);
}
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);
}
}
- 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;
/*
* 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) {
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);
}
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;
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) {
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) {
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);
}
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);
}
}
- 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;
}
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);
}
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);
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);
}
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)) {
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);
}
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),
}
}
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) {
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;
}
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;
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);
}
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);
}
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);
}
"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);
}
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);
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)));
(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)));
}
- 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,
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);
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) {
}
}
- 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);
}
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) {
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;
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);
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,
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;
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);
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;
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;
}
/* 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);
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);
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));
}
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);
}
}
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]);
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);
}
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,
}
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),