comparison th_util.c @ 99:0313fabd8049

Added varargs versions of some functions.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 17 Nov 2009 23:08:15 +0200
parents 69aed051f84d
children 4ec36204d34e
comparison
equal deleted inserted replaced
98:b7c981e27b66 99:0313fabd8049
46 46
47 47
48 /* Print formatted error, warning and information messages 48 /* Print formatted error, warning and information messages
49 * TODO: Implement th_vfprintf() and friends? 49 * TODO: Implement th_vfprintf() and friends?
50 */ 50 */
51 void THERR(const char *pcFormat, ...) 51 void THERR_V(const char *fmt, va_list ap)
52 {
53 assert(th_initialized == TRUE);
54
55 fprintf(stderr, "%s: ", th_prog_name);
56 vfprintf(stderr, fmt, ap);
57 }
58
59
60 void THMSG_V(int level, const char *fmt, va_list ap)
61 {
62 assert(th_initialized == TRUE);
63
64 if (th_verbosityLevel >= level) {
65 fprintf(stderr, "%s: ", th_prog_name);
66 vfprintf(stderr, fmt, ap);
67 }
68 }
69
70
71 void THPRINT_V(int level, const char *fmt, va_list ap)
72 {
73 assert(th_initialized == TRUE);
74
75 if (th_verbosityLevel >= level) {
76 vfprintf(stderr, fmt, ap);
77 }
78 }
79
80
81 void THERR(const char *fmt, ...)
52 { 82 {
53 va_list ap; 83 va_list ap;
54 assert(th_initialized); 84 assert(th_initialized == TRUE);
55 85
56 va_start(ap, pcFormat); 86 va_start(ap, fmt);
57 fprintf(stderr, "%s: ", th_prog_name); 87 THERR_V(fmt, ap);
58 vfprintf(stderr, pcFormat, ap);
59 va_end(ap); 88 va_end(ap);
60 } 89 }
61 90
62 91
63 void THMSG(int verbLevel, const char *pcFormat, ...) 92 void THMSG(int level, const char *fmt, ...)
64 { 93 {
65 va_list ap; 94 va_list ap;
66 assert(th_initialized); 95 assert(th_initialized == TRUE);
67 96
68 /* Check if the current verbosity level is enough */ 97 va_start(ap, fmt);
69 if (th_verbosityLevel >= verbLevel) { 98 THMSG_V(level, fmt, ap);
70 va_start(ap, pcFormat); 99 va_end(ap);
71 fprintf(stderr, "%s: ", th_prog_name);
72 vfprintf(stderr, pcFormat, ap);
73 va_end(ap);
74 }
75 } 100 }
76 101
77 102
78 void THPRINT(int verbLevel, const char *pcFormat, ...) 103 void THPRINT(int level, const char *fmt, ...)
79 { 104 {
80 va_list ap; 105 va_list ap;
81 assert(th_initialized); 106 assert(th_initialized == TRUE);
82 107
83 /* Check if the current verbosity level is enough */ 108 va_start(ap, fmt);
84 if (th_verbosityLevel >= verbLevel) { 109 THPRINT_V(level, fmt, ap);
85 va_start(ap, pcFormat); 110 va_end(ap);
86 vfprintf(stderr, pcFormat, ap);
87 va_end(ap);
88 }
89 } 111 }
90 112
91 113
92 /* Memory handling routines 114 /* Memory handling routines
93 */ 115 */