Add filter_test and move query parser in its own file.
[apps/pfixtools.git] / postlicyd / filter.h
index f53b917..0aca7e9 100644 (file)
@@ -72,14 +72,13 @@ typedef struct filter_t {
 
     A(filter_param_t) params;
 
-    /* Internal: to check the filter tree structure.
+    /* Loop checking flags.
      */
-    unsigned safe   :1;
-    unsigned seen   :1;
+    int last_seen;
 } filter_t;
 ARRAY(filter_t)
 
-#define FILTER_INIT { NULL, FTK_UNKNOWN, ARRAY_INIT, NULL, ARRAY_INIT, false, false }
+#define FILTER_INIT { NULL, FTK_UNKNOWN, ARRAY_INIT, NULL, ARRAY_INIT, -1 }
 #define CHECK_FILTER(Filter)                                                   \
     assert(Filter != FTK_UNKNOWN && Filter != FTK_count                        \
            && "Unknown filter type")
@@ -174,6 +173,9 @@ void filter_wipe(filter_t *filter);
 __attribute__((nonnull(1,2)))
 const filter_hook_t *filter_run(const filter_t *filter, const query_t *query);
 
+__attribute__((nonnull(1,2)))
+bool filter_test(const filter_t *filter, const query_t *query, filter_result_t expt);
+
 
 /* Helpers
  */