1 /* Header 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
25 #include "submission.h"
26 #include "submitter.h"
31 #include "gom_internal.h"
33 struct header gom_header;
35 Gedcom_ctxt head_start(_REC_PARAMS_)
38 return (Gedcom_ctxt) MAKE_GOM_CTXT(rec, header, &gom_header);
41 STRING_CB(header, head_sour_start, source.id)
42 STRING_CB(header, head_sour_name_start, source.name)
43 STRING_CB(header, head_sour_vers_start, source.version)
44 STRING_CB(header, head_sour_corp_start, source.corporation.name)
45 STRING_CB(header, head_sour_data_start, source.data.name)
46 DATE_CB(header, head_sour_data_date_start, source.data.date)
47 STRING_CB(header, head_sour_data_copr_start, source.data.copyright)
48 STRING_CB(header, head_dest_start, destination)
49 XREF_CB(header, head_subm_start, submitter, make_submitter_record)
50 XREF_CB(header, head_subn_start, submission, make_submission_record)
51 DATE_CB(header, head_date_start, date)
52 STRING_CB(header, head_date_time_start, time)
53 STRING_CB(header, head_file_start, filename)
54 STRING_CB(header, head_copr_start, copyright)
55 NULL_CB(header, head_gedc_start)
56 STRING_CB(header, head_gedc_vers_start, gedcom.version)
57 STRING_CB(header, head_gedc_form_start, gedcom.form)
58 STRING_CB(header, head_char_start, charset.name)
59 STRING_CB(header, head_char_vers_start, charset.version)
60 STRING_CB(header, head_lang_start, language)
61 NULL_CB(header, head_plac_start)
62 STRING_CB(header, head_plac_form_start, place_hierarchy)
63 STRING_CB(header, head_note_start, note)
65 void header_add_address(Gom_ctxt ctxt, struct address* addr)
67 struct header *head = SAFE_CTXT_CAST(header, ctxt);
69 head->source.corporation.address = addr;
72 void header_add_phone(Gom_ctxt ctxt, char* phone)
74 struct header *head = SAFE_CTXT_CAST(header, ctxt);
76 struct header_corporation *corp = &(head->source.corporation);
78 while (i<2 && corp->phone[i]) i++;
79 if (! corp->phone[i]) {
80 corp->phone[i] = strdup(phone);
81 if (! corp->phone[i]) MEMORY_ERROR;
86 void header_add_to_note(NL_TYPE type, Gom_ctxt ctxt, char* str)
88 struct header *head = SAFE_CTXT_CAST(header, ctxt);
90 char *newvalue = concat_strings(type, head->note, str);
92 head->note = newvalue;
98 void header_add_user_data(Gom_ctxt ctxt, struct user_data* data)
100 struct header *head = SAFE_CTXT_CAST(header, ctxt);
102 LINK_CHAIN_ELT(user_data, head->extra, data);
105 void header_subscribe()
107 gedcom_subscribe_to_record(REC_HEAD, head_start, def_rec_end);
108 gedcom_subscribe_to_element(ELT_HEAD_SOUR, head_sour_start, def_elt_end);
109 gedcom_subscribe_to_element(ELT_HEAD_SOUR_NAME, head_sour_name_start,
111 gedcom_subscribe_to_element(ELT_HEAD_SOUR_VERS, head_sour_vers_start,
113 gedcom_subscribe_to_element(ELT_HEAD_SOUR_CORP, head_sour_corp_start,
115 gedcom_subscribe_to_element(ELT_HEAD_SOUR_DATA, head_sour_data_start,
117 gedcom_subscribe_to_element(ELT_HEAD_SOUR_DATA_DATE,
118 head_sour_data_date_start, def_elt_end);
119 gedcom_subscribe_to_element(ELT_HEAD_SOUR_DATA_COPR,
120 head_sour_data_copr_start, def_elt_end);
121 gedcom_subscribe_to_element(ELT_HEAD_DEST, head_dest_start, def_elt_end);
122 gedcom_subscribe_to_element(ELT_HEAD_DATE, head_date_start, def_elt_end);
123 gedcom_subscribe_to_element(ELT_HEAD_DATE_TIME,
124 head_date_time_start, def_elt_end);
125 gedcom_subscribe_to_element(ELT_HEAD_SUBM, head_subm_start, def_elt_end);
126 gedcom_subscribe_to_element(ELT_HEAD_SUBN, head_subn_start, def_elt_end);
127 gedcom_subscribe_to_element(ELT_HEAD_FILE, head_file_start, def_elt_end);
128 gedcom_subscribe_to_element(ELT_HEAD_COPR, head_copr_start, def_elt_end);
129 gedcom_subscribe_to_element(ELT_HEAD_GEDC, head_gedc_start, def_elt_end);
130 gedcom_subscribe_to_element(ELT_HEAD_GEDC_VERS,
131 head_gedc_vers_start, def_elt_end);
132 gedcom_subscribe_to_element(ELT_HEAD_GEDC_FORM,
133 head_gedc_form_start, def_elt_end);
134 gedcom_subscribe_to_element(ELT_HEAD_CHAR, head_char_start, def_elt_end);
135 gedcom_subscribe_to_element(ELT_HEAD_CHAR_VERS,
136 head_char_vers_start, def_elt_end);
137 gedcom_subscribe_to_element(ELT_HEAD_LANG, head_lang_start, def_elt_end);
138 gedcom_subscribe_to_element(ELT_HEAD_PLAC, head_plac_start, def_elt_end);
139 gedcom_subscribe_to_element(ELT_HEAD_PLAC_FORM,
140 head_plac_form_start, def_elt_end);
141 gedcom_subscribe_to_element(ELT_HEAD_NOTE, head_note_start, def_elt_end);
144 void header_cleanup()
146 SAFE_FREE(gom_header.source.id);
147 SAFE_FREE(gom_header.source.name);
148 SAFE_FREE(gom_header.source.version);
149 SAFE_FREE(gom_header.source.corporation.name);
150 address_cleanup(gom_header.source.corporation.address);
151 SAFE_FREE(gom_header.source.corporation.phone[0]);
152 SAFE_FREE(gom_header.source.corporation.phone[1]);
153 SAFE_FREE(gom_header.source.corporation.phone[2]);
154 SAFE_FREE(gom_header.source.data.name);
155 SAFE_FREE(gom_header.source.data.date);
156 SAFE_FREE(gom_header.source.data.copyright);
157 SAFE_FREE(gom_header.destination);
158 SAFE_FREE(gom_header.date);
159 SAFE_FREE(gom_header.time);
160 SAFE_FREE(gom_header.filename);
161 SAFE_FREE(gom_header.copyright);
162 SAFE_FREE(gom_header.gedcom.version);
163 SAFE_FREE(gom_header.gedcom.form);
164 SAFE_FREE(gom_header.charset.name);
165 SAFE_FREE(gom_header.charset.version);
166 SAFE_FREE(gom_header.language);
167 SAFE_FREE(gom_header.place_hierarchy);
168 SAFE_FREE(gom_header.note);
169 DESTROY_CHAIN_ELTS(user_data, gom_header.extra, user_data_cleanup);
172 struct header* gom_get_header()