X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gom%2Fsource_citation.c;fp=gom%2Fsource_citation.c;h=ff479d92972ec68aa56927db46b9fed07a0664b1;hb=082066d0c776403b70c366f9a7d1333c7a9fac15;hp=8aa6b51687a1311ad2bdaf8b9ff82acce69aeb6e;hpb=8a73dd117ad3bf06a89595f7cd8fdef45c231a6e;p=gedcom-parse.git diff --git a/gom/source_citation.c b/gom/source_citation.c index 8aa6b51..ff479d9 100644 --- a/gom/source_citation.c +++ b/gom/source_citation.c @@ -208,3 +208,67 @@ 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->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; +}