netinet{,6}: Assert in{,6}_inithead() are only used for system routing tables.
[dragonfly.git] / contrib / ldns / drill / error.c
1 /**
2  * error.c
3  *
4  * error reporting routines
5  * basicly 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 /* print stuff when in verbose mode (1) */
73 void
74 verbose(const char *fmt, ...)
75 {
76         va_list args;
77         if (verbosity < 1) {
78                 return;
79         }
80
81         va_start(args, fmt);
82         verbose_va_list(fmt, args);
83         va_end(args);
84 }
85
86 /* print stuff when in vverbose mode (2) */
87 void
88 vverbose(const char *fmt, ...)
89 {
90         va_list args;
91         if (verbosity < 2) {
92                 return;
93         }
94
95         va_start(args, fmt);
96         verbose_va_list(fmt, args);
97         va_end(args);
98 }
99
100 static void
101 debug_va_list(const char *fmt, va_list args)
102 {
103         vfprintf(stderr, fmt, args);
104         fprintf(stderr, "\n");
105 }
106
107 void
108 debug(const char *fmt, ...)
109 {
110         va_list args;
111         fprintf(stderr, "[DEBUG] ");
112         va_start(args, fmt);
113         debug_va_list(fmt, args);
114         va_end(args);
115 }