This clarifies how it works.
if (test->event_field != NULL) {
const char *value =
- event_find_field_str(request->event, test->event_field);
+ event_find_field_recursive_str(request->event, test->event_field);
test_assert_idx(null_strcmp(value, test->value) == 0, i);
}
}
test_assert(auth_request_import(request, "secured", ""));
test_assert(test_auth_request_export_cmp(request, "secured", ""));
- test_assert(null_strcmp(event_find_field_str(request->event, "transport"), "trusted") == 0);
+ test_assert(null_strcmp(event_find_field_recursive_str(request->event, "transport"), "trusted") == 0);
test_assert(auth_request_import(request, "secured", "tls"));
test_assert(test_auth_request_export_cmp(request, "secured", "tls"));
- test_assert(null_strcmp(event_find_field_str(request->event, "transport"), "TLS") == 0);
+ test_assert(null_strcmp(event_find_field_recursive_str(request->event, "transport"), "TLS") == 0);
test_assert(auth_request_import(request, "secured", "blah"));
test_assert(test_auth_request_export_cmp(request, "secured", ""));
- test_assert(null_strcmp(event_find_field_str(request->event, "transport"), "trusted") == 0);
+ test_assert(null_strcmp(event_find_field_recursive_str(request->event, "transport"), "trusted") == 0);
test_auth_request_deinit(request);
}
static void dict_lookup_finished(struct event *event, int ret, const char *error)
{
i_assert(ret >= 0 || error != NULL);
- const char *key = event_find_field_str(event, "key");
+ const char *key = event_find_field_recursive_str(event, "key");
if (ret < 0)
event_add_str(event, "error", error);
else if (ret == 0)
const struct event_field *field;
/* wanted_field has the value in all available formats */
- field = event_find_field(event, wanted_field->key);
+ field = event_find_field_recursive(event, wanted_field->key);
if (field == NULL) {
/* field="" matches nonexistent field */
return wanted_field->value.str[0] == '\0';
const struct event_category *category);
static struct event_field *
-event_find_field_int(const struct event *event, const char *key);
+event_find_field(const struct event *event, const char *key);
static void event_set_changed(struct event *event)
{
if (!array_is_created(&other->fields))
return TRUE;
array_foreach_modifiable(&other->fields, fld) {
- if (event_find_field_int(event, fld->key) == NULL)
+ if (event_find_field(event, fld->key) == NULL)
return FALSE;
}
return TRUE;
}
static struct event_field *
-event_find_field_int(const struct event *event, const char *key)
+event_find_field(const struct event *event, const char *key)
{
struct event_field *field;
}
const struct event_field *
-event_find_field(const struct event *event, const char *key)
+event_find_field_recursive(const struct event *event, const char *key)
{
const struct event_field *field;
do {
- if ((field = event_find_field_int(event, key)) != NULL)
+ if ((field = event_find_field(event, key)) != NULL)
return field;
event = event->parent;
} while (event != NULL);
}
const char *
-event_find_field_str(const struct event *event, const char *key)
+event_find_field_recursive_str(const struct event *event, const char *key)
{
const struct event_field *field;
- field = event_find_field(event, key);
+ field = event_find_field_recursive(event, key);
if (field == NULL)
return NULL;
{
struct event_field *field;
- field = event_find_field_int(event, key);
+ field = event_find_field(event, key);
if (field == NULL) {
if (!array_is_created(&event->fields))
p_array_init(&event->fields, event->pool, 8);
{
struct event_field *field;
- field = event_find_field_int(event, key);
+ field = event_find_field(event, key);
if (field == NULL || field->value_type != EVENT_FIELD_VALUE_TYPE_INTMAX)
return event_add_int(event, key, num);
/* Returns field for a given key, or NULL if it doesn't exist. If the key
isn't found from the event itself, find it from parent events. */
const struct event_field *
-event_find_field(const struct event *event, const char *key);
+event_find_field_recursive(const struct event *event, const char *key);
/* Returns the given key's value as string, or NULL if it doesn't exist.
If the field isn't stored as a string, the result is allocated from
data stack. */
const char *
-event_find_field_str(const struct event *event, const char *key);
+event_find_field_recursive_str(const struct event *event, const char *key);
/* Returns all key=value fields that the event has.
Parent events' fields aren't returned. */
const struct event_field *
test_begin(t_strdup_printf("%.*s log type + event {a=%s, b=%s} + filter '%s' (exp %s)",
3, /* truncate the type name to avoid CI seeing 'warning' messages */
event_filter_category_from_log_type(log_type),
- event_find_field_str(event, "a"),
- event_find_field_str(event, "b"),
+ event_find_field_recursive_str(event, "a"),
+ event_find_field_recursive_str(event, "b"),
filter_string,
expected ? "true" : "false"));
filter = event_filter_create();
event_filter_add(filter, &query);
- const struct event_field *f = event_find_field(root, "int");
+ const struct event_field *f = event_find_field_recursive(root, "int");
i_assert(f == NULL);
test_assert(!event_filter_match(filter, root, &failure_ctx));
event_inc_int(root, "int", 7);
test_assert(!event_filter_match(filter, root, &failure_ctx));
- f = event_find_field(root, "int");
+ f = event_find_field_recursive(root, "int");
i_assert(f != NULL);
test_assert_strcmp(f->key, "int");
test_assert(f->value_type == EVENT_FIELD_VALUE_TYPE_INTMAX);
event_inc_int(root, "int", 7);
test_assert(event_filter_match(filter, root, &failure_ctx));
- f = event_find_field(root, "int");
+ f = event_find_field_recursive(root, "int");
i_assert(f != NULL);
test_assert_strcmp(f->key, "int");
test_assert(f->value_type == EVENT_FIELD_VALUE_TYPE_INTMAX);
const char *name = fields[i].field_key;
const struct event_field *field;
- field = event_find_field(event, name);
+ field = event_find_field_recursive(event, name);
if (field == NULL)
continue; /* doesn't exist, skip it */
const char *name = fields[i].field_key;
const struct event_field *field;
- field = event_find_field(event, name);
+ field = event_find_field_recursive(event, name);
if (field == NULL)
continue; /* doesn't exist, skip it */
stats_metric_group_by(struct metric *metric, struct event *event, pool_t pool)
{
const struct stats_metric_settings_group_by *group_by = &metric->group_by[0];
- const struct event_field *field = event_find_field(event, group_by->field);
+ const struct event_field *field =
+ event_find_field_recursive(event, group_by->field);
struct metric *sub_metric;
struct metric_value value;
stats_metric_event_field(struct event *event, const char *fieldname,
struct stats_dist *stats)
{
- const struct event_field *field = event_find_field(event, fieldname);
+ const struct event_field *field =
+ event_find_field_recursive(event, fieldname);
intmax_t num = 0;
if (field == NULL)