Code

store: Removed sdb_store_matcher_tostring().
[sysdb.git] / src / include / core / store.h
1 /*
2  * SysDB - src/include/core/store.h
3  * Copyright (C) 2012 Sebastian 'tokkee' Harl <sh@tokkee.org>
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
19  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
28 #ifndef SDB_CORE_STORE_H
29 #define SDB_CORE_STORE_H 1
31 #include "sysdb.h"
32 #include "core/object.h"
33 #include "core/data.h"
34 #include "core/time.h"
35 #include "core/timeseries.h"
36 #include "utils/strbuf.h"
38 #include <stdio.h>
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
44 /*
45  * Store object types.
46  */
47 enum {
48         SDB_HOST = 1,
49         SDB_SERVICE,
50         SDB_METRIC,
51         SDB_ATTRIBUTE,
52 };
53 #define SDB_STORE_TYPE_TO_NAME(t) \
54         (((t) == SDB_HOST) ? "host" \
55                 : ((t) == SDB_SERVICE) ? "service" \
56                 : ((t) == SDB_METRIC) ? "metric" \
57                 : ((t) == SDB_ATTRIBUTE) ? "attribute" : "unknown")
59 /*
60  * sdb_store_obj_t represents the super-class of any object stored in the
61  * database. It inherits from sdb_object_t and may safely be cast to a generic
62  * object to access its name.
63  */
64 struct sdb_store_obj;
65 typedef struct sdb_store_obj sdb_store_obj_t;
67 /*
68  * Expressions represent arithmetic expressions based on stored objects and
69  * their various attributes.
70  *
71  * An expression object inherits from sdb_object_t and, thus, may safely be
72  * cast to a generic object.
73  */
74 struct sdb_store_expr;
75 typedef struct sdb_store_expr sdb_store_expr_t;
76 #define SDB_STORE_EXPR(obj) ((sdb_store_expr_t *)(obj))
78 /*
79  * Store matchers may be used to lookup hosts from the store based on their
80  * various attributes. Service and attribute matchers are applied to a host's
81  * services and attributes and evaluate to true if *any* service or attribute
82  * matches.
83  *
84  * A store matcher object inherits from sdb_object_t and, thus, may safely be
85  * cast to a generic object.
86  */
87 struct sdb_store_matcher;
88 typedef struct sdb_store_matcher sdb_store_matcher_t;
89 #define SDB_STORE_MATCHER(obj) ((sdb_store_matcher_t *)(obj))
91 /*
92  * Queryable fields of a stored object.
93  */
94 enum {
95         SDB_FIELD_NAME = 1,    /* string */
96         SDB_FIELD_LAST_UPDATE, /* datetime */
97         SDB_FIELD_AGE,         /* datetime */
98         SDB_FIELD_INTERVAL,    /* datetime */
99         SDB_FIELD_BACKEND,     /* string */
100 };
102 #define SDB_FIELD_TO_NAME(f) \
103         (((f) == SDB_FIELD_NAME) ? "name" \
104                 : ((f) == SDB_FIELD_LAST_UPDATE) ? "last-update" \
105                 : ((f) == SDB_FIELD_AGE) ? "age" \
106                 : ((f) == SDB_FIELD_INTERVAL) ? "interval" \
107                 : ((f) == SDB_FIELD_BACKEND) ? "backend" : "unknown")
109 /*
110  * sdb_store_clear:
111  * Clear the entire store and remove all stored objects.
112  */
113 void
114 sdb_store_clear(void);
116 /*
117  * sdb_store_host:
118  * Add/update a host in the store. If the host, identified by its
119  * canonicalized name, already exists, it will be updated according to the
120  * specified name and timestamp. Else, a new entry will be created in the
121  * store. Any memory required for storing the entry will be allocated an
122  * managed by the store itself.
123  *
124  * Returns:
125  *  - 0 on success
126  *  - a positive value if the new entry is older than the currently stored
127  *    entry (in this case, no update will happen)
128  *  - a negative value on error
129  */
130 int
131 sdb_store_host(const char *name, sdb_time_t last_update);
133 /*
134  * sdb_store_has_host:
135  * sdb_store_get_host:
136  * Query the store for a host by its (canonicalized) name.
137  *
138  * sdb_store_get_host increments the ref count of the host object. The caller
139  * needs to deref it when no longer using it.
140  */
141 _Bool
142 sdb_store_has_host(const char *name);
144 sdb_store_obj_t *
145 sdb_store_get_host(const char *name);
147 /*
148  * sdb_store_attribute:
149  * Add/update a host's attribute in the store. If the attribute, identified by
150  * its key, already exists for the specified host, it will be updated to the
151  * specified values. If the referenced host does not exist, an error will be
152  * reported. Else, a new entry will be created in the store. Any memory
153  * required for storing the entry will be allocated and managed by the store
154  * itself.
155  *
156  * Returns:
157  *  - 0 on success
158  *  - a positive value if the new entry is older than the currently stored
159  *    entry (in this case, no update will happen)
160  *  - a negative value on error
161  */
162 int
163 sdb_store_attribute(const char *hostname,
164                 const char *key, const sdb_data_t *value,
165                 sdb_time_t last_update);
167 /*
168  * sdb_store_service:
169  * Add/update a service in the store. If the service, identified by its name,
170  * already exists for the specified host, it will be updated according to the
171  * specified 'service' object. If the referenced host does not exist, an error
172  * will be reported. Else, a new entry will be created in the store. Any
173  * memory required for storing the entry will be allocated an managed by the
174  * store itself.
175  *
176  * Returns:
177  *  - 0 on success
178  *  - a positive value if the new entry is older than the currently stored
179  *    entry (in this case, no update will happen)
180  *  - a negative value on error
181  */
182 int
183 sdb_store_service(const char *hostname, const char *name,
184                 sdb_time_t last_update);
186 /*
187  * sdb_store_service_attr:
188  * Add/update a service's attribute in the store. If the attribute, identified
189  * by its key, already exists for the specified service, it will be updated to
190  * the specified value. If the references service (for the specified host)
191  * does not exist, an error will be reported. Any memory required for storing
192  * the entry will be allocated and managed by the store itself.
193  *
194  * Returns:
195  *  - 0 on success
196  *  - a positive value if the new entry is older than the currently stored
197  *    entry (in this case, no update will happen)
198  *  - a negative value on error
199  */
200 int
201 sdb_store_service_attr(const char *hostname, const char *service,
202                 const char *key, const sdb_data_t *value, sdb_time_t last_update);
204 /*
205  * A metric store describes how to access a metric's data.
206  */
207 typedef struct {
208         const char *type;
209         const char *id;
210 } sdb_metric_store_t;
212 /*
213  * sdb_store_metric:
214  * Add/update a metric in the store. If the metric, identified by its name,
215  * already exists for the specified host, it will be updated according to the
216  * specified 'metric' object. If the referenced host does not exist, an error
217  * will be reported. Else, a new entry will be created in the store. Any
218  * memory required for storing the entry will be allocated an managed by the
219  * store itself.
220  *
221  * If specified, the metric store describes where to access the metric's data.
222  *
223  * Returns:
224  *  - 0 on success
225  *  - a positive value if the new entry is older than the currently stored
226  *    entry (in this case, no update will happen)
227  *  - a negative value on error
228  */
229 int
230 sdb_store_metric(const char *hostname, const char *name,
231                 sdb_metric_store_t *store, sdb_time_t last_update);
233 /*
234  * sdb_store_metric_attr:
235  * Add/update a metric's attribute in the store. If the attribute, identified
236  * by its key, already exists for the specified metric, it will be updated to
237  * the specified value. If the references metric (for the specified host)
238  * does not exist, an error will be reported. Any memory required for storing
239  * the entry will be allocated and managed by the store itself.
240  *
241  * Returns:
242  *  - 0 on success
243  *  - a positive value if the new entry is older than the currently stored
244  *    entry (in this case, no update will happen)
245  *  - a negative value on error
246  */
247 int
248 sdb_store_metric_attr(const char *hostname, const char *metric,
249                 const char *key, const sdb_data_t *value, sdb_time_t last_update);
251 /*
252  * sdb_store_fetch_timeseries:
253  * Fetch the time-series described by the specified host's metric and
254  * serialize it as JSON into the provided string buffer.
255  *
256  * Returns:
257  *  - 0 on success
258  *  - a negative value else
259  */
260 int
261 sdb_store_fetch_timeseries(const char *hostname, const char *metric,
262                 sdb_timeseries_opts_t *opts, sdb_strbuf_t *buf);
264 /*
265  * sdb_store_get_field:
266  * Get the value of a stored object's queryable field. The caller is
267  * responsible for freeing any dynamically allocated memory possibly stored in
268  * the returned value. If 'res' is NULL, the function will return whether the
269  * field exists.
270  *
271  * Note: Retrieving the backend this way is not currently supported.
272  *
273  * Returns:
274  *  - 0 on success
275  *  - a negative value else
276  */
277 int
278 sdb_store_get_field(sdb_store_obj_t *obj, int field, sdb_data_t *res);
280 /*
281  * sdb_store_get_attr:
282  * Get the value of a stored object's attribute. The caller is responsible for
283  * freeing any dynamically allocated memory possibly stored in the returned
284  * value. If 'res' is NULL, the function will return whether the attribute
285  * exists. If specified, only attributes matching the filter will be
286  * considered.
287  *
288  * Returns:
289  *  - 0 if the attribute exists
290  *  - a negative value else
291  */
292 int
293 sdb_store_get_attr(sdb_store_obj_t *obj, const char *name, sdb_data_t *res,
294                 sdb_store_matcher_t *filter);
296 /*
297  * sdb_store_expr_create:
298  * Creates an arithmetic expression implementing the specified operator on the
299  * specified left and right operand.
300  *
301  * Returns:
302  *  - an expression object on success
303  *  - NULL else
304  */
305 sdb_store_expr_t *
306 sdb_store_expr_create(int op, sdb_store_expr_t *left, sdb_store_expr_t *right);
308 /*
309  * sdb_store_expr_fieldvalue:
310  * Creates an expression which evaluates to the value of the specified
311  * queryable field of a stored object.
312  *
313  * Returns:
314  *  - an expression object on success
315  *  - NULL else
316  */
317 sdb_store_expr_t *
318 sdb_store_expr_fieldvalue(int field);
320 /*
321  * sdb_store_expr_attrvalue:
322  * Creates an expression which evaluates to the value of the specified
323  * attribute of a stored object. Evaluates to a NULL value if the attribute
324  * does not exist.
325  *
326  * Returns:
327  *  - an expression object on success
328  *  - NULL else
329  */
330 sdb_store_expr_t *
331 sdb_store_expr_attrvalue(const char *name);
333 /*
334  * sdb_store_expr_constvalue:
335  * Creates an expression which evaluates to the specified constant value.
336  *
337  * Returns:
338  *  - an expression object on success
339  *  - NULL else
340  */
341 sdb_store_expr_t *
342 sdb_store_expr_constvalue(const sdb_data_t *value);
344 /*
345  * sdb_store_expr_eval:
346  * Evaluate an expression for the specified stored object and stores the
347  * result in 'res'. The result's value will be allocated dynamically if
348  * necessary and, thus, should be free'd by the caller (e.g. using
349  * sdb_data_free_datum). The object may be NULL, in which case the expression
350  * needs to evaluate to a constant value. If specified, only objects matching
351  * the filter will be used during the evaluation.
352  *
353  * Returns:
354  *  - 0 on success
355  *  - a negative value else
356  */
357 int
358 sdb_store_expr_eval(sdb_store_expr_t *expr, sdb_store_obj_t *obj,
359                 sdb_data_t *res, sdb_store_matcher_t *filter);
361 /*
362  * Conditionals may be used to lookup hosts from the store based on a
363  * conditional expression.
364  *
365  * A conditional object inherits from sdb_object_t and, thus, may safely be
366  * cast to a generic object.
367  */
368 struct sdb_store_cond;
369 typedef struct sdb_store_cond sdb_store_cond_t;
370 #define SDB_STORE_COND(obj) ((sdb_store_cond_t *)(obj))
372 /*
373  * sdb_store_attr_cond:
374  * Creates a conditional based on attribute values. The value of stored
375  * attributes is compared against the value the expression evaluates to. See
376  * sdb_data_cmp for details about the comparison.
377  */
378 sdb_store_cond_t *
379 sdb_store_attr_cond(const char *name, sdb_store_expr_t *expr);
381 /*
382  * sdb_store_obj_cond:
383  * Creates a conditional based on queryable object fields. The respective
384  * field of *any* object type is compared against the value the expression
385  * evaluates to.
386  */
387 sdb_store_cond_t *
388 sdb_store_obj_cond(int field, sdb_store_expr_t *expr);
390 /*
391  * sdb_store_name_matcher:
392  * Creates a matcher matching by the specified object type's name. If 're' is
393  * true, the specified name is treated as a POSIX extended regular expression.
394  * Else, the exact name has to match (case-insensitive).
395  */
396 sdb_store_matcher_t *
397 sdb_store_name_matcher(int type, const char *name, _Bool re);
399 /*
400  * sdb_store_attr_matcher:
401  * Creates a matcher matching attributes based on their value. If 're' is
402  * true, the specified name is treated as a POSIX extended regular expression.
403  * Else, the exact name has to match (case-insensitive).
404  */
405 sdb_store_matcher_t *
406 sdb_store_attr_matcher(const char *name, const char *value, _Bool re);
408 /*
409  * sdb_store_isnull_matcher:
410  * Creates a matcher matching NULL values.
411  */
412 sdb_store_matcher_t *
413 sdb_store_isnull_matcher(sdb_store_expr_t *expr);
415 /*
416  * sdb_store_isnnull_matcher:
417  * Creates a matcher matching non-NULL values.
418  */
419 sdb_store_matcher_t *
420 sdb_store_isnnull_matcher(sdb_store_expr_t *expr);
422 /*
423  * sdb_store_child_matcher:
424  * Creates a matcher matching an object's children of the specified type. It
425  * matches if *any* of those children match 'm'.
426  */
427 sdb_store_matcher_t *
428 sdb_store_child_matcher(int type, sdb_store_matcher_t *m);
430 /*
431  * sdb_store_lt_matcher, sdb_store_le_matcher, sdb_store_eq_matcher,
432  * sdb_store_ge_matcher, sdb_store_gt_matcher:
433  * Creates a matcher based on a conditional. The matcher matches objects for
434  * which the conditional evaluates the object to compare less than, less or
435  * equal, equal, greater or equal, or greater than the conditional's value
436  * repsectively.
437  */
438 sdb_store_matcher_t *
439 sdb_store_lt_matcher(sdb_store_cond_t *cond);
440 sdb_store_matcher_t *
441 sdb_store_le_matcher(sdb_store_cond_t *cond);
442 sdb_store_matcher_t *
443 sdb_store_eq_matcher(sdb_store_cond_t *cond);
444 sdb_store_matcher_t *
445 sdb_store_ge_matcher(sdb_store_cond_t *cond);
446 sdb_store_matcher_t *
447 sdb_store_gt_matcher(sdb_store_cond_t *cond);
449 sdb_store_matcher_t *
450 sdb_store_cmp_lt(sdb_store_expr_t *left, sdb_store_expr_t *right);
451 sdb_store_matcher_t *
452 sdb_store_cmp_le(sdb_store_expr_t *left, sdb_store_expr_t *right);
453 sdb_store_matcher_t *
454 sdb_store_cmp_eq(sdb_store_expr_t *left, sdb_store_expr_t *right);
455 sdb_store_matcher_t *
456 sdb_store_cmp_ne(sdb_store_expr_t *left, sdb_store_expr_t *right);
457 sdb_store_matcher_t *
458 sdb_store_cmp_ge(sdb_store_expr_t *left, sdb_store_expr_t *right);
459 sdb_store_matcher_t *
460 sdb_store_cmp_gt(sdb_store_expr_t *left, sdb_store_expr_t *right);
462 /*
463  * sdb_store_in_matcher:
464  * Creates a matcher which matches if the right value evaluates to an array
465  * value and the left value is included in that array. See sdb_data_inarray
466  * for more details.
467  */
468 sdb_store_matcher_t *
469 sdb_store_in_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right);
471 /*
472  * sdb_store_regex_matcher:
473  * Creates a matcher which matches the string value the left expression
474  * evaluates to against the regular expression the right expression evaluates
475  * to. The right expression may either be a constant value regular expression
476  * or string or a dynamic value evaluating to a string. In the latter case,
477  * the string is compiled to a regex every time the matcher is executed.
478  */
479 sdb_store_matcher_t *
480 sdb_store_regex_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right);
482 /*
483  * sdb_store_nregex_matcher:
484  * Creates a regex matcher just like sdb_store_regex_matcher except that it
485  * matches in case the regular expression does not match.
486  */
487 sdb_store_matcher_t *
488 sdb_store_nregex_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right);
490 /*
491  * sdb_store_matcher_op_cb:
492  * Callback constructing a matcher operator.
493  */
494 typedef sdb_store_matcher_t *(*sdb_store_matcher_op_cb)
495         (sdb_store_expr_t *, sdb_store_expr_t *);
497 /*
498  * sdb_store_parse_matcher_op:
499  * Parse a matcher operator and return a constructor for the respective
500  * matcher.
501  *
502  * Returns:
503  *  - matcher operator constructor on success
504  *  - NULL else
505  */
506 sdb_store_matcher_op_cb
507 sdb_store_parse_matcher_op(const char *op);
509 /*
510  * sdb_store_parse_object_type_plural:
511  * Parse the type name (plural) of a stored object.
512  *
513  * Returns:
514  *  - the object type on success
515  *  - a negative value else
516  */
517 int
518 sdb_store_parse_object_type_plural(const char *name);
520 /*
521  * sdb_store_parse_field_name:
522  * Parse the name of a stored object's queryable field.
523  *
524  * Returns:
525  *  - the field id on success
526  *  - a negative value else
527  */
528 int
529 sdb_store_parse_field_name(const char *name);
531 /*
532  * sdb_store_matcher_parse_cmp:
533  * Parse a simple compare expression (<obj_type>.<attr> <op> <expression>).
534  *
535  * Returns:
536  *  - a matcher object on success
537  *  - NULL else
538  */
539 sdb_store_matcher_t *
540 sdb_store_matcher_parse_cmp(const char *obj_type, const char *attr,
541                 const char *op, sdb_store_expr_t *expr);
543 /*
544  * sdb_store_matcher_parse_field_cmp:
545  * Parse a simple compare expression for queryable object fields (<field> <op>
546  * <expression>).
547  *
548  * Returns:
549  *  - a matcher object on success
550  *  - NULL else
551  */
552 sdb_store_matcher_t *
553 sdb_store_matcher_parse_field_cmp(const char *name, const char *op,
554                 sdb_store_expr_t *expr);
556 /*
557  * sdb_store_dis_matcher:
558  * Creates a matcher matching the disjunction (logical OR) of two matchers.
559  */
560 sdb_store_matcher_t *
561 sdb_store_dis_matcher(sdb_store_matcher_t *left, sdb_store_matcher_t *right);
563 /*
564  * sdb_store_con_matcher:
565  * Creates a matcher matching the conjunction (logical AND) of two matchers.
566  */
567 sdb_store_matcher_t *
568 sdb_store_con_matcher(sdb_store_matcher_t *left, sdb_store_matcher_t *right);
570 /*
571  * sdb_store_con_matcher::
572  * Creates a matcher matching the inverse (logical NOT) of a matcher.
573  */
574 sdb_store_matcher_t *
575 sdb_store_inv_matcher(sdb_store_matcher_t *m);
577 /*
578  * sdb_store_matcher_matches:
579  * Check whether the specified matcher matches the specified store object. If
580  * specified, the filter will be used to preselect objects for further
581  * evaluation. It is applied to any object that's used during the evaluation
582  * of the matcher. Only those objects matching the filter will be considered.
583  *
584  * Note that the filter is applied to all object types (hosts, service,
585  * metric, attribute). Thus, any object-specific matchers are mostly unsuited
586  * for this purpose and, if used, may result in unexpected behavior.
587  *
588  * Returns:
589  *  - 1 if the object matches
590  *  - 0 else
591  */
592 int
593 sdb_store_matcher_matches(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
594                 sdb_store_matcher_t *filter);
596 /*
597  * sdb_store_lookup_cb:
598  * Lookup callback. It is called for each matching object when looking up data
599  * in the store. The lookup aborts if the callback returns non-zero.
600  */
601 typedef int (*sdb_store_lookup_cb)(sdb_store_obj_t *obj, void *user_data);
603 /*
604  * sdb_store_scan:
605  * Look up objects in the store. The specified callback function is called for
606  * each object in the store matching 'm'. The function performs a full scan of
607  * all hosts stored in the database. If specified, the filter will be used to
608  * preselect objects for further evaluation. See the description of
609  * 'sdb_store_matcher_matches' for details.
610  *
611  * Returns:
612  *  - 0 on success
613  *  - a negative value else
614  */
615 int
616 sdb_store_scan(sdb_store_matcher_t *m, sdb_store_matcher_t *filter,
617                 sdb_store_lookup_cb cb, void *user_data);
619 /*
620  * Flags for serialization functions.
621  *
622  * By default, the full host object will be included in the serialized output.
623  * When specifying any of the flags, the respective information will be left
624  * out. The SKIP_EMPTY flags may be used to skip host objects entirely.
625  */
626 enum {
627         SDB_SKIP_ATTRIBUTES         = 1 << 0,
628         SDB_SKIP_SERVICES           = 1 << 1,
629         SDB_SKIP_METRICS            = 1 << 2,
630         SDB_SKIP_SERVICE_ATTRIBUTES = 1 << 3,
632         SDB_SKIP_ALL                = (1 << 8) - 1,
634         /* skip hosts if they do not reference any services/metrics */
635         SDB_SKIP_EMPTY_SERVICES     = 1 << 8,
636         SDB_SKIP_EMPTY_METRICS      = 1 << 9,
637 };
639 /*
640  * sdb_store_tojson:
641  * Serialize the entire store to JSON and append the result to the specified
642  * buffer. If specified, only objects matching the filter will be included in
643  * the result (see sdb_store_host_tojson for details).
644  *
645  * Returns:
646  *  - 0 on success
647  *  - a negative value on error
648  */
649 int
650 sdb_store_tojson(sdb_strbuf_t *buf, sdb_store_matcher_t *filter, int flags);
652 /*
653  * sdb_store_host_tojson:
654  * Serialize a host object to JSON and append the result to the specified
655  * buffer. If specified, only objects matching the filter will be included in
656  * the result. The filter is applied to each object individually and, thus,
657  * should not be of any object-type specific kind. The filter is never applied
658  * to the specified host object; the caller is responsible for this and for
659  * correctly handling skipped hosts.
660  *
661  * Returns:
662  *  - 0 on success
663  *  - a negative value on error
664  */
665 int
666 sdb_store_host_tojson(sdb_store_obj_t *host, sdb_strbuf_t *buf,
667                 sdb_store_matcher_t *filter, int flags);
669 /*
670  * sdb_store_iter_cb:
671  * Store iterator callback. Iteration stops if the callback returns non-zero.
672  */
673 typedef int (*sdb_store_iter_cb)(sdb_store_obj_t *obj, void *user_data);
675 /*
676  * sdb_store_iterate:
677  * Iterate the entire store, calling the specified callback for each object.
678  * The user_data pointer is passed on to each call of the callback.
679  *
680  * Returns:
681  *  - 0 on success
682  *  - a negative value else
683  */
684 int
685 sdb_store_iterate(sdb_store_iter_cb cb, void *user_data);
687 #ifdef __cplusplus
688 } /* extern "C" */
689 #endif
691 #endif /* ! SDB_CORE_STORE_H */
693 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */