nutcracker 0.3.0.12 → 0.4.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.md +3 -3
- data/Rakefile +12 -10
- data/ext/nutcracker/Makefile.in +215 -162
- data/ext/nutcracker/README.md +16 -4
- data/ext/nutcracker/aclocal.m4 +432 -254
- data/ext/nutcracker/{contrib/yaml-0.1.4/configure → autom4te.cache/output.0} +11367 -4545
- data/ext/nutcracker/autom4te.cache/output.1 +19907 -0
- data/ext/nutcracker/autom4te.cache/output.2 +19907 -0
- data/ext/nutcracker/autom4te.cache/requests +518 -0
- data/ext/nutcracker/autom4te.cache/traces.0 +2715 -0
- data/ext/nutcracker/autom4te.cache/traces.1 +967 -0
- data/ext/nutcracker/autom4te.cache/traces.2 +2715 -0
- data/ext/nutcracker/config/compile +347 -0
- data/ext/nutcracker/config/config.guess +116 -78
- data/ext/nutcracker/config/config.sub +65 -45
- data/ext/nutcracker/config/depcomp +295 -192
- data/ext/nutcracker/config/install-sh +7 -7
- data/ext/nutcracker/config/ltmain.sh +15 -20
- data/ext/nutcracker/config/missing +149 -265
- data/ext/nutcracker/configure +493 -367
- data/ext/nutcracker/contrib/Makefile.in +158 -116
- data/ext/nutcracker/extconf.rb +0 -1
- data/ext/nutcracker/m4/libtool.m4 +4 -23
- data/ext/nutcracker/m4/ltoptions.m4 +0 -0
- data/ext/nutcracker/m4/ltsugar.m4 +0 -0
- data/ext/nutcracker/m4/ltversion.m4 +0 -0
- data/ext/nutcracker/m4/lt~obsolete.m4 +0 -0
- data/ext/nutcracker/notes/recommendation.md +1 -1
- data/ext/nutcracker/notes/redis.md +35 -3
- data/ext/nutcracker/scripts/benchmark-mget.py +43 -0
- data/ext/nutcracker/scripts/nutcracker.spec +61 -3
- data/ext/nutcracker/scripts/redis-check.sh +43 -0
- data/ext/nutcracker/src/Makefile.in +205 -142
- data/ext/nutcracker/src/event/Makefile.in +164 -66
- data/ext/nutcracker/src/hashkit/Makefile.in +164 -66
- data/ext/nutcracker/src/nc_conf.c +2 -0
- data/ext/nutcracker/src/nc_connection.c +31 -0
- data/ext/nutcracker/src/nc_connection.h +3 -0
- data/ext/nutcracker/src/nc_core.c +38 -2
- data/ext/nutcracker/src/nc_core.h +11 -0
- data/ext/nutcracker/src/nc_log.c +90 -12
- data/ext/nutcracker/src/nc_log.h +11 -0
- data/ext/nutcracker/src/nc_mbuf.h +1 -1
- data/ext/nutcracker/src/nc_message.c +162 -116
- data/ext/nutcracker/src/nc_message.h +161 -129
- data/ext/nutcracker/src/nc_proxy.c +34 -4
- data/ext/nutcracker/src/nc_request.c +158 -32
- data/ext/nutcracker/src/nc_server.c +59 -5
- data/ext/nutcracker/src/nc_server.h +1 -0
- data/ext/nutcracker/src/nc_signal.c +2 -2
- data/ext/nutcracker/src/nc_stats.c +21 -0
- data/ext/nutcracker/src/nc_stats.h +28 -26
- data/ext/nutcracker/src/nc_string.c +176 -1
- data/ext/nutcracker/src/nc_string.h +26 -0
- data/ext/nutcracker/src/nc_util.c +12 -0
- data/ext/nutcracker/src/nc_util.h +1 -0
- data/ext/nutcracker/src/proto/Makefile.in +164 -66
- data/ext/nutcracker/src/proto/nc_memcache.c +279 -88
- data/ext/nutcracker/src/proto/nc_proto.h +3 -4
- data/ext/nutcracker/src/proto/nc_redis.c +561 -134
- data/lib/nutcracker/version.rb +1 -1
- metadata +31 -67
- data/ext/nutcracker/contrib/yaml-0.1.4/LICENSE +0 -19
- data/ext/nutcracker/contrib/yaml-0.1.4/Makefile.am +0 -20
- data/ext/nutcracker/contrib/yaml-0.1.4/Makefile.in +0 -736
- data/ext/nutcracker/contrib/yaml-0.1.4/README +0 -27
- data/ext/nutcracker/contrib/yaml-0.1.4/aclocal.m4 +0 -956
- data/ext/nutcracker/contrib/yaml-0.1.4/config.h.in +0 -80
- data/ext/nutcracker/contrib/yaml-0.1.4/config/config.guess +0 -1561
- data/ext/nutcracker/contrib/yaml-0.1.4/config/config.sub +0 -1686
- data/ext/nutcracker/contrib/yaml-0.1.4/config/depcomp +0 -630
- data/ext/nutcracker/contrib/yaml-0.1.4/config/install-sh +0 -520
- data/ext/nutcracker/contrib/yaml-0.1.4/config/ltmain.sh +0 -8406
- data/ext/nutcracker/contrib/yaml-0.1.4/config/missing +0 -376
- data/ext/nutcracker/contrib/yaml-0.1.4/configure.ac +0 -75
- data/ext/nutcracker/contrib/yaml-0.1.4/doc/doxygen.cfg +0 -222
- data/ext/nutcracker/contrib/yaml-0.1.4/include/yaml.h +0 -1971
- data/ext/nutcracker/contrib/yaml-0.1.4/m4/libtool.m4 +0 -7357
- data/ext/nutcracker/contrib/yaml-0.1.4/m4/ltoptions.m4 +0 -368
- data/ext/nutcracker/contrib/yaml-0.1.4/m4/ltsugar.m4 +0 -123
- data/ext/nutcracker/contrib/yaml-0.1.4/m4/ltversion.m4 +0 -23
- data/ext/nutcracker/contrib/yaml-0.1.4/m4/lt~obsolete.m4 +0 -92
- data/ext/nutcracker/contrib/yaml-0.1.4/src/Makefile.am +0 -4
- data/ext/nutcracker/contrib/yaml-0.1.4/src/Makefile.in +0 -484
- data/ext/nutcracker/contrib/yaml-0.1.4/src/api.c +0 -1392
- data/ext/nutcracker/contrib/yaml-0.1.4/src/dumper.c +0 -394
- data/ext/nutcracker/contrib/yaml-0.1.4/src/emitter.c +0 -2329
- data/ext/nutcracker/contrib/yaml-0.1.4/src/loader.c +0 -432
- data/ext/nutcracker/contrib/yaml-0.1.4/src/parser.c +0 -1374
- data/ext/nutcracker/contrib/yaml-0.1.4/src/reader.c +0 -465
- data/ext/nutcracker/contrib/yaml-0.1.4/src/scanner.c +0 -3570
- data/ext/nutcracker/contrib/yaml-0.1.4/src/writer.c +0 -141
- data/ext/nutcracker/contrib/yaml-0.1.4/src/yaml_private.h +0 -640
- data/ext/nutcracker/contrib/yaml-0.1.4/tests/Makefile.am +0 -8
- data/ext/nutcracker/contrib/yaml-0.1.4/tests/Makefile.in +0 -675
- data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-deconstructor-alt.c +0 -800
- data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-deconstructor.c +0 -1130
- data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-reformatter-alt.c +0 -217
- data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-reformatter.c +0 -202
- data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-dumper.c +0 -311
- data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-emitter.c +0 -327
- data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-loader.c +0 -63
- data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-parser.c +0 -63
- data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-scanner.c +0 -63
- data/ext/nutcracker/contrib/yaml-0.1.4/tests/test-reader.c +0 -354
- data/ext/nutcracker/contrib/yaml-0.1.4/tests/test-version.c +0 -29
@@ -1,327 +0,0 @@
|
|
1
|
-
#include <yaml.h>
|
2
|
-
|
3
|
-
#include <stdlib.h>
|
4
|
-
#include <stdio.h>
|
5
|
-
#include <string.h>
|
6
|
-
|
7
|
-
#ifdef NDEBUG
|
8
|
-
#undef NDEBUG
|
9
|
-
#endif
|
10
|
-
#include <assert.h>
|
11
|
-
|
12
|
-
#define BUFFER_SIZE 65536
|
13
|
-
#define MAX_EVENTS 1024
|
14
|
-
|
15
|
-
int copy_event(yaml_event_t *event_to, yaml_event_t *event_from)
|
16
|
-
{
|
17
|
-
switch (event_from->type)
|
18
|
-
{
|
19
|
-
case YAML_STREAM_START_EVENT:
|
20
|
-
return yaml_stream_start_event_initialize(event_to,
|
21
|
-
event_from->data.stream_start.encoding);
|
22
|
-
|
23
|
-
case YAML_STREAM_END_EVENT:
|
24
|
-
return yaml_stream_end_event_initialize(event_to);
|
25
|
-
|
26
|
-
case YAML_DOCUMENT_START_EVENT:
|
27
|
-
return yaml_document_start_event_initialize(event_to,
|
28
|
-
event_from->data.document_start.version_directive,
|
29
|
-
event_from->data.document_start.tag_directives.start,
|
30
|
-
event_from->data.document_start.tag_directives.end,
|
31
|
-
event_from->data.document_start.implicit);
|
32
|
-
|
33
|
-
case YAML_DOCUMENT_END_EVENT:
|
34
|
-
return yaml_document_end_event_initialize(event_to,
|
35
|
-
event_from->data.document_end.implicit);
|
36
|
-
|
37
|
-
case YAML_ALIAS_EVENT:
|
38
|
-
return yaml_alias_event_initialize(event_to,
|
39
|
-
event_from->data.alias.anchor);
|
40
|
-
|
41
|
-
case YAML_SCALAR_EVENT:
|
42
|
-
return yaml_scalar_event_initialize(event_to,
|
43
|
-
event_from->data.scalar.anchor,
|
44
|
-
event_from->data.scalar.tag,
|
45
|
-
event_from->data.scalar.value,
|
46
|
-
event_from->data.scalar.length,
|
47
|
-
event_from->data.scalar.plain_implicit,
|
48
|
-
event_from->data.scalar.quoted_implicit,
|
49
|
-
event_from->data.scalar.style);
|
50
|
-
|
51
|
-
case YAML_SEQUENCE_START_EVENT:
|
52
|
-
return yaml_sequence_start_event_initialize(event_to,
|
53
|
-
event_from->data.sequence_start.anchor,
|
54
|
-
event_from->data.sequence_start.tag,
|
55
|
-
event_from->data.sequence_start.implicit,
|
56
|
-
event_from->data.sequence_start.style);
|
57
|
-
|
58
|
-
case YAML_SEQUENCE_END_EVENT:
|
59
|
-
return yaml_sequence_end_event_initialize(event_to);
|
60
|
-
|
61
|
-
case YAML_MAPPING_START_EVENT:
|
62
|
-
return yaml_mapping_start_event_initialize(event_to,
|
63
|
-
event_from->data.mapping_start.anchor,
|
64
|
-
event_from->data.mapping_start.tag,
|
65
|
-
event_from->data.mapping_start.implicit,
|
66
|
-
event_from->data.mapping_start.style);
|
67
|
-
|
68
|
-
case YAML_MAPPING_END_EVENT:
|
69
|
-
return yaml_mapping_end_event_initialize(event_to);
|
70
|
-
|
71
|
-
default:
|
72
|
-
assert(1);
|
73
|
-
}
|
74
|
-
|
75
|
-
return 0;
|
76
|
-
}
|
77
|
-
|
78
|
-
int compare_events(yaml_event_t *event1, yaml_event_t *event2)
|
79
|
-
{
|
80
|
-
int k;
|
81
|
-
|
82
|
-
if (event1->type != event2->type)
|
83
|
-
return 0;
|
84
|
-
|
85
|
-
switch (event1->type)
|
86
|
-
{
|
87
|
-
case YAML_STREAM_START_EVENT:
|
88
|
-
return 1;
|
89
|
-
/* return (event1->data.stream_start.encoding ==
|
90
|
-
event2->data.stream_start.encoding); */
|
91
|
-
|
92
|
-
case YAML_DOCUMENT_START_EVENT:
|
93
|
-
if ((event1->data.document_start.version_directive && !event2->data.document_start.version_directive)
|
94
|
-
|| (!event1->data.document_start.version_directive && event2->data.document_start.version_directive)
|
95
|
-
|| (event1->data.document_start.version_directive && event2->data.document_start.version_directive
|
96
|
-
&& (event1->data.document_start.version_directive->major != event2->data.document_start.version_directive->major
|
97
|
-
|| event1->data.document_start.version_directive->minor != event2->data.document_start.version_directive->minor)))
|
98
|
-
return 0;
|
99
|
-
if ((event1->data.document_start.tag_directives.end - event1->data.document_start.tag_directives.start) !=
|
100
|
-
(event2->data.document_start.tag_directives.end - event2->data.document_start.tag_directives.start))
|
101
|
-
return 0;
|
102
|
-
for (k = 0; k < (event1->data.document_start.tag_directives.end - event1->data.document_start.tag_directives.start); k ++) {
|
103
|
-
if ((strcmp((char *)event1->data.document_start.tag_directives.start[k].handle,
|
104
|
-
(char *)event2->data.document_start.tag_directives.start[k].handle) != 0)
|
105
|
-
|| (strcmp((char *)event1->data.document_start.tag_directives.start[k].prefix,
|
106
|
-
(char *)event2->data.document_start.tag_directives.start[k].prefix) != 0))
|
107
|
-
return 0;
|
108
|
-
}
|
109
|
-
/* if (event1->data.document_start.implicit != event2->data.document_start.implicit)
|
110
|
-
return 0; */
|
111
|
-
return 1;
|
112
|
-
|
113
|
-
case YAML_DOCUMENT_END_EVENT:
|
114
|
-
return 1;
|
115
|
-
/* return (event1->data.document_end.implicit ==
|
116
|
-
event2->data.document_end.implicit); */
|
117
|
-
|
118
|
-
case YAML_ALIAS_EVENT:
|
119
|
-
return (strcmp((char *)event1->data.alias.anchor,
|
120
|
-
(char *)event2->data.alias.anchor) == 0);
|
121
|
-
|
122
|
-
case YAML_SCALAR_EVENT:
|
123
|
-
if ((event1->data.scalar.anchor && !event2->data.scalar.anchor)
|
124
|
-
|| (!event1->data.scalar.anchor && event2->data.scalar.anchor)
|
125
|
-
|| (event1->data.scalar.anchor && event2->data.scalar.anchor
|
126
|
-
&& strcmp((char *)event1->data.scalar.anchor,
|
127
|
-
(char *)event2->data.scalar.anchor) != 0))
|
128
|
-
return 0;
|
129
|
-
if ((event1->data.scalar.tag && !event2->data.scalar.tag
|
130
|
-
&& strcmp((char *)event1->data.scalar.tag, "!") != 0)
|
131
|
-
|| (!event1->data.scalar.tag && event2->data.scalar.tag
|
132
|
-
&& strcmp((char *)event2->data.scalar.tag, "!") != 0)
|
133
|
-
|| (event1->data.scalar.tag && event2->data.scalar.tag
|
134
|
-
&& strcmp((char *)event1->data.scalar.tag,
|
135
|
-
(char *)event2->data.scalar.tag) != 0))
|
136
|
-
return 0;
|
137
|
-
if ((event1->data.scalar.length != event2->data.scalar.length)
|
138
|
-
|| memcmp(event1->data.scalar.value, event2->data.scalar.value,
|
139
|
-
event1->data.scalar.length) != 0)
|
140
|
-
return 0;
|
141
|
-
if ((event1->data.scalar.plain_implicit != event2->data.scalar.plain_implicit)
|
142
|
-
|| (event2->data.scalar.quoted_implicit != event2->data.scalar.quoted_implicit)
|
143
|
-
/* || (event2->data.scalar.style != event2->data.scalar.style) */)
|
144
|
-
return 0;
|
145
|
-
return 1;
|
146
|
-
|
147
|
-
case YAML_SEQUENCE_START_EVENT:
|
148
|
-
if ((event1->data.sequence_start.anchor && !event2->data.sequence_start.anchor)
|
149
|
-
|| (!event1->data.sequence_start.anchor && event2->data.sequence_start.anchor)
|
150
|
-
|| (event1->data.sequence_start.anchor && event2->data.sequence_start.anchor
|
151
|
-
&& strcmp((char *)event1->data.sequence_start.anchor,
|
152
|
-
(char *)event2->data.sequence_start.anchor) != 0))
|
153
|
-
return 0;
|
154
|
-
if ((event1->data.sequence_start.tag && !event2->data.sequence_start.tag)
|
155
|
-
|| (!event1->data.sequence_start.tag && event2->data.sequence_start.tag)
|
156
|
-
|| (event1->data.sequence_start.tag && event2->data.sequence_start.tag
|
157
|
-
&& strcmp((char *)event1->data.sequence_start.tag,
|
158
|
-
(char *)event2->data.sequence_start.tag) != 0))
|
159
|
-
return 0;
|
160
|
-
if ((event1->data.sequence_start.implicit != event2->data.sequence_start.implicit)
|
161
|
-
/* || (event2->data.sequence_start.style != event2->data.sequence_start.style) */)
|
162
|
-
return 0;
|
163
|
-
return 1;
|
164
|
-
|
165
|
-
case YAML_MAPPING_START_EVENT:
|
166
|
-
if ((event1->data.mapping_start.anchor && !event2->data.mapping_start.anchor)
|
167
|
-
|| (!event1->data.mapping_start.anchor && event2->data.mapping_start.anchor)
|
168
|
-
|| (event1->data.mapping_start.anchor && event2->data.mapping_start.anchor
|
169
|
-
&& strcmp((char *)event1->data.mapping_start.anchor,
|
170
|
-
(char *)event2->data.mapping_start.anchor) != 0))
|
171
|
-
return 0;
|
172
|
-
if ((event1->data.mapping_start.tag && !event2->data.mapping_start.tag)
|
173
|
-
|| (!event1->data.mapping_start.tag && event2->data.mapping_start.tag)
|
174
|
-
|| (event1->data.mapping_start.tag && event2->data.mapping_start.tag
|
175
|
-
&& strcmp((char *)event1->data.mapping_start.tag,
|
176
|
-
(char *)event2->data.mapping_start.tag) != 0))
|
177
|
-
return 0;
|
178
|
-
if ((event1->data.mapping_start.implicit != event2->data.mapping_start.implicit)
|
179
|
-
/* || (event2->data.mapping_start.style != event2->data.mapping_start.style) */)
|
180
|
-
return 0;
|
181
|
-
return 1;
|
182
|
-
|
183
|
-
default:
|
184
|
-
return 1;
|
185
|
-
}
|
186
|
-
}
|
187
|
-
|
188
|
-
int print_output(char *name, unsigned char *buffer, size_t size, int count)
|
189
|
-
{
|
190
|
-
FILE *file;
|
191
|
-
char data[BUFFER_SIZE];
|
192
|
-
size_t data_size = 1;
|
193
|
-
size_t total_size = 0;
|
194
|
-
if (count >= 0) {
|
195
|
-
printf("FAILED (at the event #%d)\nSOURCE:\n", count+1);
|
196
|
-
}
|
197
|
-
file = fopen(name, "rb");
|
198
|
-
assert(file);
|
199
|
-
while (data_size > 0) {
|
200
|
-
data_size = fread(data, 1, BUFFER_SIZE, file);
|
201
|
-
assert(!ferror(file));
|
202
|
-
if (!data_size) break;
|
203
|
-
assert(fwrite(data, 1, data_size, stdout) == data_size);
|
204
|
-
total_size += data_size;
|
205
|
-
if (feof(file)) break;
|
206
|
-
}
|
207
|
-
fclose(file);
|
208
|
-
printf("#### (length: %d)\n", total_size);
|
209
|
-
printf("OUTPUT:\n%s#### (length: %d)\n", buffer, size);
|
210
|
-
return 0;
|
211
|
-
}
|
212
|
-
|
213
|
-
int
|
214
|
-
main(int argc, char *argv[])
|
215
|
-
{
|
216
|
-
int number;
|
217
|
-
int canonical = 0;
|
218
|
-
int unicode = 0;
|
219
|
-
|
220
|
-
number = 1;
|
221
|
-
while (number < argc) {
|
222
|
-
if (strcmp(argv[number], "-c") == 0) {
|
223
|
-
canonical = 1;
|
224
|
-
}
|
225
|
-
else if (strcmp(argv[number], "-u") == 0) {
|
226
|
-
unicode = 1;
|
227
|
-
}
|
228
|
-
else if (argv[number][0] == '-') {
|
229
|
-
printf("Unknown option: '%s'\n", argv[number]);
|
230
|
-
return 0;
|
231
|
-
}
|
232
|
-
if (argv[number][0] == '-') {
|
233
|
-
if (number < argc-1) {
|
234
|
-
memmove(argv+number, argv+number+1, (argc-number-1)*sizeof(char *));
|
235
|
-
}
|
236
|
-
argc --;
|
237
|
-
}
|
238
|
-
else {
|
239
|
-
number ++;
|
240
|
-
}
|
241
|
-
}
|
242
|
-
|
243
|
-
if (argc < 2) {
|
244
|
-
printf("Usage: %s [-c] [-u] file1.yaml ...\n", argv[0]);
|
245
|
-
return 0;
|
246
|
-
}
|
247
|
-
|
248
|
-
for (number = 1; number < argc; number ++)
|
249
|
-
{
|
250
|
-
FILE *file;
|
251
|
-
yaml_parser_t parser;
|
252
|
-
yaml_emitter_t emitter;
|
253
|
-
yaml_event_t event;
|
254
|
-
unsigned char buffer[BUFFER_SIZE];
|
255
|
-
size_t written = 0;
|
256
|
-
yaml_event_t events[MAX_EVENTS];
|
257
|
-
size_t event_number = 0;
|
258
|
-
int done = 0;
|
259
|
-
int count = 0;
|
260
|
-
int error = 0;
|
261
|
-
int k;
|
262
|
-
memset(buffer, 0, BUFFER_SIZE);
|
263
|
-
memset(events, 0, MAX_EVENTS*sizeof(yaml_event_t));
|
264
|
-
|
265
|
-
printf("[%d] Parsing, emitting, and parsing again '%s': ", number, argv[number]);
|
266
|
-
fflush(stdout);
|
267
|
-
|
268
|
-
file = fopen(argv[number], "rb");
|
269
|
-
assert(file);
|
270
|
-
|
271
|
-
assert(yaml_parser_initialize(&parser));
|
272
|
-
yaml_parser_set_input_file(&parser, file);
|
273
|
-
assert(yaml_emitter_initialize(&emitter));
|
274
|
-
if (canonical) {
|
275
|
-
yaml_emitter_set_canonical(&emitter, 1);
|
276
|
-
}
|
277
|
-
if (unicode) {
|
278
|
-
yaml_emitter_set_unicode(&emitter, 1);
|
279
|
-
}
|
280
|
-
yaml_emitter_set_output_string(&emitter, buffer, BUFFER_SIZE, &written);
|
281
|
-
|
282
|
-
while (!done)
|
283
|
-
{
|
284
|
-
if (!yaml_parser_parse(&parser, &event)) {
|
285
|
-
error = 1;
|
286
|
-
break;
|
287
|
-
}
|
288
|
-
|
289
|
-
done = (event.type == YAML_STREAM_END_EVENT);
|
290
|
-
assert(event_number < MAX_EVENTS);
|
291
|
-
assert(copy_event(&(events[event_number++]), &event));
|
292
|
-
assert(yaml_emitter_emit(&emitter, &event) ||
|
293
|
-
(yaml_emitter_flush(&emitter) && print_output(argv[number], buffer, written, count)));
|
294
|
-
count ++;
|
295
|
-
}
|
296
|
-
|
297
|
-
yaml_parser_delete(&parser);
|
298
|
-
assert(!fclose(file));
|
299
|
-
yaml_emitter_delete(&emitter);
|
300
|
-
|
301
|
-
if (!error)
|
302
|
-
{
|
303
|
-
count = done = 0;
|
304
|
-
assert(yaml_parser_initialize(&parser));
|
305
|
-
yaml_parser_set_input_string(&parser, buffer, written);
|
306
|
-
|
307
|
-
while (!done)
|
308
|
-
{
|
309
|
-
assert(yaml_parser_parse(&parser, &event) || print_output(argv[number], buffer, written, count));
|
310
|
-
done = (event.type == YAML_STREAM_END_EVENT);
|
311
|
-
assert(compare_events(events+count, &event) || print_output(argv[number], buffer, written, count));
|
312
|
-
yaml_event_delete(&event);
|
313
|
-
count ++;
|
314
|
-
}
|
315
|
-
yaml_parser_delete(&parser);
|
316
|
-
}
|
317
|
-
|
318
|
-
for (k = 0; k < event_number; k ++) {
|
319
|
-
yaml_event_delete(events+k);
|
320
|
-
}
|
321
|
-
|
322
|
-
printf("PASSED (length: %d)\n", written);
|
323
|
-
print_output(argv[number], buffer, written, -1);
|
324
|
-
}
|
325
|
-
|
326
|
-
return 0;
|
327
|
-
}
|
@@ -1,63 +0,0 @@
|
|
1
|
-
#include <yaml.h>
|
2
|
-
|
3
|
-
#include <stdlib.h>
|
4
|
-
#include <stdio.h>
|
5
|
-
|
6
|
-
#ifdef NDEBUG
|
7
|
-
#undef NDEBUG
|
8
|
-
#endif
|
9
|
-
#include <assert.h>
|
10
|
-
|
11
|
-
int
|
12
|
-
main(int argc, char *argv[])
|
13
|
-
{
|
14
|
-
int number;
|
15
|
-
|
16
|
-
if (argc < 2) {
|
17
|
-
printf("Usage: %s file1.yaml ...\n", argv[0]);
|
18
|
-
return 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
for (number = 1; number < argc; number ++)
|
22
|
-
{
|
23
|
-
FILE *file;
|
24
|
-
yaml_parser_t parser;
|
25
|
-
yaml_document_t document;
|
26
|
-
int done = 0;
|
27
|
-
int count = 0;
|
28
|
-
int error = 0;
|
29
|
-
|
30
|
-
printf("[%d] Loading '%s': ", number, argv[number]);
|
31
|
-
fflush(stdout);
|
32
|
-
|
33
|
-
file = fopen(argv[number], "rb");
|
34
|
-
assert(file);
|
35
|
-
|
36
|
-
assert(yaml_parser_initialize(&parser));
|
37
|
-
|
38
|
-
yaml_parser_set_input_file(&parser, file);
|
39
|
-
|
40
|
-
while (!done)
|
41
|
-
{
|
42
|
-
if (!yaml_parser_load(&parser, &document)) {
|
43
|
-
error = 1;
|
44
|
-
break;
|
45
|
-
}
|
46
|
-
|
47
|
-
done = (!yaml_document_get_root_node(&document));
|
48
|
-
|
49
|
-
yaml_document_delete(&document);
|
50
|
-
|
51
|
-
if (!done) count ++;
|
52
|
-
}
|
53
|
-
|
54
|
-
yaml_parser_delete(&parser);
|
55
|
-
|
56
|
-
assert(!fclose(file));
|
57
|
-
|
58
|
-
printf("%s (%d documents)\n", (error ? "FAILURE" : "SUCCESS"), count);
|
59
|
-
}
|
60
|
-
|
61
|
-
return 0;
|
62
|
-
}
|
63
|
-
|
@@ -1,63 +0,0 @@
|
|
1
|
-
#include <yaml.h>
|
2
|
-
|
3
|
-
#include <stdlib.h>
|
4
|
-
#include <stdio.h>
|
5
|
-
|
6
|
-
#ifdef NDEBUG
|
7
|
-
#undef NDEBUG
|
8
|
-
#endif
|
9
|
-
#include <assert.h>
|
10
|
-
|
11
|
-
int
|
12
|
-
main(int argc, char *argv[])
|
13
|
-
{
|
14
|
-
int number;
|
15
|
-
|
16
|
-
if (argc < 2) {
|
17
|
-
printf("Usage: %s file1.yaml ...\n", argv[0]);
|
18
|
-
return 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
for (number = 1; number < argc; number ++)
|
22
|
-
{
|
23
|
-
FILE *file;
|
24
|
-
yaml_parser_t parser;
|
25
|
-
yaml_event_t event;
|
26
|
-
int done = 0;
|
27
|
-
int count = 0;
|
28
|
-
int error = 0;
|
29
|
-
|
30
|
-
printf("[%d] Parsing '%s': ", number, argv[number]);
|
31
|
-
fflush(stdout);
|
32
|
-
|
33
|
-
file = fopen(argv[number], "rb");
|
34
|
-
assert(file);
|
35
|
-
|
36
|
-
assert(yaml_parser_initialize(&parser));
|
37
|
-
|
38
|
-
yaml_parser_set_input_file(&parser, file);
|
39
|
-
|
40
|
-
while (!done)
|
41
|
-
{
|
42
|
-
if (!yaml_parser_parse(&parser, &event)) {
|
43
|
-
error = 1;
|
44
|
-
break;
|
45
|
-
}
|
46
|
-
|
47
|
-
done = (event.type == YAML_STREAM_END_EVENT);
|
48
|
-
|
49
|
-
yaml_event_delete(&event);
|
50
|
-
|
51
|
-
count ++;
|
52
|
-
}
|
53
|
-
|
54
|
-
yaml_parser_delete(&parser);
|
55
|
-
|
56
|
-
assert(!fclose(file));
|
57
|
-
|
58
|
-
printf("%s (%d events)\n", (error ? "FAILURE" : "SUCCESS"), count);
|
59
|
-
}
|
60
|
-
|
61
|
-
return 0;
|
62
|
-
}
|
63
|
-
|