index 557b93662f55d0ce4a83329112c98a2382b74a85..0bb157c76e7a49162e3832f5b9ae0e013372485a 100644 (file)
--- a/src/core/store_lookup.c
+++ b/src/core/store_lookup.c
sdb_store_matcher_t *m;
sdb_store_lookup_cb cb;
void *user_data;
-} lookup_iter_data_t;
+} scan_iter_data_t;
/*
* private helper functions
*/
static int
-lookup_iter(sdb_store_obj_t *obj, void *user_data)
+scan_iter(sdb_store_obj_t *obj, void *user_data)
{
- lookup_iter_data_t *d = user_data;
+ scan_iter_data_t *d = user_data;
if (sdb_store_matcher_matches(d->m, obj))
return d->cb(obj, d->user_data);
return 0;
-} /* lookup_iter */
+} /* scan_iter */
static sdb_attribute_t *
attr_get(sdb_host_t *host, const char *name)
static char *
isnull_tostring(sdb_store_matcher_t *m, char *buf, size_t buflen)
{
- snprintf(buf, buflen, "(IS NULL, attr.%s)", ISNULL_M(m)->attr_name);
+ snprintf(buf, buflen, "(IS NULL, ATTR[%s])", ISNULL_M(m)->attr_name);
return buf;
} /* isnull_tostring */
sdb_store_cond_t *cond;
_Bool inv = 0;
- /* TODO: this will reject any attributes called "name";
- * use a different syntax for querying objects by name */
- if (! strcasecmp(attr, "name"))
+ if (! attr)
return NULL;
- if (! strcasecmp(op, "IS"))
- return sdb_store_isnull_matcher(attr);
+ if (! strcasecmp(op, "IS")) {
+ if (! value)
+ return sdb_store_isnull_matcher(attr);
+ else
+ return NULL;
+ }
else if (! value)
return NULL;
else if (! strcasecmp(op, "<"))
return NULL;
}
- if (! strcasecmp(attr, "name"))
+ if (! attr)
m = sdb_store_name_matcher(type, value->data.string, re);
else if (type == SDB_ATTRIBUTE)
m = sdb_store_attr_matcher(attr, value->data.string, re);
} /* sdb_store_matcher_tostring */
int
-sdb_store_lookup(sdb_store_matcher_t *m, sdb_store_lookup_cb cb,
+sdb_store_scan(sdb_store_matcher_t *m, sdb_store_lookup_cb cb,
void *user_data)
{
- lookup_iter_data_t data = { m, cb, user_data };
+ scan_iter_data_t data = { m, cb, user_data };
if (! cb)
return -1;
- return sdb_store_iterate(lookup_iter, &data);
-} /* sdb_store_lookup */
+ return sdb_store_iterate(scan_iter, &data);
+} /* sdb_store_scan */
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */