From a49ed2ad7f046517f1e48b417a71ac2005362d2f Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 9 Feb 2012 10:48:50 +0100 Subject: [PATCH] write_graphite plugin: Report configuration errors for the EscapeCharacter option. Change-Id: Ia99e2c8d9c7ced344bb52f4d80957fa9abe3e7db --- src/write_graphite.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/write_graphite.c b/src/write_graphite.c index 857258a6..b7924ba8 100644 --- a/src/write_graphite.c +++ b/src/write_graphite.c @@ -598,14 +598,30 @@ static int wg_write (const data_set_t *ds, const value_list_t *vl, static int config_set_char (char *dest, oconfig_item_t *ci) { - if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) + char buffer[4]; + int status; + + memset (buffer, 0, sizeof (buffer)); + + status = cf_util_get_string_buffer (ci, buffer, sizeof (buffer)); + if (status != 0) + return (status); + + if (buffer[0] == 0) { - WARNING ("write_graphite plugin: The `%s' config option " - "needs exactly one string argument.", ci->key); + ERROR ("write_graphite plugin: Cannot use an empty string for the " + "\"EscapeCharacter\" option."); return (-1); } - *dest = ci->values[0].value.string[0]; + if (buffer[1] != 0) + { + WARNING ("write_graphite plugin: Only the first character of the " + "\"EscapeCharacter\" option ('%c') will be used.", + (int) buffer[0]); + } + + *dest = buffer[0]; return (0); } -- 2.11.0