1 /*
2  * Copyright (c) 2002-2014 Balabit
3  * Copyright (c) 1998-2014 Balázs Scheidler
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  *
19  * As an additional exemption you are allowed to compile & link against the
20  * OpenSSL libraries as published by the OpenSSL project. See the file
21  * COPYING for details.
22  *
23  */
24 
25 #ifndef TEMPLATE_REPR_H_INCLUDED
26 #define TEMPLATE_REPR_H_INCLUDED
27 
28 #include "template/function.h"
29 #include "template/macros.h"
30 #include "logmsg/logmsg.h"
31 
32 enum
33 {
34   LTE_MACRO,
35   LTE_VALUE,
36   LTE_FUNC
37 };
38 
39 typedef struct _LogTemplateElem
40 {
41   gsize text_len;
42   gchar *text;
43   gchar *default_value;
44   guint16 msg_ref;
45   guint8 type;
46   union
47   {
48     guint macro;
49     NVHandle value_handle;
50     struct
51     {
52       LogTemplateFunction *ops;
53       gpointer state;
54     } func;
55   };
56 } LogTemplateElem;
57 
58 
59 LogTemplateElem *log_template_elem_new_macro(const gchar *text, guint macro, gchar *default_value, gint msg_ref);
60 LogTemplateElem *log_template_elem_new_value(const gchar *text, gchar *value_name, gchar *default_value, gint msg_ref);
61 LogTemplateElem *log_template_elem_new_func(LogTemplate *template,
62                                             const gchar *text, gint argc, gchar *argv[], gint msg_ref,
63                                             GError **error);
64 
65 static inline gboolean
log_template_elem_is_literal_string(const LogTemplateElem * self)66 log_template_elem_is_literal_string(const LogTemplateElem *self)
67 {
68   return self->type == LTE_MACRO && self->macro == M_NONE;
69 }
70 
71 void log_template_elem_free_list(GList *el);
72 
73 
74 #endif
75