aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/aoc.c
blob: b1ca2fd484243d1c8ced446a9030ade2401a4904 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "aoc.h"
#include "util.h"

#include <string.h>
#include <stdarg.h>
#include <stdio.h>

void
aoc_check(const char *sol, const char *fmtstr, ...)
{
	char buf[256];
	va_list ap;

	va_start(ap, fmtstr);
	vsnprintf(buf, 256, fmtstr, ap);
	va_end(ap);

	if (strcmp(sol, buf))
		die("aoc: solution check failed");
}

void
aoc_debug(const char *fmtstr, ...)
{
	va_list ap;

	if (!aoc.debug) return;

	va_start(ap, fmtstr);
	vfprintf(stderr, fmtstr, ap);
	va_end(ap);
}