X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=postlicyd%2Ffilter.c;h=aadc58c2c4f1e195578fe5b750e34ca075360842;hb=86bf8f7a016cfd8475ffc363a4cac0a29a4aacfd;hp=bbb08c5c619afa21105b7f613c55c89a2ea48d20;hpb=dd53acce112e59a9ba35e3389c9bad4ea81480ca;p=apps%2Fpfixtools.git diff --git a/postlicyd/filter.c b/postlicyd/filter.c index bbb08c5..aadc58c 100644 --- a/postlicyd/filter.c +++ b/postlicyd/filter.c @@ -133,9 +133,26 @@ void filter_wipe(filter_t *filter) p_delete(&filter->name); } -filter_result_t filter_run(const filter_t *filter, const query_t *query) +filter_hook_t *filter_run(const filter_t *filter, const query_t *query) { - return runners[filter->type](filter, query); + int start = 0; + int end = filter->hooks.len; + filter_result_t res = runners[filter->type](filter, query); + + while (start < end) { + int mid = (start + end) / 2; + filter_hook_t *hook = array_ptr(filter->hooks, mid); + if (hook->type == res) { + return hook; + } else if (res < hook->type) { + end = mid; + } else { + start = mid + 1; + } + } + syslog(LOG_WARNING, "missing hook %s for filter %s", + htokens[res], filter->name); + return NULL; } void filter_set_name(filter_t *filter, const char *name, ssize_t len) @@ -154,7 +171,7 @@ bool filter_set_type(filter_t *filter, const char *type, ssize_t len) bool filter_add_param(filter_t *filter, const char *name, ssize_t name_len, const char *value, ssize_t value_len) { - filter_params_t param; + filter_param_t param; param.type = param_tokenize(name, name_len); if (param.type == ATK_UNKNOWN) { syslog(LOG_ERR, "unknown parameter %.*s", name_len, name);