Skip to content

Commit

Permalink
filterx: add has-sdata() function
Browse files Browse the repository at this point in the history
Signed-off-by: Szilard Parrag <[email protected]>
  • Loading branch information
OverOrion committed Aug 7, 2024
1 parent d7eca3a commit 0642d73
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/filterx/filterx-globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ _simple_init(void)
g_assert(filterx_builtin_simple_function_register("upper", filterx_simple_function_upper));
g_assert(filterx_builtin_simple_function_register("is_sdata_from_enterprise",
filterx_simple_function_is_sdata_from_enterprise));
g_assert(filterx_builtin_simple_function_register("has_sdata",
filterx_simple_function_has_sdata));
}

static void
Expand Down
15 changes: 15 additions & 0 deletions lib/filterx/func-sdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,18 @@ filterx_simple_function_is_sdata_from_enterprise(FilterXExpr *s, GPtrArray *args
filterx_object_unref(obj);
return filterx_boolean_new(contains);
}


FilterXObject *
filterx_simple_function_has_sdata(FilterXExpr *s, GPtrArray *args)
{
if (args && args->len != 0)
{
filterx_simple_function_argument_error(s, "Incorrect number of arguments", FALSE);
return NULL;
}

FilterXEvalContext *context = filterx_eval_get_context();
LogMessage *msg = context->msgs[0];
return filterx_boolean_new(msg->num_sdata != 0);
}
1 change: 1 addition & 0 deletions lib/filterx/func-sdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
#include "filterx/expr-function.h"

FilterXObject *filterx_simple_function_is_sdata_from_enterprise(FilterXExpr *s, GPtrArray *args);
FilterXObject *filterx_simple_function_has_sdata(FilterXExpr *s, GPtrArray *args);

#endif

0 comments on commit 0642d73

Please sign in to comment.