blob: 7c0aa28904d9bd7d0db623787693efd3d3da2abd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/* header for lookup.c
*
* Copyright 2013-2023 Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* -or-
* see COPYING.ASL20 in the source distribution
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef INCLUDED_LOOKUP_H
#define INCLUDED_LOOKUP_H
#include <libestr.h>
#define STRING_LOOKUP_TABLE 1
#define ARRAY_LOOKUP_TABLE 2
#define SPARSE_ARRAY_LOOKUP_TABLE 3
#define STUBBED_LOOKUP_TABLE 4
#define LOOKUP_KEY_TYPE_STRING 1
#define LOOKUP_KEY_TYPE_UINT 2
#define LOOKUP_KEY_TYPE_NONE 3
struct lookup_tables_s {
lookup_ref_t *root; /* the root of the template list */
lookup_ref_t *last; /* points to the last element of the template list */
};
struct lookup_array_tab_s {
uint32_t first_key;
uchar **interned_val_refs;
};
struct lookup_sparseArray_tab_entry_s {
uint32_t key;
uchar *interned_val_ref;
};
struct lookup_sparseArray_tab_s {
lookup_sparseArray_tab_entry_t *entries;
};
struct lookup_string_tab_entry_s {
uchar *key;
uchar *interned_val_ref;
};
struct lookup_string_tab_s {
lookup_string_tab_entry_t *entries;
};
struct lookup_ref_s {
pthread_rwlock_t rwlock; /* protect us in case of dynamic reloads */
uchar *name;
uchar *filename;
lookup_t *self;
lookup_ref_t *next;
/* reload specific attributes */
pthread_mutex_t reloader_mut; /* signaling + access to reload-flow variables*/
/* rwlock(above) may be acquired inside critical-section reloader_mut guards */
pthread_cond_t run_reloader;
pthread_t reloader;
pthread_attr_t reloader_thd_attr;
uchar *stub_value_for_reload_failure;
uint8_t do_reload;
uint8_t do_stop;
uint8_t reload_on_hup;
};
typedef es_str_t* (lookup_fn_t)(lookup_t*, lookup_key_t);
/* a single lookup table */
struct lookup_s {
uint32_t nmemb;
uint8_t type;
uint8_t key_type;
union {
lookup_string_tab_t *str;
lookup_array_tab_t *arr;
lookup_sparseArray_tab_t *sprsArr;
} table;
uint32_t interned_val_count;
uchar **interned_vals;
uchar *nomatch;
lookup_fn_t *lookup;
};
union lookup_key_u {
uchar* k_str;
uint32_t k_uint;
};
/* prototypes */
void lookupInitCnf(lookup_tables_t *lu_tabs);
rsRetVal lookupTableDefProcessCnf(struct cnfobj *o);
lookup_ref_t *lookupFindTable(uchar *name);
es_str_t * lookupKey(lookup_ref_t *pThis, lookup_key_t key);
void lookupDestroyCnf(void);
void lookupClassExit(void);
void lookupDoHUP(void);
rsRetVal lookupReload(lookup_ref_t *pThis, const uchar *stub_value_if_reload_fails);
uint lookupPendingReloadCount(void);
rsRetVal lookupClassInit(void);
void lookupActivateConf(void);
#endif /* #ifndef INCLUDED_LOOKUP_H */
|