diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2016-03-21 15:31:21 +0100 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2016-03-21 15:31:21 +0100 |
commit | 15d3b7ba7cf2db52aa1b33b517425dcae3ccadde (patch) | |
tree | 976f3e3333e017515d0854d5aeb2e7cda511d32d /nq.c | |
parent | d6c8f4fee8392620dd7c33dc8e94ff1d84455633 (diff) | |
download | nq-15d3b7ba7cf2db52aa1b33b517425dcae3ccadde.tar.gz nq-15d3b7ba7cf2db52aa1b33b517425dcae3ccadde.tar.xz nq-15d3b7ba7cf2db52aa1b33b517425dcae3ccadde.zip |
nq: add dprintf stub for Solaris
Diffstat (limited to 'nq.c')
-rw-r--r-- | nq.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/nq.c b/nq.c index 67e3485..9fda2b0 100644 --- a/nq.c +++ b/nq.c @@ -23,6 +23,10 @@ /* for FreeBSD. */ #define _WITH_DPRINTF +#if defined(__sun) && defined(__SVR4) && !defined(HAVE_DPRINTF) +#define NEED_DPRINTF +#endif + #include <sys/file.h> #include <sys/stat.h> #include <sys/time.h> @@ -40,6 +44,24 @@ #include <time.h> #include <unistd.h> +#ifdef NEED_DPRINTF +#include <stdarg.h> +static int +dprintf(int fd, const char *fmt, ...) +{ + char buf[128]; // good enough for usage in nq + va_list ap; + int r; + + va_start(ap, fmt); + r = vsnprintf(buf, sizeof buf, fmt, ap); + va_end(ap); + if (r >= 0 && r < sizeof buf) + return write(fd, buf, r); + return -1; +} +#endif + static void swrite(int fd, char *str) { |