static void fop_free(FilterExprNode *s) { FilterOp *self = (FilterOp *) s; filter_expr_unref(self->left); filter_expr_unref(self->right); }
void test_filters(gboolean not) { LogMessage *msg = log_msg_new_empty(); FilterExprNode *f = filter_tags_new(NULL); guint i; GList *l = NULL; test_msg("=== filter tests %s===\n", not ? "not " : ""); for (i = 1; i < FILTER_TAGS; i += 3) l = g_list_prepend(l, get_tag_by_id(i)); filter_tags_add(f, l); f->comp = not; for (i = 0; i < FILTER_TAGS; i++) { test_msg("Testing filter, message has tag %d\n", i); log_msg_set_tag_by_id(msg, i); if (((i % 3 == 1) ^ filter_expr_eval(f, msg)) ^ not) test_fail("Failed to match message by tag %d\n", i); test_msg("Testing filter, message no tag\n"); log_msg_clear_tag_by_id(msg, i); if (filter_expr_eval(f, msg) ^ not) test_fail("Failed to match message with no tags\n"); } filter_expr_unref(f); log_msg_unref(msg); }
static void log_filter_pipe_free(LogPipe *s) { LogFilterPipe *self = (LogFilterPipe *) s; g_free(self->name); filter_expr_unref(self->expr); log_pipe_free_method(s); }
static void tf_cond_free_state(gpointer s) { TFCondState *state = (TFCondState *) s; if (state->filter) filter_expr_unref(state->filter); tf_simple_func_free_state(&state->super); }
static void filter_call_free(FilterExprNode *s) { FilterCall *self = (FilterCall *) s; filter_expr_unref(self->filter_expr); g_free((gchar *) self->super.type); g_free(self->rule); }
void pdb_action_free(PDBAction *self) { if (self->condition) filter_expr_unref(self->condition); if (self->content_type == RAC_MESSAGE) pdb_message_clean(&self->content.message); g_free(self); }
void log_rewrite_free_method(LogPipe *s) { LogRewrite *self = (LogRewrite *) s; if (self->condition) filter_expr_unref(self->condition); g_free(self->name); log_pipe_free_method(s); }
void tf_cond_free_state(TFCondState *args) { gint i; if (args->filter) filter_expr_unref(args->filter); for (i = 0; i < args->argc; i++) { if (args->argv[i]) log_template_unref(args->argv[i]); } g_free(args); }
gboolean evaluate_testcase(const gchar *msg, FilterExprNode *filter_node) { LogMessage *log_msg; gboolean result; assert_not_null(filter_node, "Constructing an in-list filter"); log_msg = log_msg_new(msg, strlen(msg), NULL, &parse_options); result = filter_expr_eval(filter_node, log_msg); log_msg_unref(log_msg); filter_expr_unref(filter_node); return result; }