comparison th_util.c @ 453:efd33accdc81

Break backwards compatibility by renaming BOOL, TRUE and FALSE to lowercase. Introduce optional but default use of stdbool.h.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 02 Jan 2018 22:56:03 +0200
parents 2991e6b52d95
children 85fa3d333556
comparison
equal deleted inserted replaced
452:4471eadea472 453:efd33accdc81
10 #include <errno.h> 10 #include <errno.h>
11 11
12 12
13 /* Default settings 13 /* Default settings
14 */ 14 */
15 static BOOL th_initialized = FALSE; 15 static bool th_initialized = false;
16 int th_verbosityLevel = 2; 16 int th_verbosityLevel = 2;
17 char *th_prog_name = NULL, 17 char *th_prog_name = NULL,
18 *th_prog_desc = NULL, 18 *th_prog_desc = NULL,
19 *th_prog_version = NULL, 19 *th_prog_version = NULL,
20 *th_prog_author = NULL, 20 *th_prog_author = NULL,
38 if (license) 38 if (license)
39 th_prog_license = license; 39 th_prog_license = license;
40 else 40 else
41 th_prog_license = TH_PROG_LICENSE; 41 th_prog_license = TH_PROG_LICENSE;
42 42
43 th_initialized = TRUE; 43 th_initialized = true;
44 } 44 }
45 45
46 46
47 void th_print_banner(FILE *outFile, const char *name, const char *usage) 47 void th_print_banner(FILE *outFile, const char *name, const char *usage)
48 { 48 {
84 /* Print formatted error, warning and information messages 84 /* Print formatted error, warning and information messages
85 * TODO: Implement th_vfprintf() and friends? 85 * TODO: Implement th_vfprintf() and friends?
86 */ 86 */
87 void THERR_V(const char *fmt, va_list ap) 87 void THERR_V(const char *fmt, va_list ap)
88 { 88 {
89 assert(th_initialized == TRUE); 89 assert(th_initialized == true);
90 90
91 fprintf(stderr, "%s: ", th_prog_name); 91 fprintf(stderr, "%s: ", th_prog_name);
92 vfprintf(stderr, fmt, ap); 92 vfprintf(stderr, fmt, ap);
93 } 93 }
94 94
95 95
96 void THMSG_V(int level, const char *fmt, va_list ap) 96 void THMSG_V(int level, const char *fmt, va_list ap)
97 { 97 {
98 assert(th_initialized == TRUE); 98 assert(th_initialized == true);
99 99
100 if (th_verbosityLevel >= level) 100 if (th_verbosityLevel >= level)
101 { 101 {
102 fprintf(stderr, "%s: ", th_prog_name); 102 fprintf(stderr, "%s: ", th_prog_name);
103 vfprintf(stderr, fmt, ap); 103 vfprintf(stderr, fmt, ap);
105 } 105 }
106 106
107 107
108 void THPRINT_V(int level, const char *fmt, va_list ap) 108 void THPRINT_V(int level, const char *fmt, va_list ap)
109 { 109 {
110 assert(th_initialized == TRUE); 110 assert(th_initialized == true);
111 111
112 if (th_verbosityLevel >= level) 112 if (th_verbosityLevel >= level)
113 { 113 {
114 vfprintf(stderr, fmt, ap); 114 vfprintf(stderr, fmt, ap);
115 } 115 }
117 117
118 118
119 void THERR(const char *fmt, ...) 119 void THERR(const char *fmt, ...)
120 { 120 {
121 va_list ap; 121 va_list ap;
122 assert(th_initialized == TRUE); 122 assert(th_initialized == true);
123 123
124 va_start(ap, fmt); 124 va_start(ap, fmt);
125 THERR_V(fmt, ap); 125 THERR_V(fmt, ap);
126 va_end(ap); 126 va_end(ap);
127 } 127 }
128 128
129 129
130 void THMSG(int level, const char *fmt, ...) 130 void THMSG(int level, const char *fmt, ...)
131 { 131 {
132 va_list ap; 132 va_list ap;
133 assert(th_initialized == TRUE); 133 assert(th_initialized == true);
134 134
135 va_start(ap, fmt); 135 va_start(ap, fmt);
136 THMSG_V(level, fmt, ap); 136 THMSG_V(level, fmt, ap);
137 va_end(ap); 137 va_end(ap);
138 } 138 }
139 139
140 140
141 void THPRINT(int level, const char *fmt, ...) 141 void THPRINT(int level, const char *fmt, ...)
142 { 142 {
143 va_list ap; 143 va_list ap;
144 assert(th_initialized == TRUE); 144 assert(th_initialized == true);
145 145
146 va_start(ap, fmt); 146 va_start(ap, fmt);
147 THPRINT_V(level, fmt, ap); 147 THPRINT_V(level, fmt, ap);
148 va_end(ap); 148 va_end(ap);
149 } 149 }