-
Notifications
You must be signed in to change notification settings - Fork 1
/
debug.c
66 lines (51 loc) · 1.08 KB
/
debug.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
#include "std.h"
#include "lpc_incl.h"
#ifdef DEBUG_MACRO
mapping_t *debug_levels (void);
typedef struct {
char *name;
int bit;
} debug_t;
#define E(x) { #x, DBG_##x }
debug_t levels[] = {
E(call_out),
E(d_flag),
E(connections),
E(mapping),
E(sockets),
E(comp_func_tab),
E(LPC),
E(LPC_line)
};
#define NELEM(x) (sizeof(x)/sizeof(x[0]))
mapping_t *debug_levels() {
int dl = debug_level;
mapping_t *ret = allocate_mapping(10);
int i;
for (i = 0; i < NELEM(levels); i++) {
add_mapping_pair(ret, levels[i].name, dl & levels[i].bit);
dl &= ~levels[i].bit;
}
if (dl)
add_mapping_pair(ret, "unknown", dl);
return ret;
}
void debug_level_set (char * level) {
int i;
for (i = 0; i < NELEM(levels); i++) {
if (strcmp(level, levels[i].name) == 0) {
debug_level |= levels[i].bit;
return;
}
}
}
void debug_level_clear (char * level) {
int i;
for (i = 0; i < NELEM(levels); i++) {
if (strcmp(level, levels[i].name) == 0) {
debug_level &= ~levels[i].bit;
return;
}
}
}
#endif