noice

small file browser
git clone git://git.2f30.org/noice
Log | Files | Refs | README | LICENSE

dprintf.c (363B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <stdarg.h>
      3 #include <stdio.h>
      4 #include <unistd.h>
      5 
      6 #include "util.h"
      7 
      8 int
      9 dprintf(int fd, const char *fmt, ...)
     10 {
     11 	char buf[BUFSIZ];
     12 	int r;
     13 	va_list ap;
     14 
     15 	va_start(ap, fmt);
     16 	r = vsnprintf(buf, sizeof(buf), fmt, ap);
     17 	if (r > 0 && r < sizeof(buf))
     18 		write(fd, buf, r);
     19 	va_end(ap);
     20 	return r;
     21 }