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 16static void 17warning_va_list(const char *fmt, va_list args) 18{ 19 fprintf(stderr, "Warning: "); 20 vfprintf(stderr, fmt, args); 21 fprintf(stderr, "\n"); 22} 23 24void 25warning(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 33static void 34error_va_list(const char *fmt, va_list args) 35{ 36 fprintf(stderr, "Error: "); 37 vfprintf(stderr, fmt, args); 38 fprintf(stderr, "\n"); 39} 40 41void 42error(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 51static void 52verbose_va_list(const char *fmt, va_list args) 53{ 54 vfprintf(stdout, fmt, args); 55 fprintf(stdout, "\n"); 56} 57 58/* print stuff */ 59void 60mesg(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) */ 74void 75verbose(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