X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=postlicyd%2Ffilter.h;h=50378683fcf9e6016f18ec59d543063ba237230d;hb=dd53acce112e59a9ba35e3389c9bad4ea81480ca;hp=db8e4573f1755f9d9a64a0ee19037391603872c3;hpb=929bb1ca2452a5bc7410896fd4e5eea44901a0b7;p=apps%2Fpfixtools.git diff --git a/postlicyd/filter.h b/postlicyd/filter.h index db8e457..5037868 100644 --- a/postlicyd/filter.h +++ b/postlicyd/filter.h @@ -38,13 +38,17 @@ #include "common.h" #include "filter_tokens.h" +#include "hook_tokens.h" +#include "param_tokens.h" #include "query.h" #include "array.h" typedef filter_token filter_type_t; +typedef hook_token filter_result_t; +typedef param_token filter_param_id_t; typedef struct filter_hook_t { - char *name; + filter_result_t type; char *value; bool postfix; @@ -53,7 +57,7 @@ typedef struct filter_hook_t { ARRAY(filter_hook_t) typedef struct filter_params_t { - char *name; + filter_param_id_t type; char *value; } filter_params_t; ARRAY(filter_params_t) @@ -70,16 +74,30 @@ typedef struct filter_t { ARRAY(filter_t) #define FILTER_INIT { NULL, FTK_UNKNOWN, ARRAY_INIT, NULL, ARRAY_INIT } +#define CHECK_FILTER(Filter) \ + assert(Filter != FTK_UNKNOWN && Filter != FTK_count \ + && "Unknown filter type") +#define CHECK_HOOK(Hook) \ + assert(Hook != HTK_UNKNOWN && Hook != HTK_count \ + && "Unknown hook") +#define CHECK_PARAM(Param) \ + assert(Param != ATK_UNKNOWN && Param != ATK_count \ + && "Unknown param") -typedef const char *filter_result_t; typedef filter_result_t (*filter_runner_t)(const filter_t *filter, const query_t *query); typedef bool (*filter_constructor_t)(filter_t *filter); typedef void (*filter_destructor_t)(filter_t *filter); __attribute__((nonnull(1,4))) -void filter_register(const char *type, filter_constructor_t constructor, - filter_destructor_t destructor, filter_runner_t runner); +filter_type_t filter_register(const char *type, filter_constructor_t constructor, + filter_destructor_t destructor, filter_runner_t runner); + +__attribute__((nonnull(2))) +filter_result_t filter_hook_register(filter_type_t filter, const char *name); + +__attribute__((nonnull(2))) +filter_param_id_t filter_param_register(filter_type_t filter, const char *name); __attribute__((nonnull(1))) static inline void filter_init(filter_t *filter) @@ -132,14 +150,12 @@ bool filter_update_references(filter_t *filter, A(filter_t) *array); __attribute__((nonnull(1))) static inline void filter_hook_wipe(filter_hook_t *hook) { - p_delete(&hook->name); p_delete(&hook->value); } __attribute__((nonnull(1))) static inline void filter_params_wipe(filter_params_t *param) { - p_delete(¶m->name); p_delete(¶m->value); }