summaryrefslogtreecommitdiffstats
path: root/fluent-bit/lib/cfl/include
diff options
context:
space:
mode:
Diffstat (limited to 'fluent-bit/lib/cfl/include')
-rw-r--r--fluent-bit/lib/cfl/include/CMakeLists.txt17
-rw-r--r--fluent-bit/lib/cfl/include/cfl/cfl.h42
-rw-r--r--fluent-bit/lib/cfl/include/cfl/cfl_array.h62
-rw-r--r--fluent-bit/lib/cfl/include/cfl/cfl_checksum.h27
-rw-r--r--fluent-bit/lib/cfl/include/cfl/cfl_compat.h46
-rw-r--r--fluent-bit/lib/cfl/include/cfl/cfl_found.h47
-rw-r--r--fluent-bit/lib/cfl/include/cfl/cfl_hash.h38
-rw-r--r--fluent-bit/lib/cfl/include/cfl/cfl_info.h.in28
-rw-r--r--fluent-bit/lib/cfl/include/cfl/cfl_kv.h43
-rw-r--r--fluent-bit/lib/cfl/include/cfl/cfl_kvlist.h76
-rw-r--r--fluent-bit/lib/cfl/include/cfl/cfl_list.h236
-rw-r--r--fluent-bit/lib/cfl/include/cfl/cfl_log.h35
-rw-r--r--fluent-bit/lib/cfl/include/cfl/cfl_sds.h65
-rw-r--r--fluent-bit/lib/cfl/include/cfl/cfl_time.h27
-rw-r--r--fluent-bit/lib/cfl/include/cfl/cfl_variant.h65
-rw-r--r--fluent-bit/lib/cfl/include/cfl/cfl_version.h.in36
16 files changed, 890 insertions, 0 deletions
diff --git a/fluent-bit/lib/cfl/include/CMakeLists.txt b/fluent-bit/lib/cfl/include/CMakeLists.txt
new file mode 100644
index 00000000..bf2e3879
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/CMakeLists.txt
@@ -0,0 +1,17 @@
+file(GLOB cflHeaders "cfl/*.h")
+install(FILES ${cflHeaders}
+ DESTINATION ${CFL_INSTALL_INCLUDEDIR}/cfl
+ COMPONENT headers
+ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+
+# xxHash
+if(CFL_INSTALL_BUNDLED_XXHASH_HEADERS)
+ install(FILES ${CFL_ROOT}/lib/xxhash/xxh3.h
+ DESTINATION ${CFL_INSTALL_INCLUDEDIR}
+ COMPONENT headers
+ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+ install(FILES ${CFL_ROOT}/lib/xxhash/xxhash.h
+ DESTINATION ${CFL_INSTALL_INCLUDEDIR}
+ COMPONENT headers
+ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+endif()
diff --git a/fluent-bit/lib/cfl/include/cfl/cfl.h b/fluent-bit/lib/cfl/include/cfl/cfl.h
new file mode 100644
index 00000000..fee8fcf4
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/cfl/cfl.h
@@ -0,0 +1,42 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* CFL
+ * ===
+ * Copyright (C) 2022 The CFL 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 CFL_H
+#define CFL_H
+
+#define CFL_FALSE 0
+#define CFL_TRUE !CFL_FALSE
+
+/* headers that are needed in general */
+#include <cfl/cfl_info.h>
+#include <cfl/cfl_version.h>
+#include <cfl/cfl_compat.h>
+#include <cfl/cfl_log.h>
+#include <cfl/cfl_sds.h>
+#include <cfl/cfl_list.h>
+#include <cfl/cfl_hash.h>
+#include <cfl/cfl_array.h>
+#include <cfl/cfl_kv.h>
+#include <cfl/cfl_kvlist.h>
+#include <cfl/cfl_time.h>
+#include <cfl/cfl_variant.h>
+
+int cfl_init();
+
+#endif
diff --git a/fluent-bit/lib/cfl/include/cfl/cfl_array.h b/fluent-bit/lib/cfl/include/cfl/cfl_array.h
new file mode 100644
index 00000000..e260d24d
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/cfl/cfl_array.h
@@ -0,0 +1,62 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* CFL
+ * ===
+ * Copyright (C) 2022 The CFL 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 CFL_ARRAY_H
+#define CFL_ARRAY_H
+
+#include <stdio.h>
+#include <cfl/cfl_variant.h>
+
+struct cfl_array {
+ int resizable;
+ struct cfl_variant **entries;
+ size_t slot_count;
+ size_t entry_count;
+};
+
+struct cfl_array *cfl_array_create(size_t slot_count);
+void cfl_array_destroy(struct cfl_array *array);
+
+static inline struct cfl_variant *cfl_array_fetch_by_index(struct cfl_array *array,
+ size_t position)
+{
+ if (position >= array->entry_count) {
+ return NULL;
+ }
+
+ return array->entries[position];
+}
+
+int cfl_array_resizable(struct cfl_array *array, int v);
+int cfl_array_remove_by_index(struct cfl_array *array, size_t position);
+int cfl_array_remove_by_reference(struct cfl_array *array, struct cfl_variant *value);
+int cfl_array_append(struct cfl_array *array, struct cfl_variant *value);
+int cfl_array_append_string(struct cfl_array *array, char *value);
+int cfl_array_append_bytes(struct cfl_array *array, char *value, size_t length);
+int cfl_array_append_reference(struct cfl_array *array, void *value);
+int cfl_array_append_bool(struct cfl_array *array, int value);
+int cfl_array_append_int64(struct cfl_array *array, int64_t value);
+int cfl_array_append_double(struct cfl_array *array, double value);
+int cfl_array_append_array(struct cfl_array *array, struct cfl_array *value);
+int cfl_array_append_new_array(struct cfl_array *array, size_t size);
+int cfl_array_append_kvlist(struct cfl_array *array, struct
+cfl_kvlist *value);
+int cfl_array_print(FILE *fp, struct cfl_array *array);
+
+#endif
diff --git a/fluent-bit/lib/cfl/include/cfl/cfl_checksum.h b/fluent-bit/lib/cfl/include/cfl/cfl_checksum.h
new file mode 100644
index 00000000..d9690aa8
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/cfl/cfl_checksum.h
@@ -0,0 +1,27 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* CFL
+ * ===
+ * Copyright (C) 2022 The CFL 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 CFL_CHECKSUM_H
+#define CFL_CHECKSUM_H
+
+#include <stdint.h>
+
+uint32_t cfl_checksum_crc32c(unsigned char *buffer, size_t length);
+
+#endif
diff --git a/fluent-bit/lib/cfl/include/cfl/cfl_compat.h b/fluent-bit/lib/cfl/include/cfl/cfl_compat.h
new file mode 100644
index 00000000..36c56233
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/cfl/cfl_compat.h
@@ -0,0 +1,46 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* CFL
+ * ===
+ * Copyright (C) 2022 The CFL 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.
+ */
+
+/*
+ * This file contains compatibility functions and macros for various platforms.
+ *
+ * Including this header file should make platforms behave more consistently;
+ * Add more macros if you find any missing features.
+ */
+
+#ifndef CFL_COMPAT_H
+#define CFL_COMPAT_H
+
+#ifdef CFL_SYSTEM_WINDOWS
+
+#ifdef _MSC_VER
+/*
+ * cl.exe that is one of the C++ compilers for Windows prefers
+ * to add an underscore to each POSIX function.
+ * To suppress compiler warnings, we need these trivial macros.
+ * For MSYS2 platform on Windows, we don't need to do.
+ */
+#define timezone _timezone
+#define tzname _tzname
+#define strncasecmp _strnicmp
+#define timegm _mkgmtime
+#endif /* _MSC_VER */
+
+#endif
+#endif
diff --git a/fluent-bit/lib/cfl/include/cfl/cfl_found.h b/fluent-bit/lib/cfl/include/cfl/cfl_found.h
new file mode 100644
index 00000000..d6416be8
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/cfl/cfl_found.h
@@ -0,0 +1,47 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* CFL
+ * ===
+ * Copyright (C) 2022 The CFL 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.
+ */
+
+/*
+ * This is a dummy header that can be used by parent projects to check if
+ * CFL headers are found in their path.
+ *
+ * Why ?, because <cfl/cfl.h> includes "cfl_info.h" which is only generated once
+ * CMake runs in CFL project. Likely this check is done before that.
+ *
+ *
+ * In order to use it, the caller might try to use check_c_source_compiles() CMake function
+ * and try to include this header and invoke the inline function defined here, e.g:
+ *
+ * check_c_source_compiles("
+ * include <cfl/cfl_found.h>
+ *
+ * int main() {
+ * return cfl_found();
+ * }" CFL_FOUND)
+ */
+
+#ifndef CFL_FOUND_H
+#define CFL_FOUND_H
+
+static inline int cfl_found()
+{
+ return 0;
+}
+
+#endif
diff --git a/fluent-bit/lib/cfl/include/cfl/cfl_hash.h b/fluent-bit/lib/cfl/include/cfl/cfl_hash.h
new file mode 100644
index 00000000..fb2fc4e6
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/cfl/cfl_hash.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* CFL
+ * ===
+ * Copyright (C) 2022 The CFL 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 CFL_HASH_H
+#define CFL_HASH_H
+
+/* NOTE: this is just a wrapper for naming convention */
+
+#include <stdint.h>
+#include "xxh3.h"
+
+#define cfl_hash_64bits_t XXH64_hash_t
+#define cfl_hash_state_t XXH3_state_t
+#define cfl_hash_64bits_reset XXH3_64bits_reset
+#define cfl_hash_64bits_update XXH3_64bits_update
+#define cfl_hash_64bits_digest XXH3_64bits_digest
+#define cfl_hash_64bits XXH3_64bits
+
+#define cfl_hash_128bits_t XXH128_hash_t
+#define cfl_hash_128bits XXH3_128bits
+
+#endif
diff --git a/fluent-bit/lib/cfl/include/cfl/cfl_info.h.in b/fluent-bit/lib/cfl/include/cfl/cfl_info.h.in
new file mode 100644
index 00000000..e2f0d511
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/cfl/cfl_info.h.in
@@ -0,0 +1,28 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* CFL
+ * ===
+ * Copyright (C) 2022 The CFL 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 CFL_INFO_H
+#define CFL_INFO_H
+
+#define CFL_SOURCE_DIR "@CMAKE_SOURCE_DIR@"
+
+/* General flags set by /CMakeLists.txt */
+@CFL_BUILD_FLAGS@
+
+#endif
diff --git a/fluent-bit/lib/cfl/include/cfl/cfl_kv.h b/fluent-bit/lib/cfl/include/cfl/cfl_kv.h
new file mode 100644
index 00000000..f44c5be6
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/cfl/cfl_kv.h
@@ -0,0 +1,43 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* CFL
+ * ===
+ * Copyright (C) 2022 The CFL 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 CFL_KV_H
+#define CFL_KV_H
+
+#include <cfl/cfl_info.h>
+#include <cfl/cfl_sds.h>
+#include <cfl/cfl_list.h>
+
+struct cfl_kv {
+ cfl_sds_t key;
+ cfl_sds_t val;
+ struct cfl_list _head;
+};
+
+void cfl_kv_init(struct cfl_list *list);
+struct cfl_kv *cfl_kv_item_create_len(struct cfl_list *list,
+ char *k_buf, size_t k_len,
+ char *v_buf, size_t v_len);
+struct cfl_kv *cfl_kv_item_create(struct cfl_list *list,
+ char *k_buf, char *v_buf);
+void cfl_kv_item_destroy(struct cfl_kv *kv);
+void cfl_kv_release(struct cfl_list *list);
+const char *cfl_kv_get_key_value(const char *key, struct cfl_list *list);
+
+#endif
diff --git a/fluent-bit/lib/cfl/include/cfl/cfl_kvlist.h b/fluent-bit/lib/cfl/include/cfl/cfl_kvlist.h
new file mode 100644
index 00000000..5f920e58
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/cfl/cfl_kvlist.h
@@ -0,0 +1,76 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* CFL
+ * ===
+ * Copyright (C) 2022 The CFL 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 CFL_KVLIST_H
+#define CFL_KVLIST_H
+
+#include <stdio.h>
+#include <cfl/cfl_sds.h>
+#include <cfl/cfl_list.h>
+#include <cfl/cfl_variant.h>
+
+struct cfl_kvpair {
+ cfl_sds_t key; /* Key */
+ struct cfl_variant *val; /* Value */
+ struct cfl_list _head; /* Link to list cfl_kvlist->list */
+};
+
+struct cfl_kvlist {
+ struct cfl_list list;
+};
+
+struct cfl_kvlist *cfl_kvlist_create();
+void cfl_kvlist_destroy(struct cfl_kvlist *list);
+
+int cfl_kvlist_insert_string(struct cfl_kvlist *list,
+ char *key, char *value);
+
+int cfl_kvlist_insert_bytes(struct cfl_kvlist *list,
+ char *key, char *value,
+ size_t value_length);
+
+int cfl_kvlist_insert_reference(struct cfl_kvlist *list,
+ char *key, void *value);
+
+int cfl_kvlist_insert_bool(struct cfl_kvlist *list,
+ char *key, int value);
+
+int cfl_kvlist_insert_int64(struct cfl_kvlist *list,
+ char *key, int64_t value);
+
+int cfl_kvlist_insert_double(struct cfl_kvlist *list,
+ char *key, double value);
+
+int cfl_kvlist_insert_array(struct cfl_kvlist *list,
+ char *key, struct cfl_array *value);
+
+int cfl_kvlist_insert_new_array(struct cfl_kvlist *list,
+ char *key, size_t size);
+
+int cfl_kvlist_insert_kvlist(struct cfl_kvlist *list,
+ char *key, struct cfl_kvlist *value);
+
+int cfl_kvlist_insert(struct cfl_kvlist *list,
+ char *key, struct cfl_variant *value);
+
+int cfl_kvlist_count(struct cfl_kvlist *list);
+struct cfl_variant *cfl_kvlist_fetch(struct cfl_kvlist *list, char *key);
+int cfl_kvlist_print(FILE *fp, struct cfl_kvlist *list);
+
+#endif
diff --git a/fluent-bit/lib/cfl/include/cfl/cfl_list.h b/fluent-bit/lib/cfl/include/cfl/cfl_list.h
new file mode 100644
index 00000000..f2709288
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/cfl/cfl_list.h
@@ -0,0 +1,236 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* CFL
+ * ===
+ * Copyright (C) 2022 The CFL 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.
+ */
+
+/*
+ * This is a rebranded copy of the original Monkey HTTP Server linked list
+ * interface (cfl_list).
+ *
+ * - http://monkey-project.com
+ * - https://github.com/monkey/monkey
+ */
+
+#ifndef CFL_LIST_H
+#define CFL_LIST_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#ifdef _WIN32
+/* Windows */
+#define cfl_container_of(address, type, field) ((type *)( \
+ (unsigned char *)(address) - \
+ (intptr_t)(&((type *)0)->field)))
+#else
+/* Rest of the world */
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
+#define cfl_container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+#endif
+
+struct cfl_list {
+ struct cfl_list *prev, *next;
+};
+
+static inline int cfl_list_is_empty(struct cfl_list *head)
+{
+ if (head->next == head) {
+ return 1;
+ }
+
+ return 0;
+}
+
+static inline void cfl_list_init(struct cfl_list *list)
+{
+ list->next = list;
+ list->prev = list;
+}
+
+static inline void __cfl_list_del(struct cfl_list *prev,
+ struct cfl_list *next)
+{
+ prev->next = next;
+ next->prev = prev;
+}
+
+static inline void cfl_list_del(struct cfl_list *entry)
+{
+ __cfl_list_del(entry->prev, entry->next);
+
+ entry->prev = NULL;
+ entry->next = NULL;
+}
+
+static inline void __cfl_list_add(struct cfl_list *_new,
+ struct cfl_list *prev,
+ struct cfl_list *next)
+{
+ next->prev = _new;
+ _new->next = next;
+ _new->prev = prev;
+ prev->next = _new;
+}
+
+static inline void cfl_list_add(struct cfl_list *_new,
+ struct cfl_list *head)
+{
+ __cfl_list_add(_new, head->prev, head);
+}
+
+static inline void cfl_list_add_after(struct cfl_list *_new,
+ struct cfl_list *prev,
+ struct cfl_list *head)
+{
+ struct cfl_list *next;
+
+ if (_new == NULL || prev == NULL || head == NULL) {
+ return;
+ }
+
+ next = prev->next;
+ next->prev = prev;
+ _new->next = next;
+ _new->prev = prev;
+ prev->next = _new;
+}
+
+static inline void cfl_list_add_before(struct cfl_list *_new,
+ struct cfl_list *next,
+ struct cfl_list *head)
+{
+ struct cfl_list *prev;
+
+ if (_new == NULL || next == NULL || head == NULL) {
+ return;
+ }
+
+ prev = next->prev;
+ _new->next = next;
+ _new->prev = prev;
+ prev->next = _new;
+ next->prev = _new;
+}
+
+static inline void cfl_list_append(struct cfl_list *_new,
+ struct cfl_list *head)
+{
+ if (cfl_list_is_empty(head)) {
+ __cfl_list_add(_new, head->prev, head);
+ }
+ else {
+ cfl_list_add_after(_new,
+ head->prev,
+ head);
+ }
+}
+
+static inline void cfl_list_prepend(struct cfl_list *_new,
+ struct cfl_list *head)
+{
+ if (cfl_list_is_empty(head)) {
+ __cfl_list_add(_new, head->prev, head);
+ }
+ else {
+ cfl_list_add_before(_new,
+ head->next,
+ head);
+ }
+}
+
+static inline int cfl_list_size(struct cfl_list *head)
+{
+ int ret = 0;
+ struct cfl_list *it;
+
+ for (it = head->next; it != head; it = it->next, ret++);
+
+ return ret;
+}
+
+static inline void cfl_list_entry_init(struct cfl_list *entry)
+{
+ entry->next = NULL;
+ entry->prev = NULL;
+}
+
+static inline int cfl_list_entry_is_orphan(struct cfl_list *entry)
+{
+ if (entry->next != NULL &&
+ entry->prev != NULL) {
+ return CFL_FALSE;
+ }
+
+ return CFL_TRUE;
+}
+
+static inline void cfl_list_cat(struct cfl_list *list, struct cfl_list *head)
+{
+ struct cfl_list *last;
+
+ last = head->prev;
+ last->next = list->next;
+ list->next->prev = last;
+ list->prev->next = head;
+ head->prev = list->prev;
+}
+
+#define cfl_list_foreach(curr, head) for( curr = (head)->next; curr != (head); curr = curr->next )
+#define cfl_list_foreach_safe(curr, n, head) \
+ for (curr = (head)->next, n = curr->next; curr != (head); curr = n, n = curr->next)
+
+
+#define cfl_list_foreach_r(curr, head) for( curr = (head)->prev; curr != (head); curr = curr->prev )
+#define cfl_list_foreach_safe_r(curr, n, head) \
+ for (curr = (head)->prev, n = curr->prev; curr != (head); curr = n, n = curr->prev)
+
+#define cfl_list_entry( ptr, type, member ) cfl_container_of( ptr, type, member )
+
+/*
+ * First node of the list
+ * ----------------------
+ * Be careful with this Macro, its intended to be used when some node is already linked
+ * to the list (ptr). If the list is empty it will return the list address as it points
+ * to it self: list == list->prev == list->next.
+ *
+ * If exists some possiblity that your code handle an empty list, use cfl_list_is_empty()
+ * previously to check if its empty or not.
+ */
+#define cfl_list_entry_first(ptr, type, member) cfl_container_of((ptr)->next, type, member)
+
+/* First node of the list
+ * ---------------------
+ * Be careful with this Macro, its intended to be used when some node is already linked
+ * to the list (ptr). If the list is empty it will return the list address as it points
+ * to it self: list == list->prev == list->next.
+ *
+ * If exists some possiblity that your code handle an empty list, use cfl_list_is_empty()
+ * previously to check if its empty or not.
+ */
+#define cfl_list_entry_last(ptr, type, member) cfl_container_of((ptr)->prev, type, member)
+
+/* Next node */
+#define cfl_list_entry_next(ptr, type, member, head) \
+ (ptr)->next == (head) ? cfl_container_of((head)->next, type, member) : \
+ cfl_container_of((ptr)->next, type, member);
+
+#endif /* !cfl_list_H_ */
diff --git a/fluent-bit/lib/cfl/include/cfl/cfl_log.h b/fluent-bit/lib/cfl/include/cfl/cfl_log.h
new file mode 100644
index 00000000..9ceb0015
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/cfl/cfl_log.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* CFL
+ * ===
+ * Copyright (C) 2022 The CFL 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 CFL_LOG_H
+#define CFL_LOG_H
+
+#include <errno.h>
+
+int cfl_report_runtime_error_impl(int errnum, char *file, int line);
+
+#ifdef __FILENAME__
+#define cfl_report_runtime_error() cfl_report_runtime_error_impl(errno, __FILENAME__, __LINE__)
+#else
+#define cfl_report_runtime_error() cfl_report_runtime_error_impl(errno, __FILE__, __LINE__)
+#endif
+
+#define cfl_errno() do {} while (0)
+
+#endif
diff --git a/fluent-bit/lib/cfl/include/cfl/cfl_sds.h b/fluent-bit/lib/cfl/include/cfl/cfl_sds.h
new file mode 100644
index 00000000..35054737
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/cfl/cfl_sds.h
@@ -0,0 +1,65 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* CFL
+ * ===
+ * Copyright (C) 2022 The CFL 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 CFL_SDS_H
+#define CFL_SDS_H
+
+/*
+ * This interface is a minimized version of Fluent Bit SDS just for easily
+ * string storage
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+
+#define CFL_SDS_HEADER_SIZE (sizeof(uint64_t) + sizeof(uint64_t))
+
+typedef char *cfl_sds_t;
+
+#pragma pack(push, 1)
+struct cfl_sds {
+ uint64_t len; /* used */
+ uint64_t alloc; /* excluding the header and null terminator */
+ char buf[];
+};
+#pragma pack(pop)
+
+#define CFL_SDS_HEADER(s) ((struct cfl_sds *) (s - CFL_SDS_HEADER_SIZE))
+
+static inline void cfl_sds_len_set(cfl_sds_t s, size_t len)
+{
+ CFL_SDS_HEADER(s)->len = len;
+}
+
+size_t cfl_sds_avail(cfl_sds_t s);
+cfl_sds_t sds_alloc(size_t size);
+size_t cfl_sds_alloc(cfl_sds_t s);
+cfl_sds_t cfl_sds_increase(cfl_sds_t s, size_t len);
+size_t cfl_sds_len(cfl_sds_t s);
+cfl_sds_t cfl_sds_create_len(const char *str, int len);
+cfl_sds_t cfl_sds_create(const char *str);
+void cfl_sds_destroy(cfl_sds_t s);
+cfl_sds_t cfl_sds_cat(cfl_sds_t s, const char *str, int len);
+cfl_sds_t cfl_sds_create_size(size_t size);
+void cfl_sds_set_len(cfl_sds_t s, size_t len);
+void cfl_sds_cat_safe(cfl_sds_t *buf, const char *str, int len);
+cfl_sds_t cfl_sds_printf(cfl_sds_t *sds, const char *fmt, ...);
+
+#endif
diff --git a/fluent-bit/lib/cfl/include/cfl/cfl_time.h b/fluent-bit/lib/cfl/include/cfl/cfl_time.h
new file mode 100644
index 00000000..9c141c1b
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/cfl/cfl_time.h
@@ -0,0 +1,27 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* CFL
+ * ===
+ * Copyright (C) 2022 The CFL 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 CFL_TIME_H
+#define CFL_TIME_H
+
+#include <cfl/cfl.h>
+
+uint64_t cfl_time_now();
+
+#endif
diff --git a/fluent-bit/lib/cfl/include/cfl/cfl_variant.h b/fluent-bit/lib/cfl/include/cfl/cfl_variant.h
new file mode 100644
index 00000000..6249ffdd
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/cfl/cfl_variant.h
@@ -0,0 +1,65 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* CFL
+ * ===
+ * Copyright (C) 2022 The CFL 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 CFL_VARIANT_H
+#define CFL_VARIANT_H
+
+#include <stdio.h>
+#include <inttypes.h>
+
+#define CFL_VARIANT_STRING 1
+#define CFL_VARIANT_BOOL 2
+#define CFL_VARIANT_INT 3
+#define CFL_VARIANT_DOUBLE 4
+#define CFL_VARIANT_ARRAY 5
+#define CFL_VARIANT_KVLIST 6
+#define CFL_VARIANT_BYTES 7
+#define CFL_VARIANT_REFERENCE 8
+
+struct cfl_array;
+struct cfl_kvlist;
+
+struct cfl_variant {
+ int type;
+
+ union {
+ cfl_sds_t as_string;
+ cfl_sds_t as_bytes;
+ unsigned int as_bool;
+ int64_t as_int64;
+ double as_double;
+ void *as_reference;
+ struct cfl_array *as_array;
+ struct cfl_kvlist *as_kvlist;
+ } data;
+};
+int cfl_variant_print(FILE *fp, struct cfl_variant *val);
+struct cfl_variant *cfl_variant_create_from_string(char *value);
+struct cfl_variant *cfl_variant_create_from_bytes(char *value, size_t length);
+struct cfl_variant *cfl_variant_create_from_bool(int value);
+struct cfl_variant *cfl_variant_create_from_int64(int64_t value);
+struct cfl_variant *cfl_variant_create_from_double(double value);
+struct cfl_variant *cfl_variant_create_from_array(struct cfl_array *value);
+struct cfl_variant *cfl_variant_create_from_kvlist(struct cfl_kvlist *value);
+struct cfl_variant *cfl_variant_create_from_reference(void *value);
+struct cfl_variant *cfl_variant_create();
+
+void cfl_variant_destroy(struct cfl_variant *instance);
+
+#endif
diff --git a/fluent-bit/lib/cfl/include/cfl/cfl_version.h.in b/fluent-bit/lib/cfl/include/cfl/cfl_version.h.in
new file mode 100644
index 00000000..9df8459a
--- /dev/null
+++ b/fluent-bit/lib/cfl/include/cfl/cfl_version.h.in
@@ -0,0 +1,36 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/* CFL
+ * ===
+ * Copyright (C) 2022 The CFL 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 CFL_VERSION_H
+#define CFL_VERSION_H
+
+/* Helpers to convert/format version string */
+#define STR_HELPER(s) #s
+#define STR(s) STR_HELPER(s)
+
+/* CTraces Version */
+#define CFL_VERSION_MAJOR @CFL_VERSION_MAJOR@
+#define CFL_VERSION_MINOR @CFL_VERSION_MINOR@
+#define CFL_VERSION_PATCH @CFL_VERSION_PATCH@
+#define CFL_VERSION (CFL_VERSION_MAJOR * 10000 \
+ CFL_VERSION_MINOR * 100 \
+ CFL_VERSION_PATCH)
+#define CFL_VERSION_STR "@CFL_VERSION_STR@"
+
+#endif