syslog-ng source
macros.h
Go to the documentation of this file.
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_MACROS_H_INCLUDED
26 #define TEMPLATE_MACROS_H_INCLUDED
27 
28 #include "syslog-ng.h"
30 #include "eval.h"
31 
32 /* macro IDs */
33 enum
34 {
36 
45 
48 
62 
70 
71  /* only touch this section if you want to add three macros, one w/o
72  * prefix, and a R_ and S_ prefixed macro that relates one of the
73  * timestamps of the log message. */
74 
104 
109 };
110 
111 /* macros (not NV pairs!) that syslog-ng knows about. This was the
112  * earliest mechanism for inserting message-specific information into
113  * texts. It is now superseded by name-value pairs where the value is
114  * text, but remains to be used for time and other metadata.
115  */
116 typedef struct _LogMacroDef
117 {
118  const char *name;
119  int id;
120 } LogMacroDef;
121 
122 extern LogMacroDef macros[];
123 
124 /* low level macro functions */
125 guint log_macro_lookup(const gchar *macro, gint len);
126 gboolean log_macro_expand(gint id, LogTemplateEvalOptions *options,
127  const LogMessage *msg,
128  GString *result, LogMessageValueType *type);
129 gboolean log_macro_expand_simple(gint id, const LogMessage *msg,
130  GString *result, LogMessageValueType *type);
131 
132 void log_macros_global_init(void);
133 void log_macros_global_deinit(void);
134 
135 #endif
NVType LogMessageValueType
Definition: logmsg.h:195
gboolean log_macro_expand_simple(gint id, const LogMessage *msg, GString *result, LogMessageValueType *type)
Definition: macros.c:783
void log_macros_global_deinit(void)
Definition: macros.c:821
guint log_macro_lookup(const gchar *macro, gint len)
Definition: macros.c:790
gboolean log_macro_expand(gint id, LogTemplateEvalOptions *options, const LogMessage *msg, GString *result, LogMessageValueType *type)
Definition: macros.c:450
@ M_RAWMSG_SIZE
Definition: macros.h:59
@ M_DEST_PORT
Definition: macros.h:54
@ M_FACILITY
Definition: macros.h:37
@ M_MSEC
Definition: macros.h:91
@ M_RUNID
Definition: macros.h:66
@ M_MONTH_WEEK
Definition: macros.h:82
@ M_PROTOCOL
Definition: macros.h:58
@ M_SDATA
Definition: macros.h:47
@ M_TIME_FIRST
Definition: macros.h:101
@ M__ASTERISK
Definition: macros.h:69
@ M_WEEK_DAY_ABBREV
Definition: macros.h:94
@ M_FACILITY_NUM
Definition: macros.h:38
@ M_IP_PROTOCOL
Definition: macros.h:57
@ M_SEQNUM
Definition: macros.h:60
@ M_SEC
Definition: macros.h:89
@ M_HOUR
Definition: macros.h:86
@ M_YEAR_DAY
Definition: macros.h:80
@ M_SEVERITY
Definition: macros.h:39
@ M_PRI
Definition: macros.h:44
@ M_WEEK_DAY
Definition: macros.h:93
@ M_RCPTID
Definition: macros.h:65
@ M_PEER_PORT
Definition: macros.h:56
@ M_UNIQID
Definition: macros.h:68
@ M_WEEK
Definition: macros.h:96
@ M_MONTH
Definition: macros.h:81
@ M_PROCESSED_OFS
Definition: macros.h:108
@ M_MONTH_ABBREV
Definition: macros.h:83
@ M_MONTH_NAME
Definition: macros.h:84
@ M_TIME_LAST
Definition: macros.h:102
@ M_ISOWEEK
Definition: macros.h:97
@ M_SYSUPTIME
Definition: macros.h:64
@ M_SEVERITY_NUM
Definition: macros.h:40
@ M_TIME_MACROS_MAX
Definition: macros.h:103
@ M_HOUR12
Definition: macros.h:87
@ M_UNIXTIME
Definition: macros.h:100
@ M_DEST_IP
Definition: macros.h:53
@ M_BSDTAG
Definition: macros.h:43
@ M_STAMP
Definition: macros.h:78
@ M_FULLDATE
Definition: macros.h:76
@ M_STAMP_OFS
Definition: macros.h:106
@ M_CONTEXT_ID
Definition: macros.h:61
@ M_PEER_IP
Definition: macros.h:55
@ M_RECVD_OFS
Definition: macros.h:105
@ M_TZ
Definition: macros.h:99
@ M_DATE
Definition: macros.h:75
@ M_SOURCE_PORT
Definition: macros.h:52
@ M_MIN
Definition: macros.h:88
@ M_YEAR
Definition: macros.h:79
@ M_CSTAMP_OFS
Definition: macros.h:107
@ M_ISODATE
Definition: macros.h:77
@ M_WEEK_DAY_NAME
Definition: macros.h:95
@ M_TZOFFSET
Definition: macros.h:98
@ M_MSGHDR
Definition: macros.h:49
@ M_MESSAGE
Definition: macros.h:50
@ M_DAY
Definition: macros.h:85
@ M_HOST
Definition: macros.h:46
@ M_NONE
Definition: macros.h:35
@ M_SOURCE_IP
Definition: macros.h:51
@ M_HOSTID
Definition: macros.h:67
@ M_USEC
Definition: macros.h:90
@ M_TAGS
Definition: macros.h:42
@ M_TAG
Definition: macros.h:41
@ M_AMPM
Definition: macros.h:92
@ M_LOGHOST
Definition: macros.h:63
LogMacroDef macros[]
Definition: macros.c:49
void log_macros_global_init(void)
Definition: macros.c:804
Definition: macros.h:117
const char * name
Definition: macros.h:118
int id
Definition: macros.h:119
Definition: eval.h:34
GString * result
Definition: test_lexer_block.c:34
LogMessage * msg
Definition: test_rename.c:35