Forgotten internal header file.
[gedcom-parse.git] / gom / lds_event.c
1 /* LDS spouse sealing sub-structure 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.
5
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.
10
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.
15
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
19    02111-1307 USA.  */
20
21 /* $Id$ */
22 /* $Name$ */
23
24 #include <stdlib.h>
25 #include <string.h>
26 #include "lds_event.h"
27 #include "family.h"
28 #include "individual.h"
29 #include "note_sub.h"
30 #include "source_citation.h"
31 #include "user_rec.h"
32 #include "gom.h"
33 #include "gedcom.h"
34 #include "gom_internal.h"
35
36 Gedcom_ctxt sub_lds_event_start(_ELT_PARAMS_)
37 {
38   Gom_ctxt ctxt = (Gom_ctxt)parent;
39   struct lds_event *lds_evt = NULL;
40
41   if (ctxt) {
42     lds_evt = (struct lds_event*)malloc(sizeof(struct lds_event));
43     memset (lds_evt, 0, sizeof(struct lds_event));
44
45     switch (ctxt->ctxt_type) {
46       case REC_FAM:
47         family_add_lss(ctxt, lds_evt); break;
48       case REC_INDI:
49         individual_add_lio(ctxt, lds_evt); break;
50       default:
51         UNEXPECTED_CONTEXT(ctxt->ctxt_type);
52     }
53   }
54
55   return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, lds_event, lds_evt);
56 }
57
58 STRING_CB(lds_event, sub_lds_event_stat_start, date_status)
59 DATE_CB(lds_event, sub_lds_event_date_start, date)
60 STRING_CB(lds_event, sub_lds_event_temp_start, temple_code)
61 STRING_CB(lds_event, sub_lds_event_plac_start, place_living_ordinance)
62 XREF_CB(lds_event, sub_lds_event_famc_start, family, make_family_record)
63      
64 void lds_event_subscribe()
65 {
66   gedcom_subscribe_to_element(ELT_SUB_LSS_SLGS,
67                               sub_lds_event_start, def_elt_end);
68   gedcom_subscribe_to_element(ELT_SUB_LIO_BAPL,
69                               sub_lds_event_start, def_elt_end);
70   gedcom_subscribe_to_element(ELT_SUB_LIO_SLGC,
71                               sub_lds_event_start, def_elt_end);
72   gedcom_subscribe_to_element(ELT_SUB_LSS_SLGS_STAT,
73                               sub_lds_event_stat_start, def_elt_end);
74   gedcom_subscribe_to_element(ELT_SUB_LIO_BAPL_STAT,
75                               sub_lds_event_stat_start, def_elt_end);
76   gedcom_subscribe_to_element(ELT_SUB_LSS_SLGS_DATE,
77                               sub_lds_event_date_start, def_elt_end);
78   gedcom_subscribe_to_element(ELT_SUB_LIO_BAPL_DATE,
79                               sub_lds_event_date_start, def_elt_end);
80   gedcom_subscribe_to_element(ELT_SUB_LSS_SLGS_TEMP,
81                               sub_lds_event_temp_start, def_elt_end);
82   gedcom_subscribe_to_element(ELT_SUB_LIO_BAPL_TEMP,
83                               sub_lds_event_temp_start, def_elt_end);
84   gedcom_subscribe_to_element(ELT_SUB_LSS_SLGS_PLAC,
85                               sub_lds_event_plac_start, def_elt_end);
86   gedcom_subscribe_to_element(ELT_SUB_LIO_BAPL_PLAC,
87                               sub_lds_event_plac_start, def_elt_end);
88   gedcom_subscribe_to_element(ELT_SUB_LIO_SLGC_FAMC,
89                               sub_lds_event_famc_start, def_elt_end);
90 }
91
92 void lds_event_add_note(Gom_ctxt ctxt, struct note_sub* note)
93 {
94   struct lds_event *lds = SAFE_CTXT_CAST(lds_event, ctxt);
95   LINK_CHAIN_ELT(note_sub, lds->note, note)    
96 }
97
98 void lds_event_add_citation(Gom_ctxt ctxt, struct source_citation* cit)
99 {
100   struct lds_event *lds = SAFE_CTXT_CAST(lds_event, ctxt);
101   LINK_CHAIN_ELT(source_citation, lds->citation, cit)    
102 }
103
104 void lds_event_add_user_data(Gom_ctxt ctxt, struct user_data* data)
105 {
106   struct lds_event *obj = SAFE_CTXT_CAST(lds_event, ctxt);
107   LINK_CHAIN_ELT(user_data, obj->extra, data)
108 }
109
110 void lds_event_cleanup(struct lds_event* lds)
111 {
112   if (lds) {
113     SAFE_FREE(lds->date_status);
114     SAFE_FREE(lds->date);
115     SAFE_FREE(lds->temple_code);
116     SAFE_FREE(lds->place_living_ordinance);
117     DESTROY_CHAIN_ELTS(source_citation, lds->citation, citation_cleanup)  
118     DESTROY_CHAIN_ELTS(note_sub, lds->note, note_sub_cleanup)
119     DESTROY_CHAIN_ELTS(user_data, lds->extra, user_data_cleanup)
120   }
121 }