X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=include%2Ftr_filter.h;h=d241a500957b8206b2e5343c0b23ad8f3247be3b;hb=fc7fb82d2661d977e7bacb4ffe469f3857a06b63;hp=caabe5d051dd48605108ef8f32baf42bef207220;hpb=5ca23c802b939827b429a7fe63578d898ba15d95;p=trust_router.git diff --git a/include/tr_filter.h b/include/tr_filter.h index caabe5d..d241a50 100644 --- a/include/tr_filter.h +++ b/include/tr_filter.h @@ -39,14 +39,12 @@ #include #include +#include #include #include #include #include -#define TR_MAX_FILTER_SPECS 8 -#define TR_MAX_FILTER_SPEC_MATCHES 64 - /* Filter actions */ typedef enum tr_filter_action { TR_FILTER_ACTION_REJECT = 0, @@ -68,26 +66,21 @@ typedef enum { typedef struct tr_fspec { TR_NAME *field; - TR_NAME *match[TR_MAX_FILTER_SPEC_MATCHES]; + TR_LIST *match; } TR_FSPEC; typedef struct tr_fline { TR_FILTER_ACTION action; - TR_FSPEC *specs[TR_MAX_FILTER_SPECS]; + TR_LIST *specs; TR_CONSTRAINT *realm_cons; TR_CONSTRAINT *domain_cons; } TR_FLINE; typedef struct tr_filter { TR_FILTER_TYPE type; - GPtrArray *lines; + TR_LIST *lines; } TR_FILTER; -typedef struct tr_filter_iter { - TR_FILTER *filter; - guint ii; -} TR_FILTER_ITER; - typedef struct tr_filter_set TR_FILTER_SET; struct tr_filter_set { TR_FILTER *this; @@ -119,21 +112,38 @@ TR_FILTER_TYPE tr_filter_get_type(TR_FILTER *filt); TR_FLINE *tr_filter_add_line(TR_FILTER *filt, TR_FLINE *line); TR_FLINE *tr_fline_new(TALLOC_CTX *mem_ctx); - void tr_fline_free(TR_FLINE *fline); +TR_FSPEC *tr_fline_add_spec(TR_FLINE *fline, TR_FSPEC *spec); TR_FSPEC *tr_fspec_new(TALLOC_CTX *mem_ctx); - void tr_fspec_free(TR_FSPEC *fspec); - -void tr_fspec_add_match(TR_FSPEC *fspec, TR_NAME *match); +TR_NAME *tr_fspec_add_match(TR_FSPEC *fspec, TR_NAME *match); int tr_fspec_matches(TR_FSPEC *fspec, TR_FILTER_TYPE ftype, TR_FILTER_TARGET *target); -TR_FILTER_ITER *tr_filter_iter_new(TALLOC_CTX *mem_ctx); -void tr_filter_iter_free(TR_FILTER_ITER *iter); -TR_FLINE *tr_filter_iter_first(TR_FILTER_ITER *iter, TR_FILTER *filter); -TR_FLINE *tr_filter_iter_next(TR_FILTER_ITER *iter); +/* Iterator for TR_FILTER lines */ +typedef TR_LIST_ITER TR_FILTER_ITER; +#define tr_filter_iter_new(CTX) (tr_list_iter_new(CTX)) +#define tr_filter_iter_free(ITER) (tr_list_iter_free(ITER)) +#define tr_filter_iter_first(ITER, FILT) ((TR_FLINE *) tr_list_iter_first((ITER), (FILT)->lines)) +#define tr_filter_iter_next(ITER) ((TR_FLINE *) tr_list_iter_next(ITER)) +#define tr_filter_add_line(FILT, LINE) ((TR_FLINE *) tr_list_add((FILT)->lines, (LINE), 1)) + +/* Iterator for TR_FSPEC matches */ +typedef TR_LIST_ITER TR_FSPEC_ITER; +#define tr_fspec_iter_new(CTX) (tr_list_iter_new(CTX)) +#define tr_fspec_iter_free(ITER) (tr_list_iter_free(ITER)) +#define tr_fspec_iter_first(ITER, SPEC) (tr_list_iter_first((ITER), (SPEC)->match)) +#define tr_fspec_iter_next(ITER) (tr_list_iter_next(ITER)) +#define tr_fspec_add_match(SPEC, MATCH) ((TR_NAME *) tr_list_add((SPEC)->match, (MATCH), 0)) + +/* Iterator for TR_FLINE specs */ +typedef TR_LIST_ITER TR_FLINE_ITER; +#define tr_fline_iter_new(CTX) (tr_list_iter_new(CTX)) +#define tr_fline_iter_free(ITER) (tr_list_iter_free(ITER)) +#define tr_fline_iter_first(ITER, LINE) (tr_list_iter_first((ITER), (LINE)->specs)) +#define tr_fline_iter_next(ITER) (tr_list_iter_next(ITER)) +#define tr_fline_add_spec(LINE, SPEC) ((TR_NAME *) tr_list_add((LINE)->specs, (SPEC), 1)) /*In tr_constraint.c and exported, but not really a public symbol; needed by tr_filter.c and by tr_constraint.c*/ int TR_EXPORT tr_prefix_wildcard_match(const char *str, const char *wc_str);