summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c999713)
raw | patch | inline | side by side (parent: c999713)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 17 Jan 2009 11:15:49 +0000 (12:15 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 17 Jan 2009 11:15:49 +0000 (12:15 +0100) |
src/bind.c | patch | blob | history |
diff --git a/src/bind.c b/src/bind.c
index 43b61dd25c6233c8e9914300d8e5e05005c3b79d..d6914999a73859a87d597bb30c4406378fb56238 100644 (file)
--- a/src/bind.c
+++ b/src/bind.c
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
+static void remove_special (char *buffer, size_t buffer_size)
+{
+ size_t i;
+
+ for (i = 0; i < buffer_size; i++)
+ {
+ if (buffer[i] == 0)
+ return;
+ if (!isalnum ((int) buffer[i]))
+ buffer[i] = '_';
+ }
+} /* void remove_special */
+
static void submit_counter(time_t ts, const char *plugin_instance, const char *type,
const char *type_instance, counter_t value)
{
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- char *p;
values[0].counter = value;
@@ -93,17 +105,13 @@ static void submit_counter(time_t ts, const char *plugin_instance, const char *t
if (plugin_instance) {
sstrncpy(vl.plugin_instance, plugin_instance,
sizeof(vl.plugin_instance));
- for (p = vl.type_instance; *p; p++)
- if ((*p < 'a' || *p > 'z') && (*p < 'A' || *p > 'Z') && (*p < '0' || *p > '9') && *p != '_')
- *p = '_';
+ remove_special (vl.plugin_instance, sizeof (vl.plugin_instance));
}
sstrncpy(vl.type, type, sizeof(vl.type));
if (type_instance) {
sstrncpy(vl.type_instance, type_instance,
sizeof(vl.type_instance));
- for (p = vl.type_instance; *p; p++)
- if ((*p < 'a' || *p > 'z') && (*p < 'A' || *p > 'Z') && (*p < '0' || *p > '9') && *p != '_')
- *p = '_';
+ remove_special (vl.plugin_instance, sizeof (vl.plugin_instance));
}
plugin_dispatch_values(&vl);
} /* void submit_counter */