forked from cyxx/rawgl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.cpp
57 lines (49 loc) · 949 Bytes
/
util.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* Another World engine rewrite
* Copyright (C) 2004-2005 Gregory Montoir ([email protected])
*/
#include <cstdarg>
#include "util.h"
uint16_t g_debugMask;
void debug(uint16_t cm, const char *msg, ...) {
char buf[1024];
if (cm & g_debugMask) {
va_list va;
va_start(va, msg);
vsprintf(buf, msg, va);
va_end(va);
printf("%s\n", buf);
fflush(stdout);
}
}
void error(const char *msg, ...) {
char buf[1024];
va_list va;
va_start(va, msg);
vsprintf(buf, msg, va);
va_end(va);
fprintf(stderr, "ERROR: %s!\n", buf);
exit(-1);
}
void warning(const char *msg, ...) {
char buf[1024];
va_list va;
va_start(va, msg);
vsprintf(buf, msg, va);
va_end(va);
fprintf(stderr, "WARNING: %s!\n", buf);
}
void string_lower(char *p) {
for (; *p; ++p) {
if (*p >= 'A' && *p <= 'Z') {
*p += 'a' - 'A';
}
}
}
void string_upper(char *p) {
for (; *p; ++p) {
if (*p >= 'a' && *p <= 'z') {
*p += 'A' - 'a';
}
}
}