X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Finclude%2Fcore%2Fstore.h;h=533f4080ec17f049051f19a04b97111d226cfc33;hb=6fbccd38ba921b0f08b4a38ef3568bd9ca12fcd5;hp=a9788f44bb5b59ac7b166b46667bdb0acc9a70f1;hpb=0e369b5129e64580e444e7d7ef4033a9d2995a28;p=sysdb.git diff --git a/src/include/core/store.h b/src/include/core/store.h index a9788f4..533f408 100644 --- a/src/include/core/store.h +++ b/src/include/core/store.h @@ -173,6 +173,21 @@ int sdb_store_service_attr(const char *hostname, const char *service, const char *key, const sdb_data_t *value, sdb_time_t last_update); +/* + * sdb_store_get_field: + * Get the value of a stored object's queryable field. The caller is + * responsible for freeing any dynamically allocated memory possibly stored in + * the returned value. + * + * Note: Retrieving the backend this way is not currently supported. + * + * Returns: + * - 0 on success + * - a negative value else + */ +int +sdb_store_get_field(sdb_store_obj_t *obj, int field, sdb_data_t *res); + /* * Expressions specify arithmetic expressions. * @@ -317,6 +332,19 @@ sdb_store_matcher_t * sdb_store_matcher_parse_cmp(const char *obj_type, const char *attr, const char *op, sdb_store_expr_t *expr); +/* + * sdb_store_matcher_parse_field_cmp: + * Parse a simple compare expression for queryable object fields ( + * ). + * + * Returns: + * - a matcher object on success + * - NULL else + */ +sdb_store_matcher_t * +sdb_store_matcher_parse_field_cmp(const char *name, const char *op, + sdb_store_expr_t *expr); + /* * sdb_store_dis_matcher: * Creates a matcher matching the disjunction (logical OR) of two matchers. @@ -405,26 +433,32 @@ enum { /* * sdb_store_tojson: * Serialize the entire store to JSON and append the result to the specified - * buffer. + * buffer. If specified, only objects matching the filter will be included in + * the result (see sdb_store_host_tojson for details). * * Returns: * - 0 on success * - a negative value on error */ int -sdb_store_tojson(sdb_strbuf_t *buf, int flags); +sdb_store_tojson(sdb_strbuf_t *buf, sdb_store_matcher_t *filter, int flags); /* * sdb_store_host_tojson: * Serialize a host object to JSON and append the result to the specified - * buffer. + * buffer. If specified, only objects matching the filter will be included in + * the result. The filter is applied to each object individually and, thus, + * should not be of any object-type specific kind. The filter is never applied + * to the specified host object; the caller is responsible for this and for + * correctly handling skipped hosts. * * Returns: * - 0 on success * - a negative value on error */ int -sdb_store_host_tojson(sdb_store_obj_t *host, sdb_strbuf_t *buf, int flags); +sdb_store_host_tojson(sdb_store_obj_t *host, sdb_strbuf_t *buf, + sdb_store_matcher_t *filter, int flags); /* * sdb_store_iter_cb: