-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessage.c
113 lines (97 loc) · 1.87 KB
/
message.c
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include "message.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "defs.h"
#define colorRed(s) fprintf(s, "\033[1;31m")
#define colorBlue(s) fprintf(s, "\033[1;34m")
#define colorGreen(s) fprintf(s, "\033[1;32m")
#define colorEnd(s) fprintf(s, "\033[0m")
void message_CriticalError(const char *msg)
{
#ifdef __BASH_COLORS
colorRed(stderr);
#endif
fprintf(stderr, "E: ");
fprintf(stderr, "critical error: %s", msg);
exit(1);
#ifdef __BASH_COLORS
colorEnd(stderr);
#endif
}
void message_Warning(const char *msg)
{
#ifdef __BASH_COLORS
colorBlue(stderr);
#endif
fprintf(stderr, "W: %s", msg);
#ifdef __BASH_COLORS
colorEnd(stderr);
#endif
}
void message_CriticalErrorEx(const char *fmt, ...)
{
#ifdef __BASH_COLORS
colorRed(stderr);
#endif
fprintf(stderr, "E: ");
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
#ifdef __BASH_COLORS
colorEnd(stderr);
#endif
}
void message_WarningEx(const char *fmt, ...)
{
#ifdef __BASH_COLORS
colorBlue(stderr);
#endif
fprintf(stderr, "W: ");
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
#ifdef __BASH_COLORS
colorEnd(stderr);
#endif
}
void message_Out(const char *msg)
{
printf("M: ");
printf(msg);
}
void message_OutEx(const char *fmt, ...)
{
printf("M: ");
va_list args;
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
}
void message_OutEmf(const char *msg)
{
#ifdef __BASH_COLORS
colorGreen(stdout);
#endif
printf("!M: ");
printf(msg);
#ifdef __BASH_COLORS
colorEnd(stdout);
#endif
}
void message_OutEmfEx(const char *fmt, ...)
{
#ifdef __BASH_COLORS
colorGreen(stdout);
#endif
printf("!M: ");
va_list args;
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
#ifdef __BASH_COLORS
colorEnd(stdout);
#endif
}