typedef struct cf_global_option_s {
const char *key;
char *value;
- _Bool from_cli; /* value set from CLI */
+ bool from_cli; /* value set from CLI */
const char *def;
} cf_global_option_t;
/*
* Private variables
*/
-static cf_callback_t *first_callback = NULL;
-static cf_complex_callback_t *complex_callback_head = NULL;
+static cf_callback_t *first_callback;
+static cf_complex_callback_t *complex_callback_head;
static cf_value_map_t cf_value_map[] = {{"TypesDB", dispatch_value_typesdb},
{"PluginDir", dispatch_value_plugindir},
return global_option_set(ci->key, ci->values[0].value.string, 0);
else if (ci->values[0].type == OCONFIG_TYPE_NUMBER) {
char tmp[128];
- ssnprintf(tmp, sizeof(tmp), "%lf", ci->values[0].value.number);
+ snprintf(tmp, sizeof(tmp), "%lf", ci->values[0].value.number);
return global_option_set(ci->key, tmp, 0);
} else if (ci->values[0].type == OCONFIG_TYPE_BOOLEAN) {
if (ci->values[0].value.boolean)
static int dispatch_loadplugin(oconfig_item_t *ci) {
const char *name;
- _Bool global = 0;
+ bool global = false;
plugin_ctx_t ctx = {0};
plugin_ctx_t old_ctx;
int ret_val;
if (ci->values[i].type == OCONFIG_TYPE_STRING)
status =
- ssnprintf(buffer_ptr, buffer_free, " %s", ci->values[i].value.string);
+ snprintf(buffer_ptr, buffer_free, " %s", ci->values[i].value.string);
else if (ci->values[i].type == OCONFIG_TYPE_NUMBER)
- status = ssnprintf(buffer_ptr, buffer_free, " %lf",
- ci->values[i].value.number);
+ status =
+ snprintf(buffer_ptr, buffer_free, " %lf", ci->values[i].value.number);
else if (ci->values[i].type == OCONFIG_TYPE_BOOLEAN)
- status = ssnprintf(buffer_ptr, buffer_free, " %s",
- ci->values[i].value.boolean ? "true" : "false");
+ status = snprintf(buffer_ptr, buffer_free, " %s",
+ ci->values[i].value.boolean ? "true" : "false");
if ((status < 0) || (status >= buffer_free))
return -1;
ctx.interval = cf_get_default_interval();
old_ctx = plugin_set_ctx(ctx);
- status = plugin_load(name, /* flags = */ 0);
+ status = plugin_load(name, /* flags = */ false);
/* reset to the "global" context */
plugin_set_ctx(old_ctx);
return 0;
}
- temp =
- realloc(dst->children, sizeof(oconfig_item_t) *
- (dst->children_num + src->children_num - 1));
+ temp = realloc(dst->children,
+ sizeof(oconfig_item_t) *
+ (dst->children_num + src->children_num - 1));
if (temp == NULL) {
ERROR("configfile: realloc failed.");
return -1;
if ((src == NULL) || (src->children_num == 0))
return 0;
- temp = realloc(dst->children, sizeof(oconfig_item_t) *
- (dst->children_num + src->children_num));
+ temp =
+ realloc(dst->children,
+ sizeof(oconfig_item_t) * (dst->children_num + src->children_num));
if (temp == NULL) {
ERROR("configfile: realloc failed.");
return -1;
dh = opendir(dir);
if (dh == NULL) {
- char errbuf[1024];
- ERROR("configfile: opendir failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("configfile: opendir failed: %s", STRERRNO);
return NULL;
}
if ((de->d_name[0] == '.') || (de->d_name[0] == 0))
continue;
- status = ssnprintf(name, sizeof(name), "%s/%s", dir, de->d_name);
+ status = snprintf(name, sizeof(name), "%s/%s", dir, de->d_name);
if ((status < 0) || ((size_t)status >= sizeof(name))) {
ERROR("configfile: Not including `%s/%s' because its"
" name is too long.",
status = stat(path_ptr, &statbuf);
if (status != 0) {
- char errbuf[1024];
- WARNING("configfile: stat (%s) failed: %s", path_ptr,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("configfile: stat (%s) failed: %s", path_ptr, STRERRNO);
continue;
}
status = stat(path, &statbuf);
if (status != 0) {
- char errbuf[1024];
- ERROR("configfile: stat (%s) failed: %s", path,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("configfile: stat (%s) failed: %s", path, STRERRNO);
return NULL;
}
/*
* Public functions
*/
-int global_option_set(const char *option, const char *value, _Bool from_cli) {
+int global_option_set(const char *option, const char *value, bool from_cli) {
int i;
DEBUG("option = %s; value = %s;", option, value);
return NULL;
}
- return (cf_global_options[i].value != NULL) ? cf_global_options[i].value : cf_global_options[i].def;
+ return (cf_global_options[i].value != NULL) ? cf_global_options[i].value
+ : cf_global_options[i].def;
} /* char *global_option_get */
long global_option_get_long(const char *option, long default_value) {
}
return ret;
+
} /* int cf_read */
/* Assures the config option is a string, duplicates it and returns the copy in
return 0;
} /* }}} int cf_util_get_double */
-int cf_util_get_boolean(const oconfig_item_t *ci, _Bool *ret_bool) /* {{{ */
+int cf_util_get_boolean(const oconfig_item_t *ci, bool *ret_bool) /* {{{ */
{
if ((ci == NULL) || (ret_bool == NULL))
return EINVAL;
switch (ci->values[0].type) {
case OCONFIG_TYPE_BOOLEAN:
- *ret_bool = ci->values[0].value.boolean ? 1 : 0;
+ *ret_bool = ci->values[0].value.boolean ? true : false;
break;
case OCONFIG_TYPE_STRING:
WARNING("cf_util_get_boolean: Using string value `%s' for boolean option "
ci->values[0].value.string, ci->key);
if (IS_TRUE(ci->values[0].value.string))
- *ret_bool = 1;
+ *ret_bool = true;
else if (IS_FALSE(ci->values[0].value.string))
- *ret_bool = 0;
+ *ret_bool = false;
else {
ERROR("cf_util_get_boolean: Cannot parse string value `%s' of the `%s' "
"option as a boolean value.",
int cf_util_get_flag(const oconfig_item_t *ci, /* {{{ */
unsigned int *ret_value, unsigned int flag) {
int status;
- _Bool b;
if (ret_value == NULL)
return EINVAL;
- b = 0;
+ bool b = false;
status = cf_util_get_boolean(ci, &b);
if (status != 0)
return status;
ERROR("cf_util_get_service: Out of memory.");
return -1;
}
- ssnprintf(service, 6, "%i", port);
+ snprintf(service, 6, "%i", port);
sfree(*ret_string);
*ret_string = service;