X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gom%2Ffamily_link.c;h=1ab6d4b668b23e7ebd6ff05bd33ec499c6972290;hb=5684a3ce93e11c887cbf3c237fd007d517cb2c30;hp=4c5fa9b0f357d666610c8970ba8b5cd9edc45830;hpb=bdf47fdee469d5a1d7ddfd06a0e4b26f3b40b0f4;p=gedcom-parse.git diff --git a/gom/family_link.c b/gom/family_link.c index 4c5fa9b..1ab6d4b 100644 --- a/gom/family_link.c +++ b/gom/family_link.c @@ -126,3 +126,43 @@ void family_link_cleanup(struct family_link *link) DESTROY_CHAIN_ELTS(user_data, link->extra, user_data_cleanup); } } + +int write_pedigrees(Gedcom_write_hndl hndl, int parent, struct pedigree* ped) +{ + int result = 0; + struct pedigree* obj; + + if (!ped) return 1; + + for (obj = ped; obj; obj = obj->next) { + result |= gedcom_write_element_str(hndl, ELT_SUB_FAMC_PEDI, 0, parent, + obj->pedigree); + if (obj->extra) + result |= write_user_data(hndl, obj->extra); + } + + return result; +} + +int write_family_links(Gedcom_write_hndl hndl, int parent, LinkType type, + struct family_link *link) +{ + int result = 0; + struct family_link* obj; + int elt = (type == LINK_TYPE_CHILD ? ELT_SUB_FAMC : ELT_SUB_FAMS); + + if (!link) return 1; + + for (obj = link; obj; obj = obj->next) { + result |= gedcom_write_element_xref(hndl, elt, 0, parent, + obj->family); + if (obj->pedigree) + result |= write_pedigrees(hndl, elt, obj->pedigree); + if (obj->note) + result |= write_note_subs(hndl, elt, obj->note); + if (obj->extra) + result |= write_user_data(hndl, obj->extra); + } + + return result; +}