syslog-ng source
file_reader.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Balabit
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; 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 LOGGEN_FILE_READER_H_INCLUDED
25 #define LOGGEN_FILE_READER_H_INCLUDED
26 
27 #include "compat/glib.h"
28 #include "compat/compat.h"
29 
30 /* RFC5424 specific constants */
31 #define RFC5424_NIL_VALUE "-"
32 #define RFC5424_DELIMITERS " >"
33 #define RFC5424_BOM ""
34 
35 #define RFC5424_HEADER_TOKEN_NUM 8
36 #define RFC5424_PRI_INDEX 0
37 #define RFC5424_VER_INDEX 1
38 #define RFC5424_TIMESTAMP_INDEX 2
39 #define RFC5424_HOST_NAME_INDEX 3
40 #define RFC5424_APP_NAME_INDEX 4
41 #define RFC5424_PID_INDEX 5
42 #define RFC5424_MSGID_INDEX 6
43 #define RFC5424_SDATA_INDEX 7
44 
45 /* RFC3164 specific constants */
46 #define RFC3164_TIMESTAMP_SIZE 15
47 
48 /* buffer & constants for parsed messages */
49 #define PARS_BUF_PRI_SIZE 3+1
50 #define PARS_BUF_VER_SIZE 2+1
51 #define PARS_BUF_TIME_STAMP_SIZE 128+1
52 #define PARS_BUF_HOST_SIZE 255+1
53 #define PARS_BUF_APP_SIZE 48+1
54 #define PARS_BUF_MSG_ID_SIZE 32+1
55 #define PARS_BUF_PID_SIZE 128+1
56 #define PARS_BUF_SDATA_SIZE 1024+1
57 #define PARS_BUF_MSG_SIZE 4096+1
58 
59 typedef enum _LogFormatType
60 {
65 
66 typedef struct _SyslogMsgElements
67 {
68  gchar pri[PARS_BUF_PRI_SIZE];
69  gchar ver[PARS_BUF_VER_SIZE];
70  gchar time_stamp[PARS_BUF_TIME_STAMP_SIZE];
71  gchar host[PARS_BUF_HOST_SIZE];
72  gchar app[PARS_BUF_APP_SIZE];
73  gchar pid[PARS_BUF_PID_SIZE];
74  gchar msgid[PARS_BUF_MSG_ID_SIZE];
75  gchar sdata[PARS_BUF_SDATA_SIZE];
76  gchar message[PARS_BUF_MSG_SIZE];
78 
79 GOptionEntry *get_file_reader_options(void);
80 int read_next_message_from_file(char *buf, int buflen, int syslog_proto, int thread_index);
81 int init_file_reader(int nr_threads);
82 void close_file_reader(int nr_threads);
83 
84 #endif
int init_file_reader(int nr_threads)
Definition: file_reader.c:55
#define PARS_BUF_VER_SIZE
Definition: file_reader.h:50
#define PARS_BUF_PRI_SIZE
Definition: file_reader.h:49
#define PARS_BUF_PID_SIZE
Definition: file_reader.h:55
GOptionEntry * get_file_reader_options(void)
Definition: file_reader.c:50
#define PARS_BUF_TIME_STAMP_SIZE
Definition: file_reader.h:51
#define PARS_BUF_APP_SIZE
Definition: file_reader.h:53
void close_file_reader(int nr_threads)
Definition: file_reader.c:93
#define PARS_BUF_MSG_ID_SIZE
Definition: file_reader.h:54
int read_next_message_from_file(char *buf, int buflen, int syslog_proto, int thread_index)
Definition: file_reader.c:348
#define PARS_BUF_SDATA_SIZE
Definition: file_reader.h:56
#define PARS_BUF_HOST_SIZE
Definition: file_reader.h:52
LogFormatType
Definition: file_reader.h:60
@ LOG_FORMAT_RFC5424
Definition: file_reader.h:62
@ LOG_FORMAT_RFC3164
Definition: file_reader.h:63
@ LOG_FORMAT_UNKNOWN
Definition: file_reader.h:61
#define PARS_BUF_MSG_SIZE
Definition: file_reader.h:57
Definition: file_reader.h:67