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 void obje_blob_end(_ELT_END_PARAMS_)
46 Gom_ctxt ctxt = (Gom_ctxt)self;
51 struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
53 char *str = GEDCOM_STRING(parsed_value);
54 char *newvalue = strdup(str);
63 Gedcom_ctxt obje_blob_cont_start(_ELT_PARAMS_)
65 Gom_ctxt ctxt = (Gom_ctxt)parent;
66 Gom_ctxt result = NULL;
71 result = make_gom_ctxt(elt, ctxt->obj_type, ctxt->ctxt_ptr);
73 return (Gedcom_ctxt)result;
76 void multimedia_subscribe()
78 gedcom_subscribe_to_record(REC_OBJE, obje_start, def_rec_end);
79 gedcom_subscribe_to_element(ELT_OBJE_FORM, obje_form_start, def_elt_end);
80 gedcom_subscribe_to_element(ELT_OBJE_TITL, obje_titl_start, def_elt_end);
81 gedcom_subscribe_to_element(ELT_OBJE_BLOB, obje_blob_start, obje_blob_end);
82 gedcom_subscribe_to_element(ELT_OBJE_BLOB_CONT, obje_blob_cont_start,
84 gedcom_subscribe_to_element(ELT_OBJE_OBJE, obje_obje_start, def_elt_end);
87 void multimedia_add_note(Gom_ctxt ctxt, struct note_sub* note)
89 struct multimedia* obj = SAFE_CTXT_CAST(multimedia, ctxt);
91 LINK_CHAIN_ELT(note_sub, obj->note, note);
94 void multimedia_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref)
96 struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
98 LINK_CHAIN_ELT(user_ref_number, obj->ref, ref);
101 void multimedia_set_record_id(Gom_ctxt ctxt, const char *rin)
103 struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
105 obj->record_id = strdup(rin);
106 if (! obj->record_id) MEMORY_ERROR;
110 void multimedia_set_change_date(Gom_ctxt ctxt, struct change_date* chan)
112 struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
114 obj->change_date = chan;
117 void multimedia_add_user_data(Gom_ctxt ctxt, struct user_data* data)
119 struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
121 LINK_CHAIN_ELT(user_data, obj->extra, data);
124 void multimedia_cleanup(struct multimedia* obj)
127 SAFE_FREE(obj->xrefstr);
128 SAFE_FREE(obj->form);
129 SAFE_FREE(obj->title);
130 DESTROY_CHAIN_ELTS(note_sub, obj->note, note_sub_cleanup);
131 SAFE_FREE(obj->data);
132 DESTROY_CHAIN_ELTS(user_ref_number, obj->ref, user_ref_cleanup);
133 SAFE_FREE(obj->record_id);
134 change_date_cleanup(obj->change_date);
135 DESTROY_CHAIN_ELTS(user_data, obj->extra, user_data_cleanup);
139 void multimedias_cleanup()
141 DESTROY_CHAIN_ELTS(multimedia, gom_first_multimedia, multimedia_cleanup);
144 struct multimedia* gom_get_first_multimedia()
146 return gom_first_multimedia;
149 struct multimedia* make_multimedia_record(const char* xrefstr)
151 struct multimedia* multi = NULL;
152 MAKE_CHAIN_ELT(multimedia, gom_first_multimedia, multi);
154 multi->xrefstr = strdup(xrefstr);
155 if (! multi->xrefstr) MEMORY_ERROR;