1 /* Multimedia 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 "multimedia.h"
29 #include "change_date.h"
33 #include "gom_internal.h"
35 struct multimedia* gom_first_multimedia = NULL;
37 REC_CB(multimedia, obje_start, make_multimedia_record)
38 GET_REC_BY_XREF(multimedia, XREF_OBJE, gom_get_multimedia_by_xref)
39 STRING_CB(multimedia, obje_form_start, form)
40 STRING_CB(multimedia, obje_titl_start, title)
41 NULL_CB(multimedia, obje_blob_start)
42 XREF_CB(multimedia, obje_obje_start, continued, make_multimedia_record)
44 Gedcom_ctxt obje_blob_cont_start(_ELT_PARAMS_)
46 Gom_ctxt ctxt = (Gom_ctxt)parent;
47 Gom_ctxt result = NULL;
52 struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
54 char *str = GEDCOM_STRING(parsed_value);
56 char *newvalue = concat_strings (WITHOUT_NL, obj->data, str);
65 obj->data = strdup(str);
72 result = make_gom_ctxt(elt, ctxt->obj_type, ctxt->ctxt_ptr);
75 return (Gedcom_ctxt)result;
78 void multimedia_subscribe()
80 gedcom_subscribe_to_record(REC_OBJE, obje_start, def_rec_end);
81 gedcom_subscribe_to_element(ELT_OBJE_FORM, obje_form_start, def_elt_end);
82 gedcom_subscribe_to_element(ELT_OBJE_TITL, obje_titl_start, def_elt_end);
83 gedcom_subscribe_to_element(ELT_OBJE_BLOB, obje_blob_start, def_elt_end);
84 gedcom_subscribe_to_element(ELT_OBJE_BLOB_CONT, obje_blob_cont_start,
86 gedcom_subscribe_to_element(ELT_OBJE_OBJE, obje_obje_start, def_elt_end);
89 void multimedia_add_note(Gom_ctxt ctxt, struct note_sub* note)
91 struct multimedia* obj = SAFE_CTXT_CAST(multimedia, ctxt);
93 LINK_CHAIN_ELT(note_sub, obj->note, note);
96 void multimedia_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref)
98 struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
100 LINK_CHAIN_ELT(user_ref_number, obj->ref, ref);
103 void multimedia_set_record_id(Gom_ctxt ctxt, const char *rin)
105 struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
107 obj->record_id = strdup(rin);
108 if (! obj->record_id) MEMORY_ERROR;
112 void multimedia_set_change_date(Gom_ctxt ctxt, struct change_date* chan)
114 struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
116 obj->change_date = chan;
119 void multimedia_add_user_data(Gom_ctxt ctxt, struct user_data* data)
121 struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
123 LINK_CHAIN_ELT(user_data, obj->extra, data);
126 void multimedia_cleanup(struct multimedia* obj)
129 SAFE_FREE(obj->xrefstr);
130 SAFE_FREE(obj->form);
131 SAFE_FREE(obj->title);
132 DESTROY_CHAIN_ELTS(note_sub, obj->note, note_sub_cleanup);
133 SAFE_FREE(obj->data);
134 DESTROY_CHAIN_ELTS(user_ref_number, obj->ref, user_ref_cleanup);
135 SAFE_FREE(obj->record_id);
136 change_date_cleanup(obj->change_date);
137 DESTROY_CHAIN_ELTS(user_data, obj->extra, user_data_cleanup);
141 void multimedias_cleanup()
143 DESTROY_CHAIN_ELTS(multimedia, gom_first_multimedia, multimedia_cleanup);
146 struct multimedia* gom_get_first_multimedia()
148 return gom_first_multimedia;
151 struct multimedia* make_multimedia_record(const char* xrefstr)
153 struct multimedia* multi = NULL;
154 MAKE_CHAIN_ELT(multimedia, gom_first_multimedia, multi);
156 multi->xrefstr = strdup(xrefstr);
157 if (! multi->xrefstr) MEMORY_ERROR;