X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gom%2Fsource_citation.c;h=17c2b6dcb2d1b19ff08e47a1f70ce192db4c89c5;hb=39bb8d4c3317074cfa3e8e92cc12e6160675e246;hp=8aa6b51687a1311ad2bdaf8b9ff82acce69aeb6e;hpb=d7e4149f2d99ab6eed88685eeeaac614b7139a01;p=gedcom-parse.git diff --git a/gom/source_citation.c b/gom/source_citation.c index 8aa6b51..17c2b6d 100644 --- a/gom/source_citation.c +++ b/gom/source_citation.c @@ -208,3 +208,70 @@ void citation_cleanup(struct source_citation* cit) DESTROY_CHAIN_ELTS(user_data, cit->extra, user_data_cleanup); } } + +int write_texts(Gedcom_write_hndl hndl, int parent, struct text* t) +{ + int result = 0; + struct text* obj; + + if (!t) return 1; + + for (obj = t; obj; obj = obj->next) { + result |= gedcom_write_element_str(hndl, ELT_SUB_SOUR_TEXT, 0, parent, + obj->text); + if (obj->extra) + result |= write_user_data(hndl, obj->extra); + } + + return result; +} + +int write_citations(Gedcom_write_hndl hndl, int parent, + struct source_citation* cit) +{ + int result = 0; + struct source_citation* obj; + + if (!cit) return 1; + + for (obj = cit; obj; obj = obj->next) { + if (obj->reference) { + result |= gedcom_write_element_xref(hndl, ELT_SUB_SOUR, 0, parent, + obj->reference); + if (obj->page) + result |= gedcom_write_element_str(hndl, ELT_SUB_SOUR_PAGE, 0, + ELT_SUB_SOUR, obj->page); + if (obj->event) + result |= gedcom_write_element_str(hndl, ELT_SUB_SOUR_EVEN, 0, + ELT_SUB_SOUR, obj->event); + if (obj->role) + result |= gedcom_write_element_str(hndl, ELT_SUB_SOUR_EVEN_ROLE, 0, + ELT_SUB_SOUR_EVEN, obj->role); + if (obj->date || obj->text) + result |= gedcom_write_element_str(hndl, ELT_SUB_SOUR_DATA, 0, + ELT_SUB_SOUR, NULL); + if (obj->date) + result |= gedcom_write_element_date(hndl, ELT_SUB_SOUR_DATA_DATE, 0, + ELT_SUB_SOUR_DATA, obj->date); + if (obj->text) + result |= write_texts(hndl, ELT_SUB_SOUR_DATA, obj->text); + if (obj->quality) + result |= gedcom_write_element_str(hndl, ELT_SUB_SOUR_QUAY, 0, + ELT_SUB_SOUR, obj->quality); + if (obj->mm_link) + result |= write_multimedia_links(hndl, ELT_SUB_SOUR, obj->mm_link); + } + else { + result |= gedcom_write_element_str(hndl, ELT_SUB_SOUR, 0, parent, + obj->description); + if (obj->text) + result |= write_texts(hndl, ELT_SUB_SOUR, obj->text); + } + if (obj->note) + result |= write_note_subs(hndl, ELT_SUB_SOUR, obj->note); + if (obj->extra) + result |= write_user_data(hndl, obj->extra); + } + + return result; +}