X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcommon.h;h=f12b5e4d73b659503e3f7d959e4e1fd4cbba1a3d;hb=8a35017c70b0fc1a3531a0b630071dedbbaa9372;hp=ce1ffe52d65568a3090711c79a46a1c8732ec6c4;hpb=79d36d9eb61ac09f253769feff144383b2b665c9;p=collectd.git diff --git a/src/common.h b/src/common.h index ce1ffe52..f12b5e4d 100644 --- a/src/common.h +++ b/src/common.h @@ -24,6 +24,11 @@ #define COMMON_H #include "collectd.h" +#include "plugin.h" + +#if HAVE_PWD_H +# include +#endif #define sfree(ptr) \ if((ptr) != NULL) { \ @@ -31,9 +36,12 @@ } \ (ptr) = NULL +#define STATIC_ARRAY_SIZE(a) (sizeof (a) / sizeof (*(a))) + void sstrncpy(char *d, const char *s, int len); char *sstrdup(const char *s); void *smalloc(size_t size); +char *sstrerror (int errnum, char *buf, size_t buflen); /* * NAME @@ -140,6 +148,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); @@ -153,4 +163,22 @@ long long get_kstat_value (kstat_t *ksp, char *name); unsigned long long ntohll (unsigned long long n); unsigned long long htonll (unsigned long long n); +int format_name (char *ret, int ret_len, + const char *hostname, + const char *plugin, const char *plugin_instance, + const char *type, const char *type_instance); +#define FORMAT_VL(ret, ret_len, vl, ds) \ + format_name (ret, ret_len, (vl)->host, (vl)->plugin, (vl)->plugin_instance, \ + (ds)->type, (vl)->type_instance) + +int parse_identifier (char *str, char **ret_host, + char **ret_plugin, char **ret_plugin_instance, + char **ret_type, char **ret_type_instance); +int parse_values (char *buffer, value_list_t *vl, const data_set_t *ds); + +#if !HAVE_GETPWNAM_R +int getpwnam_r (const char *name, struct passwd *pwbuf, char *buf, + size_t buflen, struct passwd **pwbufp); +#endif + #endif /* COMMON_H */