1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 /*  Fluent Bit
4  *  ==========
5  *  Copyright (C) 2019-2021 The Fluent Bit Authors
6  *  Copyright (C) 2015-2018 Treasure Data Inc.
7  *
8  *  Licensed under the Apache License, Version 2.0 (the "License");
9  *  you may not use this file except in compliance with the License.
10  *  You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  *  Unless required by applicable law or agreed to in writing, software
15  *  distributed under the License is distributed on an "AS IS" BASIS,
16  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  *  See the License for the specific language governing permissions and
18  *  limitations under the License.
19  */
20 
21 #ifndef FLB_RECORD_ACCESSOR_H
22 #define FLB_RECORD_ACCESSOR_H
23 
24 #include <fluent-bit/flb_info.h>
25 #include <fluent-bit/flb_regex.h>
26 #include <monkey/mk_core.h>
27 #include <msgpack.h>
28 
29 struct flb_record_accessor {
30     size_t size_hint;
31     flb_sds_t pattern;
32     struct mk_list list;         /* List of parsed strings */
33     struct mk_list _head;        /* Head to custom list (only used by flb_mp.h) */
34 };
35 
36 struct flb_record_accessor *flb_ra_create(char *str, int translate_env);
37 void flb_ra_destroy(struct flb_record_accessor *ra);
38 void flb_ra_dump(struct flb_record_accessor *ra);
39 flb_sds_t flb_ra_translate(struct flb_record_accessor *ra,
40                            char *tag, int tag_len,
41                            msgpack_object map, struct flb_regex_search *result);
42 int flb_ra_is_static(struct flb_record_accessor *ra);
43 int flb_ra_strcmp(struct flb_record_accessor *ra, msgpack_object map,
44                   char *str, int len);
45 int flb_ra_regex_match(struct flb_record_accessor *ra, msgpack_object map,
46                        struct flb_regex *regex,
47                        struct flb_regex_search *result);
48 
49 int flb_ra_get_kv_pair(struct flb_record_accessor *ra, msgpack_object map,
50                        msgpack_object **start_key,
51                        msgpack_object **out_key, msgpack_object **out_val);
52 
53 struct flb_ra_value *flb_ra_get_value_object(struct flb_record_accessor *ra,
54                                              msgpack_object map);
55 
56 #endif
57