1 /* Multimedia link 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.
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 "multimedia_link.h"
28 #include "source_citation.h"
31 #include "individual.h"
33 #include "submitter.h"
37 #include "gom_internal.h"
39 Gedcom_ctxt sub_obje_start(_ELT_PARAMS_)
41 Gom_ctxt ctxt = (Gom_ctxt)parent;
42 Gom_ctxt result = NULL;
47 struct multimedia_link *mm = SUB_MAKEFUNC(multimedia_link)();
49 int type = ctxt_type(ctxt);
50 if (GEDCOM_IS_XREF_PTR(parsed_value))
51 mm->reference = GEDCOM_XREF_PTR(parsed_value);
55 case ELT_SUB_FAM_EVT_EVEN:
56 case ELT_SUB_INDIV_ATTR:
57 case ELT_SUB_INDIV_RESI:
58 case ELT_SUB_INDIV_BIRT:
59 case ELT_SUB_INDIV_GEN:
60 case ELT_SUB_INDIV_ADOP:
61 case ELT_SUB_INDIV_EVEN:
62 ADDFUNC2(event,multimedia_link)(ctxt, mm); break;
64 ADDFUNC2(source_citation,multimedia_link)(ctxt, mm); break;
66 ADDFUNC2(family,multimedia_link)(ctxt, mm); break;
68 ADDFUNC2(individual,multimedia_link)(ctxt, mm); break;
70 ADDFUNC2(source,multimedia_link)(ctxt, mm); break;
72 ADDFUNC2(submitter,multimedia_link)(ctxt, mm); break;
74 UNEXPECTED_CONTEXT(type);
76 result = MAKE_GOM_CTXT(elt, multimedia_link, mm);
80 return (Gedcom_ctxt)result;
83 DEFINE_SUB_MAKEFUNC(multimedia_link)
84 DEFINE_SUB_ADDFUNC(multimedia_link)
85 DEFINE_SUB_FINDFUNC(multimedia_link)
86 DEFINE_SUB_REMOVEFUNC(multimedia_link)
87 DEFINE_SUB_MOVEFUNC(multimedia_link)
89 DEFINE_STRING_CB(multimedia_link, sub_obje_form_start, form)
90 DEFINE_STRING_CB(multimedia_link, sub_obje_titl_start, title)
91 DEFINE_STRING_CB(multimedia_link, sub_obje_file_start, file)
93 DEFINE_ADDFUNC2(multimedia_link, note_sub, note)
94 DEFINE_ADDFUNC2(multimedia_link, user_data, extra)
96 void multimedia_link_subscribe()
98 gedcom_subscribe_to_element(ELT_SUB_MULTIM_OBJE,
99 sub_obje_start, def_elt_end);
100 gedcom_subscribe_to_element(ELT_SUB_MULTIM_OBJE_FORM,
101 sub_obje_form_start, def_elt_end);
102 gedcom_subscribe_to_element(ELT_SUB_MULTIM_OBJE_TITL,
103 sub_obje_titl_start, def_elt_end);
104 gedcom_subscribe_to_element(ELT_SUB_MULTIM_OBJE_FILE,
105 sub_obje_file_start, def_elt_end);
108 void UNREFALLFUNC(multimedia_link)(struct multimedia_link* obj)
111 struct multimedia_link* runner;
112 for (runner = obj; runner; runner = runner->next) {
113 unref_xref_value(runner->reference);
114 UNREFALLFUNC(note_sub)(runner->note);
115 UNREFALLFUNC(user_data)(runner->extra);
120 void CLEANFUNC(multimedia_link)(struct multimedia_link* mm)
124 SAFE_FREE(mm->title);
126 DESTROY_CHAIN_ELTS(note_sub, mm->note);
127 DESTROY_CHAIN_ELTS(user_data, mm->extra);
131 int write_multimedia_links(Gedcom_write_hndl hndl, int parent,
132 struct multimedia_link* mm)
135 struct multimedia_link* obj;
139 for (obj = mm; obj; obj = obj->next) {
140 if (obj->reference) {
141 result |= gedcom_write_element_xref(hndl, ELT_SUB_MULTIM_OBJE, 0,
142 parent, obj->reference);
145 result |= gedcom_write_element_str(hndl, ELT_SUB_MULTIM_OBJE, 0,
148 result |= gedcom_write_element_str(hndl, ELT_SUB_MULTIM_OBJE_FORM, 0,
149 ELT_SUB_MULTIM_OBJE, obj->form);
151 result |= gedcom_write_element_str(hndl, ELT_SUB_MULTIM_OBJE_TITL, 0,
152 ELT_SUB_MULTIM_OBJE, obj->title);
154 result |= gedcom_write_element_str(hndl, ELT_SUB_MULTIM_OBJE_FILE, 0,
155 ELT_SUB_MULTIM_OBJE, obj->file);
157 result |= write_note_subs(hndl, ELT_SUB_MULTIM_OBJE, obj->note);
159 result |= write_user_data(hndl, obj->extra);