1 /* External header for the Gedcom parser library.
2 Copyright (C) 2001 The Genes Development Team
3 This file is part of the Gedcom parser library.
4 Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2001.
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
31 /**************************************************************************/
32 /*** First the records and elements to subscribe upon ***/
33 /**************************************************************************/
46 NR_OF_RECS /* Just a final value to be used in array boundaries */
55 ELT_HEAD_SOUR_DATA_DATE,
56 ELT_HEAD_SOUR_DATA_COPR,
99 ELT_SOUR_DATA_EVEN_DATE,
100 ELT_SOUR_DATA_EVEN_PLAC,
134 NR_OF_ELTS /* Just a final value to be used in array boundaries */
137 /**************************************************************************/
138 /*** Definition of some auxiliary types ***/
139 /**************************************************************************/
153 typedef enum _DATE_TYPE {
154 DATE_UNRECOGNIZED, /* Neither jday1 as jday2 are significant */
155 DATE_EXACT, /* Only jday1 is significant */
156 DATE_BOUNDED /* Both jday1 and jday2 are significant */
159 typedef enum _CALENDAR_TYPE {
167 typedef enum _YEAR_TYPE {
169 YEAR_DOUBLE /* In this case, the 'year' indicates the last value */
172 typedef enum _DATE_VAL_MOD {
178 DV_BETWEEN, /* Two dates are given */
182 DV_FROM_TO, /* Two dates are given */
188 DV_INTERPRETED, /* One date and a phrase is given */
189 DV_PHRASE /* Only phrase is given */
192 #define MAX_DAY_LEN 2
193 #define MAX_MONTH_LEN 4
194 #define MAX_YEAR_LEN 7
195 #define MAX_PHRASE_LEN 35
199 char day_str[MAX_DAY_LEN + 1];
200 char month_str[MAX_MONTH_LEN + 1];
201 char year_str[MAX_YEAR_LEN + 1];
202 int day; /* starts at 1 */
203 int month; /* starts at 1 */
204 int year; /* the highest value for double years */
212 Date_value_type type;
215 char phrase[MAX_PHRASE_LEN + 1];
218 /**************************************************************************/
219 /*** Things meant to be internal, susceptible to changes ***/
220 /*** Use the GEDCOM_STRING/GEDCOM_DATE interface instead of relying ***/
222 /**************************************************************************/
224 typedef enum _GEDCOM_VAL_TYPE {
229 union _Gedcom_val_union {
231 struct date_value date_val;
234 typedef struct _Gedcom_val_struct {
235 Gedcom_val_type type;
236 union _Gedcom_val_union value;
239 void gedcom_cast_error(char* file, int line);
240 extern struct date_value def_date_val;
242 #define GV_CHECK_CAST(VAL, TYPE, MEMBER, DEFVAL) \
243 ((VAL->type == TYPE) ? \
244 VAL->value.MEMBER : \
245 (gedcom_cast_error(__FILE__,__LINE__), DEFVAL))
247 /**************************************************************************/
248 /*** Function interface ***/
249 /**************************************************************************/
251 /* Type for context handling, meant to be opaque */
252 typedef void* Gedcom_ctxt;
254 /* Type for parsed values, meant to be opaque */
255 typedef Gedcom_val_struct* Gedcom_val;
257 /* This returns the char* from a Gedcom_val, if appropriate */
258 /* It gives a gedcom_warning if the cast is not correct */
259 #define GEDCOM_STRING(VAL) \
260 GV_CHECK_CAST(VAL, GV_CHAR_PTR, string_val, "")
262 /* This returns the struct date_value from a Gedcom_val, if appropriate */
263 /* It gives a gedcom_warning if the cast is not correct */
264 #define GEDCOM_DATE(VAL) \
265 GV_CHECK_CAST(VAL, GV_DATE_VALUE, date_val, def_date_val)
268 (*Gedcom_msg_handler)
269 (Gedcom_msg_type type, char *msg);
272 (*Gedcom_rec_start_cb)
273 (int level, char *xref, char *tag);
279 (*Gedcom_elt_start_cb)
281 int level, char *tag, char *raw_value, Gedcom_val parsed_value);
284 (Gedcom_ctxt parent, Gedcom_ctxt self, Gedcom_val parsed_value);
288 (Gedcom_ctxt parent, int level, char *tag, char *raw_value);
290 int gedcom_parse_file(char* file_name);
291 void gedcom_set_debug_level(int level, FILE* trace_output);
292 void gedcom_set_error_handling(Gedcom_err_mech mechanism);
293 void gedcom_set_compat_handling(int enable_compat);
294 void gedcom_set_message_handler(Gedcom_msg_handler func);
295 void gedcom_set_default_callback(Gedcom_def_cb func);
297 void gedcom_subscribe_to_record(Gedcom_rec rec,
298 Gedcom_rec_start_cb cb_start,
299 Gedcom_rec_end_cb cb_end);
300 void gedcom_subscribe_to_element(Gedcom_elt elt,
301 Gedcom_elt_start_cb cb_start,
302 Gedcom_elt_end_cb cb_end);
304 /* Separate value parsing functions */
305 struct date_value gedcom_parse_date(char* line_value);
309 #endif /* __GEDCOM_H */