From: Sebastian Harl Date: Wed, 22 Oct 2014 09:16:05 +0000 (+0200) Subject: store: Removed unused, old conditional matchers. X-Git-Tag: sysdb-0.6.0~76 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4a5eb5e9a97fac1ad51a1e7be94c460d2f071ae3;p=sysdb.git store: Removed unused, old conditional matchers. --- diff --git a/src/core/store-private.h b/src/core/store-private.h index be262ec..6e232dd 100644 --- a/src/core/store-private.h +++ b/src/core/store-private.h @@ -124,27 +124,6 @@ struct sdb_store_expr { sdb_data_t data; }; -/* - * conditionals - */ - -/* compares an object using the specified conditional and taking the specified - * filter into account */ -typedef int (*cmp_cb)(sdb_store_obj_t *, sdb_store_cond_t *, - sdb_store_matcher_t *); - -struct sdb_store_cond { - sdb_object_t super; - cmp_cb cmp; -}; - -typedef struct { - sdb_store_cond_t super; - char *name; - sdb_store_expr_t *expr; -} attr_cond_t; -#define ATTR_C(obj) ((attr_cond_t *)(obj)) - /* * matchers */ @@ -160,11 +139,6 @@ enum { MATCHER_SERVICE, MATCHER_METRIC, MATCHER_ATTRIBUTE, - MATCHER_LT, - MATCHER_LE, - MATCHER_EQ, - MATCHER_GE, - MATCHER_GT, MATCHER_CMP_LT, MATCHER_CMP_LE, MATCHER_CMP_EQ, @@ -187,12 +161,7 @@ enum { : ((t) == MATCHER_SERVICE) ? "SERVICE" \ : ((t) == MATCHER_METRIC) ? "METRIC" \ : ((t) == MATCHER_ATTRIBUTE) ? "ATTRIBUTE" \ - : ((t) == MATCHER_LT) ? "<" \ - : ((t) == MATCHER_LE) ? "<=" \ - : ((t) == MATCHER_EQ) ? "=" \ : ((t) == MATCHER_CMP_NE) ? "!=" \ - : ((t) == MATCHER_GE) ? ">=" \ - : ((t) == MATCHER_GT) ? ">" \ : ((t) == MATCHER_IN) ? "IN" \ : ((t) == MATCHER_REGEX) ? "=~" \ : ((t) == MATCHER_NREGEX) ? "!~" \ @@ -273,13 +242,6 @@ typedef struct { } isnull_matcher_t; #define ISNULL_M(m) ((isnull_matcher_t *)(m)) -/* match using conditionals */ -typedef struct { - sdb_store_matcher_t super; - sdb_store_cond_t *cond; -} cond_matcher_t; -#define COND_M(m) ((cond_matcher_t *)(m)) - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/core/store_lookup.c b/src/core/store_lookup.c index 6730e11..05e6b74 100644 --- a/src/core/store_lookup.c +++ b/src/core/store_lookup.c @@ -250,56 +250,6 @@ match_child(sdb_store_matcher_t *m, sdb_store_obj_t *obj, return status; } /* match_child */ -static int -match_lt(sdb_store_matcher_t *m, sdb_store_obj_t *obj, - sdb_store_matcher_t *filter) -{ - int status; - assert(m->type == MATCHER_LT); - status = COND_M(m)->cond->cmp(obj, COND_M(m)->cond, filter); - return (status != INT_MAX) && (status < 0); -} /* match_lt */ - -static int -match_le(sdb_store_matcher_t *m, sdb_store_obj_t *obj, - sdb_store_matcher_t *filter) -{ - int status; - assert(m->type == MATCHER_LE); - status = COND_M(m)->cond->cmp(obj, COND_M(m)->cond, filter); - return (status != INT_MAX) && (status <= 0); -} /* match_le */ - -static int -match_eq(sdb_store_matcher_t *m, sdb_store_obj_t *obj, - sdb_store_matcher_t *filter) -{ - int status; - assert(m->type == MATCHER_EQ); - status = COND_M(m)->cond->cmp(obj, COND_M(m)->cond, filter); - return (status != INT_MAX) && (! status); -} /* match_eq */ - -static int -match_ge(sdb_store_matcher_t *m, sdb_store_obj_t *obj, - sdb_store_matcher_t *filter) -{ - int status; - assert(m->type == MATCHER_GE); - status = COND_M(m)->cond->cmp(obj, COND_M(m)->cond, filter); - return (status != INT_MAX) && (status >= 0); -} /* match_ge */ - -static int -match_gt(sdb_store_matcher_t *m, sdb_store_obj_t *obj, - sdb_store_matcher_t *filter) -{ - int status; - assert(m->type == MATCHER_GT); - status = COND_M(m)->cond->cmp(obj, COND_M(m)->cond, filter); - return (status != INT_MAX) && (status > 0); -} /* match_gt */ - /* * cmp_expr: * Compare the values of two expressions when evaluating them using the @@ -514,11 +464,6 @@ matchers[] = { match_child, match_child, match_child, - match_lt, - match_le, - match_eq, - match_ge, - match_gt, match_cmp_lt, match_cmp_le, match_cmp_eq, @@ -610,28 +555,6 @@ attr_matcher_destroy(sdb_object_t *obj) string_matcher_destroy(&attr->value); } /* attr_matcher_destroy */ -static int -cond_matcher_init(sdb_object_t *obj, va_list ap) -{ - int type = va_arg(ap, int); - sdb_store_cond_t *cond = va_arg(ap, sdb_store_cond_t *); - - if (! cond) - return -1; - - sdb_object_ref(SDB_OBJ(cond)); - - M(obj)->type = type; - COND_M(obj)->cond = cond; - return 0; -} /* cond_matcher_init */ - -static void -cond_matcher_destroy(sdb_object_t *obj) -{ - sdb_object_deref(SDB_OBJ(COND_M(obj)->cond)); -} /* cond_matcher_destroy */ - static int op_matcher_init(sdb_object_t *obj, va_list ap) { @@ -752,12 +675,6 @@ static sdb_type_t attr_type = { /* destroy = */ attr_matcher_destroy, }; -static sdb_type_t cond_type = { - /* size = */ sizeof(cond_matcher_t), - /* init = */ cond_matcher_init, - /* destroy = */ cond_matcher_destroy, -}; - static sdb_type_t op_type = { /* size = */ sizeof(op_matcher_t), /* init = */ op_matcher_init, @@ -840,41 +757,6 @@ sdb_store_child_matcher(int type, sdb_store_matcher_t *m) return M(sdb_object_create("any-matcher", child_type, type, m)); } /* sdb_store_child_matcher */ -sdb_store_matcher_t * -sdb_store_lt_matcher(sdb_store_cond_t *cond) -{ - return M(sdb_object_create("lt-matcher", cond_type, - MATCHER_LT, cond)); -} /* sdb_store_lt_matcher */ - -sdb_store_matcher_t * -sdb_store_le_matcher(sdb_store_cond_t *cond) -{ - return M(sdb_object_create("le-matcher", cond_type, - MATCHER_LE, cond)); -} /* sdb_store_le_matcher */ - -sdb_store_matcher_t * -sdb_store_eq_matcher(sdb_store_cond_t *cond) -{ - return M(sdb_object_create("eq-matcher", cond_type, - MATCHER_EQ, cond)); -} /* sdb_store_eq_matcher */ - -sdb_store_matcher_t * -sdb_store_ge_matcher(sdb_store_cond_t *cond) -{ - return M(sdb_object_create("ge-matcher", cond_type, - MATCHER_GE, cond)); -} /* sdb_store_ge_matcher */ - -sdb_store_matcher_t * -sdb_store_gt_matcher(sdb_store_cond_t *cond) -{ - return M(sdb_object_create("gt-matcher", cond_type, - MATCHER_GT, cond)); -} /* sdb_store_gt_matcher */ - /* * TODO: Rename sdb_store_cmp_* to sdb_store_* once the old code is unused and * has been removed. diff --git a/src/include/core/store.h b/src/include/core/store.h index 684a3cc..cef3d06 100644 --- a/src/include/core/store.h +++ b/src/include/core/store.h @@ -358,17 +358,6 @@ int sdb_store_expr_eval(sdb_store_expr_t *expr, sdb_store_obj_t *obj, sdb_data_t *res, sdb_store_matcher_t *filter); -/* - * Conditionals may be used to lookup hosts from the store based on a - * conditional expression. - * - * A conditional object inherits from sdb_object_t and, thus, may safely be - * cast to a generic object. - */ -struct sdb_store_cond; -typedef struct sdb_store_cond sdb_store_cond_t; -#define SDB_STORE_COND(obj) ((sdb_store_cond_t *)(obj)) - /* * sdb_store_name_matcher: * Creates a matcher matching by the specified object type's name. If 're' is @@ -417,17 +406,6 @@ sdb_store_child_matcher(int type, sdb_store_matcher_t *m); * equal, equal, greater or equal, or greater than the conditional's value * repsectively. */ -sdb_store_matcher_t * -sdb_store_lt_matcher(sdb_store_cond_t *cond); -sdb_store_matcher_t * -sdb_store_le_matcher(sdb_store_cond_t *cond); -sdb_store_matcher_t * -sdb_store_eq_matcher(sdb_store_cond_t *cond); -sdb_store_matcher_t * -sdb_store_ge_matcher(sdb_store_cond_t *cond); -sdb_store_matcher_t * -sdb_store_gt_matcher(sdb_store_cond_t *cond); - sdb_store_matcher_t * sdb_store_cmp_lt(sdb_store_expr_t *left, sdb_store_expr_t *right); sdb_store_matcher_t *