X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fcore%2Fstore-private.h;h=49ddaf547465f349b8ba57aede974e0388628652;hb=fd3e376f4c7dc24c40717c056548c4e26e4e8b97;hp=f33768579575524857b9991376b55c2262364439;hpb=c659b3f0b772cd479654eb41be2a4d71965d2795;p=sysdb.git diff --git a/src/core/store-private.h b/src/core/store-private.h index f337685..49ddaf5 100644 --- a/src/core/store-private.h +++ b/src/core/store-private.h @@ -77,6 +77,25 @@ typedef struct { #define _last_update super.last_update #define _interval super.interval +/* + * conditionals + */ + +/* compares a store object using the specified conditional */ +typedef int (*cmp_cb)(sdb_store_base_t *, sdb_store_cond_t *); + +struct sdb_store_cond { + sdb_object_t super; + cmp_cb cmp; +}; + +typedef struct { + sdb_store_cond_t super; + char *name; + sdb_data_t value; +} attr_cond_t; +#define ATTR_C(obj) ((attr_cond_t *)(obj)) + /* * matchers */ @@ -89,8 +108,26 @@ enum { MATCHER_NOT, MATCHER_NAME, MATCHER_ATTR, + MATCHER_LT, + MATCHER_LE, + MATCHER_EQ, + MATCHER_GE, + MATCHER_GT, }; +#define MATCHER_SYM(t) \ + (((t) == MATCHER_OR) ? "OR" \ + : ((t) == MATCHER_AND) ? "AND" \ + : ((t) == MATCHER_NOT) ? "NOT" \ + : ((t) == MATCHER_NAME) ? "NAME" \ + : ((t) == MATCHER_ATTR) ? "ATTR" \ + : ((t) == MATCHER_LT) ? "<" \ + : ((t) == MATCHER_LE) ? "<=" \ + : ((t) == MATCHER_EQ) ? "=" \ + : ((t) == MATCHER_GE) ? ">=" \ + : ((t) == MATCHER_GT) ? ">" \ + : "UNKNOWN") + /* match the name of something */ typedef struct { char *name; @@ -105,7 +142,7 @@ struct sdb_store_matcher { }; #define M(m) ((sdb_store_matcher_t *)(m)) -/* logical infix operator matcher */ +/* infix operator matcher */ typedef struct { sdb_store_matcher_t super; @@ -115,7 +152,7 @@ typedef struct { } op_matcher_t; #define OP_M(m) ((op_matcher_t *)(m)) -/* logical unary operator matcher */ +/* unary operator matcher */ typedef struct { sdb_store_matcher_t super; @@ -143,6 +180,13 @@ typedef struct { } attr_matcher_t; #define ATTR_M(m) ((attr_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