aboutsummaryrefslogtreecommitdiffstats
path: root/src/error/error.c
blob: c286b464934cee1c85219349e7169893bcebfd5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include "error.h"

void error(int err, char *fmt, ...)
{
	va_list args;

	va_start(args, fmt);
	fprintf(stderr, "error: ");
	vfprintf(stderr, fmt, args);
	fprintf(stderr, "\n");
	va_end(args);
	if (err != 0)
		fprintf(stderr, "%s", strerror(err));
	exit(1);
}