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