syslog-ng source
msg-generator-source-options.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Balabit
3  * Copyright (c) 2018 László Várady <laszlo.varady@balabit.com>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 as published
7  * by the Free Software Foundation, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * As an additional exemption you are allowed to compile & link against the
19  * OpenSSL libraries as published by the OpenSSL project. See the file
20  * COPYING for details.
21  *
22  */
23 
24 #ifndef MSG_GENERATOR_SOURCE_OPTIONS_H
25 #define MSG_GENERATOR_SOURCE_OPTIONS_H
26 
27 #include "logsource.h"
28 #include "template/templates.h"
29 #include "logmsg/logmsg.h"
30 #include <compat/glib.h>
31 
32 typedef struct
33 {
35  guint freq;
36  gint max_num;
37  LogTemplate *template;
38  GHashTable *name_value;
40 
41 static inline void
42 msg_generator_source_options_defaults(MsgGeneratorSourceOptions *self)
43 {
45  self->freq = 1000;
46 }
47 
48 static inline void
49 msg_generator_source_options_init(MsgGeneratorSourceOptions *self, GlobalConfig *cfg, const gchar *group_name)
50 {
51  log_source_options_init(&self->super, cfg, group_name);
52 }
53 
54 static inline void
55 msg_generator_source_options_destroy(MsgGeneratorSourceOptions *self)
56 {
57  log_template_unref(self->template);
59 }
60 
61 static inline void
62 msg_generator_source_options_set_freq(MsgGeneratorSourceOptions *self, gdouble freq)
63 {
64  self->freq = (guint) (freq * 1000);
65 }
66 
67 static inline void
68 msg_generator_source_options_set_num(MsgGeneratorSourceOptions *self, gint max_num)
69 {
70  self->max_num = max_num;
71 }
72 
73 static inline void
74 msg_generator_source_options_set_template(MsgGeneratorSourceOptions *self, LogTemplate *template)
75 {
76  log_template_unref(self->template);
77  self->template = log_template_ref(template);
78 }
79 static inline void
80 msg_generator_source_options_set_value_pair(MsgGeneratorSourceOptions *self, const gchar *name, LogTemplate *value)
81 {
82  g_hash_table_insert(self->name_value, g_strdup(name), log_template_ref(value));
83 }
84 #endif
const gchar * name
Definition: debugger.c:265
#define g_hash_table_insert
Definition: glib.h:53
void log_source_options_defaults(LogSourceOptions *options)
Definition: logsource.c:851
void log_source_options_init(LogSourceOptions *options, GlobalConfig *cfg, const gchar *group_name)
Definition: logsource.c:866
void log_source_options_destroy(LogSourceOptions *options)
Definition: logsource.c:889
#define self
Definition: rcptid.c:38
Definition: logsource.h:36
Definition: msg-generator-source-options.h:33
LogSourceOptions super
Definition: msg-generator-source-options.h:34
GHashTable * name_value
Definition: msg-generator-source-options.h:38
guint freq
Definition: msg-generator-source-options.h:35
gint max_num
Definition: msg-generator-source-options.h:36
void log_template_unref(LogTemplate *s)
Definition: templates.c:406
LogTemplate * log_template_ref(LogTemplate *s)
Definition: templates.c:398
GlobalConfig * cfg
Definition: test_batched_ack_tracker.c:34
GString * value
Definition: test_decode.c:28