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

#include "errors.h"
#include "macros.h"

void
(usage)(const char *s, ...)
{
	ASSUME(s != nullptr);
	ASSUME(mlib_progname() != nullptr);

	va_list ap;
	va_start(ap, s);

	fprintf(stderr, "Usage: %s %s\n", mlib_progname(), s);
	while ((s = va_arg(ap, char *)) != nullptr)
		fprintf(stderr, "       %s %s\n", mlib_progname(), s);

	va_end(ap);
}