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 struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
48 char *str = GEDCOM_STRING(parsed_value);
50 obj->data = concat_strings (WITHOUT_NL, obj->data, str);
52 obj->data = strdup(str);
53 return (Gedcom_ctxt) make_gom_ctxt(elt, ctxt->obj_type, ctxt->ctxt_ptr);
56 void multimedia_subscribe()
58 gedcom_subscribe_to_record(REC_OBJE, obje_start, def_rec_end);
59 gedcom_subscribe_to_element(ELT_OBJE_FORM, obje_form_start, def_elt_end);
60 gedcom_subscribe_to_element(ELT_OBJE_TITL, obje_titl_start, def_elt_end);
61 gedcom_subscribe_to_element(ELT_OBJE_BLOB, obje_blob_start, def_elt_end);
62 gedcom_subscribe_to_element(ELT_OBJE_BLOB_CONT, obje_blob_cont_start,
64 gedcom_subscribe_to_element(ELT_OBJE_OBJE, obje_obje_start, def_elt_end);
67 void multimedia_add_note(Gom_ctxt ctxt, struct note_sub* note)
69 struct multimedia* obj = SAFE_CTXT_CAST(multimedia, ctxt);
70 LINK_CHAIN_ELT(note_sub, obj->note, note)
73 void multimedia_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref)
75 struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
76 LINK_CHAIN_ELT(user_ref_number, obj->ref, ref)
79 void multimedia_set_record_id(Gom_ctxt ctxt, char *rin)
81 struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
82 obj->record_id = strdup(rin);
85 void multimedia_set_change_date(Gom_ctxt ctxt, struct change_date* chan)
87 struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
88 obj->change_date = chan;
91 void multimedia_add_user_data(Gom_ctxt ctxt, struct user_data* data)
93 struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
94 LINK_CHAIN_ELT(user_data, obj->extra, data)
97 void multimedia_cleanup(struct multimedia* obj)
99 SAFE_FREE(obj->xrefstr);
100 SAFE_FREE(obj->form);
101 SAFE_FREE(obj->title);
102 DESTROY_CHAIN_ELTS(note_sub, obj->note, note_sub_cleanup)
103 SAFE_FREE(obj->data);
104 DESTROY_CHAIN_ELTS(user_ref_number, obj->ref, user_ref_cleanup)
105 SAFE_FREE(obj->record_id);
106 change_date_cleanup(obj->change_date);
107 DESTROY_CHAIN_ELTS(user_data, obj->extra, user_data_cleanup)
110 void multimedias_cleanup()
112 DESTROY_CHAIN_ELTS(multimedia, gom_first_multimedia, multimedia_cleanup);
115 struct multimedia* gom_get_first_multimedia()
117 return gom_first_multimedia;
120 struct multimedia* make_multimedia_record(char* xrefstr)
122 struct multimedia* multi;
123 MAKE_CHAIN_ELT(multimedia, gom_first_multimedia, multi);
124 multi->xrefstr = strdup(xrefstr);