X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Fcommon.h;h=cf4c5a71b9ac484a52be4cb2b6975434afd6922e;hb=d4cc32c4dddb01081c49a67d13ab4a737cda0ed0;hp=afd292a3d9b5a31bc91200b59694eb57ab2aac62;hpb=68c08bd380d63281f5707e893c27f952c5fde1d8;p=collectd.git diff --git a/src/daemon/common.h b/src/daemon/common.h index afd292a3..cf4c5a71 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