summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_install/sign/stand.c
blob: 4788a79ced36f20cee1a69922e7b95c58c671f41 (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "stand.h"

#ifdef BSD4_4
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <stdarg.h>

/* shortened version of warn */
static const char *program_name;

void 
set_program_name(n)
	const char *n;
{
	if ((program_name = strrchr(n, '/')) != NULL)
		program_name++;
	else
		program_name = n;
}

void 
warn(const char *fmt, ...)
{
	va_list ap;
	int interrno;

	va_start(ap, fmt);

	interrno = errno;
	(void)fprintf(stderr, "%s", program_name);
	if (fmt != NULL) {
		(void)vfprintf(stderr, fmt, ap);
		(void)fprintf(stderr, ": ");
	}
	(void)fprintf(stderr, "%s\n", strerror(interrno));

	va_end(ap);
}

void 
warnx(const char *fmt, ...)
{
	va_list ap;

	va_start(ap, fmt);
	(void)fprintf(stderr, "%s", program_name);
	if (fmt != NULL) 
		(void)vfprintf(stderr, fmt, ap);
	(void)fprintf(stderr, "\n");
	va_end(ap);
}

#endif