-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathutil.cpp
63 lines (55 loc) · 1.22 KB
/
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
58
59
60
61
62
/*
* REminiscence - Flashback interpreter
* Copyright (C) 2005-2019 Gregory Montoir ([email protected])
*/
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#ifdef __ANDROID__
#define LOG_TAG "FbJni"
#include <android/log.h>
#endif
#include <stdarg.h>
#include "util.h"
uint32_t g_debugMask;
void debug(uint32_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);
#ifdef __ANDROID__
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "%s", buf);
#endif
}
}
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
#ifdef __ANDROID__
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "%s", buf);
#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);
#ifdef __ANDROID__
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "%s", buf);
#endif
}