Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/fluent-bit/flb_mp.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,7 @@ void flb_mp_accessor_set_active(struct flb_mp_accessor *mpa, int status);
int flb_mp_accessor_set_active_by_pattern(struct flb_mp_accessor *mpa,
const char *pattern, int status);

struct cfl_object *flb_mp_object_to_cfl(msgpack_object *o);
int flb_mp_cfl_to_msgpack(struct cfl_object *obj, char **out_buf, size_t *out_size);

#endif
2 changes: 1 addition & 1 deletion lib/cfl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# C Floppy Version
set(CFL_VERSION_MAJOR 0)
set(CFL_VERSION_MINOR 3)
set(CFL_VERSION_MINOR 4)
set(CFL_VERSION_PATCH 0)
set(CFL_VERSION_STR "${CFL_VERSION_MAJOR}.${CFL_VERSION_MINOR}.${CFL_VERSION_PATCH}")

Expand Down
1 change: 1 addition & 0 deletions lib/cfl/include/cfl/cfl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <cfl/cfl_kvlist.h>
#include <cfl/cfl_time.h>
#include <cfl/cfl_variant.h>
#include <cfl/cfl_object.h>

int cfl_init();

Expand Down
4 changes: 2 additions & 2 deletions lib/cfl/include/cfl/cfl_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ 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_uint64(struct cfl_array *array, uint64_t value);
int cfl_array_append_double(struct cfl_array *array, double value);
int cfl_array_append_null(struct cfl_array *array);
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_append_kvlist(struct cfl_array *array, struct cfl_kvlist *value);
int cfl_array_print(FILE *fp, struct cfl_array *array);

#endif
2 changes: 2 additions & 0 deletions lib/cfl/include/cfl/cfl_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
#define timezone _timezone
#define tzname _tzname
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#define timegm _mkgmtime
#endif /* _MSC_VER */

#endif
#endif

51 changes: 51 additions & 0 deletions lib/cfl/include/cfl/cfl_kvlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,55 @@ 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);

int cfl_kvlist_insert_string_s(struct cfl_kvlist *list,
char *key, size_t key_size,
char *value, size_t value_size);

int cfl_kvlist_insert_bytes_s(struct cfl_kvlist *list,
char *key, size_t key_size,
char *value,
size_t value_length);

int cfl_kvlist_insert_reference_s(struct cfl_kvlist *list,
char *key, size_t key_size,
void *value);

int cfl_kvlist_insert_bool_s(struct cfl_kvlist *list,
char *key, size_t key_size, int value);

int cfl_kvlist_insert_int64_s(struct cfl_kvlist *list,
char *key, size_t key_size,
int64_t value);

int cfl_kvlist_insert_uint64_s(struct cfl_kvlist *list,
char *key, size_t key_size,
uint64_t value);

int cfl_kvlist_insert_double_s(struct cfl_kvlist *list,
char *key, size_t key_size,
double value);

int cfl_kvlist_insert_array_s(struct cfl_kvlist *list,
char *key, size_t key_size,
struct cfl_array *value);

int cfl_kvlist_insert_new_array_s(struct cfl_kvlist *list,
char *key, size_t key_size,
size_t size);

int cfl_kvlist_insert_kvlist_s(struct cfl_kvlist *list,
char *key, size_t key_size,
struct cfl_kvlist *value);

int cfl_kvlist_insert_s(struct cfl_kvlist *list,
char *key, size_t key_size,
struct cfl_variant *value);

struct cfl_variant *cfl_kvlist_fetch_s(struct cfl_kvlist *list, char *key, size_t key_size);

int cfl_kvlist_contains(struct cfl_kvlist *kvlist, char *name);
int cfl_kvlist_remove(struct cfl_kvlist *kvlist, char *name);
void cfl_kvpair_destroy(struct cfl_kvpair *pair);


#endif
41 changes: 41 additions & 0 deletions lib/cfl/include/cfl/cfl_object.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* -*- 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_OBJECT_H
#define CFL_OBJECT_H

enum {
CFL_OBJECT_NONE = 0,
CFL_OBJECT_KVLIST = 1,
CFL_OBJECT_VARIANT,
CFL_OBJECT_ARRAY
};

struct cfl_object {
int type;
struct cfl_variant *variant;
struct cfl_list _head;
};

struct cfl_object *cfl_object_create();
void cfl_object_destroy(struct cfl_object *obj);
int cfl_object_set(struct cfl_object *o, int type, void *ptr);
int cfl_object_print(FILE *stream, struct cfl_object *o);

#endif
24 changes: 15 additions & 9 deletions lib/cfl/include/cfl/cfl_variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,26 @@
#define CFL_VARIANT_H

#include <stdio.h>
#include <string.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
#define CFL_VARIANT_UINT 9
#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
#define CFL_VARIANT_UINT 9
#define CFL_VARIANT_NULL 10

struct cfl_array;
struct cfl_kvlist;

struct cfl_variant {
int type;
size_t size;

union {
cfl_sds_t as_string;
Expand All @@ -51,14 +54,17 @@ struct cfl_variant {
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_string_s(char *value, size_t value_length);
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_uint64(uint64_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_null();
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();
Expand Down
1 change: 1 addition & 0 deletions lib/cfl/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(src
cfl_time.c
cfl_kv.c
cfl_kvlist.c
cfl_object.c
cfl_array.c
cfl_variant.c
cfl_checksum.c
Expand Down
23 changes: 20 additions & 3 deletions lib/cfl/src/cfl_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* CFL
* ===
* Copyright (C) 2022 The CFL Authors
* Copyright (C) 2022-2024 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.
Expand Down Expand Up @@ -305,6 +305,24 @@ int cfl_array_append_double(struct cfl_array *array, double value)
return 0;
}

int cfl_array_append_null(struct cfl_array *array)
{
struct cfl_variant *value_instance;
int result;

value_instance = cfl_variant_create_from_null();
if (value_instance == NULL) {
return -1;
}

result = cfl_array_append(array, value_instance);
if (result) {
cfl_variant_destroy(value_instance);
return -2;
}

return 0;
}

int cfl_array_append_array(struct cfl_array *array, struct cfl_array *value)
{
Expand Down Expand Up @@ -347,8 +365,7 @@ int cfl_array_append_new_array(struct cfl_array *array, size_t size)
return result;
}

int cfl_array_append_kvlist(struct cfl_array *array, struct
cfl_kvlist *value)
int cfl_array_append_kvlist(struct cfl_array *array, struct cfl_kvlist *value)
{
struct cfl_variant *value_instance;
int result;
Expand Down
Loading