forked from mailru/confetti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
d_dump.c
74 lines (68 loc) · 1.39 KB
/
d_dump.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
#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
#include <prscfl.h>
static void
putt(int level) {
while(level--)
putchar('\t');
}
static void
printDef(char *type, ParamDef *def) {
printf("%s (%s%s)\t%s\n",
type,
(def->flags & PARAMDEF_RDONLY) ? "RO" : "RW",
(def->flags & PARAMDEF_REQUIRED) ? ", REQ" : "",
def->name);
}
static void
debugParamDef(ParamDef *def, int level) {
while(def) {
putt(level);
switch(def->paramType) {
case int32Type:
printDef("int32_t", def);
break;
case uint32Type:
printDef("u_int32_t", def);
break;
case int64Type:
printDef("int64_t", def);
break;
case uint64Type:
printDef("u_int64_t", def);
break;
case doubleType:
printDef("double", def);
break;
case stringType:
printDef("char*", def);
break;
case boolType:
printDef("bool", def);
break;
case commentType:
fprintf(stderr, "Unexpected comment");
break;
case structType:
printDef("struct", def);
debugParamDef(def->paramValue.structval, level+1);
break;
case arrayType:
printDef("array", def);
debugParamDef(def->paramValue.arrayval, level+1);
break;
case builtinType:
printf("BUILTIN\n");
break;
default:
fprintf(stderr,"Unknown paramType (%d)\n", def->paramType);
exit(1);
}
def = def->next;
}
}
void
dDump(ParamDef *def) {
debugParamDef(def, 0);
}