Skip to content

Commit 3b26484

Browse files
cosmo0920edsiper
authored andcommitted
cfl_record_accessor: Implement generic CFL based record accessor
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 70a7ecf commit 3b26484

File tree

3 files changed

+1047
-0
lines changed

3 files changed

+1047
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2+
3+
/* Fluent Bit
4+
* ==========
5+
* Copyright (C) 2015-2024 The Fluent Bit Authors
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
#ifndef FLB_CFL_RECORD_ACCESSOR_H
21+
#define FLB_CFL_RECORD_ACCESSOR_H
22+
23+
#include <fluent-bit/flb_info.h>
24+
#include <fluent-bit/flb_regex.h>
25+
#include <fluent-bit/flb_sds.h>
26+
#include <fluent-bit/flb_sds_list.h>
27+
#include <monkey/mk_core.h>
28+
#include <cfl/cfl.h>
29+
30+
struct flb_cfl_record_accessor {
31+
size_t size_hint;
32+
flb_sds_t pattern;
33+
struct mk_list list; /* List of parsed strings */
34+
struct mk_list _head; /* Head to custom list (only used by flb_mp.h) */
35+
};
36+
void flb_cfl_ra_destroy(struct flb_cfl_record_accessor *cra);
37+
int flb_cfl_ra_subkey_count(struct flb_cfl_record_accessor *cra);
38+
struct flb_cfl_record_accessor *flb_cfl_ra_create(char *str, int translate_env);
39+
flb_sds_t flb_cfl_ra_create_str_from_list(struct flb_sds_list *str_list);
40+
struct flb_cfl_record_accessor *flb_cfl_ra_create_from_list(struct flb_sds_list *str_list, int translate_env);
41+
flb_sds_t flb_cfl_ra_translate(struct flb_cfl_record_accessor *cra,
42+
char *tag, int tag_len,
43+
struct cfl_variant var, struct flb_regex_search *result);
44+
flb_sds_t flb_cfl_ra_translate_check(struct flb_cfl_record_accessor *cra,
45+
char *tag, int tag_len,
46+
struct cfl_variant var, struct flb_regex_search *result,
47+
int check);
48+
void flb_cfl_ra_dump(struct flb_cfl_record_accessor *cra);
49+
int flb_cfl_ra_is_static(struct flb_cfl_record_accessor *cra);
50+
int flb_cfl_ra_strcmp(struct flb_cfl_record_accessor *ra, struct cfl_variant var,
51+
char *str, int len);
52+
int flb_cfl_ra_regex_match(struct flb_cfl_record_accessor *cra, struct cfl_variant var,
53+
struct flb_regex *regex, struct flb_regex_search *result);
54+
int flb_cfl_ra_get_kv_pair(struct flb_cfl_record_accessor *ra,
55+
struct cfl_variant var,
56+
cfl_sds_t *start_key,
57+
cfl_sds_t *out_key, struct cfl_variant **out_val);
58+
struct flb_cfl_ra_value *flb_cfl_ra_get_value_object(struct flb_cfl_record_accessor *cra,
59+
struct cfl_variant var);
60+
int flb_cfl_ra_update_kv_pair(struct flb_cfl_record_accessor *cra, struct cfl_variant var,
61+
cfl_sds_t in_key, struct cfl_variant *in_val);
62+
int flb_cfl_ra_append_kv_pair(struct flb_cfl_record_accessor *cra, struct cfl_variant var,
63+
struct cfl_variant *in_val);
64+
#endif

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ set(src
8686
flb_notification.c
8787
flb_lock.c
8888
flb_cfl_ra_key.c
89+
flb_cfl_record_accessor.c
8990
)
9091

9192
# Config format

0 commit comments

Comments
 (0)