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
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* Fluent Bit
* ==========
* Copyright (C) 2015-2022 The Fluent Bit Authors
*
* 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
*
* 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 FLB_CONFIG_MAP_H
#define FLB_CONFIG_MAP_H
#include <fluent-bit/flb_info.h>
#include <fluent-bit/flb_slist.h>
#include <fluent-bit/flb_sds.h>
#include <monkey/mk_core.h>
/* Configuration types */
#define FLB_CONFIG_MAP_STR 0 /* string */
#define FLB_CONFIG_MAP_STR_PREFIX 1 /* string that starts with */
#define FLB_CONFIG_MAP_INT 2 /* integer */
#define FLB_CONFIG_MAP_BOOL 3 /* boolean */
#define FLB_CONFIG_MAP_DOUBLE 4 /* double */
#define FLB_CONFIG_MAP_SIZE 5 /* string size to integer (e.g: 2M) */
#define FLB_CONFIG_MAP_TIME 6 /* string time to integer seconds (e.g: 2H) */
#define FLB_CONFIG_MAP_DEPRECATED 7 /* for deprecated parameter */
#define FLB_CONFIG_MAP_CLIST 30 /* comma separated list of strings */
#define FLB_CONFIG_MAP_CLIST_1 31 /* split up to 1 node + remaining data */
#define FLB_CONFIG_MAP_CLIST_2 32 /* split up to 2 nodes + remaining data */
#define FLB_CONFIG_MAP_CLIST_3 33 /* split up to 3 nodes + remaining data */
#define FLB_CONFIG_MAP_CLIST_4 34 /* split up to 4 nodes + remaining data */
#define FLB_CONFIG_MAP_SLIST 40 /* empty space separated list of strings */
#define FLB_CONFIG_MAP_SLIST_1 41 /* split up to 1 node + remaining data */
#define FLB_CONFIG_MAP_SLIST_2 42 /* split up to 2 nodes + remaining data */
#define FLB_CONFIG_MAP_SLIST_3 43 /* split up to 3 nodes + remaining data */
#define FLB_CONFIG_MAP_SLIST_4 44 /* split up to 4 nodes + remaining data */
#define FLB_CONFIG_MAP_MULT 1
struct flb_config_map_val {
union {
int i_num; /* FLB_CONFIG_MAP_INT */
char boolean; /* FLB_CONFIG_MAP_BOOL */
double d_num; /* FLB_CONFIG_MAP_DOUBLE */
size_t s_num; /* FLB_CONFIG_MAP_SIZE */
flb_sds_t str; /* FLB_CONFIG_MAP_STR */
struct mk_list *list; /* FLB_CONFIG_MAP_CLIST and FLB_CONFIG_MAP_SLIST */
} val;
struct mk_list *mult;
struct mk_list _head; /* Link to list if this entry is a 'multiple' entry */
};
struct flb_config_map {
/* Public fields used by plugins at registration */
int type; /* type */
flb_sds_t name; /* property name */
flb_sds_t def_value; /* default value */
int flags; /* option flags (e.g: multiple entries allowed) */
int set_property; /* set context property ? (use offset ?) */
uintptr_t offset; /* member offset */
flb_sds_t desc; /* description */
struct flb_config_map_val value; /* lookup value */
struct mk_list _head;
};
#define flb_config_map_foreach(curr, v, head) \
for (curr = (head)->next, v = mk_list_entry(curr, \
struct flb_config_map_val, \
_head); \
curr != (head); curr = curr->next, v = mk_list_entry(curr, \
struct flb_config_map_val, \
_head))
static inline int flb_config_map_mult_type(int type)
{
if (type >= FLB_CONFIG_MAP_CLIST && type <= FLB_CONFIG_MAP_CLIST_4) {
return FLB_CONFIG_MAP_CLIST;
}
if (type >= FLB_CONFIG_MAP_SLIST && type <= FLB_CONFIG_MAP_SLIST_4) {
return FLB_CONFIG_MAP_SLIST;
}
return -1;
}
int flb_config_map_properties_check(char *context_name,
struct mk_list *in_properties,
struct mk_list *map);
struct mk_list *flb_config_map_create(struct flb_config *config,
struct flb_config_map *map);
void flb_config_map_destroy(struct mk_list *list);
int flb_config_map_expected_values(int type);
int flb_config_map_set(struct mk_list *properties, struct mk_list *map, void *context);
#endif
|