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.
Files changed (107) hide show
  1. checksums.yaml +5 -13
  2. data/README.md +3 -3
  3. data/Rakefile +12 -10
  4. data/ext/nutcracker/Makefile.in +215 -162
  5. data/ext/nutcracker/README.md +16 -4
  6. data/ext/nutcracker/aclocal.m4 +432 -254
  7. data/ext/nutcracker/{contrib/yaml-0.1.4/configure → autom4te.cache/output.0} +11367 -4545
  8. data/ext/nutcracker/autom4te.cache/output.1 +19907 -0
  9. data/ext/nutcracker/autom4te.cache/output.2 +19907 -0
  10. data/ext/nutcracker/autom4te.cache/requests +518 -0
  11. data/ext/nutcracker/autom4te.cache/traces.0 +2715 -0
  12. data/ext/nutcracker/autom4te.cache/traces.1 +967 -0
  13. data/ext/nutcracker/autom4te.cache/traces.2 +2715 -0
  14. data/ext/nutcracker/config/compile +347 -0
  15. data/ext/nutcracker/config/config.guess +116 -78
  16. data/ext/nutcracker/config/config.sub +65 -45
  17. data/ext/nutcracker/config/depcomp +295 -192
  18. data/ext/nutcracker/config/install-sh +7 -7
  19. data/ext/nutcracker/config/ltmain.sh +15 -20
  20. data/ext/nutcracker/config/missing +149 -265
  21. data/ext/nutcracker/configure +493 -367
  22. data/ext/nutcracker/contrib/Makefile.in +158 -116
  23. data/ext/nutcracker/extconf.rb +0 -1
  24. data/ext/nutcracker/m4/libtool.m4 +4 -23
  25. data/ext/nutcracker/m4/ltoptions.m4 +0 -0
  26. data/ext/nutcracker/m4/ltsugar.m4 +0 -0
  27. data/ext/nutcracker/m4/ltversion.m4 +0 -0
  28. data/ext/nutcracker/m4/lt~obsolete.m4 +0 -0
  29. data/ext/nutcracker/notes/recommendation.md +1 -1
  30. data/ext/nutcracker/notes/redis.md +35 -3
  31. data/ext/nutcracker/scripts/benchmark-mget.py +43 -0
  32. data/ext/nutcracker/scripts/nutcracker.spec +61 -3
  33. data/ext/nutcracker/scripts/redis-check.sh +43 -0
  34. data/ext/nutcracker/src/Makefile.in +205 -142
  35. data/ext/nutcracker/src/event/Makefile.in +164 -66
  36. data/ext/nutcracker/src/hashkit/Makefile.in +164 -66
  37. data/ext/nutcracker/src/nc_conf.c +2 -0
  38. data/ext/nutcracker/src/nc_connection.c +31 -0
  39. data/ext/nutcracker/src/nc_connection.h +3 -0
  40. data/ext/nutcracker/src/nc_core.c +38 -2
  41. data/ext/nutcracker/src/nc_core.h +11 -0
  42. data/ext/nutcracker/src/nc_log.c +90 -12
  43. data/ext/nutcracker/src/nc_log.h +11 -0
  44. data/ext/nutcracker/src/nc_mbuf.h +1 -1
  45. data/ext/nutcracker/src/nc_message.c +162 -116
  46. data/ext/nutcracker/src/nc_message.h +161 -129
  47. data/ext/nutcracker/src/nc_proxy.c +34 -4
  48. data/ext/nutcracker/src/nc_request.c +158 -32
  49. data/ext/nutcracker/src/nc_server.c +59 -5
  50. data/ext/nutcracker/src/nc_server.h +1 -0
  51. data/ext/nutcracker/src/nc_signal.c +2 -2
  52. data/ext/nutcracker/src/nc_stats.c +21 -0
  53. data/ext/nutcracker/src/nc_stats.h +28 -26
  54. data/ext/nutcracker/src/nc_string.c +176 -1
  55. data/ext/nutcracker/src/nc_string.h +26 -0
  56. data/ext/nutcracker/src/nc_util.c +12 -0
  57. data/ext/nutcracker/src/nc_util.h +1 -0
  58. data/ext/nutcracker/src/proto/Makefile.in +164 -66
  59. data/ext/nutcracker/src/proto/nc_memcache.c +279 -88
  60. data/ext/nutcracker/src/proto/nc_proto.h +3 -4
  61. data/ext/nutcracker/src/proto/nc_redis.c +561 -134
  62. data/lib/nutcracker/version.rb +1 -1
  63. metadata +31 -67
  64. data/ext/nutcracker/contrib/yaml-0.1.4/LICENSE +0 -19
  65. data/ext/nutcracker/contrib/yaml-0.1.4/Makefile.am +0 -20
  66. data/ext/nutcracker/contrib/yaml-0.1.4/Makefile.in +0 -736
  67. data/ext/nutcracker/contrib/yaml-0.1.4/README +0 -27
  68. data/ext/nutcracker/contrib/yaml-0.1.4/aclocal.m4 +0 -956
  69. data/ext/nutcracker/contrib/yaml-0.1.4/config.h.in +0 -80
  70. data/ext/nutcracker/contrib/yaml-0.1.4/config/config.guess +0 -1561
  71. data/ext/nutcracker/contrib/yaml-0.1.4/config/config.sub +0 -1686
  72. data/ext/nutcracker/contrib/yaml-0.1.4/config/depcomp +0 -630
  73. data/ext/nutcracker/contrib/yaml-0.1.4/config/install-sh +0 -520
  74. data/ext/nutcracker/contrib/yaml-0.1.4/config/ltmain.sh +0 -8406
  75. data/ext/nutcracker/contrib/yaml-0.1.4/config/missing +0 -376
  76. data/ext/nutcracker/contrib/yaml-0.1.4/configure.ac +0 -75
  77. data/ext/nutcracker/contrib/yaml-0.1.4/doc/doxygen.cfg +0 -222
  78. data/ext/nutcracker/contrib/yaml-0.1.4/include/yaml.h +0 -1971
  79. data/ext/nutcracker/contrib/yaml-0.1.4/m4/libtool.m4 +0 -7357
  80. data/ext/nutcracker/contrib/yaml-0.1.4/m4/ltoptions.m4 +0 -368
  81. data/ext/nutcracker/contrib/yaml-0.1.4/m4/ltsugar.m4 +0 -123
  82. data/ext/nutcracker/contrib/yaml-0.1.4/m4/ltversion.m4 +0 -23
  83. data/ext/nutcracker/contrib/yaml-0.1.4/m4/lt~obsolete.m4 +0 -92
  84. data/ext/nutcracker/contrib/yaml-0.1.4/src/Makefile.am +0 -4
  85. data/ext/nutcracker/contrib/yaml-0.1.4/src/Makefile.in +0 -484
  86. data/ext/nutcracker/contrib/yaml-0.1.4/src/api.c +0 -1392
  87. data/ext/nutcracker/contrib/yaml-0.1.4/src/dumper.c +0 -394
  88. data/ext/nutcracker/contrib/yaml-0.1.4/src/emitter.c +0 -2329
  89. data/ext/nutcracker/contrib/yaml-0.1.4/src/loader.c +0 -432
  90. data/ext/nutcracker/contrib/yaml-0.1.4/src/parser.c +0 -1374
  91. data/ext/nutcracker/contrib/yaml-0.1.4/src/reader.c +0 -465
  92. data/ext/nutcracker/contrib/yaml-0.1.4/src/scanner.c +0 -3570
  93. data/ext/nutcracker/contrib/yaml-0.1.4/src/writer.c +0 -141
  94. data/ext/nutcracker/contrib/yaml-0.1.4/src/yaml_private.h +0 -640
  95. data/ext/nutcracker/contrib/yaml-0.1.4/tests/Makefile.am +0 -8
  96. data/ext/nutcracker/contrib/yaml-0.1.4/tests/Makefile.in +0 -675
  97. data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-deconstructor-alt.c +0 -800
  98. data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-deconstructor.c +0 -1130
  99. data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-reformatter-alt.c +0 -217
  100. data/ext/nutcracker/contrib/yaml-0.1.4/tests/example-reformatter.c +0 -202
  101. data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-dumper.c +0 -311
  102. data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-emitter.c +0 -327
  103. data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-loader.c +0 -63
  104. data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-parser.c +0 -63
  105. data/ext/nutcracker/contrib/yaml-0.1.4/tests/run-scanner.c +0 -63
  106. data/ext/nutcracker/contrib/yaml-0.1.4/tests/test-reader.c +0 -354
  107. data/ext/nutcracker/contrib/yaml-0.1.4/tests/test-version.c +0 -29
@@ -1,800 +0,0 @@
1
-
2
- #include <yaml.h>
3
-
4
- #include <stdlib.h>
5
- #include <stdio.h>
6
-
7
- int
8
- main(int argc, char *argv[])
9
- {
10
- int help = 0;
11
- int canonical = 0;
12
- int unicode = 0;
13
- int k;
14
- int done = 0;
15
-
16
- yaml_parser_t parser;
17
- yaml_emitter_t emitter;
18
- yaml_event_t input_event;
19
- yaml_document_t output_document;
20
-
21
- int root;
22
-
23
- /* Clear the objects. */
24
-
25
- memset(&parser, 0, sizeof(parser));
26
- memset(&emitter, 0, sizeof(emitter));
27
- memset(&input_event, 0, sizeof(input_event));
28
- memset(&output_document, 0, sizeof(output_document));
29
-
30
- /* Analyze command line options. */
31
-
32
- for (k = 1; k < argc; k ++)
33
- {
34
- if (strcmp(argv[k], "-h") == 0
35
- || strcmp(argv[k], "--help") == 0) {
36
- help = 1;
37
- }
38
-
39
- else if (strcmp(argv[k], "-c") == 0
40
- || strcmp(argv[k], "--canonical") == 0) {
41
- canonical = 1;
42
- }
43
-
44
- else if (strcmp(argv[k], "-u") == 0
45
- || strcmp(argv[k], "--unicode") == 0) {
46
- unicode = 1;
47
- }
48
-
49
- else {
50
- fprintf(stderr, "Unrecognized option: %s\n"
51
- "Try `%s --help` for more information.\n",
52
- argv[k], argv[0]);
53
- return 1;
54
- }
55
- }
56
-
57
- /* Display the help string. */
58
-
59
- if (help)
60
- {
61
- printf("%s <input\n"
62
- "or\n%s -h | --help\nDeconstruct a YAML stream\n\nOptions:\n"
63
- "-h, --help\t\tdisplay this help and exit\n"
64
- "-c, --canonical\t\toutput in the canonical YAML format\n"
65
- "-u, --unicode\t\toutput unescaped non-ASCII characters\n",
66
- argv[0], argv[0]);
67
- return 0;
68
- }
69
-
70
- /* Initialize the parser and emitter objects. */
71
-
72
- if (!yaml_parser_initialize(&parser)) {
73
- fprintf(stderr, "Could not initialize the parser object\n");
74
- return 1;
75
- }
76
-
77
- if (!yaml_emitter_initialize(&emitter)) {
78
- yaml_parser_delete(&parser);
79
- fprintf(stderr, "Could not inialize the emitter object\n");
80
- return 1;
81
- }
82
-
83
- /* Set the parser parameters. */
84
-
85
- yaml_parser_set_input_file(&parser, stdin);
86
-
87
- /* Set the emitter parameters. */
88
-
89
- yaml_emitter_set_output_file(&emitter, stdout);
90
-
91
- yaml_emitter_set_canonical(&emitter, canonical);
92
- yaml_emitter_set_unicode(&emitter, unicode);
93
-
94
- /* Create and emit the STREAM-START event. */
95
-
96
- if (!yaml_emitter_open(&emitter))
97
- goto emitter_error;
98
-
99
- /* Create a output_document object. */
100
-
101
- if (!yaml_document_initialize(&output_document, NULL, NULL, NULL, 0, 0))
102
- goto document_error;
103
-
104
- /* Create the root sequence. */
105
-
106
- root = yaml_document_add_sequence(&output_document, NULL,
107
- YAML_BLOCK_SEQUENCE_STYLE);
108
- if (!root) goto document_error;
109
-
110
- /* Loop through the input events. */
111
-
112
- while (!done)
113
- {
114
- int properties, key, value, map, seq;
115
-
116
- /* Get the next event. */
117
-
118
- if (!yaml_parser_parse(&parser, &input_event))
119
- goto parser_error;
120
-
121
- /* Check if this is the stream end. */
122
-
123
- if (input_event.type == YAML_STREAM_END_EVENT) {
124
- done = 1;
125
- }
126
-
127
- /* Create a mapping node and attach it to the root sequence. */
128
-
129
- properties = yaml_document_add_mapping(&output_document, NULL,
130
- YAML_BLOCK_MAPPING_STYLE);
131
- if (!properties) goto document_error;
132
- if (!yaml_document_append_sequence_item(&output_document,
133
- root, properties)) goto document_error;
134
-
135
- /* Analyze the event. */
136
-
137
- switch (input_event.type)
138
- {
139
- case YAML_STREAM_START_EVENT:
140
-
141
- /* Add 'type': 'STREAM-START'. */
142
-
143
- key = yaml_document_add_scalar(&output_document, NULL,
144
- "type", -1, YAML_PLAIN_SCALAR_STYLE);
145
- if (!key) goto document_error;
146
- value = yaml_document_add_scalar(&output_document, NULL,
147
- "STREAM-START", -1, YAML_PLAIN_SCALAR_STYLE);
148
- if (!value) goto document_error;
149
- if (!yaml_document_append_mapping_pair(&output_document,
150
- properties, key, value)) goto document_error;
151
-
152
- /* Add 'encoding': <encoding>. */
153
-
154
- if (input_event.data.stream_start.encoding)
155
- {
156
- yaml_encoding_t encoding
157
- = input_event.data.stream_start.encoding;
158
-
159
- key = yaml_document_add_scalar(&output_document, NULL,
160
- "encoding", -1, YAML_PLAIN_SCALAR_STYLE);
161
- if (!key) goto document_error;
162
- value = yaml_document_add_scalar(&output_document, NULL,
163
- (encoding == YAML_UTF8_ENCODING ? "utf-8" :
164
- encoding == YAML_UTF16LE_ENCODING ? "utf-16-le" :
165
- encoding == YAML_UTF16BE_ENCODING ? "utf-16-be" :
166
- "unknown"), -1, YAML_PLAIN_SCALAR_STYLE);
167
- if (!value) goto document_error;
168
- if (!yaml_document_append_mapping_pair(&output_document,
169
- properties, key, value)) goto document_error;
170
- }
171
-
172
- break;
173
-
174
- case YAML_STREAM_END_EVENT:
175
-
176
- /* Add 'type': 'STREAM-END'. */
177
-
178
- key = yaml_document_add_scalar(&output_document, NULL,
179
- "type", -1, YAML_PLAIN_SCALAR_STYLE);
180
- if (!key) goto document_error;
181
- value = yaml_document_add_scalar(&output_document, NULL,
182
- "STREAM-END", -1, YAML_PLAIN_SCALAR_STYLE);
183
- if (!value) goto document_error;
184
- if (!yaml_document_append_mapping_pair(&output_document,
185
- properties, key, value)) goto document_error;
186
-
187
- break;
188
-
189
- case YAML_DOCUMENT_START_EVENT:
190
-
191
- /* Add 'type': 'DOCUMENT-START'. */
192
-
193
- key = yaml_document_add_scalar(&output_document, NULL,
194
- "type", -1, YAML_PLAIN_SCALAR_STYLE);
195
- if (!key) goto document_error;
196
- value = yaml_document_add_scalar(&output_document, NULL,
197
- "DOCUMENT-START", -1, YAML_PLAIN_SCALAR_STYLE);
198
- if (!value) goto document_error;
199
- if (!yaml_document_append_mapping_pair(&output_document,
200
- properties, key, value)) goto document_error;
201
-
202
- /* Display the output_document version numbers. */
203
-
204
- if (input_event.data.document_start.version_directive)
205
- {
206
- yaml_version_directive_t *version
207
- = input_event.data.document_start.version_directive;
208
- char number[64];
209
-
210
- /* Add 'version': {}. */
211
-
212
- key = yaml_document_add_scalar(&output_document, NULL,
213
- "version", -1, YAML_PLAIN_SCALAR_STYLE);
214
- if (!key) goto document_error;
215
- map = yaml_document_add_mapping(&output_document, NULL,
216
- YAML_FLOW_MAPPING_STYLE);
217
- if (!map) goto document_error;
218
- if (!yaml_document_append_mapping_pair(&output_document,
219
- properties, key, map)) goto document_error;
220
-
221
- /* Add 'major': <number>. */
222
-
223
- key = yaml_document_add_scalar(&output_document, NULL,
224
- "major", -1, YAML_PLAIN_SCALAR_STYLE);
225
- if (!key) goto document_error;
226
- sprintf(number, "%d", version->major);
227
- value = yaml_document_add_scalar(&output_document, YAML_INT_TAG,
228
- number, -1, YAML_PLAIN_SCALAR_STYLE);
229
- if (!value) goto document_error;
230
- if (!yaml_document_append_mapping_pair(&output_document,
231
- map, key, value)) goto document_error;
232
-
233
- /* Add 'minor': <number>. */
234
-
235
- key = yaml_document_add_scalar(&output_document, NULL,
236
- "minor", -1, YAML_PLAIN_SCALAR_STYLE);
237
- if (!key) goto document_error;
238
- sprintf(number, "%d", version->minor);
239
- value = yaml_document_add_scalar(&output_document, YAML_INT_TAG,
240
- number, -1, YAML_PLAIN_SCALAR_STYLE);
241
- if (!value) goto document_error;
242
- if (!yaml_document_append_mapping_pair(&output_document,
243
- map, key, value)) goto document_error;
244
- }
245
-
246
- /* Display the output_document tag directives. */
247
-
248
- if (input_event.data.document_start.tag_directives.start
249
- != input_event.data.document_start.tag_directives.end)
250
- {
251
- yaml_tag_directive_t *tag;
252
-
253
- /* Add 'tags': []. */
254
-
255
- key = yaml_document_add_scalar(&output_document, NULL,
256
- "tags", -1, YAML_PLAIN_SCALAR_STYLE);
257
- if (!key) goto document_error;
258
- seq = yaml_document_add_sequence(&output_document, NULL,
259
- YAML_BLOCK_SEQUENCE_STYLE);
260
- if (!seq) goto document_error;
261
- if (!yaml_document_append_mapping_pair(&output_document,
262
- properties, key, seq)) goto document_error;
263
-
264
- for (tag = input_event.data.document_start.tag_directives.start;
265
- tag != input_event.data.document_start.tag_directives.end;
266
- tag ++)
267
- {
268
- /* Add {}. */
269
-
270
- map = yaml_document_add_mapping(&output_document, NULL,
271
- YAML_FLOW_MAPPING_STYLE);
272
- if (!map) goto document_error;
273
- if (!yaml_document_append_sequence_item(&output_document,
274
- seq, map)) goto document_error;
275
-
276
- /* Add 'handle': <handle>. */
277
-
278
- key = yaml_document_add_scalar(&output_document, NULL,
279
- "handle", -1, YAML_PLAIN_SCALAR_STYLE);
280
- if (!key) goto document_error;
281
- value = yaml_document_add_scalar(&output_document, NULL,
282
- tag->handle, -1, YAML_DOUBLE_QUOTED_SCALAR_STYLE);
283
- if (!value) goto document_error;
284
- if (!yaml_document_append_mapping_pair(&output_document,
285
- map, key, value)) goto document_error;
286
-
287
- /* Add 'prefix': <prefix>. */
288
-
289
- key = yaml_document_add_scalar(&output_document, NULL,
290
- "prefix", -1, YAML_PLAIN_SCALAR_STYLE);
291
- if (!key) goto document_error;
292
- value = yaml_document_add_scalar(&output_document, NULL,
293
- tag->prefix, -1, YAML_DOUBLE_QUOTED_SCALAR_STYLE);
294
- if (!value) goto document_error;
295
- if (!yaml_document_append_mapping_pair(&output_document,
296
- map, key, value)) goto document_error;
297
- }
298
- }
299
-
300
- /* Add 'implicit': <flag>. */
301
-
302
- key = yaml_document_add_scalar(&output_document, NULL,
303
- "implicit", -1, YAML_PLAIN_SCALAR_STYLE);
304
- if (!key) goto document_error;
305
- value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG,
306
- (input_event.data.document_start.implicit ?
307
- "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE);
308
- if (!value) goto document_error;
309
- if (!yaml_document_append_mapping_pair(&output_document,
310
- properties, key, value)) goto document_error;
311
-
312
- break;
313
-
314
- case YAML_DOCUMENT_END_EVENT:
315
-
316
- /* Add 'type': 'DOCUMENT-END'. */
317
-
318
- key = yaml_document_add_scalar(&output_document, NULL,
319
- "type", -1, YAML_PLAIN_SCALAR_STYLE);
320
- if (!key) goto document_error;
321
- value = yaml_document_add_scalar(&output_document, NULL,
322
- "DOCUMENT-END", -1, YAML_PLAIN_SCALAR_STYLE);
323
- if (!value) goto document_error;
324
- if (!yaml_document_append_mapping_pair(&output_document,
325
- properties, key, value)) goto document_error;
326
-
327
- /* Add 'implicit': <flag>. */
328
-
329
- key = yaml_document_add_scalar(&output_document, NULL,
330
- "implicit", -1, YAML_PLAIN_SCALAR_STYLE);
331
- if (!key) goto document_error;
332
- value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG,
333
- (input_event.data.document_end.implicit ?
334
- "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE);
335
- if (!value) goto document_error;
336
- if (!yaml_document_append_mapping_pair(&output_document,
337
- properties, key, value)) goto document_error;
338
-
339
- break;
340
-
341
- case YAML_ALIAS_EVENT:
342
-
343
- /* Add 'type': 'ALIAS'. */
344
-
345
- key = yaml_document_add_scalar(&output_document, NULL,
346
- "type", -1, YAML_PLAIN_SCALAR_STYLE);
347
- if (!key) goto document_error;
348
- value = yaml_document_add_scalar(&output_document, NULL,
349
- "ALIAS", -1, YAML_PLAIN_SCALAR_STYLE);
350
- if (!value) goto document_error;
351
- if (!yaml_document_append_mapping_pair(&output_document,
352
- properties, key, value)) goto document_error;
353
-
354
- /* Add 'anchor': <anchor>. */
355
-
356
- key = yaml_document_add_scalar(&output_document, NULL,
357
- "anchor", -1, YAML_PLAIN_SCALAR_STYLE);
358
- if (!key) goto document_error;
359
- value = yaml_document_add_scalar(&output_document, NULL,
360
- input_event.data.alias.anchor, -1,
361
- YAML_DOUBLE_QUOTED_SCALAR_STYLE);
362
- if (!value) goto document_error;
363
- if (!yaml_document_append_mapping_pair(&output_document,
364
- properties, key, value)) goto document_error;
365
-
366
- break;
367
-
368
- case YAML_SCALAR_EVENT:
369
-
370
- /* Add 'type': 'SCALAR'. */
371
-
372
- key = yaml_document_add_scalar(&output_document, NULL,
373
- "type", -1, YAML_PLAIN_SCALAR_STYLE);
374
- if (!key) goto document_error;
375
- value = yaml_document_add_scalar(&output_document, NULL,
376
- "SCALAR", -1, YAML_PLAIN_SCALAR_STYLE);
377
- if (!value) goto document_error;
378
- if (!yaml_document_append_mapping_pair(&output_document,
379
- properties, key, value)) goto document_error;
380
-
381
- /* Add 'anchor': <anchor>. */
382
-
383
- if (input_event.data.scalar.anchor)
384
- {
385
- key = yaml_document_add_scalar(&output_document, NULL,
386
- "anchor", -1, YAML_PLAIN_SCALAR_STYLE);
387
- if (!key) goto document_error;
388
- value = yaml_document_add_scalar(&output_document, NULL,
389
- input_event.data.scalar.anchor, -1,
390
- YAML_DOUBLE_QUOTED_SCALAR_STYLE);
391
- if (!value) goto document_error;
392
- if (!yaml_document_append_mapping_pair(&output_document,
393
- properties, key, value)) goto document_error;
394
- }
395
-
396
- /* Add 'tag': <tag>. */
397
-
398
- if (input_event.data.scalar.tag)
399
- {
400
- key = yaml_document_add_scalar(&output_document, NULL,
401
- "tag", -1, YAML_PLAIN_SCALAR_STYLE);
402
- if (!key) goto document_error;
403
- value = yaml_document_add_scalar(&output_document, NULL,
404
- input_event.data.scalar.tag, -1,
405
- YAML_DOUBLE_QUOTED_SCALAR_STYLE);
406
- if (!value) goto document_error;
407
- if (!yaml_document_append_mapping_pair(&output_document,
408
- properties, key, value)) goto document_error;
409
- }
410
-
411
- /* Add 'value': <value>. */
412
-
413
- key = yaml_document_add_scalar(&output_document, NULL,
414
- "value", -1, YAML_PLAIN_SCALAR_STYLE);
415
- if (!key) goto document_error;
416
- value = yaml_document_add_scalar(&output_document, NULL,
417
- input_event.data.scalar.value,
418
- input_event.data.scalar.length,
419
- YAML_DOUBLE_QUOTED_SCALAR_STYLE);
420
- if (!value) goto document_error;
421
- if (!yaml_document_append_mapping_pair(&output_document,
422
- properties, key, value)) goto document_error;
423
-
424
- /* Display if the scalar tag is implicit. */
425
-
426
- /* Add 'implicit': {} */
427
-
428
- key = yaml_document_add_scalar(&output_document, NULL,
429
- "version", -1, YAML_PLAIN_SCALAR_STYLE);
430
- if (!key) goto document_error;
431
- map = yaml_document_add_mapping(&output_document, NULL,
432
- YAML_FLOW_MAPPING_STYLE);
433
- if (!map) goto document_error;
434
- if (!yaml_document_append_mapping_pair(&output_document,
435
- properties, key, map)) goto document_error;
436
-
437
- /* Add 'plain': <flag>. */
438
-
439
- key = yaml_document_add_scalar(&output_document, NULL,
440
- "plain", -1, YAML_PLAIN_SCALAR_STYLE);
441
- if (!key) goto document_error;
442
- value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG,
443
- (input_event.data.scalar.plain_implicit ?
444
- "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE);
445
- if (!value) goto document_error;
446
- if (!yaml_document_append_mapping_pair(&output_document,
447
- map, key, value)) goto document_error;
448
-
449
- /* Add 'quoted': <flag>. */
450
-
451
- key = yaml_document_add_scalar(&output_document, NULL,
452
- "quoted", -1, YAML_PLAIN_SCALAR_STYLE);
453
- if (!key) goto document_error;
454
- value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG,
455
- (input_event.data.scalar.quoted_implicit ?
456
- "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE);
457
- if (!value) goto document_error;
458
- if (!yaml_document_append_mapping_pair(&output_document,
459
- map, key, value)) goto document_error;
460
-
461
- /* Display the style information. */
462
-
463
- if (input_event.data.scalar.style)
464
- {
465
- yaml_scalar_style_t style = input_event.data.scalar.style;
466
-
467
- /* Add 'style': <style>. */
468
-
469
- key = yaml_document_add_scalar(&output_document, NULL,
470
- "style", -1, YAML_PLAIN_SCALAR_STYLE);
471
- if (!key) goto document_error;
472
- value = yaml_document_add_scalar(&output_document, NULL,
473
- (style == YAML_PLAIN_SCALAR_STYLE ? "plain" :
474
- style == YAML_SINGLE_QUOTED_SCALAR_STYLE ?
475
- "single-quoted" :
476
- style == YAML_DOUBLE_QUOTED_SCALAR_STYLE ?
477
- "double-quoted" :
478
- style == YAML_LITERAL_SCALAR_STYLE ? "literal" :
479
- style == YAML_FOLDED_SCALAR_STYLE ? "folded" :
480
- "unknown"), -1, YAML_PLAIN_SCALAR_STYLE);
481
- if (!value) goto document_error;
482
- if (!yaml_document_append_mapping_pair(&output_document,
483
- properties, key, value)) goto document_error;
484
- }
485
-
486
- break;
487
-
488
- case YAML_SEQUENCE_START_EVENT:
489
-
490
- /* Add 'type': 'SEQUENCE-START'. */
491
-
492
- key = yaml_document_add_scalar(&output_document, NULL,
493
- "type", -1, YAML_PLAIN_SCALAR_STYLE);
494
- if (!key) goto document_error;
495
- value = yaml_document_add_scalar(&output_document, NULL,
496
- "SEQUENCE-START", -1, YAML_PLAIN_SCALAR_STYLE);
497
- if (!value) goto document_error;
498
- if (!yaml_document_append_mapping_pair(&output_document,
499
- properties, key, value)) goto document_error;
500
-
501
- /* Add 'anchor': <anchor>. */
502
-
503
- if (input_event.data.sequence_start.anchor)
504
- {
505
- key = yaml_document_add_scalar(&output_document, NULL,
506
- "anchor", -1, YAML_PLAIN_SCALAR_STYLE);
507
- if (!key) goto document_error;
508
- value = yaml_document_add_scalar(&output_document, NULL,
509
- input_event.data.sequence_start.anchor, -1,
510
- YAML_DOUBLE_QUOTED_SCALAR_STYLE);
511
- if (!value) goto document_error;
512
- if (!yaml_document_append_mapping_pair(&output_document,
513
- properties, key, value)) goto document_error;
514
- }
515
-
516
- /* Add 'tag': <tag>. */
517
-
518
- if (input_event.data.sequence_start.tag)
519
- {
520
- key = yaml_document_add_scalar(&output_document, NULL,
521
- "tag", -1, YAML_PLAIN_SCALAR_STYLE);
522
- if (!key) goto document_error;
523
- value = yaml_document_add_scalar(&output_document, NULL,
524
- input_event.data.sequence_start.tag, -1,
525
- YAML_DOUBLE_QUOTED_SCALAR_STYLE);
526
- if (!value) goto document_error;
527
- if (!yaml_document_append_mapping_pair(&output_document,
528
- properties, key, value)) goto document_error;
529
- }
530
-
531
- /* Add 'implicit': <flag>. */
532
-
533
- key = yaml_document_add_scalar(&output_document, NULL,
534
- "implicit", -1, YAML_PLAIN_SCALAR_STYLE);
535
- if (!key) goto document_error;
536
- value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG,
537
- (input_event.data.sequence_start.implicit ?
538
- "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE);
539
- if (!value) goto document_error;
540
- if (!yaml_document_append_mapping_pair(&output_document,
541
- properties, key, value)) goto document_error;
542
-
543
- /* Display the style information. */
544
-
545
- if (input_event.data.sequence_start.style)
546
- {
547
- yaml_sequence_style_t style
548
- = input_event.data.sequence_start.style;
549
-
550
- /* Add 'style': <style>. */
551
-
552
- key = yaml_document_add_scalar(&output_document, NULL,
553
- "style", -1, YAML_PLAIN_SCALAR_STYLE);
554
- if (!key) goto document_error;
555
- value = yaml_document_add_scalar(&output_document, NULL,
556
- (style == YAML_BLOCK_SEQUENCE_STYLE ? "block" :
557
- style == YAML_FLOW_SEQUENCE_STYLE ? "flow" :
558
- "unknown"), -1, YAML_PLAIN_SCALAR_STYLE);
559
- if (!value) goto document_error;
560
- if (!yaml_document_append_mapping_pair(&output_document,
561
- properties, key, value)) goto document_error;
562
- }
563
-
564
- break;
565
-
566
- case YAML_SEQUENCE_END_EVENT:
567
-
568
- /* Add 'type': 'SEQUENCE-END'. */
569
-
570
- key = yaml_document_add_scalar(&output_document, NULL,
571
- "type", -1, YAML_PLAIN_SCALAR_STYLE);
572
- if (!key) goto document_error;
573
- value = yaml_document_add_scalar(&output_document, NULL,
574
- "SEQUENCE-END", -1, YAML_PLAIN_SCALAR_STYLE);
575
- if (!value) goto document_error;
576
- if (!yaml_document_append_mapping_pair(&output_document,
577
- properties, key, value)) goto document_error;
578
-
579
- break;
580
-
581
- case YAML_MAPPING_START_EVENT:
582
-
583
- /* Add 'type': 'MAPPING-START'. */
584
-
585
- key = yaml_document_add_scalar(&output_document, NULL,
586
- "type", -1, YAML_PLAIN_SCALAR_STYLE);
587
- if (!key) goto document_error;
588
- value = yaml_document_add_scalar(&output_document, NULL,
589
- "MAPPING-START", -1, YAML_PLAIN_SCALAR_STYLE);
590
- if (!value) goto document_error;
591
- if (!yaml_document_append_mapping_pair(&output_document,
592
- properties, key, value)) goto document_error;
593
-
594
- /* Add 'anchor': <anchor>. */
595
-
596
- if (input_event.data.mapping_start.anchor)
597
- {
598
- key = yaml_document_add_scalar(&output_document, NULL,
599
- "anchor", -1, YAML_PLAIN_SCALAR_STYLE);
600
- if (!key) goto document_error;
601
- value = yaml_document_add_scalar(&output_document, NULL,
602
- input_event.data.mapping_start.anchor, -1,
603
- YAML_DOUBLE_QUOTED_SCALAR_STYLE);
604
- if (!value) goto document_error;
605
- if (!yaml_document_append_mapping_pair(&output_document,
606
- properties, key, value)) goto document_error;
607
- }
608
-
609
- /* Add 'tag': <tag>. */
610
-
611
- if (input_event.data.mapping_start.tag)
612
- {
613
- key = yaml_document_add_scalar(&output_document, NULL,
614
- "tag", -1, YAML_PLAIN_SCALAR_STYLE);
615
- if (!key) goto document_error;
616
- value = yaml_document_add_scalar(&output_document, NULL,
617
- input_event.data.mapping_start.tag, -1,
618
- YAML_DOUBLE_QUOTED_SCALAR_STYLE);
619
- if (!value) goto document_error;
620
- if (!yaml_document_append_mapping_pair(&output_document,
621
- properties, key, value)) goto document_error;
622
- }
623
-
624
- /* Add 'implicit': <flag>. */
625
-
626
- key = yaml_document_add_scalar(&output_document, NULL,
627
- "implicit", -1, YAML_PLAIN_SCALAR_STYLE);
628
- if (!key) goto document_error;
629
- value = yaml_document_add_scalar(&output_document, YAML_BOOL_TAG,
630
- (input_event.data.mapping_start.implicit ?
631
- "true" : "false"), -1, YAML_PLAIN_SCALAR_STYLE);
632
- if (!value) goto document_error;
633
- if (!yaml_document_append_mapping_pair(&output_document,
634
- properties, key, value)) goto document_error;
635
-
636
- /* Display the style information. */
637
-
638
- if (input_event.data.sequence_start.style)
639
- {
640
- yaml_sequence_style_t style
641
- = input_event.data.mapping_start.style;
642
-
643
- /* Add 'style': <style>. */
644
-
645
- key = yaml_document_add_scalar(&output_document, NULL,
646
- "style", -1, YAML_PLAIN_SCALAR_STYLE);
647
- if (!key) goto document_error;
648
- value = yaml_document_add_scalar(&output_document, NULL,
649
- (style == YAML_BLOCK_MAPPING_STYLE ? "block" :
650
- style == YAML_FLOW_MAPPING_STYLE ? "flow" :
651
- "unknown"), -1, YAML_PLAIN_SCALAR_STYLE);
652
- if (!value) goto document_error;
653
- if (!yaml_document_append_mapping_pair(&output_document,
654
- properties, key, value)) goto document_error;
655
- }
656
-
657
- break;
658
-
659
- case YAML_MAPPING_END_EVENT:
660
-
661
- /* Add 'type': 'MAPPING-END'. */
662
-
663
- key = yaml_document_add_scalar(&output_document, NULL,
664
- "type", -1, YAML_PLAIN_SCALAR_STYLE);
665
- if (!key) goto document_error;
666
- value = yaml_document_add_scalar(&output_document, NULL,
667
- "MAPPING-END", -1, YAML_PLAIN_SCALAR_STYLE);
668
- if (!value) goto document_error;
669
- if (!yaml_document_append_mapping_pair(&output_document,
670
- properties, key, value)) goto document_error;
671
-
672
- break;
673
-
674
- default:
675
- /* It couldn't really happen. */
676
- break;
677
- }
678
-
679
- /* Delete the event object. */
680
-
681
- yaml_event_delete(&input_event);
682
- }
683
-
684
- if (!yaml_emitter_dump(&emitter, &output_document))
685
- goto emitter_error;
686
- if (!yaml_emitter_close(&emitter))
687
- goto emitter_error;
688
-
689
- yaml_parser_delete(&parser);
690
- yaml_emitter_delete(&emitter);
691
-
692
- return 0;
693
-
694
- parser_error:
695
-
696
- /* Display a parser error message. */
697
-
698
- switch (parser.error)
699
- {
700
- case YAML_MEMORY_ERROR:
701
- fprintf(stderr, "Memory error: Not enough memory for parsing\n");
702
- break;
703
-
704
- case YAML_READER_ERROR:
705
- if (parser.problem_value != -1) {
706
- fprintf(stderr, "Reader error: %s: #%X at %d\n", parser.problem,
707
- parser.problem_value, parser.problem_offset);
708
- }
709
- else {
710
- fprintf(stderr, "Reader error: %s at %d\n", parser.problem,
711
- parser.problem_offset);
712
- }
713
- break;
714
-
715
- case YAML_SCANNER_ERROR:
716
- if (parser.context) {
717
- fprintf(stderr, "Scanner error: %s at line %d, column %d\n"
718
- "%s at line %d, column %d\n", parser.context,
719
- parser.context_mark.line+1, parser.context_mark.column+1,
720
- parser.problem, parser.problem_mark.line+1,
721
- parser.problem_mark.column+1);
722
- }
723
- else {
724
- fprintf(stderr, "Scanner error: %s at line %d, column %d\n",
725
- parser.problem, parser.problem_mark.line+1,
726
- parser.problem_mark.column+1);
727
- }
728
- break;
729
-
730
- case YAML_PARSER_ERROR:
731
- if (parser.context) {
732
- fprintf(stderr, "Parser error: %s at line %d, column %d\n"
733
- "%s at line %d, column %d\n", parser.context,
734
- parser.context_mark.line+1, parser.context_mark.column+1,
735
- parser.problem, parser.problem_mark.line+1,
736
- parser.problem_mark.column+1);
737
- }
738
- else {
739
- fprintf(stderr, "Parser error: %s at line %d, column %d\n",
740
- parser.problem, parser.problem_mark.line+1,
741
- parser.problem_mark.column+1);
742
- }
743
- break;
744
-
745
- default:
746
- /* Couldn't happen. */
747
- fprintf(stderr, "Internal error\n");
748
- break;
749
- }
750
-
751
- yaml_event_delete(&input_event);
752
- yaml_document_delete(&output_document);
753
- yaml_parser_delete(&parser);
754
- yaml_emitter_delete(&emitter);
755
-
756
- return 1;
757
-
758
- emitter_error:
759
-
760
- /* Display an emitter error message. */
761
-
762
- switch (emitter.error)
763
- {
764
- case YAML_MEMORY_ERROR:
765
- fprintf(stderr, "Memory error: Not enough memory for emitting\n");
766
- break;
767
-
768
- case YAML_WRITER_ERROR:
769
- fprintf(stderr, "Writer error: %s\n", emitter.problem);
770
- break;
771
-
772
- case YAML_EMITTER_ERROR:
773
- fprintf(stderr, "Emitter error: %s\n", emitter.problem);
774
- break;
775
-
776
- default:
777
- /* Couldn't happen. */
778
- fprintf(stderr, "Internal error\n");
779
- break;
780
- }
781
-
782
- yaml_event_delete(&input_event);
783
- yaml_document_delete(&output_document);
784
- yaml_parser_delete(&parser);
785
- yaml_emitter_delete(&emitter);
786
-
787
- return 1;
788
-
789
- document_error:
790
-
791
- fprintf(stderr, "Memory error: Not enough memory for creating a document\n");
792
-
793
- yaml_event_delete(&input_event);
794
- yaml_document_delete(&output_document);
795
- yaml_parser_delete(&parser);
796
- yaml_emitter_delete(&emitter);
797
-
798
- return 1;
799
- }
800
-