X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Ftarget_replace.c;h=62928c0924278905872ff336c29d4d206de3545a;hp=66fc98d4c83025e9801f81c1d25189373fbdfbd2;hb=48efd3deb4c9139fd060ff3d289896e9031bcc7c;hpb=a1b19a64325554b0410daaefed3ce229b34958b7 diff --git a/src/target_replace.c b/src/target_replace.c index 66fc98d4..62928c09 100644 --- a/src/target_replace.c +++ b/src/target_replace.c @@ -26,8 +26,8 @@ #include "collectd.h" -#include "common.h" #include "filter_chain.h" +#include "utils/common/common.h" #include "utils_subst.h" #include @@ -37,7 +37,7 @@ typedef struct tr_action_s tr_action_t; struct tr_action_s { regex_t re; char *replacement; - _Bool may_be_empty; + bool may_be_empty; tr_action_t *next; }; @@ -110,7 +110,7 @@ static void tr_meta_data_action_destroy(tr_meta_data_action_t *act) /* {{{ */ } /* }}} void tr_meta_data_action_destroy */ static int tr_config_add_action(tr_action_t **dest, /* {{{ */ - const oconfig_item_t *ci, _Bool may_be_empty) { + const oconfig_item_t *ci, bool may_be_empty) { tr_action_t *act; int status; @@ -172,7 +172,7 @@ static int tr_config_add_action(tr_action_t **dest, /* {{{ */ static int tr_config_add_meta_action(tr_meta_data_action_t **dest, /* {{{ */ const oconfig_item_t *ci, - _Bool should_delete) { + bool should_delete) { tr_meta_data_action_t *act; int status; @@ -262,7 +262,7 @@ static int tr_config_add_meta_action(tr_meta_data_action_t **dest, /* {{{ */ static int tr_action_invoke(tr_action_t *act_head, /* {{{ */ char *buffer_in, size_t buffer_in_size, - _Bool may_be_empty) { + bool may_be_empty) { int status; char buffer[DATA_MAX_NAME_LEN]; regmatch_t matches[8] = {[0] = {0}}; @@ -294,7 +294,8 @@ static int tr_action_invoke(tr_action_t *act_head, /* {{{ */ subst_status = subst(temp, sizeof(temp), buffer, (size_t)matches[0].rm_so, (size_t)matches[0].rm_eo, act->replacement); if (subst_status == NULL) { - ERROR("Target `replace': subst (buffer = %s, start = %zu, end = %zu, " + ERROR("Target `replace': subst (buffer = %s, start = %" PRIsz + ", end = %" PRIsz ", " "replacement = %s) failed.", buffer, (size_t)matches[0].rm_so, (size_t)matches[0].rm_eo, act->replacement); @@ -305,7 +306,7 @@ static int tr_action_invoke(tr_action_t *act_head, /* {{{ */ DEBUG("target_replace plugin: tr_action_invoke: -- buffer = %s;", buffer); } /* for (act = act_head; act != NULL; act = act->next) */ - if ((may_be_empty == 0) && (buffer[0] == 0)) { + if ((may_be_empty == false) && (buffer[0] == 0)) { WARNING("Target `replace': Replacement resulted in an empty string, " "which is not allowed for this buffer (`host' or `plugin')."); return 0; @@ -386,7 +387,8 @@ static int tr_meta_data_action_invoke(/* {{{ */ subst_status = subst(temp, sizeof(temp), value, (size_t)matches[0].rm_so, (size_t)matches[0].rm_eo, act->replacement); if (subst_status == NULL) { - ERROR("Target `replace': subst (value = %s, start = %zu, end = %zu, " + ERROR("Target `replace': subst (value = %s, start = %" PRIsz + ", end = %" PRIsz ", " "replacement = %s) failed.", value, (size_t)matches[0].rm_so, (size_t)matches[0].rm_eo, act->replacement); @@ -468,13 +470,13 @@ static int tr_create(const oconfig_item_t *ci, void **user_data) /* {{{ */ if ((strcasecmp("Host", child->key) == 0) || (strcasecmp("Hostname", child->key) == 0)) status = tr_config_add_action(&data->host, child, - /* may be empty = */ 0); + /* may be empty = */ false); else if (strcasecmp("Plugin", child->key) == 0) status = tr_config_add_action(&data->plugin, child, - /* may be empty = */ 0); + /* may be empty = */ false); else if (strcasecmp("PluginInstance", child->key) == 0) status = tr_config_add_action(&data->plugin_instance, child, - /* may be empty = */ 1); + /* may be empty = */ true); #if 0 else if (strcasecmp ("Type", child->key) == 0) status = tr_config_add_action (&data->type, child, @@ -482,13 +484,13 @@ static int tr_create(const oconfig_item_t *ci, void **user_data) /* {{{ */ #endif else if (strcasecmp("TypeInstance", child->key) == 0) status = tr_config_add_action(&data->type_instance, child, - /* may be empty = */ 1); + /* may be empty = */ true); else if (strcasecmp("MetaData", child->key) == 0) status = tr_config_add_meta_action(&data->meta, child, - /* should delete = */ 0); + /* should delete = */ false); else if (strcasecmp("DeleteMetaData", child->key) == 0) status = tr_config_add_meta_action(&data->meta, child, - /* should delete = */ 1); + /* should delete = */ true); else { ERROR("Target `replace': The `%s' configuration option is not understood " "and will be ignored.", @@ -544,11 +546,11 @@ static int tr_invoke(const data_set_t *ds, value_list_t *vl, /* {{{ */ #define HANDLE_FIELD(f, e) \ if (data->f != NULL) \ tr_action_invoke(data->f, vl->f, sizeof(vl->f), e) - HANDLE_FIELD(host, 0); - HANDLE_FIELD(plugin, 0); - HANDLE_FIELD(plugin_instance, 1); - /* HANDLE_FIELD (type, 0); */ - HANDLE_FIELD(type_instance, 1); + HANDLE_FIELD(host, false); + HANDLE_FIELD(plugin, false); + HANDLE_FIELD(plugin_instance, true); + /* HANDLE_FIELD (type, false); */ + HANDLE_FIELD(type_instance, true); return FC_TARGET_CONTINUE; } /* }}} int tr_invoke */