Initial import from FreeBSD RELENG_4:
[dragonfly.git] / usr.sbin / pkg_install / sign / stand.c
1 #include <sys/cdefs.h>
2 __FBSDID("$FreeBSD: src/usr.sbin/pkg_install/sign/stand.c,v 1.1.2.2 2002/08/20 06:35:08 obrien Exp $");
3
4 #include "stand.h"
5
6 #ifdef BSD4_4
7 #include <string.h>
8 #include <stdio.h>
9 #include <errno.h>
10 #include <stdarg.h>
11
12 /* shortened version of warn */
13 static const char *program_name;
14
15 void 
16 set_program_name(n)
17         const char *n;
18 {
19         if ((program_name = strrchr(n, '/')) != NULL)
20                 program_name++;
21         else
22                 program_name = n;
23 }
24
25 void 
26 warn(const char *fmt, ...)
27 {
28         va_list ap;
29         int interrno;
30
31         va_start(ap, fmt);
32
33         interrno = errno;
34         (void)fprintf(stderr, "%s: ", program_name);
35         if (fmt != NULL) {
36                 (void)vfprintf(stderr, fmt, ap);
37                 (void)fprintf(stderr, ": ");
38         }
39         (void)fprintf(stderr, "%s\n", strerror(interrno));
40
41         va_end(ap);
42 }
43
44 void 
45 warnx(const char *fmt, ...)
46 {
47         va_list ap;
48
49         va_start(ap, fmt);
50         (void)fprintf(stderr, "%s: ", program_name);
51         if (fmt != NULL) 
52                 (void)vfprintf(stderr, fmt, ap);
53         (void)fprintf(stderr, "\n");
54         va_end(ap);
55 }
56
57 #endif