-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #269 from OverOrion/filterx-drop-done
Filterx: add drop/done
- Loading branch information
Showing
15 changed files
with
453 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2024 Axoflow | ||
* Copyright (c) 2024 Szilard Parrag <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As an additional exemption you are allowed to compile & link against the | ||
* OpenSSL libraries as published by the OpenSSL project. See the file | ||
* COPYING for details. | ||
* | ||
*/ | ||
|
||
|
||
#include "filterx/expr-done.h" | ||
#include "filterx/filterx-eval.h" | ||
#include "filterx/object-primitive.h" | ||
|
||
static FilterXObject * | ||
_eval(FilterXExpr *s) | ||
{ | ||
FilterXEvalContext *context = filterx_eval_get_context(); | ||
context->eval_control_modifier = FXC_DONE; | ||
|
||
return filterx_boolean_new(TRUE); | ||
} | ||
|
||
FilterXExpr * | ||
filterx_expr_done(void) | ||
{ | ||
FilterXExpr *self = g_new0(FilterXExpr, 1); | ||
filterx_expr_init_instance(self); | ||
self->eval = _eval; | ||
|
||
return self; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2024 Axoflow | ||
* Copyright (c) 2024 Szilard Parrag <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As an additional exemption you are allowed to compile & link against the | ||
* OpenSSL libraries as published by the OpenSSL project. See the file | ||
* COPYING for details. | ||
* | ||
*/ | ||
|
||
#ifndef FILTERX_FUNC_DONE_H_INCLUDED | ||
#define FILTERX_FUNC_DONE_H_INCLUDED | ||
|
||
#include "filterx/expr-function.h" | ||
|
||
FilterXExpr *filterx_expr_done(void); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2024 Axoflow | ||
* Copyright (c) 2024 Szilard Parrag <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As an additional exemption you are allowed to compile & link against the | ||
* OpenSSL libraries as published by the OpenSSL project. See the file | ||
* COPYING for details. | ||
* | ||
*/ | ||
|
||
#include "filterx/expr-drop.h" | ||
#include "filterx/filterx-eval.h" | ||
#include "filterx/object-primitive.h" | ||
|
||
static FilterXObject * | ||
_eval(FilterXExpr *s) | ||
{ | ||
FilterXEvalContext *context = filterx_eval_get_context(); | ||
context->eval_control_modifier = FXC_DROP; | ||
|
||
return filterx_boolean_new(TRUE); | ||
} | ||
|
||
FilterXExpr * | ||
filterx_expr_drop_msg(void) | ||
{ | ||
FilterXExpr *self = g_new0(FilterXExpr, 1); | ||
filterx_expr_init_instance(self); | ||
self->eval = _eval; | ||
|
||
return self; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2024 Axoflow | ||
* Copyright (c) 2024 Szilard Parrag <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As an additional exemption you are allowed to compile & link against the | ||
* OpenSSL libraries as published by the OpenSSL project. See the file | ||
* COPYING for details. | ||
* | ||
*/ | ||
|
||
#ifndef FILTERX_EXPR_DROP_H_INCLUDED | ||
#define FILTERX_EXPR_DROP_H_INCLUDED | ||
#include "filterx/expr-function.h" | ||
|
||
FilterXExpr *filterx_expr_drop_msg(void); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright (c) 2023 Balazs Scheidler <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As an additional exemption you are allowed to compile & link against the | ||
* OpenSSL libraries as published by the OpenSSL project. See the file | ||
* COPYING for details. | ||
* | ||
*/ | ||
|
||
#include "filterx/filterx-error.h" | ||
#include "scratch-buffers.h" | ||
|
||
void | ||
filterx_error_clear(FilterXError *error) | ||
{ | ||
filterx_object_unref(error->object); | ||
if (error->free_info) | ||
g_free(error->info); | ||
memset(error, 0, sizeof(*error)); | ||
} | ||
|
||
EVTTAG * | ||
filterx_error_format(FilterXError *error) | ||
{ | ||
|
||
if (!error->message) | ||
return evt_tag_str("error", "Error information unset"); | ||
|
||
const gchar *extra_info = NULL; | ||
|
||
if (error->info) | ||
{ | ||
extra_info = error->info; | ||
} | ||
else if (error->object) | ||
{ | ||
GString *buf = scratch_buffers_alloc(); | ||
|
||
if (!filterx_object_repr(error->object, buf)) | ||
{ | ||
LogMessageValueType t; | ||
if (!filterx_object_marshal(error->object, buf, &t)) | ||
g_assert_not_reached(); | ||
} | ||
extra_info = buf->str; | ||
} | ||
|
||
return evt_tag_printf("error", "%s%s%s", | ||
error->message, | ||
extra_info ? ": " : "", | ||
extra_info ? : ""); | ||
} | ||
|
||
EVTTAG * | ||
filterx_error_format_location(FilterXError *error) | ||
{ | ||
return filterx_expr_format_location_tag(error->expr); | ||
} | ||
|
||
void | ||
filterx_error_set_values(FilterXError *error, const gchar *message, FilterXExpr *expr, FilterXObject *object) | ||
{ | ||
error->message = message; | ||
error->expr = expr; | ||
error->object = filterx_object_ref(object); | ||
} | ||
|
||
void | ||
filterx_error_set_info(FilterXError *error, gchar *info, gboolean free_info) | ||
{ | ||
error->info = info; | ||
error->free_info = free_info; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2023 Balazs Scheidler <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As an additional exemption you are allowed to compile & link against the | ||
* OpenSSL libraries as published by the OpenSSL project. See the file | ||
* COPYING for details. | ||
* | ||
*/ | ||
|
||
|
||
#ifndef FILTERX_ERROR_H_INCLUDED | ||
#define FILTERX_ERROR_H_INCLUDED | ||
|
||
#include "filterx/filterx-scope.h" | ||
#include "filterx/filterx-expr.h" | ||
#include "template/eval.h" | ||
|
||
typedef struct _FilterXError | ||
{ | ||
const gchar *message; | ||
FilterXExpr *expr; | ||
FilterXObject *object; | ||
gchar *info; | ||
gboolean free_info; | ||
} FilterXError; | ||
|
||
void filterx_error_clear(FilterXError *error); | ||
EVTTAG *filterx_error_format(FilterXError *error); | ||
EVTTAG *filterx_error_format_location(FilterXError *error); | ||
void filterx_error_set_info(FilterXError *error, gchar *info, gboolean free_info); | ||
void filterx_error_set_values(FilterXError *error, const gchar *message, FilterXExpr *expr, FilterXObject *object); | ||
|
||
|
||
#endif |
Oops, something went wrong.