X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fdaemon%2Fcommon.h;h=c3f7f5485cb5888ed7a95634e538ff9c35b82d46;hb=872126c9a7e0a8f8ae2b28217c12c27c35af5237;hp=434ed019bc2d1a2359db6bbcf8d982fba98e091c;hpb=216c6246b73645ac093de15b87aedc9abc6ebc80;p=collectd.git diff --git a/src/daemon/common.h b/src/daemon/common.h index 434ed019..c3f7f548 100644 --- a/src/daemon/common.h +++ b/src/daemon/common.h @@ -186,6 +186,27 @@ int strjoin (char *dst, size_t dst_len, char **fields, size_t fields_num, const */ int escape_slashes (char *buffer, size_t buffer_size); +/** + * NAME + * escape_string + * + * DESCRIPTION + * escape_string quotes and escapes a string to be usable with collectd's + * plain text protocol. "simple" strings are left as they are, for example if + * buffer is 'simple' before the call, it will remain 'simple'. However, if + * buffer contains 'more "complex"' before the call, the returned buffer will + * contain '"more \"complex\""'. + * + * If the buffer is too small to contain the escaped string, the string will + * be truncated. However, leading and trailing double quotes, as well as an + * ending null byte are guaranteed. + * + * RETURN VALUE + * Returns zero on success, even if the string was truncated. Non-zero on + * failure. + */ +int escape_string (char *buffer, size_t buffer_size); + /* * NAME * replace_special @@ -336,8 +357,8 @@ counter_t counter_diff (counter_t old_value, counter_t new_value); int rate_to_value (value_t *ret_value, gauge_t rate, rate_to_value_state_t *state, int ds_type, cdtime_t t); -int value_to_rate (value_t *ret_rate, derive_t value, - value_to_rate_state_t *state, int ds_type, cdtime_t t); +int value_to_rate (gauge_t *ret_rate, value_t value, int ds_type, cdtime_t t, + value_to_rate_state_t *state); /* Converts a service name (a string) to a port number * (in the range [1-65535]). Returns less than zero on error. */