comparison src/dmlib.c @ 2586:9807ae37ad69

Require stdbool.h, we require C11 now.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 08 Dec 2022 15:59:22 +0200
parents 69a5af2eb1ea
children
comparison
equal deleted inserted replaced
2585:ef6c826c5b7a 2586:9807ae37ad69
121 *ptr = NULL; 121 *ptr = NULL;
122 } 122 }
123 } 123 }
124 124
125 125
126 BOOL dmGetIntVal(const char *str, unsigned int *value, BOOL *neg) 126 bool dmGetIntVal(const char *str, unsigned int *value, bool *neg)
127 { 127 {
128 int ch; 128 int ch;
129 BOOL hex = FALSE; 129 bool hex = false;
130 130
131 // Is the value negative? 131 // Is the value negative?
132 if (*str == '-') 132 if (*str == '-')
133 { 133 {
134 if (neg == NULL) 134 if (neg == NULL)
135 return FALSE; 135 return false;
136 136
137 *neg = TRUE; 137 *neg = true;
138 str++; 138 str++;
139 } 139 }
140 else 140 else
141 if (neg != NULL) 141 if (neg != NULL)
142 *neg = FALSE; 142 *neg = false;
143 143
144 // Is it hexadecimal? 144 // Is it hexadecimal?
145 if (*str == '$') 145 if (*str == '$')
146 { 146 {
147 hex = TRUE; 147 hex = true;
148 str++; 148 str++;
149 } 149 }
150 else 150 else
151 if (str[0] == '0' && str[1] == 'x') 151 if (str[0] == '0' && str[1] == 'x')
152 { 152 {
153 hex = TRUE; 153 hex = true;
154 str += 2; 154 str += 2;
155 } 155 }
156 156
157 // Parse the value 157 // Parse the value
158 *value = 0; 158 *value = 0;
176 { 176 {
177 *value <<= 4; 177 *value <<= 4;
178 *value |= ch - 'a' + 10; 178 *value |= ch - 'a' + 10;
179 } 179 }
180 else 180 else
181 return FALSE; 181 return false;
182 } 182 }
183 } 183 }
184 else 184 else
185 { 185 {
186 while ((ch = *str++)) 186 while ((ch = *str++))
189 { 189 {
190 *value *= 10; 190 *value *= 10;
191 *value += ch - '0'; 191 *value += ch - '0';
192 } 192 }
193 else 193 else
194 return FALSE; 194 return false;
195 } 195 }
196 } 196 }
197 return TRUE; 197 return true;
198 } 198 }
199 199
200 200
201 /* 201 /*
202 * Error handling and messages 202 * Error handling and messages
349 { 349 {
350 DMMutexLock *lock = &(mutex->locks[i]); 350 DMMutexLock *lock = &(mutex->locks[i]);
351 if (!lock->used) 351 if (!lock->used)
352 { 352 {
353 int res; 353 int res;
354 lock->used = TRUE; 354 lock->used = true;
355 lock->id = SDL_ThreadID(); 355 lock->id = SDL_ThreadID();
356 lock->state++; 356 lock->state++;
357 res = SDL_mutexP(mutex->m); 357 res = SDL_mutexP(mutex->m);
358 fprintf(stderr, "LOCKING %p @ thread=%d done [2].\n", mutex, SDL_ThreadID()); 358 fprintf(stderr, "LOCKING %p @ thread=%d done [2].\n", mutex, SDL_ThreadID());
359 return res; 359 return res;