aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar sin <sin@2f30.org>2014-11-14 13:05:17 +0000
committerGravatar sin <sin@2f30.org>2014-11-14 13:05:17 +0000
commit3e8555fdc62905e1b696d1d96f981492d7ccbd13 (patch)
tree45c374dfd2f92103ac337d35a9416b2c30b5f6e3
parent3639f1bbb4547f14ec792b311f117aef27dcc7f9 (diff)
downloadnnn-3e8555fdc62905e1b696d1d96f981492d7ccbd13.tar.gz
Add a simple dprintf() implementation for systems that do not have it
-rw-r--r--noice.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/noice.c b/noice.c
index d0b0094..e656949 100644
--- a/noice.c
+++ b/noice.c
@@ -10,6 +10,7 @@
#include <limits.h>
#include <locale.h>
#include <regex.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
@@ -90,6 +91,22 @@ void printwarn(void);
void printerr(int ret, char *prefix);
char *makepath(char *dir, char *name);
+#undef dprintf
+int
+dprintf(int fd, const char *fmt, ...)
+{
+ char buf[BUFSIZ];
+ int r;
+ va_list ap;
+
+ va_start(ap, fmt);
+ r = vsnprintf(buf, sizeof(buf), fmt, ap);
+ if (r > 0)
+ write(fd, buf, r);
+ va_end(ap);
+ return r;
+}
+
void *
xmalloc(size_t size)
{