X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Fcommon.h;h=8cd4e22c41a77023bcc5f5d471c6be65daab14de;hb=7c9d772c992647fcba64a96800c146eb9f1647f8;hp=afd292a3d9b5a31bc91200b59694eb57ab2aac62;hpb=9f77f493ef7cf6077deaa2385d2392d144cf606f;p=collectd.git diff --git a/src/daemon/common.h b/src/daemon/common.h index afd292a3..8cd4e22c 100644 --- a/src/daemon/common.h +++ b/src/daemon/common.h @@ -73,14 +73,20 @@ char *sstrdup(const char *s); void *smalloc(size_t size); char *sstrerror(int errnum, char *buf, size_t buflen); +#ifndef ERRBUF_SIZE +#define ERRBUF_SIZE 256 +#endif + +#define STRERROR(e) sstrerror((e), (char[ERRBUF_SIZE]){0}, ERRBUF_SIZE) +#define STRERRNO STRERROR(errno) + /* * NAME * sread * * DESCRIPTION * Reads exactly `n' bytes or fails. Syntax and other behavior is analogous - * to `read(2)'. If EOF is received the file descriptor is closed and an - * error is returned. + * to `read(2)'. * * PARAMETERS * `fd' File descriptor to write to. @@ -91,7 +97,7 @@ char *sstrerror(int errnum, char *buf, size_t buflen); * Zero upon success or non-zero if an error occurred. `errno' is set in this * case. */ -ssize_t sread(int fd, void *buf, size_t count); +int sread(int fd, void *buf, size_t count); /* * NAME @@ -110,7 +116,7 @@ ssize_t sread(int fd, void *buf, size_t count); * Zero upon success or non-zero if an error occurred. `errno' is set in this * case. */ -ssize_t swrite(int fd, const void *buf, size_t count); +int swrite(int fd, const void *buf, size_t count); /* * NAME @@ -283,6 +289,9 @@ int timeval_cmp(struct timeval tv0, struct timeval tv1, struct timeval *delta); int check_create_dir(const char *file_orig); #ifdef HAVE_LIBKSTAT +#if HAVE_KSTAT_H +#include +#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 @@ -310,7 +319,7 @@ int format_name(char *ret, int ret_len, const char *hostname, 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, - const value_list_t *vl, _Bool store_rates); + const value_list_t *vl, bool store_rates); int parse_identifier(char *str, char **ret_host, char **ret_plugin, char **ret_plugin_instance, char **ret_type, @@ -326,6 +335,7 @@ int parse_values(char *buffer, value_list_t *vl, const data_set_t *ds); int parse_value_file(char const *path, value_t *ret_value, int ds_type); #if !HAVE_GETPWNAM_R +struct passwd; int getpwnam_r(const char *name, struct passwd *pwbuf, char *buf, size_t buflen, struct passwd **pwbufp); #endif @@ -377,12 +387,10 @@ int strtogauge(const char *string, gauge_t *ret_value); int strarray_add(char ***ret_array, size_t *ret_array_len, char const *str); void strarray_free(char **array, size_t array_len); -#ifdef HAVE_SYS_CAPABILITY_H /** 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. * */ int check_capability(int arg); -#endif /* HAVE_SYS_CAPABILITY_H */ #endif /* COMMON_H */