nutcracker 0.4.0.16 → 0.4.1.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +3 -3
  3. data/ext/nutcracker/ChangeLog +33 -8
  4. data/ext/nutcracker/Makefile.in +34 -21
  5. data/ext/nutcracker/README.md +61 -26
  6. data/ext/nutcracker/aclocal.m4 +34 -31
  7. data/ext/nutcracker/autom4te.cache/output.0 +1875 -1330
  8. data/ext/nutcracker/autom4te.cache/output.1 +1875 -1330
  9. data/ext/nutcracker/autom4te.cache/requests +232 -451
  10. data/ext/nutcracker/autom4te.cache/traces.0 +2256 -2129
  11. data/ext/nutcracker/autom4te.cache/traces.1 +73 -59
  12. data/ext/nutcracker/config.h.in +1 -2
  13. data/ext/nutcracker/config.h.in~ +333 -0
  14. data/ext/nutcracker/config/compile +1 -1
  15. data/ext/nutcracker/config/config.guess +13 -160
  16. data/ext/nutcracker/config/config.sub +25 -11
  17. data/ext/nutcracker/config/depcomp +1 -1
  18. data/ext/nutcracker/config/install-sh +170 -196
  19. data/ext/nutcracker/config/ltmain.sh +3509 -2018
  20. data/ext/nutcracker/config/missing +1 -1
  21. data/ext/nutcracker/configure +1874 -1329
  22. data/ext/nutcracker/configure.ac +3 -2
  23. data/ext/nutcracker/contrib/Makefile.in +18 -5
  24. data/ext/nutcracker/contrib/yaml-0.1.4/LICENSE +19 -0
  25. data/ext/nutcracker/contrib/yaml-0.1.4/Makefile.am +20 -0
  26. data/ext/nutcracker/contrib/yaml-0.1.4/Makefile.in +832 -0
  27. data/ext/nutcracker/contrib/yaml-0.1.4/README +27 -0
  28. data/ext/nutcracker/contrib/yaml-0.1.4/aclocal.m4 +1157 -0
  29. data/ext/nutcracker/contrib/yaml-0.1.4/autom4te.cache/output.0 +13342 -0
  30. data/ext/nutcracker/contrib/yaml-0.1.4/autom4te.cache/output.1 +14611 -0
  31. data/ext/nutcracker/{autom4te.cache → contrib/yaml-0.1.4/autom4te.cache}/output.2 +3465 -8761
  32. data/ext/nutcracker/contrib/yaml-0.1.4/autom4te.cache/requests +516 -0
  33. data/ext/nutcracker/{autom4te.cache/traces.2 → contrib/yaml-0.1.4/autom4te.cache/traces.0} +662 -698
  34. data/ext/nutcracker/contrib/yaml-0.1.4/autom4te.cache/traces.1 +577 -0
  35. data/ext/nutcracker/contrib/yaml-0.1.4/autom4te.cache/traces.2 +2721 -0
  36. data/ext/nutcracker/contrib/yaml-0.1.4/config.h.in +79 -0
  37. data/ext/nutcracker/contrib/yaml-0.1.4/config.h.in~ +80 -0
  38. data/ext/nutcracker/contrib/yaml-0.1.4/config/compile +347 -0
  39. data/ext/nutcracker/contrib/yaml-0.1.4/config/config.guess +1421 -0
  40. data/ext/nutcracker/contrib/yaml-0.1.4/config/config.sub +1807 -0
  41. data/ext/nutcracker/contrib/yaml-0.1.4/config/depcomp +791 -0
  42. data/ext/nutcracker/contrib/yaml-0.1.4/config/install-sh +501 -0
  43. data/ext/nutcracker/contrib/yaml-0.1.4/config/ltmain.sh +11147 -0
  44. data/ext/nutcracker/contrib/yaml-0.1.4/config/missing +215 -0
  45. data/ext/nutcracker/contrib/yaml-0.1.4/config/test-driver +148 -0
  46. data/ext/nutcracker/contrib/yaml-0.1.4/configure +14611 -0
  47. data/ext/nutcracker/contrib/yaml-0.1.4/configure.ac +75 -0
  48. data/ext/nutcracker/contrib/yaml-0.1.4/doc/doxygen.cfg +222 -0
  49. data/ext/nutcracker/contrib/yaml-0.1.4/include/yaml.h +1971 -0
  50. data/ext/nutcracker/contrib/yaml-0.1.4/m4/libtool.m4 +8369 -0
  51. data/ext/nutcracker/contrib/yaml-0.1.4/m4/ltoptions.m4 +437 -0
  52. data/ext/nutcracker/contrib/yaml-0.1.4/m4/ltsugar.m4 +124 -0
  53. data/ext/nutcracker/contrib/yaml-0.1.4/m4/ltversion.m4 +23 -0
  54. data/ext/nutcracker/contrib/yaml-0.1.4/m4/lt~obsolete.m4 +99 -0
  55. data/ext/nutcracker/contrib/yaml-0.1.4/src/Makefile.am +4 -0
  56. data/ext/nutcracker/contrib/yaml-0.1.4/src/Makefile.in +600 -0
  57. data/ext/nutcracker/contrib/yaml-0.1.4/src/api.c +1392 -0
  58. data/ext/nutcracker/contrib/yaml-0.1.4/src/dumper.c +394 -0
  59. data/ext/nutcracker/contrib/yaml-0.1.4/src/emitter.c +2329 -0
  60. data/ext/nutcracker/contrib/yaml-0.1.4/src/loader.c +432 -0
  61. data/ext/nutcracker/contrib/yaml-0.1.4/src/parser.c +1374 -0
  62. data/ext/nutcracker/contrib/yaml-0.1.4/src/reader.c +465 -0
  63. data/ext/nutcracker/contrib/yaml-0.1.4/src/scanner.c +3570 -0
  64. data/ext/nutcracker/contrib/yaml-0.1.4/src/writer.c +141 -0
  65. data/ext/nutcracker/contrib/yaml-0.1.4/src/yaml_private.h +640 -0
  66. data/ext/nutcracker/contrib/yaml-0.1.4/tests/Makefile.am +8 -0
  67. data/ext/nutcracker/contrib/yaml-0.1.4/tests/Makefile.in +1083 -0
  68. data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-deconstructor-alt.c +800 -0
  69. data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-deconstructor.c +1130 -0
  70. data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-reformatter-alt.c +217 -0
  71. data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-reformatter.c +202 -0
  72. data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-dumper.c +311 -0
  73. data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-emitter.c +327 -0
  74. data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-loader.c +63 -0
  75. data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-parser.c +63 -0
  76. data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-scanner.c +63 -0
  77. data/ext/nutcracker/contrib/yaml-0.1.4/tests/test-reader.c +354 -0
  78. data/ext/nutcracker/contrib/yaml-0.1.4/tests/test-version.c +29 -0
  79. data/ext/nutcracker/m4/libtool.m4 +1474 -1087
  80. data/ext/nutcracker/m4/ltoptions.m4 +90 -37
  81. data/ext/nutcracker/m4/ltsugar.m4 +4 -3
  82. data/ext/nutcracker/m4/ltversion.m4 +6 -6
  83. data/ext/nutcracker/m4/lt~obsolete.m4 +4 -3
  84. data/ext/nutcracker/man/nutcracker.8 +1 -1
  85. data/ext/nutcracker/notes/memcache.md +162 -0
  86. data/ext/nutcracker/notes/recommendation.md +10 -5
  87. data/ext/nutcracker/notes/redis.md +23 -9
  88. data/ext/nutcracker/scripts/nutcracker.init +10 -0
  89. data/ext/nutcracker/scripts/nutcracker.init.debian +83 -0
  90. data/ext/nutcracker/scripts/nutcracker.spec +36 -2
  91. data/ext/nutcracker/scripts/redis-check.sh +4 -0
  92. data/ext/nutcracker/src/Makefile.am +6 -1
  93. data/ext/nutcracker/src/Makefile.in +26 -12
  94. data/ext/nutcracker/src/event/Makefile.in +19 -6
  95. data/ext/nutcracker/src/hashkit/Makefile.in +19 -6
  96. data/ext/nutcracker/src/hashkit/nc_jenkins.c +1 -1
  97. data/ext/nutcracker/src/hashkit/nc_ketama.c +3 -3
  98. data/ext/nutcracker/src/nc.c +1 -1
  99. data/ext/nutcracker/src/nc_conf.c +67 -19
  100. data/ext/nutcracker/src/nc_conf.h +9 -4
  101. data/ext/nutcracker/src/nc_connection.c +35 -2
  102. data/ext/nutcracker/src/nc_connection.h +53 -47
  103. data/ext/nutcracker/src/nc_core.c +8 -1
  104. data/ext/nutcracker/src/nc_message.c +23 -7
  105. data/ext/nutcracker/src/nc_message.h +24 -1
  106. data/ext/nutcracker/src/nc_proxy.c +14 -3
  107. data/ext/nutcracker/src/nc_rbtree.c +1 -5
  108. data/ext/nutcracker/src/nc_request.c +58 -10
  109. data/ext/nutcracker/src/nc_response.c +27 -4
  110. data/ext/nutcracker/src/nc_server.c +33 -5
  111. data/ext/nutcracker/src/nc_server.h +10 -9
  112. data/ext/nutcracker/src/nc_string.h +17 -0
  113. data/ext/nutcracker/src/nc_util.c +5 -1
  114. data/ext/nutcracker/src/proto/Makefile.in +19 -6
  115. data/ext/nutcracker/src/proto/nc_memcache.c +76 -12
  116. data/ext/nutcracker/src/proto/nc_proto.h +9 -0
  117. data/ext/nutcracker/src/proto/nc_redis.c +400 -18
  118. data/lib/nutcracker.rb +1 -1
  119. data/lib/nutcracker/version.rb +1 -1
  120. metadata +61 -6
  121. data/ext/nutcracker/notes/memcache.txt +0 -123
@@ -0,0 +1,327 @@
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
+ }
@@ -0,0 +1,63 @@
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
+
@@ -0,0 +1,63 @@
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
+