-__attribute__((format(printf, 3, 4))) int ssnprintf(char *dest, size_t n,
- const char *format, ...);
-
__attribute__((format(printf, 1, 2))) char *ssnprintf_alloc(char const *format,
...);
__attribute__((format(printf, 1, 2))) char *ssnprintf_alloc(char const *format,
...);
void *smalloc(size_t size);
char *sstrerror(int errnum, char *buf, size_t buflen);
void *smalloc(size_t size);
char *sstrerror(int errnum, char *buf, size_t buflen);
* `dst_len' Length of the destination buffer. No more than this many
* bytes will be written to the memory pointed to by `dst',
* `dst_len' Length of the destination buffer. No more than this many
* bytes will be written to the memory pointed to by `dst',
* `fields' Array of strings to be joined.
* `fields_num' Number of elements in the `fields' array.
* `sep' String to be inserted between any two elements of `fields'.
* `fields' Array of strings to be joined.
* `fields_num' Number of elements in the `fields' array.
* `sep' String to be inserted between any two elements of `fields'.
- * Returns the number of characters in `dst', NOT including the trailing
- * null-byte. If an error occurred (empty array or `dst' too small) a value
- * smaller than zero will be returned.
+ * Returns the number of characters in the resulting string, excluding a
+ * tailing null byte. If this value is greater than or equal to "dst_len", the
+ * result in "dst" is truncated (but still null terminated). On error a
+ * negative value is returned.
*/
int strjoin(char *dst, size_t dst_len, char **fields, size_t fields_num,
const char *sep);
*/
int strjoin(char *dst, size_t dst_len, char **fields, size_t fields_num,
const char *sep);
int get_kstat(kstat_t **ksp_ptr, char *module, int instance, char *name);
long long get_kstat_value(kstat_t *ksp, char *name);
#endif
int get_kstat(kstat_t **ksp_ptr, char *module, int instance, char *name);
long long get_kstat_value(kstat_t *ksp, char *name);
#endif
format_name(ret, ret_len, (vl)->host, (vl)->plugin, (vl)->plugin_instance, \
(vl)->type, (vl)->type_instance)
int format_values(char *ret, size_t ret_len, const data_set_t *ds,
format_name(ret, ret_len, (vl)->host, (vl)->plugin, (vl)->plugin_instance, \
(vl)->type, (vl)->type_instance)
int format_values(char *ret, size_t ret_len, const data_set_t *ds,
int parse_identifier(char *str, char **ret_host, char **ret_plugin,
char **ret_plugin_instance, char **ret_type,
int parse_identifier(char *str, char **ret_host, char **ret_plugin,
char **ret_plugin_instance, char **ret_type,
int parse_identifier_vl(const char *str, value_list_t *vl);
int parse_value(const char *value, value_t *ret_value, int ds_type);
int parse_values(char *buffer, value_list_t *vl, const data_set_t *ds);
int parse_identifier_vl(const char *str, value_list_t *vl);
int parse_value(const char *value, value_t *ret_value, int ds_type);
int parse_values(char *buffer, value_list_t *vl, const data_set_t *ds);
+/* parse_value_file reads "path" and parses its content as an integer or
+ * floating point, depending on "ds_type". On success, the value is stored in
+ * "ret_value" and zero is returned. On failure, a non-zero value is returned.
+ */
+int parse_value_file(char const *path, value_t *ret_value, int ds_type);
+
#if !HAVE_GETPWNAM_R
int getpwnam_r(const char *name, struct passwd *pwbuf, char *buf, size_t buflen,
struct passwd **pwbufp);
#if !HAVE_GETPWNAM_R
int getpwnam_r(const char *name, struct passwd *pwbuf, char *buf, size_t buflen,
struct passwd **pwbufp);
int strarray_add(char ***ret_array, size_t *ret_array_len, char const *str);
void strarray_free(char **array, size_t array_len);
int strarray_add(char ***ret_array, size_t *ret_array_len, char const *str);
void strarray_free(char **array, size_t array_len);
/** Check if the current process benefits from the capability passed in
* argument. Returns zero if it does, less than zero if it doesn't or on error.
* See capabilities(7) for the list of possible capabilities.
* */
/** Check if the current process benefits from the capability passed in
* argument. Returns zero if it does, less than zero if it doesn't or on error.
* See capabilities(7) for the list of possible capabilities.
* */