From aed9a008cc5d155fc08f69f3e1da1e3069deaf13 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sun, 20 May 2007 09:55:54 +0200 Subject: [PATCH] src/plugin.c: Remove slashed from host, {plugin,type}{,-instance} here. A fix in the disk plugin has been removed again. --- src/common.c | 10 +++++++--- src/common.h | 2 ++ src/disk.c | 7 ------- src/plugin.c | 9 +++++++-- src/plugin.h | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/common.c b/src/common.c index bcdf59aa..9a28cdbf 100644 --- a/src/common.c +++ b/src/common.c @@ -241,7 +241,7 @@ int strsubstitute (char *str, char c_from, char c_to) } return (ret); -} +} /* int strsubstitute */ int escape_slashes (char *buf, int buf_len) { @@ -256,8 +256,12 @@ int escape_slashes (char *buf, int buf_len) return (0); } + if (buf_len <= 1) + return (0); + /* Move one to the left */ - memmove (buf, buf + 1, buf_len - 1); + if (buf[0] == '/') + memmove (buf, buf + 1, buf_len - 1); for (i = 0; i < buf_len - 1; i++) { @@ -269,7 +273,7 @@ int escape_slashes (char *buf, int buf_len) buf[i] = '\0'; return (0); -} +} /* int escape_slashes */ int timeval_sub_timespec (struct timeval *tv0, struct timeval *tv1, struct timespec *ret) { diff --git a/src/common.h b/src/common.h index 6c097f6c..7808ac93 100644 --- a/src/common.h +++ b/src/common.h @@ -143,6 +143,8 @@ int strjoin (char *dst, size_t dst_len, char **fields, size_t fields_num, const */ int escape_slashes (char *buf, int buf_len); +int strsubstitute (char *str, char c_from, char c_to); + /* FIXME: `timeval_sub_timespec' needs a description */ int timeval_sub_timespec (struct timeval *tv0, struct timeval *tv1, struct timespec *ret); diff --git a/src/disk.c b/src/disk.c index 5739f369..38c161f5 100644 --- a/src/disk.c +++ b/src/disk.c @@ -421,13 +421,6 @@ static int disk_read (void) minor = atoll (fields[1]); disk_name = fields[2]; - { /* Strip slashes from disk_name */ - int i; - for (i = 0; disk_name[i] != '\0'; i++) - if (disk_name[i] == '/') - disk_name[i] = '_'; - } - for (ds = disklist, pre_ds = disklist; ds != NULL; pre_ds = ds, ds = ds->next) if (strcmp (disk_name, ds->name) == 0) diff --git a/src/plugin.c b/src/plugin.c index 64dbf780..36cd80af 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -613,7 +613,7 @@ void plugin_shutdown_all (void) } } /* void plugin_shutdown_all */ -int plugin_dispatch_values (const char *name, const value_list_t *vl) +int plugin_dispatch_values (const char *name, value_list_t *vl) { int (*callback) (const data_set_t *, const value_list_t *); data_set_t *ds; @@ -650,6 +650,11 @@ int plugin_dispatch_values (const char *name, const value_list_t *vl) } #endif + escape_slashes (vl->host, sizeof (vl->host)); + escape_slashes (vl->plugin, sizeof (vl->plugin)); + escape_slashes (vl->plugin_instance, sizeof (vl->plugin_instance)); + escape_slashes (vl->type_instance, sizeof (vl->type_instance)); + le = llist_head (list_write); while (le != NULL) { @@ -660,7 +665,7 @@ int plugin_dispatch_values (const char *name, const value_list_t *vl) } return (0); -} +} /* int plugin_dispatch_values */ void plugin_log (int level, const char *format, ...) { diff --git a/src/plugin.h b/src/plugin.h index db556fce..83c21094 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -178,7 +178,7 @@ int plugin_unregister_log (const char *name); * `vl' Value list of the values that have been read by a `read' * function. */ -int plugin_dispatch_values (const char *name, const value_list_t *vl); +int plugin_dispatch_values (const char *name, value_list_t *vl); void plugin_log (int level, const char *format, ...); #define ERROR(...) plugin_log (LOG_ERR, __VA_ARGS__) -- 2.30.2