Mercurial > hg > th-libs
comparison th_util.c @ 735:31bc1ed07cf5
Renaming BOOL->bool and TRUE/FALSE to true/false, and using stdbool.h if available.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 07 Dec 2022 12:14:39 +0200 |
parents | 29e44a58bc73 |
children | db1a132c7754 |
comparison
equal
deleted
inserted
replaced
734:2ae1045f6c18 | 735:31bc1ed07cf5 |
---|---|
13 #endif | 13 #endif |
14 | 14 |
15 | 15 |
16 /* Default settings | 16 /* Default settings |
17 */ | 17 */ |
18 static BOOL th_initialized = FALSE; | 18 static bool th_initialized = false; |
19 int th_verbosity = 2; | 19 int th_verbosity = 2; |
20 char *th_prog_name = NULL, | 20 char *th_prog_name = NULL, |
21 *th_prog_desc = NULL, | 21 *th_prog_desc = NULL, |
22 *th_prog_version = NULL, | 22 *th_prog_version = NULL, |
23 *th_prog_author = NULL, | 23 *th_prog_author = NULL, |
43 th_prog_license = license == NULL ? TH_PROG_LICENSE : NULL; | 43 th_prog_license = license == NULL ? TH_PROG_LICENSE : NULL; |
44 #else | 44 #else |
45 th_prog_license = license; | 45 th_prog_license = license; |
46 #endif | 46 #endif |
47 | 47 |
48 th_initialized = TRUE; | 48 th_initialized = true; |
49 } | 49 } |
50 | 50 |
51 | 51 |
52 void th_print_banner(FILE *outFile, const char *name, const char *usage) | 52 void th_print_banner(FILE *outFile, const char *name, const char *usage) |
53 { | 53 { |
114 /* Print formatted error, warning and information messages | 114 /* Print formatted error, warning and information messages |
115 * TODO: Implement th_vfprintf() and friends? | 115 * TODO: Implement th_vfprintf() and friends? |
116 */ | 116 */ |
117 void THERR_V(const char *fmt, va_list ap) | 117 void THERR_V(const char *fmt, va_list ap) |
118 { | 118 { |
119 assert(th_initialized == TRUE); | 119 assert(th_initialized == true); |
120 | 120 |
121 fprintf(stderr, "%s: ", th_prog_name); | 121 fprintf(stderr, "%s: ", th_prog_name); |
122 vfprintf(stderr, fmt, ap); | 122 vfprintf(stderr, fmt, ap); |
123 } | 123 } |
124 | 124 |
125 | 125 |
126 void THMSG_V(int level, const char *fmt, va_list ap) | 126 void THMSG_V(int level, const char *fmt, va_list ap) |
127 { | 127 { |
128 assert(th_initialized == TRUE); | 128 assert(th_initialized == true); |
129 | 129 |
130 if (th_verbosity >= level) | 130 if (th_verbosity >= level) |
131 { | 131 { |
132 fprintf(stderr, "%s: ", th_prog_name); | 132 fprintf(stderr, "%s: ", th_prog_name); |
133 vfprintf(stderr, fmt, ap); | 133 vfprintf(stderr, fmt, ap); |
135 } | 135 } |
136 | 136 |
137 | 137 |
138 void THPRINT_V(int level, const char *fmt, va_list ap) | 138 void THPRINT_V(int level, const char *fmt, va_list ap) |
139 { | 139 { |
140 assert(th_initialized == TRUE); | 140 assert(th_initialized == true); |
141 | 141 |
142 if (th_verbosity >= level) | 142 if (th_verbosity >= level) |
143 { | 143 { |
144 vfprintf(stderr, fmt, ap); | 144 vfprintf(stderr, fmt, ap); |
145 } | 145 } |
147 | 147 |
148 | 148 |
149 void THERR(const char *fmt, ...) | 149 void THERR(const char *fmt, ...) |
150 { | 150 { |
151 va_list ap; | 151 va_list ap; |
152 assert(th_initialized == TRUE); | 152 assert(th_initialized == true); |
153 | 153 |
154 va_start(ap, fmt); | 154 va_start(ap, fmt); |
155 THERR_V(fmt, ap); | 155 THERR_V(fmt, ap); |
156 va_end(ap); | 156 va_end(ap); |
157 } | 157 } |
158 | 158 |
159 | 159 |
160 void THMSG(int level, const char *fmt, ...) | 160 void THMSG(int level, const char *fmt, ...) |
161 { | 161 { |
162 va_list ap; | 162 va_list ap; |
163 assert(th_initialized == TRUE); | 163 assert(th_initialized == true); |
164 | 164 |
165 va_start(ap, fmt); | 165 va_start(ap, fmt); |
166 THMSG_V(level, fmt, ap); | 166 THMSG_V(level, fmt, ap); |
167 va_end(ap); | 167 va_end(ap); |
168 } | 168 } |
169 | 169 |
170 | 170 |
171 void THPRINT(int level, const char *fmt, ...) | 171 void THPRINT(int level, const char *fmt, ...) |
172 { | 172 { |
173 va_list ap; | 173 va_list ap; |
174 assert(th_initialized == TRUE); | 174 assert(th_initialized == true); |
175 | 175 |
176 va_start(ap, fmt); | 176 va_start(ap, fmt); |
177 THPRINT_V(level, fmt, ap); | 177 THPRINT_V(level, fmt, ap); |
178 va_end(ap); | 178 va_end(ap); |
179 } | 179 } |