X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gom%2Frepository.c;h=3df73882ecebbde603ee01db1d373cf0c5821f6f;hb=89ff39aaedee4aa65dec40032686e8b2f8ca272a;hp=a2f61dd6bcc60aebc1f4c3b2fd24373fe30951d8;hpb=bdf47fdee469d5a1d7ddfd06a0e4b26f3b40b0f4;p=gedcom-parse.git diff --git a/gom/repository.c b/gom/repository.c index a2f61dd..3df7388 100644 --- a/gom/repository.c +++ b/gom/repository.c @@ -52,7 +52,7 @@ void repository_add_address(Gom_ctxt ctxt, struct address* address) repo->address = address; } -void repository_add_phone(Gom_ctxt ctxt, char *phone) +void repository_add_phone(Gom_ctxt ctxt, const char *phone) { struct repository *repo = SAFE_CTXT_CAST(repository, ctxt); if (repo) { @@ -79,7 +79,7 @@ void repository_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref) LINK_CHAIN_ELT(user_ref_number, repo->ref, ref); } -void repository_set_record_id(Gom_ctxt ctxt, char *rin) +void repository_set_record_id(Gom_ctxt ctxt, const char *rin) { struct repository *repo = SAFE_CTXT_CAST(repository, ctxt); if (repo) { @@ -129,7 +129,7 @@ struct repository* gom_get_first_repository() return gom_first_repository; } -struct repository* make_repository_record(char* xrefstr) +struct repository* make_repository_record(const char* xrefstr) { struct repository* repo = NULL; MAKE_CHAIN_ELT(repository, gom_first_repository, repo); @@ -139,3 +139,35 @@ struct repository* make_repository_record(char* xrefstr) } return repo; } + +int write_repositories(Gedcom_write_hndl hndl) +{ + int result = 0; + int i; + struct repository* obj; + + for (obj = gom_first_repository; obj; obj = obj->next) { + result |= gedcom_write_record_str(hndl, REC_REPO, obj->xrefstr, NULL); + if (obj->name) + result |= gedcom_write_element_str(hndl, ELT_REPO_NAME, 0, + REC_REPO, obj->name); + if (obj->address) + result |= write_address(hndl, REC_REPO, obj->address); + for (i = 0; i < 3 && obj->phone[i]; i++) + result |= gedcom_write_element_str(hndl, ELT_SUB_PHON, 0, REC_REPO, + obj->phone[i]); + if (obj->note) + result |= write_note_subs(hndl, REC_REPO, obj->note); + if (obj->ref) + result |= write_user_refs(hndl, REC_REPO, obj->ref); + if (obj->record_id) + result |= gedcom_write_element_str(hndl, ELT_SUB_IDENT_RIN, 0, + REC_REPO, obj->record_id); + if (obj->change_date) + result |= write_change_date(hndl, REC_REPO, obj->change_date); + if (obj->extra) + result |= write_user_data(hndl, obj->extra); + } + + return result; +}