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