| 719 | */ |
| 720 | |
| 721 | YAML_DECLARE(int) |
| 722 | yaml_document_start_event_initialize(yaml_event_t *event, |
| 723 | yaml_version_directive_t *version_directive, |
| 724 | yaml_tag_directive_t *tag_directives_start, |
| 725 | yaml_tag_directive_t *tag_directives_end, |
| 726 | int implicit) |
| 727 | { |
| 728 | struct { |
| 729 | yaml_error_type_t error; |
| 730 | } context; |
| 731 | yaml_mark_t mark = { 0, 0, 0 }; |
| 732 | yaml_version_directive_t *version_directive_copy = NULL; |
| 733 | struct { |
| 734 | yaml_tag_directive_t *start; |
| 735 | yaml_tag_directive_t *end; |
| 736 | yaml_tag_directive_t *top; |
| 737 | } tag_directives_copy = { NULL, NULL, NULL }; |
| 738 | yaml_tag_directive_t value = { NULL, NULL }; |
| 739 | |
| 740 | assert(event); /* Non-NULL event object is expected. */ |
| 741 | assert((tag_directives_start && tag_directives_end) || |
| 742 | (tag_directives_start == tag_directives_end)); |
| 743 | /* Valid tag directives are expected. */ |
| 744 | |
| 745 | if (version_directive) { |
| 746 | version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t)); |
| 747 | if (!version_directive_copy) goto error; |
| 748 | version_directive_copy->major = version_directive->major; |
| 749 | version_directive_copy->minor = version_directive->minor; |
| 750 | } |
| 751 | |
| 752 | if (tag_directives_start != tag_directives_end) { |
| 753 | yaml_tag_directive_t *tag_directive; |
| 754 | if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE)) |
| 755 | goto error; |
| 756 | for (tag_directive = tag_directives_start; |
| 757 | tag_directive != tag_directives_end; tag_directive ++) { |
| 758 | assert(tag_directive->handle); |
| 759 | assert(tag_directive->prefix); |
| 760 | if (!yaml_check_utf8(tag_directive->handle, |
| 761 | strlen((char *)tag_directive->handle))) |
| 762 | goto error; |
| 763 | if (!yaml_check_utf8(tag_directive->prefix, |
| 764 | strlen((char *)tag_directive->prefix))) |
| 765 | goto error; |
| 766 | value.handle = yaml_strdup(tag_directive->handle); |
| 767 | value.prefix = yaml_strdup(tag_directive->prefix); |
| 768 | if (!value.handle || !value.prefix) goto error; |
| 769 | if (!PUSH(&context, tag_directives_copy, value)) |
| 770 | goto error; |
| 771 | value.handle = NULL; |
| 772 | value.prefix = NULL; |
| 773 | } |
| 774 | } |
| 775 | |
| 776 | DOCUMENT_START_EVENT_INIT(*event, version_directive_copy, |
| 777 | tag_directives_copy.start, tag_directives_copy.top, |
| 778 | implicit, mark, mark); |
nothing calls this directly
no test coverage detected