1 #if HAVE_CONFIG_H 2 #include <config.h> 3 #endif 4 5 #include <yaml.h> 6 7 #include <assert.h> 8 #include <limits.h> 9 #include <stddef.h> 10 11 #ifndef _MSC_VER 12 #include <stdint.h> 13 #else 14 #ifdef _WIN64 15 #define PTRDIFF_MAX _I64_MAX 16 #else 17 #define PTRDIFF_MAX INT_MAX 18 #endif 19 #endif 20 21 /* 22 * Memory management. 23 */ 24 25 YAML_DECLARE(void *) 26 yaml_malloc(size_t size); 27 28 YAML_DECLARE(void *) 29 yaml_realloc(void *ptr, size_t size); 30 31 YAML_DECLARE(void) 32 yaml_free(void *ptr); 33 34 YAML_DECLARE(yaml_char_t *) 35 yaml_strdup(const yaml_char_t *); 36 37 /* 38 * Reader: Ensure that the buffer contains at least `length` characters. 39 */ 40 41 YAML_DECLARE(int) 42 yaml_parser_update_buffer(yaml_parser_t *parser, size_t length); 43 44 /* 45 * Scanner: Ensure that the token stack contains at least one token ready. 46 */ 47 48 YAML_DECLARE(int) 49 yaml_parser_fetch_more_tokens(yaml_parser_t *parser); 50 51 /* 52 * The size of the input raw buffer. 53 */ 54 55 #define INPUT_RAW_BUFFER_SIZE 16384 56 57 /* 58 * The size of the input buffer. 59 * 60 * It should be possible to decode the whole raw buffer. 61 */ 62 63 #define INPUT_BUFFER_SIZE (INPUT_RAW_BUFFER_SIZE*3) 64 65 /* 66 * The size of the output buffer. 67 */ 68 69 #define OUTPUT_BUFFER_SIZE 16384 70 71 /* 72 * The size of the output raw buffer. 73 * 74 * It should be possible to encode the whole output buffer. 75 */ 76 77 #define OUTPUT_RAW_BUFFER_SIZE (OUTPUT_BUFFER_SIZE*2+2) 78 79 /* 80 * The size of other stacks and queues. 81 */ 82 83 #define INITIAL_STACK_SIZE 16 84 #define INITIAL_QUEUE_SIZE 16 85 #define INITIAL_STRING_SIZE 16 86 87 /* 88 * Buffer management. 89 */ 90 91 #define BUFFER_INIT(context,buffer,size) \ 92 (((buffer).start = yaml_malloc(size)) ? \ 93 ((buffer).last = (buffer).pointer = (buffer).start, \ 94 (buffer).end = (buffer).start+(size), \ 95 1) : \ 96 ((context)->error = YAML_MEMORY_ERROR, \ 97 0)) 98 99 #define BUFFER_DEL(context,buffer) \ 100 (yaml_free((buffer).start), \ 101 (buffer).start = (buffer).pointer = (buffer).end = 0) 102 103 /* 104 * String management. 105 */ 106 107 typedef struct { 108 yaml_char_t *start; 109 yaml_char_t *end; 110 yaml_char_t *pointer; 111 } yaml_string_t; 112 113 YAML_DECLARE(int) 114 yaml_string_extend(yaml_char_t **start, 115 yaml_char_t **pointer, yaml_char_t **end); 116 117 YAML_DECLARE(int) 118 yaml_string_join( 119 yaml_char_t **a_start, yaml_char_t **a_pointer, yaml_char_t **a_end, 120 yaml_char_t **b_start, yaml_char_t **b_pointer, yaml_char_t **b_end); 121 122 #define NULL_STRING { NULL, NULL, NULL } 123 124 #define STRING(string,length) { (string), (string)+(length), (string) } 125 126 #define STRING_ASSIGN(value,string,length) \ 127 ((value).start = (string), \ 128 (value).end = (string)+(length), \ 129 (value).pointer = (string)) 130 131 #define STRING_INIT(context,string,size) \ 132 (((string).start = yaml_malloc(size)) ? \ 133 ((string).pointer = (string).start, \ 134 (string).end = (string).start+(size), \ 135 memset((string).start, 0, (size)), \ 136 1) : \ 137 ((context)->error = YAML_MEMORY_ERROR, \ 138 0)) 139 140 #define STRING_DEL(context,string) \ 141 (yaml_free((string).start), \ 142 (string).start = (string).pointer = (string).end = 0) 143 144 #define STRING_EXTEND(context,string) \ 145 ((((string).pointer+5 < (string).end) \ 146 || yaml_string_extend(&(string).start, \ 147 &(string).pointer, &(string).end)) ? \ 148 1 : \ 149 ((context)->error = YAML_MEMORY_ERROR, \ 150 0)) 151 152 #define CLEAR(context,string) \ 153 ((string).pointer = (string).start, \ 154 memset((string).start, 0, (string).end-(string).start)) 155 156 #define JOIN(context,string_a,string_b) \ 157 ((yaml_string_join(&(string_a).start, &(string_a).pointer, \ 158 &(string_a).end, &(string_b).start, \ 159 &(string_b).pointer, &(string_b).end)) ? \ 160 ((string_b).pointer = (string_b).start, \ 161 1) : \ 162 ((context)->error = YAML_MEMORY_ERROR, \ 163 0)) 164 165 /* 166 * String check operations. 167 */ 168 169 /* 170 * Check the octet at the specified position. 171 */ 172 173 #define CHECK_AT(string,octet,offset) \ 174 ((string).pointer[offset] == (yaml_char_t)(octet)) 175 176 /* 177 * Check the current octet in the buffer. 178 */ 179 180 #define CHECK(string,octet) CHECK_AT((string),(octet),0) 181 182 /* 183 * Check if the character at the specified position is an alphabetical 184 * character, a digit, '_', or '-'. 185 */ 186 187 #define IS_ALPHA_AT(string,offset) \ 188 (((string).pointer[offset] >= (yaml_char_t) '0' && \ 189 (string).pointer[offset] <= (yaml_char_t) '9') || \ 190 ((string).pointer[offset] >= (yaml_char_t) 'A' && \ 191 (string).pointer[offset] <= (yaml_char_t) 'Z') || \ 192 ((string).pointer[offset] >= (yaml_char_t) 'a' && \ 193 (string).pointer[offset] <= (yaml_char_t) 'z') || \ 194 (string).pointer[offset] == '_' || \ 195 (string).pointer[offset] == '-') 196 197 #define IS_ALPHA(string) IS_ALPHA_AT((string),0) 198 199 /* 200 * Check if the character at the specified position is a digit. 201 */ 202 203 #define IS_DIGIT_AT(string,offset) \ 204 (((string).pointer[offset] >= (yaml_char_t) '0' && \ 205 (string).pointer[offset] <= (yaml_char_t) '9')) 206 207 #define IS_DIGIT(string) IS_DIGIT_AT((string),0) 208 209 /* 210 * Get the value of a digit. 211 */ 212 213 #define AS_DIGIT_AT(string,offset) \ 214 ((string).pointer[offset] - (yaml_char_t) '0') 215 216 #define AS_DIGIT(string) AS_DIGIT_AT((string),0) 217 218 /* 219 * Check if the character at the specified position is a hex-digit. 220 */ 221 222 #define IS_HEX_AT(string,offset) \ 223 (((string).pointer[offset] >= (yaml_char_t) '0' && \ 224 (string).pointer[offset] <= (yaml_char_t) '9') || \ 225 ((string).pointer[offset] >= (yaml_char_t) 'A' && \ 226 (string).pointer[offset] <= (yaml_char_t) 'F') || \ 227 ((string).pointer[offset] >= (yaml_char_t) 'a' && \ 228 (string).pointer[offset] <= (yaml_char_t) 'f')) 229 230 #define IS_HEX(string) IS_HEX_AT((string),0) 231 232 /* 233 * Get the value of a hex-digit. 234 */ 235 236 #define AS_HEX_AT(string,offset) \ 237 (((string).pointer[offset] >= (yaml_char_t) 'A' && \ 238 (string).pointer[offset] <= (yaml_char_t) 'F') ? \ 239 ((string).pointer[offset] - (yaml_char_t) 'A' + 10) : \ 240 ((string).pointer[offset] >= (yaml_char_t) 'a' && \ 241 (string).pointer[offset] <= (yaml_char_t) 'f') ? \ 242 ((string).pointer[offset] - (yaml_char_t) 'a' + 10) : \ 243 ((string).pointer[offset] - (yaml_char_t) '0')) 244 245 #define AS_HEX(string) AS_HEX_AT((string),0) 246 247 /* 248 * Check if the character is ASCII. 249 */ 250 251 #define IS_ASCII_AT(string,offset) \ 252 ((string).pointer[offset] <= (yaml_char_t) '\x7F') 253 254 #define IS_ASCII(string) IS_ASCII_AT((string),0) 255 256 /* 257 * Check if the character can be printed unescaped. 258 */ 259 260 #define IS_PRINTABLE_AT(string,offset) \ 261 (((string).pointer[offset] == 0x0A) /* . == #x0A */ \ 262 || ((string).pointer[offset] >= 0x20 /* #x20 <= . <= #x7E */ \ 263 && (string).pointer[offset] <= 0x7E) \ 264 || ((string).pointer[offset] == 0xC2 /* #0xA0 <= . <= #xD7FF */ \ 265 && (string).pointer[offset+1] >= 0xA0) \ 266 || ((string).pointer[offset] > 0xC2 \ 267 && (string).pointer[offset] < 0xED) \ 268 || ((string).pointer[offset] == 0xED \ 269 && (string).pointer[offset+1] < 0xA0) \ 270 || ((string).pointer[offset] == 0xEE) \ 271 || ((string).pointer[offset] == 0xEF /* #xE000 <= . <= #xFFFD */ \ 272 && !((string).pointer[offset+1] == 0xBB /* && . != #xFEFF */ \ 273 && (string).pointer[offset+2] == 0xBF) \ 274 && !((string).pointer[offset+1] == 0xBF \ 275 && ((string).pointer[offset+2] == 0xBE \ 276 || (string).pointer[offset+2] == 0xBF)))) 277 278 #define IS_PRINTABLE(string) IS_PRINTABLE_AT((string),0) 279 280 /* 281 * Check if the character at the specified position is NUL. 282 */ 283 284 #define IS_Z_AT(string,offset) CHECK_AT((string),'\0',(offset)) 285 286 #define IS_Z(string) IS_Z_AT((string),0) 287 288 /* 289 * Check if the character at the specified position is BOM. 290 */ 291 292 #define IS_BOM_AT(string,offset) \ 293 (CHECK_AT((string),'\xEF',(offset)) \ 294 && CHECK_AT((string),'\xBB',(offset)+1) \ 295 && CHECK_AT((string),'\xBF',(offset)+2)) /* BOM (#xFEFF) */ 296 297 #define IS_BOM(string) IS_BOM_AT(string,0) 298 299 /* 300 * Check if the character at the specified position is space. 301 */ 302 303 #define IS_SPACE_AT(string,offset) CHECK_AT((string),' ',(offset)) 304 305 #define IS_SPACE(string) IS_SPACE_AT((string),0) 306 307 /* 308 * Check if the character at the specified position is tab. 309 */ 310 311 #define IS_TAB_AT(string,offset) CHECK_AT((string),'\t',(offset)) 312 313 #define IS_TAB(string) IS_TAB_AT((string),0) 314 315 /* 316 * Check if the character at the specified position is blank (space or tab). 317 */ 318 319 #define IS_BLANK_AT(string,offset) \ 320 (IS_SPACE_AT((string),(offset)) || IS_TAB_AT((string),(offset))) 321 322 #define IS_BLANK(string) IS_BLANK_AT((string),0) 323 324 /* 325 * Check if the character at the specified position is a line break. 326 */ 327 328 #define IS_BREAK_AT(string,offset) \ 329 (CHECK_AT((string),'\r',(offset)) /* CR (#xD)*/ \ 330 || CHECK_AT((string),'\n',(offset)) /* LF (#xA) */ \ 331 || (CHECK_AT((string),'\xC2',(offset)) \ 332 && CHECK_AT((string),'\x85',(offset)+1)) /* NEL (#x85) */ \ 333 || (CHECK_AT((string),'\xE2',(offset)) \ 334 && CHECK_AT((string),'\x80',(offset)+1) \ 335 && CHECK_AT((string),'\xA8',(offset)+2)) /* LS (#x2028) */ \ 336 || (CHECK_AT((string),'\xE2',(offset)) \ 337 && CHECK_AT((string),'\x80',(offset)+1) \ 338 && CHECK_AT((string),'\xA9',(offset)+2))) /* PS (#x2029) */ 339 340 #define IS_BREAK(string) IS_BREAK_AT((string),0) 341 342 #define IS_CRLF_AT(string,offset) \ 343 (CHECK_AT((string),'\r',(offset)) && CHECK_AT((string),'\n',(offset)+1)) 344 345 #define IS_CRLF(string) IS_CRLF_AT((string),0) 346 347 /* 348 * Check if the character is a line break or NUL. 349 */ 350 351 #define IS_BREAKZ_AT(string,offset) \ 352 (IS_BREAK_AT((string),(offset)) || IS_Z_AT((string),(offset))) 353 354 #define IS_BREAKZ(string) IS_BREAKZ_AT((string),0) 355 356 /* 357 * Check if the character is a line break, space, or NUL. 358 */ 359 360 #define IS_SPACEZ_AT(string,offset) \ 361 (IS_SPACE_AT((string),(offset)) || IS_BREAKZ_AT((string),(offset))) 362 363 #define IS_SPACEZ(string) IS_SPACEZ_AT((string),0) 364 365 /* 366 * Check if the character is a line break, space, tab, or NUL. 367 */ 368 369 #define IS_BLANKZ_AT(string,offset) \ 370 (IS_BLANK_AT((string),(offset)) || IS_BREAKZ_AT((string),(offset))) 371 372 #define IS_BLANKZ(string) IS_BLANKZ_AT((string),0) 373 374 /* 375 * Determine the width of the character. 376 */ 377 378 #define WIDTH_AT(string,offset) \ 379 (((string).pointer[offset] & 0x80) == 0x00 ? 1 : \ 380 ((string).pointer[offset] & 0xE0) == 0xC0 ? 2 : \ 381 ((string).pointer[offset] & 0xF0) == 0xE0 ? 3 : \ 382 ((string).pointer[offset] & 0xF8) == 0xF0 ? 4 : 0) 383 384 #define WIDTH(string) WIDTH_AT((string),0) 385 386 /* 387 * Move the string pointer to the next character. 388 */ 389 390 #define MOVE(string) ((string).pointer += WIDTH((string))) 391 392 /* 393 * Copy a character and move the pointers of both strings. 394 */ 395 396 #define COPY(string_a,string_b) \ 397 ((*(string_b).pointer & 0x80) == 0x00 ? \ 398 (*((string_a).pointer++) = *((string_b).pointer++)) : \ 399 (*(string_b).pointer & 0xE0) == 0xC0 ? \ 400 (*((string_a).pointer++) = *((string_b).pointer++), \ 401 *((string_a).pointer++) = *((string_b).pointer++)) : \ 402 (*(string_b).pointer & 0xF0) == 0xE0 ? \ 403 (*((string_a).pointer++) = *((string_b).pointer++), \ 404 *((string_a).pointer++) = *((string_b).pointer++), \ 405 *((string_a).pointer++) = *((string_b).pointer++)) : \ 406 (*(string_b).pointer & 0xF8) == 0xF0 ? \ 407 (*((string_a).pointer++) = *((string_b).pointer++), \ 408 *((string_a).pointer++) = *((string_b).pointer++), \ 409 *((string_a).pointer++) = *((string_b).pointer++), \ 410 *((string_a).pointer++) = *((string_b).pointer++)) : 0) 411 412 /* 413 * Stack and queue management. 414 */ 415 416 YAML_DECLARE(int) 417 yaml_stack_extend(void **start, void **top, void **end); 418 419 YAML_DECLARE(int) 420 yaml_queue_extend(void **start, void **head, void **tail, void **end); 421 422 #define STACK_INIT(context,stack,size) \ 423 (((stack).start = yaml_malloc((size)*sizeof(*(stack).start))) ? \ 424 ((stack).top = (stack).start, \ 425 (stack).end = (stack).start+(size), \ 426 1) : \ 427 ((context)->error = YAML_MEMORY_ERROR, \ 428 0)) 429 430 #define STACK_DEL(context,stack) \ 431 (yaml_free((stack).start), \ 432 (stack).start = (stack).top = (stack).end = 0) 433 434 #define STACK_EMPTY(context,stack) \ 435 ((stack).start == (stack).top) 436 437 #define STACK_LIMIT(context,stack,size) \ 438 ((stack).top - (stack).start < (size) ? \ 439 1 : \ 440 ((context)->error = YAML_MEMORY_ERROR, \ 441 0)) 442 443 #define PUSH(context,stack,value) \ 444 (((stack).top != (stack).end \ 445 || yaml_stack_extend((void **)&(stack).start, \ 446 (void **)&(stack).top, (void **)&(stack).end)) ? \ 447 (*((stack).top++) = value, \ 448 1) : \ 449 ((context)->error = YAML_MEMORY_ERROR, \ 450 0)) 451 452 #define POP(context,stack) \ 453 (*(--(stack).top)) 454 455 #define QUEUE_INIT(context,queue,size) \ 456 (((queue).start = yaml_malloc((size)*sizeof(*(queue).start))) ? \ 457 ((queue).head = (queue).tail = (queue).start, \ 458 (queue).end = (queue).start+(size), \ 459 1) : \ 460 ((context)->error = YAML_MEMORY_ERROR, \ 461 0)) 462 463 #define QUEUE_DEL(context,queue) \ 464 (yaml_free((queue).start), \ 465 (queue).start = (queue).head = (queue).tail = (queue).end = 0) 466 467 #define QUEUE_EMPTY(context,queue) \ 468 ((queue).head == (queue).tail) 469 470 #define ENQUEUE(context,queue,value) \ 471 (((queue).tail != (queue).end \ 472 || yaml_queue_extend((void **)&(queue).start, (void **)&(queue).head, \ 473 (void **)&(queue).tail, (void **)&(queue).end)) ? \ 474 (*((queue).tail++) = value, \ 475 1) : \ 476 ((context)->error = YAML_MEMORY_ERROR, \ 477 0)) 478 479 #define DEQUEUE(context,queue) \ 480 (*((queue).head++)) 481 482 #define QUEUE_INSERT(context,queue,index,value) \ 483 (((queue).tail != (queue).end \ 484 || yaml_queue_extend((void **)&(queue).start, (void **)&(queue).head, \ 485 (void **)&(queue).tail, (void **)&(queue).end)) ? \ 486 (memmove((queue).head+(index)+1,(queue).head+(index), \ 487 ((queue).tail-(queue).head-(index))*sizeof(*(queue).start)), \ 488 *((queue).head+(index)) = value, \ 489 (queue).tail++, \ 490 1) : \ 491 ((context)->error = YAML_MEMORY_ERROR, \ 492 0)) 493 494 /* 495 * Token initializers. 496 */ 497 498 #define TOKEN_INIT(token,token_type,token_start_mark,token_end_mark) \ 499 (memset(&(token), 0, sizeof(yaml_token_t)), \ 500 (token).type = (token_type), \ 501 (token).start_mark = (token_start_mark), \ 502 (token).end_mark = (token_end_mark)) 503 504 #define STREAM_START_TOKEN_INIT(token,token_encoding,start_mark,end_mark) \ 505 (TOKEN_INIT((token),YAML_STREAM_START_TOKEN,(start_mark),(end_mark)), \ 506 (token).data.stream_start.encoding = (token_encoding)) 507 508 #define STREAM_END_TOKEN_INIT(token,start_mark,end_mark) \ 509 (TOKEN_INIT((token),YAML_STREAM_END_TOKEN,(start_mark),(end_mark))) 510 511 #define ALIAS_TOKEN_INIT(token,token_value,start_mark,end_mark) \ 512 (TOKEN_INIT((token),YAML_ALIAS_TOKEN,(start_mark),(end_mark)), \ 513 (token).data.alias.value = (token_value)) 514 515 #define ANCHOR_TOKEN_INIT(token,token_value,start_mark,end_mark) \ 516 (TOKEN_INIT((token),YAML_ANCHOR_TOKEN,(start_mark),(end_mark)), \ 517 (token).data.anchor.value = (token_value)) 518 519 #define TAG_TOKEN_INIT(token,token_handle,token_suffix,start_mark,end_mark) \ 520 (TOKEN_INIT((token),YAML_TAG_TOKEN,(start_mark),(end_mark)), \ 521 (token).data.tag.handle = (token_handle), \ 522 (token).data.tag.suffix = (token_suffix)) 523 524 #define SCALAR_TOKEN_INIT(token,token_value,token_length,token_style,start_mark,end_mark) \ 525 (TOKEN_INIT((token),YAML_SCALAR_TOKEN,(start_mark),(end_mark)), \ 526 (token).data.scalar.value = (token_value), \ 527 (token).data.scalar.length = (token_length), \ 528 (token).data.scalar.style = (token_style)) 529 530 #define VERSION_DIRECTIVE_TOKEN_INIT(token,token_major,token_minor,start_mark,end_mark) \ 531 (TOKEN_INIT((token),YAML_VERSION_DIRECTIVE_TOKEN,(start_mark),(end_mark)), \ 532 (token).data.version_directive.major = (token_major), \ 533 (token).data.version_directive.minor = (token_minor)) 534 535 #define TAG_DIRECTIVE_TOKEN_INIT(token,token_handle,token_prefix,start_mark,end_mark) \ 536 (TOKEN_INIT((token),YAML_TAG_DIRECTIVE_TOKEN,(start_mark),(end_mark)), \ 537 (token).data.tag_directive.handle = (token_handle), \ 538 (token).data.tag_directive.prefix = (token_prefix)) 539 540 /* 541 * Event initializers. 542 */ 543 544 #define EVENT_INIT(event,event_type,event_start_mark,event_end_mark) \ 545 (memset(&(event), 0, sizeof(yaml_event_t)), \ 546 (event).type = (event_type), \ 547 (event).start_mark = (event_start_mark), \ 548 (event).end_mark = (event_end_mark)) 549 550 #define STREAM_START_EVENT_INIT(event,event_encoding,start_mark,end_mark) \ 551 (EVENT_INIT((event),YAML_STREAM_START_EVENT,(start_mark),(end_mark)), \ 552 (event).data.stream_start.encoding = (event_encoding)) 553 554 #define STREAM_END_EVENT_INIT(event,start_mark,end_mark) \ 555 (EVENT_INIT((event),YAML_STREAM_END_EVENT,(start_mark),(end_mark))) 556 557 #define DOCUMENT_START_EVENT_INIT(event,event_version_directive, \ 558 event_tag_directives_start,event_tag_directives_end,event_implicit,start_mark,end_mark) \ 559 (EVENT_INIT((event),YAML_DOCUMENT_START_EVENT,(start_mark),(end_mark)), \ 560 (event).data.document_start.version_directive = (event_version_directive), \ 561 (event).data.document_start.tag_directives.start = (event_tag_directives_start), \ 562 (event).data.document_start.tag_directives.end = (event_tag_directives_end), \ 563 (event).data.document_start.implicit = (event_implicit)) 564 565 #define DOCUMENT_END_EVENT_INIT(event,event_implicit,start_mark,end_mark) \ 566 (EVENT_INIT((event),YAML_DOCUMENT_END_EVENT,(start_mark),(end_mark)), \ 567 (event).data.document_end.implicit = (event_implicit)) 568 569 #define ALIAS_EVENT_INIT(event,event_anchor,start_mark,end_mark) \ 570 (EVENT_INIT((event),YAML_ALIAS_EVENT,(start_mark),(end_mark)), \ 571 (event).data.alias.anchor = (event_anchor)) 572 573 #define SCALAR_EVENT_INIT(event,event_anchor,event_tag,event_value,event_length, \ 574 event_plain_implicit, event_quoted_implicit,event_style,start_mark,end_mark) \ 575 (EVENT_INIT((event),YAML_SCALAR_EVENT,(start_mark),(end_mark)), \ 576 (event).data.scalar.anchor = (event_anchor), \ 577 (event).data.scalar.tag = (event_tag), \ 578 (event).data.scalar.value = (event_value), \ 579 (event).data.scalar.length = (event_length), \ 580 (event).data.scalar.plain_implicit = (event_plain_implicit), \ 581 (event).data.scalar.quoted_implicit = (event_quoted_implicit), \ 582 (event).data.scalar.style = (event_style)) 583 584 #define SEQUENCE_START_EVENT_INIT(event,event_anchor,event_tag, \ 585 event_implicit,event_style,start_mark,end_mark) \ 586 (EVENT_INIT((event),YAML_SEQUENCE_START_EVENT,(start_mark),(end_mark)), \ 587 (event).data.sequence_start.anchor = (event_anchor), \ 588 (event).data.sequence_start.tag = (event_tag), \ 589 (event).data.sequence_start.implicit = (event_implicit), \ 590 (event).data.sequence_start.style = (event_style)) 591 592 #define SEQUENCE_END_EVENT_INIT(event,start_mark,end_mark) \ 593 (EVENT_INIT((event),YAML_SEQUENCE_END_EVENT,(start_mark),(end_mark))) 594 595 #define MAPPING_START_EVENT_INIT(event,event_anchor,event_tag, \ 596 event_implicit,event_style,start_mark,end_mark) \ 597 (EVENT_INIT((event),YAML_MAPPING_START_EVENT,(start_mark),(end_mark)), \ 598 (event).data.mapping_start.anchor = (event_anchor), \ 599 (event).data.mapping_start.tag = (event_tag), \ 600 (event).data.mapping_start.implicit = (event_implicit), \ 601 (event).data.mapping_start.style = (event_style)) 602 603 #define MAPPING_END_EVENT_INIT(event,start_mark,end_mark) \ 604 (EVENT_INIT((event),YAML_MAPPING_END_EVENT,(start_mark),(end_mark))) 605 606 /* 607 * Document initializer. 608 */ 609 610 #define DOCUMENT_INIT(document,document_nodes_start,document_nodes_end, \ 611 document_version_directive,document_tag_directives_start, \ 612 document_tag_directives_end,document_start_implicit, \ 613 document_end_implicit,document_start_mark,document_end_mark) \ 614 (memset(&(document), 0, sizeof(yaml_document_t)), \ 615 (document).nodes.start = (document_nodes_start), \ 616 (document).nodes.end = (document_nodes_end), \ 617 (document).nodes.top = (document_nodes_start), \ 618 (document).version_directive = (document_version_directive), \ 619 (document).tag_directives.start = (document_tag_directives_start), \ 620 (document).tag_directives.end = (document_tag_directives_end), \ 621 (document).start_implicit = (document_start_implicit), \ 622 (document).end_implicit = (document_end_implicit), \ 623 (document).start_mark = (document_start_mark), \ 624 (document).end_mark = (document_end_mark)) 625 626 /* 627 * Node initializers. 628 */ 629 630 #define NODE_INIT(node,node_type,node_tag,node_start_mark,node_end_mark) \ 631 (memset(&(node), 0, sizeof(yaml_node_t)), \ 632 (node).type = (node_type), \ 633 (node).tag = (node_tag), \ 634 (node).start_mark = (node_start_mark), \ 635 (node).end_mark = (node_end_mark)) 636 637 #define SCALAR_NODE_INIT(node,node_tag,node_value,node_length, \ 638 node_style,start_mark,end_mark) \ 639 (NODE_INIT((node),YAML_SCALAR_NODE,(node_tag),(start_mark),(end_mark)), \ 640 (node).data.scalar.value = (node_value), \ 641 (node).data.scalar.length = (node_length), \ 642 (node).data.scalar.style = (node_style)) 643 644 #define SEQUENCE_NODE_INIT(node,node_tag,node_items_start,node_items_end, \ 645 node_style,start_mark,end_mark) \ 646 (NODE_INIT((node),YAML_SEQUENCE_NODE,(node_tag),(start_mark),(end_mark)), \ 647 (node).data.sequence.items.start = (node_items_start), \ 648 (node).data.sequence.items.end = (node_items_end), \ 649 (node).data.sequence.items.top = (node_items_start), \ 650 (node).data.sequence.style = (node_style)) 651 652 #define MAPPING_NODE_INIT(node,node_tag,node_pairs_start,node_pairs_end, \ 653 node_style,start_mark,end_mark) \ 654 (NODE_INIT((node),YAML_MAPPING_NODE,(node_tag),(start_mark),(end_mark)), \ 655 (node).data.mapping.pairs.start = (node_pairs_start), \ 656 (node).data.mapping.pairs.end = (node_pairs_end), \ 657 (node).data.mapping.pairs.top = (node_pairs_start), \ 658 (node).data.mapping.style = (node_style)) 659