syslog-ng source
add-contextual-data-selector.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Balabit
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 2 as published
6  * by the Free Software Foundation, or (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * As an additional exemption you are allowed to compile & link against the
18  * OpenSSL libraries as published by the OpenSSL project. See the file
19  * COPYING for details.
20  *
21  */
22 
23 #ifndef ADD_CONTEXTUAL_DATA_SELECTOR_H_INCLUDED
24 #define ADD_CONTEXTUAL_DATA_SELECTOR_H_INCLUDED
25 
26 #include "logmsg/logmsg.h"
27 #include "context-info-db.h"
28 
29 typedef struct _AddContextualDataSelector AddContextualDataSelector;
30 
32 {
34  gchar *(*resolve)(AddContextualDataSelector *self, LogMessage *msg);
35  void (*free)(AddContextualDataSelector *self);
36  AddContextualDataSelector *(*clone)(AddContextualDataSelector *self, GlobalConfig *cfg);
37  gboolean (*init)(AddContextualDataSelector *self, GList *ordered_selectors);
38 };
39 
40 static inline gchar *
41 add_contextual_data_selector_resolve(AddContextualDataSelector *self, LogMessage *msg)
42 {
43  if (self && self->resolve)
44  {
45  return self->resolve(self, msg);
46  }
47 
48  return NULL;
49 }
50 
51 static inline void
52 add_contextual_data_selector_free(AddContextualDataSelector *self)
53 {
54  if (self && self->free)
55  {
56  self->free(self);
57  }
58  g_free(self);
59 }
60 
61 static inline gboolean
62 add_contextual_data_selector_init(AddContextualDataSelector *self, GList *ordered_selectors)
63 {
64  if (self && self->init)
65  {
66  return self->init(self, ordered_selectors);
67  }
68 
69  return FALSE;
70 }
71 
72 static inline AddContextualDataSelector *
73 add_contextual_data_selector_clone(AddContextualDataSelector *self, GlobalConfig *cfg)
74 {
75  if (self && self->clone)
76  {
77  return self->clone(self, cfg);
78  }
79 
80  return NULL;
81 }
82 
83 static inline gboolean
84 add_contextual_data_selector_is_ordering_required(AddContextualDataSelector *self)
85 {
86  return self->ordering_required;
87 }
88 
89 #endif
#define self
Definition: rcptid.c:38
Definition: add-contextual-data-selector.h:32
gboolean(* init)(AddContextualDataSelector *self, GList *ordered_selectors)
Definition: add-contextual-data-selector.h:37
void(* free)(AddContextualDataSelector *self)
Definition: add-contextual-data-selector.h:35
gboolean ordering_required
Definition: add-contextual-data-selector.h:33
GlobalConfig * cfg
Definition: test_batched_ack_tracker.c:34
LogMessage * msg
Definition: test_rename.c:35