blob: 4c32ce55f4e3985f7b31789efef96f692e5b92f7 [file] [log] [blame]
wdenkb00ec162003-06-19 23:40:20 +00001/*
2 * (C) Copyright 2000
3 * Murray Jensen <Murray.Jensen@csiro.au>
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenkb00ec162003-06-19 23:40:20 +00006 */
7
wdenk3ba68652000-10-11 22:04:29 +00008#include <stdio.h>
9#include <stdlib.h>
10#include <string.h>
11#include <errno.h>
12#include "error.h"
13
14char *pname;
15
16void
17Warning(char *fmt, ...)
18{
19 va_list args;
20
21 fprintf(stderr, "%s: WARNING: ", pname);
22
23 va_start(args, fmt);
24 vfprintf(stderr, fmt, args);
25 va_end(args);
26
27 fprintf(stderr, "\n");
28}
29
30void
31Error(char *fmt, ...)
32{
33 va_list args;
34
35 fprintf(stderr, "%s: ERROR: ", pname);
36
37 va_start(args, fmt);
38 vfprintf(stderr, fmt, args);
39 va_end(args);
40
41 fprintf(stderr, "\n");
42
43 exit(1);
44}
45
46void
47Perror(char *fmt, ...)
48{
49 va_list args;
50 int e = errno;
51 char *p;
52
53 fprintf(stderr, "%s: ERROR: ", pname);
54
55 va_start(args, fmt);
56 vfprintf(stderr, fmt, args);
57 va_end(args);
58
59 if ((p = strerror(e)) == NULL || *p == '\0')
60 fprintf(stderr, ": Unknown Error (%d)\n", e);
61 else
62 fprintf(stderr, ": %s\n", p);
63
64 exit(1);
65}