-
Notifications
You must be signed in to change notification settings - Fork 2
/
mtest.c
118 lines (106 loc) · 1.92 KB
/
mtest.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
114
115
116
117
118
#include "pprint.h"
struct person {
int age;
int height;
struct like {
char *type;
char *name;
} like;
};
typedef enum enum_t {
A = 1 << 0,
B = 1 << 1,
C = 1 << 2,
D = 1 << 3,
} enum_t;
typedef struct sub2_t {
char *msg;
} sub2_t;
typedef struct sub_t {
int sub_dat1;
int sub_dat2;
int sub_dat3;
sub2_t *psub2a;
sub2_t *psub2b;
} sub_t;
typedef struct data_t {
int data_int;
char c;
char *str;
void *addr;
enum_t e;
sub_t sub;
char *text;
sub_t *psub;
} data_t;
int main() {
char out[10240];
char sub_out[10240];
struct person johndoe = {
.age = 6,
.like = {
.type = "Software-Developing",
.name = "C"
}
};
structInfo person_info[] = {
{
.data = &johndoe,
.structName = "person",
.level = 0 /* the first must be level 0 */
},
};
pprint_struct("johndoe", person_info, ARRAY_SIZE(person_info));
int hoge = 10;
char *str = "abcd";
struct sub2_t sub2 = {
.msg = "abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz",
};
struct sub_t sub = {
.sub_dat1 = 1,
.sub_dat2 = 2,
.sub_dat3 = 3,
.psub2b = &sub2,
};
struct data_t d = {
.data_int = 1,
.c = 'x',
.str = str,
.addr = &hoge,
.e = A | C | D,
.sub = {
.sub_dat1 = 123,
.sub_dat2 = -1,
.sub_dat3 = 0xa,
},
.text = "hogehoge",
.psub = &sub,
};
structInfo data_info[] = {
{
.data = &d,
.structName = "data_t",
.level = 0 /* the first must be level 0 */
},
{
.data = &hoge,
.func = pprint_int,
.level = 1,
},
{
.data = &sub,
.structName = "sub_t",
.level = 1
},
{
.data = &sub2,
.structName = "sub2_t",
.level = 2
},
};
pprint_struct("d", data_info, ARRAY_SIZE(data_info));
return 0;
}
/* vim: set ts=2 sw=2 expandtab: */