1 /* Repository object in the gedcom object model.
2 Copyright (C) 2002 The Genes Development Team
3 This file is part of the Gedcom parser library.
4 Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
6 The Gedcom parser library is free software; you can redistribute it
7 and/or modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The Gedcom parser library is distributed in the hope that it will be
12 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the Gedcom parser library; if not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 #include "repository.h"
30 #include "change_date.h"
34 #include "gom_internal.h"
36 struct repository* gom_first_repository = NULL;
38 DEFINE_MAKEFUNC(repository, gom_first_repository)
39 DEFINE_DESTROYFUNC(repository, gom_first_repository)
40 DEFINE_ADDFUNC(repository, XREF_REPO)
41 DEFINE_DELETEFUNC(repository)
42 DEFINE_GETXREFFUNC(repository, XREF_REPO)
44 DEFINE_REC_CB(repository, repo_start)
45 DEFINE_STRING_CB(repository, repo_name_start, name)
47 DEFINE_ADDFUNC2(repository, note_sub, note)
48 DEFINE_ADDFUNC2(repository, user_ref_number, ref)
49 DEFINE_ADDFUNC2(repository, user_data, extra)
50 DEFINE_ADDFUNC2_NOLIST(repository, address, address)
51 DEFINE_ADDFUNC2_NOLIST(repository, change_date, change_date)
52 DEFINE_ADDFUNC2_STRN(repository, phone, 3)
53 DEFINE_ADDFUNC2_STR(repository, record_id)
55 void repository_subscribe()
57 gedcom_subscribe_to_record(REC_REPO, repo_start, def_rec_end);
58 gedcom_subscribe_to_element(ELT_REPO_NAME, repo_name_start, def_elt_end);
61 void CLEANFUNC(repository)(struct repository* repo)
64 SAFE_FREE(repo->xrefstr);
65 SAFE_FREE(repo->name);
66 CLEANFUNC(address)(repo->address);
67 SAFE_FREE(repo->phone[0]);
68 SAFE_FREE(repo->phone[1]);
69 SAFE_FREE(repo->phone[2]);
70 DESTROY_CHAIN_ELTS(note_sub, repo->note);
71 DESTROY_CHAIN_ELTS(user_ref_number, repo->ref);
72 SAFE_FREE(repo->record_id);
73 CLEANFUNC(change_date)(repo->change_date);
74 DESTROY_CHAIN_ELTS(user_data, repo->extra);
78 void repositories_cleanup()
80 DESTROY_CHAIN_ELTS(repository, gom_first_repository);
83 struct repository* gom_get_first_repository()
85 return gom_first_repository;
88 int write_repositories(Gedcom_write_hndl hndl)
92 struct repository* obj;
94 for (obj = gom_first_repository; obj; obj = obj->next) {
95 result |= gedcom_write_record_str(hndl, REC_REPO, obj->xrefstr, NULL);
97 result |= gedcom_write_element_str(hndl, ELT_REPO_NAME, 0,
100 result |= write_address(hndl, REC_REPO, obj->address);
101 for (i = 0; i < 3 && obj->phone[i]; i++)
102 result |= gedcom_write_element_str(hndl, ELT_SUB_PHON, 0, REC_REPO,
105 result |= write_note_subs(hndl, REC_REPO, obj->note);
107 result |= write_user_refs(hndl, REC_REPO, obj->ref);
109 result |= gedcom_write_element_str(hndl, ELT_SUB_IDENT_RIN, 0,
110 REC_REPO, obj->record_id);
111 if (obj->change_date)
112 result |= write_change_date(hndl, REC_REPO, obj->change_date);
114 result |= write_user_data(hndl, obj->extra);