blob: fd1126427e2dfc83a5f109082ac654a5194a53e3 (
plain) (
blame)
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
|
#include <assert.h>
#include <def.h>
#include <gui.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <warnings.h>
#define WARNING_COUNT 1024 // Well, something went horribly wrong I guess
#define WARNING_LENGTH 64
struct warning {
u8 exists;
u32 line;
char text[WARNING_LENGTH];
};
static struct warning warnings[WARNING_COUNT] = { 0 };
static u32 warning_index = 0;
void warnings_add(u32 line, const char *fmt, ...)
{
assert(warning_index + 1 < WARNING_COUNT);
warnings[warning_index].exists = 1;
warnings[warning_index].line = line;
va_list ap;
va_start(ap, fmt);
vsnprintf(warnings[warning_index].text, WARNING_LENGTH, fmt, ap);
va_end(ap);
warning_index++;
}
// TODO: Print somewhere else (e.g. next to line)
void warnings_print(void)
{
for (u32 i = 0; i < WARNING_COUNT; i++) {
if (!warnings[i].exists)
continue;
/* gui_show_warning(warnings[i].text); */
printf("Line %d: %s\n", warnings[i].line, warnings[i].text);
}
}
u8 warnings_exist(void)
{
return warning_index > 0;
}
void warnings_clear(void)
{
if (warning_index)
memset(warnings, 0, sizeof(warnings));
}
|