1 /* Submitter 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 "submitter.h"
28 #include "multimedia_link.h"
29 #include "change_date.h"
33 #include "gom_internal.h"
35 struct submitter* gom_first_submitter = NULL;
37 REC_CB(submitter, subm_start, make_submitter_record)
38 GET_REC_BY_XREF(submitter, XREF_SUBM, gom_get_submitter_by_xref)
39 STRING_CB(submitter, subm_name_start, name)
40 STRING_CB(submitter, subm_rfn_start, record_file_nr)
41 STRING_CB(submitter, subm_rin_start, record_id)
43 Gedcom_ctxt subm_lang_start(_ELT_PARAMS_)
45 Gom_ctxt ctxt = (Gom_ctxt)parent;
46 struct submitter *subm = SAFE_CTXT_CAST(submitter, ctxt);
47 char *str = GEDCOM_STRING(parsed_value);
49 if (! subm->language[0])
50 subm->language[0] = strdup(str);
51 else if (! subm->language[1])
52 subm->language[1] = strdup(str);
53 else if (! subm->language[2])
54 subm->language[2] = strdup(str);
56 return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, submitter, subm);
59 void submitter_subscribe()
61 gedcom_subscribe_to_record(REC_SUBM, subm_start, def_rec_end);
62 gedcom_subscribe_to_element(ELT_SUBM_NAME, subm_name_start, def_elt_end);
63 gedcom_subscribe_to_element(ELT_SUBM_LANG, subm_lang_start, def_elt_end);
64 gedcom_subscribe_to_element(ELT_SUBM_RFN, subm_rfn_start, def_elt_end);
65 gedcom_subscribe_to_element(ELT_SUBM_RIN, subm_rin_start, def_elt_end);
68 void submitter_add_address(Gom_ctxt ctxt, struct address* address)
70 struct submitter *subm = SAFE_CTXT_CAST(submitter, ctxt);
71 subm->address = address;
74 void submitter_add_phone(Gom_ctxt ctxt, char *phone)
76 struct submitter *subm = SAFE_CTXT_CAST(submitter, ctxt);
78 subm->phone[0] = strdup(phone);
79 else if (! subm->phone[1])
80 subm->phone[1] = strdup(phone);
81 else if (! subm->phone[2])
82 subm->phone[2] = strdup(phone);
85 void submitter_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link)
87 struct submitter *subm = SAFE_CTXT_CAST(submitter, ctxt);
88 LINK_CHAIN_ELT(multimedia_link, subm->mm_link, link)
91 void submitter_set_change_date(Gom_ctxt ctxt, struct change_date* chan)
93 struct submitter *subm = SAFE_CTXT_CAST(submitter, ctxt);
94 subm->change_date = chan;
97 void submitter_add_user_data(Gom_ctxt ctxt, struct user_data* data)
99 struct submitter *obj = SAFE_CTXT_CAST(submitter, ctxt);
100 LINK_CHAIN_ELT(user_data, obj->extra, data)
103 void submitter_cleanup(struct submitter* rec)
105 SAFE_FREE(rec->xrefstr);
106 SAFE_FREE(rec->name);
107 address_cleanup(rec->address);
108 SAFE_FREE(rec->phone[0]);
109 SAFE_FREE(rec->phone[1]);
110 SAFE_FREE(rec->phone[2]);
111 DESTROY_CHAIN_ELTS(multimedia_link, rec->mm_link, multimedia_link_cleanup)
112 SAFE_FREE(rec->language[0]);
113 SAFE_FREE(rec->language[1]);
114 SAFE_FREE(rec->language[2]);
115 SAFE_FREE(rec->record_file_nr);
116 SAFE_FREE(rec->record_id);
117 change_date_cleanup(rec->change_date);
118 DESTROY_CHAIN_ELTS(user_data, rec->extra, user_data_cleanup)
121 void submitters_cleanup()
123 DESTROY_CHAIN_ELTS(submitter, gom_first_submitter, submitter_cleanup);
126 struct submitter* gom_get_first_submitter()
128 return gom_first_submitter;
131 struct submitter* make_submitter_record(char* xrefstr)
133 struct submitter* subm;
134 MAKE_CHAIN_ELT(submitter, gom_first_submitter, subm);
135 subm->xrefstr = strdup(xrefstr);