-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.cpp
50 lines (42 loc) · 914 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
/*
* REminiscence - Flashback interpreter
* Copyright (C) 2005-2019 Gregory Montoir (cyx@users.sourceforge.net)
*/
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#include <stdarg.h>
#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);
fprintf(stdout, "%s\n", buf);
fflush(stdout);
}
}
void error(const char *msg, ...) {
char buf[1024];
va_list va;
va_start(va, msg);
vsnprintf(buf, sizeof(buf), msg, va);
va_end(va);
fprintf(stderr, "ERROR: %s!\n", buf);
#ifdef _WIN32
MessageBox(0, buf, g_caption, MB_ICONERROR);
#endif
exit(-1);
}
void warning(const char *msg, ...) {
char buf[1024];
va_list va;
va_start(va, msg);
vsnprintf(buf, sizeof(buf), msg, va);
va_end(va);
fprintf(stderr, "WARNING: %s!\n", buf);
}