1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
/*
* Copyright (c) 2010-2015 Balabit
* Copyright (c) 2010-2015 Balázs Scheidler
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "plugin.h"
#include "template/simple-function.h"
#include "filter/filter-expr.h"
#include "filter/filter-expr-parser.h"
#include "cfg.h"
#include "parse-number.h"
#include "str-format.h"
#include "plugin-types.h"
#include "scratch-buffers.h"
#include <stdlib.h>
#include <errno.h>
#include <string.h>
/* in order to avoid having to declare all construct functions, we
* include them all here. If it causes compilation times to increase
* drastically, we should probably make them into separate compilation
* units. (Bazsi) */
#include "urlencode.c"
#include "numeric-funcs.c"
#include "str-funcs.c"
#include "cond-funcs.c"
#include "ip-funcs.c"
#include "misc-funcs.c"
#include "list-funcs.c"
#include "tf-template.c"
#include "context-funcs.c"
#include "fname-funcs.c"
static Plugin basicfuncs_plugins[] =
{
/* cond-funcs */
TEMPLATE_FUNCTION_PLUGIN(tf_grep, "grep"),
TEMPLATE_FUNCTION_PLUGIN(tf_if, "if"),
TEMPLATE_FUNCTION_PLUGIN(tf_or, "or"),
/* context related funcs */
TEMPLATE_FUNCTION_PLUGIN(tf_context_lookup, "context-lookup"),
TEMPLATE_FUNCTION_PLUGIN(tf_context_length, "context-length"),
TEMPLATE_FUNCTION_PLUGIN(tf_context_values, "context-values"),
/* str-funcs */
TEMPLATE_FUNCTION_PLUGIN(tf_echo, "echo"),
TEMPLATE_FUNCTION_PLUGIN(tf_length, "length"),
TEMPLATE_FUNCTION_PLUGIN(tf_substr, "substr"),
TEMPLATE_FUNCTION_PLUGIN(tf_strip, "strip"),
TEMPLATE_FUNCTION_PLUGIN(tf_sanitize, "sanitize"),
TEMPLATE_FUNCTION_PLUGIN(tf_lowercase, "lowercase"),
TEMPLATE_FUNCTION_PLUGIN(tf_uppercase, "uppercase"),
TEMPLATE_FUNCTION_PLUGIN(tf_replace_delimiter, "replace-delimiter"),
TEMPLATE_FUNCTION_PLUGIN(tf_string_padding, "padding"),
TEMPLATE_FUNCTION_PLUGIN(tf_binary, "binary"),
/* fname-funcs */
TEMPLATE_FUNCTION_PLUGIN(tf_dirname, "dirname"),
TEMPLATE_FUNCTION_PLUGIN(tf_basename, "basename"),
/* list-funcs */
TEMPLATE_FUNCTION_PLUGIN(tf_list_concat, "list-concat"),
TEMPLATE_FUNCTION_PLUGIN(tf_list_head, "list-head"),
TEMPLATE_FUNCTION_PLUGIN(tf_list_nth, "list-nth"),
TEMPLATE_FUNCTION_PLUGIN(tf_list_tail, "list-tail"),
TEMPLATE_FUNCTION_PLUGIN(tf_list_slice, "list-slice"),
TEMPLATE_FUNCTION_PLUGIN(tf_list_count, "list-count"),
TEMPLATE_FUNCTION_PLUGIN(tf_list_append, "list-append"),
/* numeric-funcs */
TEMPLATE_FUNCTION_PLUGIN(tf_num_plus, "+"),
TEMPLATE_FUNCTION_PLUGIN(tf_num_minus, "-"),
TEMPLATE_FUNCTION_PLUGIN(tf_num_multi, "*"),
TEMPLATE_FUNCTION_PLUGIN(tf_num_div, "/"),
TEMPLATE_FUNCTION_PLUGIN(tf_num_mod, "%"),
TEMPLATE_FUNCTION_PLUGIN(tf_num_sum, "sum"),
TEMPLATE_FUNCTION_PLUGIN(tf_num_min, "min"),
TEMPLATE_FUNCTION_PLUGIN(tf_num_max, "max"),
TEMPLATE_FUNCTION_PLUGIN(tf_num_average, "average"),
/* ip-funcs */
TEMPLATE_FUNCTION_PLUGIN(tf_ipv4_to_int, "ipv4-to-int"),
TEMPLATE_FUNCTION_PLUGIN(tf_indent_multi_line, "indent-multi-line"),
/* misc funcs */
TEMPLATE_FUNCTION_PLUGIN(tf_env, "env"),
TEMPLATE_FUNCTION_PLUGIN(tf_template, "template"),
TEMPLATE_FUNCTION_PLUGIN(tf_urlencode, "url-encode"),
TEMPLATE_FUNCTION_PLUGIN(tf_urldecode, "url-decode"),
TEMPLATE_FUNCTION_PLUGIN(tf_base64encode, "base64-encode")
};
gboolean
basicfuncs_module_init(PluginContext *context, CfgArgs *args)
{
plugin_register(context, basicfuncs_plugins, G_N_ELEMENTS(basicfuncs_plugins));
return TRUE;
}
const ModuleInfo module_info =
{
.canonical_name = "basicfuncs",
.version = SYSLOG_NG_VERSION,
.description = "The basicfuncs module provides various template functions for syslog-ng.",
.core_revision = SYSLOG_NG_SOURCE_REVISION,
.plugins = basicfuncs_plugins,
.plugins_len = G_N_ELEMENTS(basicfuncs_plugins),
};
|