diff options
author | sin <sin@2f30.org> | 2019-08-03 22:30:50 +0100 |
---|---|---|
committer | sin <sin@2f30.org> | 2019-08-03 22:31:34 +0100 |
commit | 1a5eb40d84cc39bdc4420ff3e591068bdfbf6669 (patch) | |
tree | 3aa3a27da5a0b5ad3535f332bbc3cf528cda0703 /dprintf.c | |
parent | 50592339bf450037972b85777d1c524e35545aa8 (diff) | |
download | noice-1a5eb40d84cc39bdc4420ff3e591068bdfbf6669.tar.gz |
Factor out dprintf()
Diffstat (limited to 'dprintf.c')
-rw-r--r-- | dprintf.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/dprintf.c b/dprintf.c new file mode 100644 index 0000000..4bbff79 --- /dev/null +++ b/dprintf.c @@ -0,0 +1,21 @@ +/* See LICENSE file for copyright and license details. */ +#include <stdarg.h> +#include <stdio.h> +#include <unistd.h> + +#include "util.h" + +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; +} |