aboutsummaryrefslogtreecommitdiff
path: root/lib/errors/vwarn.c
blob: bc1dda717ad220f9d1647c69adfd5534d1959c41 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>

#include "errors.h"

void
vwarn(const char *fmt, va_list ap)
{
	int save = errno;
	flockfile(stderr);
	fprintf(stderr, "%s: ", mlib_progname());
	vfprintf(stderr, fmt, ap);
	if (fmt[strlen(fmt) - 1] == ':')
		fprintf(stderr, " %s", strerror(save));
	fputc('\n', stderr);
	funlockfile(stderr);
}