-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
118 lines (102 loc) · 2.13 KB
/
main.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 <stdio.h>
#include <stddef.h>
#include <inttypes.h>
#include "my_struct.h"
#include "my_struct_utils.h"
#define BL_I(s) blob_init(sizeof(s)-1, (uint8_t [sizeof(s)-1]){s})
#define BL_N(s) node_elm_init_b(BL_I(s))
#define ST_I(...) \
stack_init \
( \
sizeof((node_elm []){__VA_ARGS__})/sizeof(node_elm), \
(node_elm []){__VA_ARGS__} \
)
#define ST_N(...) node_elm_init_st(ST_I(__VA_ARGS__))
int main(int argc, char *argv[], char *envp[])
{
stack *a = stack_scan_fromstream2(stdin);
stack_print(a,0,2);
stack_free(a);
#if 0
// testing stuff
if (0)
{
blob *bl = blob_scan_fromstream(stdin);
//printf("test");
//printf("%zu\n", bl->len);
blob_print(bl);
stack *a =
ST_I(
BL_N("a\n\nbc\"0\""),
BL_N("abc1"),
BL_N("abc2"),
BL_N("abc3"),
BL_N("abc4"),
ST_N
(
BL_N
("!abc0"),
BL_N("!abc1\x00"),
BL_N("!abc2"),
BL_N("!abc3"),
BL_N("!abc4"),
ST_N
(
BL_N("!!abc0"),
BL_N("!!abc1"),
BL_N("!!abc2"),
)
),
BL_N("abc5")
);
/*
stack *a = stack_init
(
4,
(node_elm[4])
{
NODE_S("abc"),
//node_elm_init_b(blob_init("123a", 4)),
node_elm_init_b(blob_init("234b", 4)),
node_elm_init_b(blob_init("345c", 4)),
node_elm_init_st(stack_init_list
(
3,
node_elm_init_b(blob_init("lalala1", 7)),
node_elm_init_b(blob_init("lalala2", 7)),
node_elm_init_b(blob_init("lalala3", 7))
))
}
);*/
stack_print(a,0,2);
printf("is same a a: %d\n", stack_cmp(a,a));
stack *b =
ST_I(
BL_N("a\n\nbc\"0\""),
BL_N("abc1"),
BL_N("abc2"),
BL_N("abc3"),
BL_N("abc4"),
ST_N
(
BL_N
("!abc0"),
BL_N("!abc1\x00"),
BL_N("!abc2"),
BL_N("!abc3"),
BL_N("!abc4"),
ST_N
(
BL_N("!!abc0"),
BL_N("!!abc1"),
BL_N("!!abc2"),
)
),
BL_N("abc5")
);
printf("is same a b: %d\n", stack_cmp(a,b));
stack_free(a);
}
#endif
return 0;
}