Skip to content

Commit

Permalink
in_tail: tests: Use proxyed function and constants for using simdutf …
Browse files Browse the repository at this point in the history
…stuffs

Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Nov 12, 2024
1 parent 6724f14 commit 6e32e81
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions plugins/in_tail/tail_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#endif

#ifdef FLB_HAVE_UNICODE_ENCODER
#include <fluent-bit/simdutf/flb_simdutf_connector.h>
#include <fluent-bit/flb_unicode.h>
#endif

static int multiline_load_parsers(struct flb_tail_config *ctx)
Expand Down Expand Up @@ -112,7 +112,7 @@ struct flb_tail_config *flb_tail_config_create(struct flb_input_instance *ins,
ctx->db_sync = 1; /* sqlite sync 'normal' */
#endif
#ifdef FLB_HAVE_UNICODE_ENCODER
ctx->preferred_input_encoding = FLB_SIMDUTF_ENCODING_TYPE_UNSPECIFIED;
ctx->preferred_input_encoding = FLB_UNICODE_ENCODING_UNSPECIFIED;
#endif

/* Load the config map */
Expand Down Expand Up @@ -201,17 +201,17 @@ struct flb_tail_config *flb_tail_config_create(struct flb_input_instance *ins,
tmp = flb_input_get_property("unicode.encoding", ins);
if (tmp) {
if (strcasecmp(tmp, "auto") == 0) {
ctx->preferred_input_encoding = FLB_SIMDUTF_ENCODING_TYPE_UNICODE_AUTO;
ctx->preferred_input_encoding = FLB_UNICODE_ENCODING_AUTO;
adjust_buffer_for_2bytes_alignments(ctx);
}
else if (strcasecmp(tmp, "utf-16le") == 0 ||
strcasecmp(tmp, "utf16-le") == 0) {
ctx->preferred_input_encoding = FLB_SIMDUTF_ENCODING_TYPE_UTF16_LE;
ctx->preferred_input_encoding = FLB_UNICODE_ENCODING_UTF16_LE;
adjust_buffer_for_2bytes_alignments(ctx);
}
else if (strcasecmp(tmp, "utf-16be") == 0 ||
strcasecmp(tmp, "utf16-be") == 0) {
ctx->preferred_input_encoding = FLB_SIMDUTF_ENCODING_TYPE_UTF16_BE;
ctx->preferred_input_encoding = FLB_UNICODE_ENCODING_UTF16_BE;
adjust_buffer_for_2bytes_alignments(ctx);
}
else {
Expand Down
10 changes: 5 additions & 5 deletions plugins/in_tail/tail_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#endif

#ifdef FLB_HAVE_UNICODE_ENCODER
#include <fluent-bit/simdutf/flb_simdutf_connector.h>
#include <fluent-bit/flb_unicode.h>
#endif

#include <cfl/cfl.h>
Expand Down Expand Up @@ -460,16 +460,16 @@ static int process_content(struct flb_tail_file *file, size_t *bytes)
file->last_processed_bytes = 0;

#ifdef FLB_HAVE_UNICODE_ENCODER
if (ctx->preferred_input_encoding != FLB_SIMDUTF_ENCODING_TYPE_UNSPECIFIED) {
if (ctx->preferred_input_encoding != FLB_UNICODE_ENCODING_UNSPECIFIED) {
original_len = end - data;
decoded = NULL;
ret = flb_simdutf_connector_convert_from_unicode(ctx->preferred_input_encoding,
data, end - data, &decoded, &decoded_len);
ret = flb_unicode_convert(ctx->preferred_input_encoding,
data, end - data, &decoded, &decoded_len);
if (ret == FLB_SIMDUTF_CONNECTOR_CONVERT_OK) {
data = decoded;
end = data + decoded_len;
}
else if (ret == FLB_SIMDUTF_CONNECTOR_CONVERT_NOP) {
else if (ret == FLB_UNICODE_CONVERT_NOP) {
flb_plg_debug(ctx->ins, "nothing to convert encoding '%.*s'", end - data, data);
}
else {
Expand Down
4 changes: 2 additions & 2 deletions tests/runtime/in_tail.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Approach for this tests is basing on filter_kubernetes tests
#include <fluent-bit/flb_pthread.h>
#include <fluent-bit/flb_compat.h>
#ifdef FLB_HAVE_UNICODE_ENCODER
#include <fluent-bit/simdutf/flb_simdutf_connector.h>
#include <fluent-bit/flb_unicode.h>
#endif
#include <stdlib.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -455,7 +455,7 @@ static int cb_check_result_unicode(void *record, size_t size, void *data)
goto exit;
}

valid = flb_simdutf_connector_validate_utf8(record, size);
valid = flb_unicode_validate(record, size);
if (valid == FLB_FALSE) {
goto exit;
}
Expand Down

0 comments on commit 6e32e81

Please sign in to comment.