Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/ldns/drill/error.c
39478 views
1
/**
2
* error.c
3
*
4
* error reporting routines
5
* basically wrappers around printf
6
*
7
* (c) 2005 NLnet Labs
8
*
9
* See the file LICENSE for the license
10
*
11
*/
12
13
#include "drill.h"
14
#include <ldns/ldns.h>
15
16
static void
17
warning_va_list(const char *fmt, va_list args)
18
{
19
fprintf(stderr, "Warning: ");
20
vfprintf(stderr, fmt, args);
21
fprintf(stderr, "\n");
22
}
23
24
void
25
warning(const char *fmt, ...)
26
{
27
va_list args;
28
va_start(args, fmt);
29
warning_va_list(fmt, args);
30
va_end(args);
31
}
32
33
static void
34
error_va_list(const char *fmt, va_list args)
35
{
36
fprintf(stderr, "Error: ");
37
vfprintf(stderr, fmt, args);
38
fprintf(stderr, "\n");
39
}
40
41
void
42
error(const char *fmt, ...)
43
{
44
va_list args;
45
va_start(args, fmt);
46
error_va_list(fmt, args);
47
va_end(args);
48
exit(EXIT_FAILURE);
49
}
50
51
static void
52
verbose_va_list(const char *fmt, va_list args)
53
{
54
vfprintf(stdout, fmt, args);
55
fprintf(stdout, "\n");
56
}
57
58
/* print stuff */
59
void
60
mesg(const char *fmt, ...)
61
{
62
va_list args;
63
if (verbosity == -1) {
64
return;
65
}
66
fprintf(stdout, ";; ");
67
va_start(args, fmt);
68
verbose_va_list(fmt, args);
69
va_end(args);
70
}
71
72
#if 0
73
/* print stuff when in verbose mode (1) */
74
void
75
verbose(const char *fmt, ...)
76
{
77
va_list args;
78
if (verbosity < 1) {
79
return;
80
}
81
82
va_start(args, fmt);
83
verbose_va_list(fmt, args);
84
va_end(args);
85
}
86
#endif
87
88