aboutsummaryrefslogtreecommitdiffstats
path: root/dprintf.c
blob: 78582532b8fbe6f9a8536b12f0d40b4bffbd0cf9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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 && r < sizeof(buf))
		write(fd, buf, r);
	va_end(ap);
	return r;
}
Un proyecto texto-plano.xyz