Skip to content

Commit

Permalink
in_tail: Use proxyed function and constants for using simdutf stuffs
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Nov 8, 2024
1 parent b19b6b1 commit 5e4da6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 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

0 comments on commit 5e4da6f

Please sign in to comment.