index f95f8ca0bc6a0a4fec8cb724e56304290ab57c78..94459cb097b1e21526f9c54f65d1cf3cd433c1ca 100644 (file)
--- a/src/core/store_lookup.c
+++ b/src/core/store_lookup.c
#include <limits.h>
-/*
- * private data types
- */
-
-typedef struct {
- sdb_store_matcher_t *m;
- sdb_store_matcher_t *filter;
- sdb_store_lookup_cb cb;
- void *user_data;
-} scan_iter_data_t;
-
-/*
- * private helper functions
- */
-
-static int
-scan_iter(sdb_store_obj_t *obj, void *user_data)
-{
- scan_iter_data_t *d = user_data;
-
- if (sdb_store_matcher_matches(d->m, obj, d->filter))
- return d->cb(obj, d->user_data);
- return 0;
-} /* scan_iter */
-
/*
* matcher implementations
*/
{
sdb_avltree_iter_t *iter = NULL;
int status;
- int all = 0;
+ int all = (int)(m->type == MATCHER_ALL);
- assert(m->type == MATCHER_ANY);
+ assert((m->type == MATCHER_ANY) || (m->type == MATCHER_ALL));
/* TODO: support all object types */
if (obj->type != SDB_HOST)
return 0;
- /* negated matchers should only match if the respective positive matchers
- * do not match; that is if the negated matcher matchers *all* children */
- if ((ITER_M(m)->m->type == MATCHER_NE)
- || (ITER_M(m)->m->type == MATCHER_NREGEX))
- all = 1;
-
if (ITER_M(m)->type == SDB_SERVICE)
iter = sdb_avltree_get_iter(HOST(obj)->services);
else if (ITER_M(m)->type == SDB_METRIC)
match_logical,
match_unary,
match_iter,
+ match_iter,
match_lt,
match_le,
match_eq,
return NULL;
return M(sdb_object_create("any-matcher", iter_type,
MATCHER_ANY, type, m));
-} /* sdb_store_iter_matcher */
+} /* sdb_store_any_matcher */
+
+sdb_store_matcher_t *
+sdb_store_all_matcher(int type, sdb_store_matcher_t *m)
+{
+ if ((type != SDB_SERVICE) && (type != SDB_METRIC)
+ && (type != SDB_ATTRIBUTE))
+ return NULL;
+ return M(sdb_object_create("all-matcher", iter_type,
+ MATCHER_ALL, type, m));
+} /* sdb_store_all_matcher */
sdb_store_matcher_t *
sdb_store_lt_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right)
return matchers[m->type](m, obj, filter);
} /* sdb_store_matcher_matches */
-int
-sdb_store_scan(sdb_store_matcher_t *m, sdb_store_matcher_t *filter,
- sdb_store_lookup_cb cb, void *user_data)
-{
- scan_iter_data_t data = { m, filter, cb, user_data };
-
- if (! cb)
- return -1;
- return sdb_store_iterate(scan_iter, &data);
-} /* sdb_store_scan */
-
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */