syslog-ng source
evt_internals.h
Go to the documentation of this file.
1 /*
2  * Event Logging API
3  * Copyright (c) 2003 BalaBit IT Ltd.
4  * All rights reserved.
5  * Author: Balazs Scheidler
6  *
7  * EventLog library internal functions/typedefs.
8  *
9  * $Id: evt_internals.h,v 1.4 2004/08/20 19:46:28 bazsi Exp $
10  *
11  * Some of the ideas are based on the discussions on the log-analysis
12  * mailing list (http://www.loganalysis.org/).
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  * 1. Redistributions of source code must retain the above copyright
18  * notice, this list of conditions and the following disclaimer.
19  * 2. Redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in the
21  * documentation and/or other materials provided with the distribution.
22  * 3. Neither the name of BalaBit nor the names of its contributors
23  * may be used to endorse or promote products derived from this software
24  * without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY BALABIT AND CONTRIBUTORS ␁S IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *
38  */
39 
40 #ifndef __EVT_INTERNALS_H_INCLUDED
41 #define __EVT_INTERNALS_H_INCLUDED
42 
43 #include "evtlog.h"
44 
45 #include <syslog-ng-config.h>
46 
47 #ifdef _MSC_VER
48 #include <windows.h>
49 #endif
50 
51 #include <sys/types.h>
52 
53 /* whether to add the given default tag */
54 #define EF_ADD_PID 0x0001
55 #define EF_ADD_PROG 0x0002
56 #define EF_ADD_ISOSTAMP 0x0004
57 #define EF_ADD_UTCSTAMP 0x0008
58 #define EF_ADD_TIMEZONE 0x0010
59 #define EF_ADD_MSGID 0x0020
60 #define EF_ADD_ALL 0x003F
61 
62 #define EF_INITIALIZED 0x8000
63 
64 typedef struct __evttaghook EVTTAGHOOK;
65 typedef struct __evtsyslogopts EVTSYSLOGOPTS;
66 typedef struct __evtstr EVTSTR;
67 
69 {
70  void (*es_openlog)(const char *ident, int option, int facility);
71  void (*es_closelog)(void);
72  void (*es_syslog)(int priority, const char *format, ...) G_GNUC_PRINTF(2, 3);
74 };
75 
77 {
78  int ec_ref;
79  char ec_formatter[32];
80  char *(*ec_formatter_fn)(EVTREC *e);
81  char ec_outmethod[32];
82  int (*ec_outmethod_fn)(EVTREC *e);
83  char *ec_prog;
85  EVTTAGHOOK *ec_tag_hooks;
86  unsigned long ec_flags;
87 };
88 
90 {
92  int (*et_callback)(EVTREC *e, void *user_ptr);
93  void *et_userptr;
94 };
95 
96 struct __evtrec
97 {
98  int ev_ref;
100  char *ev_desc;
101  EVTTAG *ev_pairs;
102  EVTTAG *ev_last_pair;
103  EVTCONTEXT *ev_ctx;
104 };
105 
106 struct __evttag
107 {
108  EVTTAG *et_next;
109  char *et_tag;
110  char *et_value;
111 };
112 
113 struct __evtstr
114 {
115  size_t es_allocated; /* number of allocated characters in es_buf */
116  size_t es_length; /* length of string without trailing NUL */
117  char *es_buf;
118 };
119 
120 /* internal functions */
121 
122 /* event context */
123 EVTCONTEXT *evt_ctx_ref(EVTCONTEXT *ctx);
124 
125 /* event records */
126 EVTREC *evt_rec_ref(EVTREC *e);
127 
128 /* event tag */
129 void evt_tag_free(EVTTAG *et);
130 
131 /* event strings */
132 EVTSTR *evt_str_init(size_t init_alloc);
133 void evt_str_free(EVTSTR *es, int free_buf);
134 int evt_str_append(EVTSTR *es, char *str);
135 int evt_str_append_len(EVTSTR *es, char *str, size_t len);
136 int evt_str_append_escape_bs(EVTSTR *es, char *unescaped, size_t unescaped_len, char escape_char);
137 char *evt_str_get_str(EVTSTR *es);
138 
139 /* syslog linked wrapper */
140 extern EVTSYSLOGOPTS syslog_opts;
141 void evt_syslog_wrapper_init(void);
142 
143 #endif
void evt_str_free(EVTSTR *es, int free_buf)
Definition: evtstr.c:164
int evt_str_append(EVTSTR *es, char *str)
Definition: evtstr.c:83
EVTSTR * evt_str_init(size_t init_alloc)
Definition: evtstr.c:140
EVTCONTEXT * evt_ctx_ref(EVTCONTEXT *ctx)
Definition: evtctx.c:130
void evt_tag_free(EVTTAG *et)
Definition: evttags.c:57
char * evt_str_get_str(EVTSTR *es)
Definition: evtstr.c:134
int evt_str_append_escape_bs(EVTSTR *es, char *unescaped, size_t unescaped_len, char escape_char)
Definition: evtstr.c:89
void evt_syslog_wrapper_init(void)
Definition: evtsyslog.c:85
EVTSYSLOGOPTS syslog_opts
Definition: evtsyslog.c:45
EVTREC * evt_rec_ref(EVTREC *e)
Definition: evtrec.c:126
int evt_str_append_len(EVTSTR *es, char *str, size_t len)
Definition: evtstr.c:67
Definition: evt_internals.h:77
char ec_outmethod[32]
Definition: evt_internals.h:81
int ec_syslog_fac
Definition: evt_internals.h:84
char ec_formatter[32]
Definition: evt_internals.h:79
char * ec_prog
Definition: evt_internals.h:83
EVTTAGHOOK * ec_tag_hooks
Definition: evt_internals.h:85
int ec_ref
Definition: evt_internals.h:78
int(* ec_outmethod_fn)(EVTREC *e)
Definition: evt_internals.h:82
unsigned long ec_flags
Definition: evt_internals.h:86
Definition: evt_internals.h:97
EVTTAG * ev_pairs
Definition: evt_internals.h:101
int ev_syslog_pri
Definition: evt_internals.h:99
char * ev_desc
Definition: evt_internals.h:100
int ev_ref
Definition: evt_internals.h:98
EVTTAG * ev_last_pair
Definition: evt_internals.h:102
EVTCONTEXT * ev_ctx
Definition: evt_internals.h:103
Definition: evt_internals.h:114
size_t es_length
Definition: evt_internals.h:116
size_t es_allocated
Definition: evt_internals.h:115
char * es_buf
Definition: evt_internals.h:117
Definition: evt_internals.h:69
void(* es_closelog)(void)
Definition: evt_internals.h:71
void(* es_openlog)(const char *ident, int option, int facility)
Definition: evt_internals.h:70
void(* es_syslog)(int priority, const char *format,...) G_GNUC_PRINTF(2
Definition: evt_internals.h:72
void(*) in es_options)
Definition: evt_internals.h:72
Definition: evt_internals.h:107
EVTTAG * et_next
Definition: evt_internals.h:108
char * et_tag
Definition: evt_internals.h:109
char * et_value
Definition: evt_internals.h:110
Definition: evt_internals.h:90
int(* et_callback)(EVTREC *e, void *user_ptr)
Definition: evt_internals.h:92
struct __evttaghook * et_next
Definition: evt_internals.h:91
void * et_userptr
Definition: evt_internals.h:93