blob: aea290111421708edb413dfda7a765f10bc225ca [file] [log] [blame]
wdenk3ba68652000-10-11 22:04:29 +00001#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <errno.h>
5#include "error.h"
6
7char *pname;
8
9void
10Warning(char *fmt, ...)
11{
12 va_list args;
13
14 fprintf(stderr, "%s: WARNING: ", pname);
15
16 va_start(args, fmt);
17 vfprintf(stderr, fmt, args);
18 va_end(args);
19
20 fprintf(stderr, "\n");
21}
22
23void
24Error(char *fmt, ...)
25{
26 va_list args;
27
28 fprintf(stderr, "%s: ERROR: ", pname);
29
30 va_start(args, fmt);
31 vfprintf(stderr, fmt, args);
32 va_end(args);
33
34 fprintf(stderr, "\n");
35
36 exit(1);
37}
38
39void
40Perror(char *fmt, ...)
41{
42 va_list args;
43 int e = errno;
44 char *p;
45
46 fprintf(stderr, "%s: ERROR: ", pname);
47
48 va_start(args, fmt);
49 vfprintf(stderr, fmt, args);
50 va_end(args);
51
52 if ((p = strerror(e)) == NULL || *p == '\0')
53 fprintf(stderr, ": Unknown Error (%d)\n", e);
54 else
55 fprintf(stderr, ": %s\n", p);
56
57 exit(1);
58}