1 /* External header for the Gedcom parser library.
2 Copyright (C) 2001,2002 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
34 #ifndef GEDCOM_INTERNAL
35 #include <gedcom-tags.h>
38 #define GEDCOM_PARSE_VERSION_MAJOR @VERSION_MAJOR@
39 #define GEDCOM_PARSE_VERSION_MINOR @VERSION_MINOR@
40 #define GEDCOM_PARSE_VERSION_PATCH @VERSION_PATCH@
41 #define GEDCOM_PARSE_VERSION \
42 (GEDCOM_PARSE_VERSION_MAJOR * 1000 + GEDCOM_PARSE_VERSION_MINOR)
44 int gedcom_check_version(int major, int minor, int patch);
46 /**************************************************************************/
47 /*** First the records and elements to subscribe upon ***/
48 /**************************************************************************/
61 NR_OF_RECS /* Just a final value to be used in array boundaries */
64 /** \brief Record types
68 <a href="interface.html#Record_identifiers">interface details</a>.
70 typedef enum _Gedcom_rec Gedcom_rec;
73 ELT_HEAD_SOUR = NR_OF_RECS,
78 ELT_HEAD_SOUR_DATA_DATE,
79 ELT_HEAD_SOUR_DATA_COPR,
122 ELT_SOUR_DATA_EVEN_DATE,
123 ELT_SOUR_DATA_EVEN_PLAC,
176 ELT_SUB_FAM_EVT_HUSB,
177 ELT_SUB_FAM_EVT_WIFE,
179 ELT_SUB_FAM_EVT_EVEN,
182 ELT_SUB_IDENT_REFN_TYPE,
188 ELT_SUB_INDIV_BIRT_FAMC,
191 ELT_SUB_INDIV_ADOP_FAMC,
192 ELT_SUB_INDIV_ADOP_FAMC_ADOP,
196 ELT_SUB_LIO_BAPL_STAT,
197 ELT_SUB_LIO_BAPL_DATE,
198 ELT_SUB_LIO_BAPL_TEMP,
199 ELT_SUB_LIO_BAPL_PLAC,
201 ELT_SUB_LIO_SLGC_FAMC,
204 ELT_SUB_LSS_SLGS_STAT,
205 ELT_SUB_LSS_SLGS_DATE,
206 ELT_SUB_LSS_SLGS_TEMP,
207 ELT_SUB_LSS_SLGS_PLAC,
210 ELT_SUB_MULTIM_OBJE_FORM,
211 ELT_SUB_MULTIM_OBJE_TITL,
212 ELT_SUB_MULTIM_OBJE_FILE,
217 ELT_SUB_PERS_NAME_NPFX,
218 ELT_SUB_PERS_NAME_GIVN,
219 ELT_SUB_PERS_NAME_NICK,
220 ELT_SUB_PERS_NAME_SPFX,
221 ELT_SUB_PERS_NAME_SURN,
222 ELT_SUB_PERS_NAME_NSFX,
230 ELT_SUB_SOUR_EVEN_ROLE,
232 ELT_SUB_SOUR_DATA_DATE,
238 ELT_SUB_REPO_CALN_MEDI,
244 NR_OF_ELTS /* Just a final value to be used in array boundaries */
247 /** \brief Element types
251 <a href="interface.html#Element_identifiers">interface details</a>.
253 typedef enum _Gedcom_elt Gedcom_elt;
255 /**************************************************************************/
256 /*** Definition of some auxiliary types ***/
257 /**************************************************************************/
259 /** \addtogroup error */
261 /** \brief Error handling mechanisms.
263 These are the possible error handling mechanisms.
264 \sa gedcom_set_error_handling
266 enum _Gedcom_err_mech {
267 IMMED_FAIL, /**< immediately fail the parsing on an error (this is
269 DEFER_FAIL, /**< continue parsing after an error, but return a failure
271 IGNORE_ERRORS /**< continue parsing after an error, return success always */
274 /** \brief Error handling mechanisms. */
275 typedef enum _Gedcom_err_mech Gedcom_err_mech;
277 /** \brief Message type in message handler callbacks
279 This will be passed to the message callback to indicate the message type.
280 \sa gedcom_set_message_handler
282 enum _Gedcom_msg_type {
283 ERROR, /**< An error message */
284 WARNING, /**< A warning message */
285 MESSAGE /**< Just a message */
288 /** \brief Message type in message handler callbacks */
289 typedef enum _Gedcom_msg_type Gedcom_msg_type;
292 /* All Unicode characters between U+0000 and U+FFFF can be encoded in
293 UTF-8 with 3 or less bytes */
296 #define MAX_DAY_LEN 2
297 #define MAX_MONTH_LEN 4
298 #define MAX_YEAR_LEN 7
299 #define MAX_PHRASE_LEN 35 * UTF_FACTOR
301 /** \addtogroup parsed_date */
305 This determines which one of the serial day numbers (Julian days) are
306 relevant in the struct date.
309 DATE_UNRECOGNIZED, /**< Neither date#sdn1 as date#sdn2 are significant */
310 DATE_EXACT, /**< Only date#sdn1 is significant */
311 DATE_BOUNDED /**< Both date#sdn1 and date#sdn2 are significant */
314 /** \brief Date type */
315 typedef enum _Date_type Date_type;
317 /** \brief Calendar type
319 This determines the calendary type (see calendar overview LINK TBD).
321 enum _Calendar_type {
322 CAL_GREGORIAN, /**< The Gregorian calendar */
323 CAL_JULIAN, /**< The Julian calendar */
324 CAL_HEBREW, /**< The Hebrew (Jewish) calendar */
325 CAL_FRENCH_REV, /**< The calendar used after the French Revolution */
326 CAL_UNKNOWN /**< An unknown calendar type */
329 /** \brief Calendar type */
330 typedef enum _Calendar_type Calendar_type;
334 This determines whether the year has one value (e.g. 1677) or two values
335 (e.g. 1677/78, the first value is in annunciation style, the second in
339 YEAR_SINGLE, /**< There is only one value for the year */
340 YEAR_DOUBLE /**< The date#year_str contains two values. Note that the
342 will then contain the circumcision style year, i.e. the
346 /** \brief Year type */
347 typedef enum _Year_type Year_type;
349 /** \brief Date value type
351 This determines which members in the struct date_value are relevant, as
352 given in the description below.
354 enum _Date_value_type {
356 DV_NO_MODIFIER, /**< Just a simple date: date1 */
358 DV_BEFORE, /**< A range (BEFORE date1) */
359 DV_AFTER, /**< A range (AFTER date1) */
360 DV_BETWEEN, /**< A range (BETWEEN date1 AND date2) */
362 DV_FROM, /**< A period (FROM date1) */
363 DV_TO, /**< A period (TO date1) */
364 DV_FROM_TO, /**< A period (FROM date1 TO date2) */
366 DV_ABOUT, /**< An approximation (ABOUT date1) */
367 DV_CALCULATED, /**< An approximation (CALCULATED date1) */
368 DV_ESTIMATED, /**< An approximation (ESTIMATED date1) */
370 DV_INTERPRETED, /**< INTERPRETED date1 FROM phrase */
371 DV_PHRASE /**< phrase */
374 /** \brief Date value type */
375 typedef enum _Date_value_type Date_value_type;
377 /** \brief Date input type for gedcom_normalize_date
379 See explanation for gedcom_normalize_date().
383 /**< compute from date#day_str, date#month_str and date#year_str */
385 /**< compute from date#day, date#month, date#year and date#year_type */
387 /**< compute from date#type, date#sdn1 and date#sdn2 */
390 /** \brief Date input type for gedcom_normalize_date */
391 typedef enum _Date_input Date_input;
393 /** \brief Parsed date
395 This struct describes exactly one date. It contains the string
396 representation, the numeric representation and the representation using
397 serial day numbers (aka Julian days).
399 It is possible that the #year_str is given as e.g. "1677/78". This is
400 coming from a date in a so called "annunciation style", where the year
401 began on 25 March: "20 March 1677/78" is 20 March 1677 in "annunciation
402 style" and 20 March 1678 in "circumcision style" (the current style).
403 See calendar overview (LINK TBD).
405 In this case, the #year will contain the "circumcision style" year (1678
406 in the example), and #year_type will be YEAR_DOUBLE. Normal dates will
407 have a #year_type equal to YEAR_SINGLE.
409 Finally, the last three fields (#type, #sdn1 and #sdn2) are probably
410 the most interesting values
411 for applications that want to process dates. Basically, the date is
412 converted to a serial day number (aka Julian day), which is the unique
413 day number since November 25, 4714 BC in the Gregorian calendar. The
414 advantage of these day numbers is that they are unique and independent
415 of the calendar system. Furthermore, date differences can just be
416 computed by subtracting the serial day numbers.
418 However, since dates in GEDCOM are not necessarily exact (e.g. "MAR
419 1990"), it is not possible to represent all GEDCOM dates with 1 serial
420 day number. Two cases can be distinguished:
422 - <b>Exact dates</b> (e.g. "25 MAR 1990"):\n\n
423 These are represented by a serial day number in #sdn1 and a
424 #type equal to DATE_EXACT.
426 - <b>Incomplete dates</b> (e.g. "MAR 1990"):\n\n
427 These are represented by 2 serial day numbers (#sdn1 and #sdn2)
428 and a #type equal to DATE_BOUNDED.\n\n
429 For example, the Gregorian date "MAR 1990" is represented by the
430 serial day numbers for "1 MAR 1990" and "31 MAR 1990", and the
431 Gregorian date "1990" is represented by the serial day numbers
432 for "1 JAN 1990" and "31 DEC 1990". Similarly for the other
436 Calendar_type cal; /**< The calendar type */
437 char day_str[MAX_DAY_LEN + 1];
438 /**< The literal string part of the date, as parsed from
439 the value in the GEDCOM file, that denotes
440 the day (can be an empty string) */
441 char month_str[MAX_MONTH_LEN + 1];
442 /**< The literal string part of the date, as parsed from
443 the value in the GEDCOM file, that denotes the month
444 (can be an empty string) */
445 char year_str[MAX_YEAR_LEN + 1];
446 /**< The literal string part of the date, as parsed from
447 the value in the GEDCOM file, that denotes the year
449 int day; /**< The numeric representation of the #day_str (starting from
450 1), or -1 if the #day_str is empty */
451 int month; /**< The month number of #month_str in the given calendar type
452 #cal (starting from 1), or -1 if the #month_str is empty */
453 int year; /**< The numeric representation of the #year_str */
455 /**< The year type (see detailed description of \ref date)*/
457 /**< The date type (see detailed description of \ref date) */
458 long int sdn1; /**< The first serial day number */
459 long int sdn2; /**< The second serial day number */
462 /** \brief Date value
464 The main struct describing a date value. It depends on the first member,
465 the type, which members are actually relevant.
468 Date_value_type type; /**< The type of date, which determines which of the
469 following members are relevant */
470 struct date date1; /**< First parsed date */
471 struct date date2; /**< Second parsed date */
472 char phrase[MAX_PHRASE_LEN + 1]; /**< Free-format date phrase */
477 /** \brief Type for context handling, meant to be opaque
480 typedef void* Gedcom_ctxt;
482 /** \addtogroup parsed_xref */
485 /** \brief Cross-reference type
487 This determines what kind of object the cross-reference points to.
490 XREF_NONE, /**< Used as a default value */
491 XREF_FAM, /**< Points to a family */
492 XREF_INDI, /**< Points to an individual */
493 XREF_NOTE, /**< Points to a note */
494 XREF_OBJE, /**< Points to a multimedia object */
495 XREF_REPO, /**< Points to a source repository */
496 XREF_SOUR, /**< Points to a source */
497 XREF_SUBM, /**< Points to a submitter */
498 XREF_SUBN, /**< Points to a submission record */
499 XREF_USER, /**< For application-specific cross-references */
500 XREF_ANY /**< If the type is not known: it has to come from further
501 information. This is the case in an association
502 (\c ELT_SUB_ASSO): the type is then given by the \c TYPE
507 /** \brief Cross-reference type */
508 typedef enum _Xref_type Xref_type;
510 /** \brief Cross-reference value
512 The struct describing a cross-reference value.
515 Xref_type type; /**< Determines what the cross-reference points to */
516 char *string; /**< The actual cross-reference string from the GEDCOM
519 /**< The referenced object. This is initially \c NULL, but
520 can be filled by the application with an object (of any
521 type) that corresponds with the cross-reference, and then
522 later extracted when the cross-reference is used or
523 defined again in the file. This relieves the application
524 from the burden of maintaining the mapping between
525 cross-references and objects. */
529 /** \addtogroup parsed_age */
532 /** \brief Age value type
534 This determines which members in the struct age_value are relevant, as
535 given in the description below.
538 AGE_UNRECOGNIZED, /**< Format not recognized, full raw value in phrase */
539 AGE_CHILD, /**< CHILD, with given modifier */
540 AGE_INFANT, /**< INFANT, with given modifier */
541 AGE_STILLBORN, /**< STILLBORN, with given modifier */
542 AGE_NUMERIC /**< An indication in years, months and/or days (each can
543 be -1 if not given), with given modifier */
546 /** \brief Age value type */
547 typedef enum _Age_type Age_type;
549 /** \brief Age modifier
551 This gives a modifier on the given date (less than or greater than).
554 AGE_NO_MODIFIER, /**< No modifier */
555 AGE_LESS_THAN, /**< The modifier '<' is added */
556 AGE_GREATER_THAN /**< The modifier '>' is added */
559 /** \brief Age modifier */
560 typedef enum _Age_modifier Age_modifier;
564 The struct describing an age value. It depends on the first member,
565 the type, which members are actually relevant.
568 Age_type type; /**< The type of age, which determines which of the
569 following members are relevant */
570 Age_modifier mod; /**< A modifier (less than or greater than) */
571 int years; /**< The number of years */
572 int months; /**< The number of months */
573 int days; /**< The number of days */
574 char phrase[MAX_PHRASE_LEN + 1]; /**< Free-format age phrase */
578 /** \addtogroup write */
581 /** \brief The encoding width and endianness
582 \sa gedcom_write_set_encoding */
584 ONE_BYTE = 0x00, /**< This should be used for all character sets except
586 TWO_BYTE_HILO = 0x01, /**< High-low encoding for UNICODE (i.e. big-endian) */
587 TWO_BYTE_LOHI = 0x02 /**< Low-high encoding for UNICODE (i.e. little-endian)
591 /** \brief The encoding width and endianness */
592 typedef enum _Encoding Encoding;
594 /** \brief The use of a byte-order-mark in the encoding
595 \sa gedcom_write_set_encoding */
597 WITHOUT_BOM = 0x00, /**< Without byte-order-mark */
598 WITH_BOM = 0x10 /**< With byte-order-mark */
601 /** \brief The use of a byte-order-mark in the encoding */
602 typedef enum _Enc_bom Enc_bom;
604 /** \brief The line terminator in the encoding
605 \sa gedcom_write_set_line_terminator */
607 END_CR = 0, /**< Only carriage return ('\\r') (system value for Mac) */
608 END_LF = 1, /**< Only line feed ('\\n') (system value for Unix, Mac OSX)
610 END_CR_LF = 2, /**< First carriage return, then line feed ('\\r\\n')
611 (system value for DOS, Windows) */
612 END_LF_CR = 3 /**< First line feed, then carriage return ('\\n\\r') */
615 /** \brief The line terminator in the encoding */
616 typedef enum _Enc_line_end Enc_line_end;
618 /** \brief Source of the encoding settings
619 \sa gedcom_write_set_encoding and gedcom_write_set_line_terminator */
621 ENC_FROM_FILE = 0, /**< The same as the read file was in */
622 ENC_FROM_SYS = 1, /**< The system value */
623 ENC_MANUAL = 2 /**< From the parameters given in the function */
626 /** \brief Source of the encoding settings */
627 typedef enum _Enc_from Enc_from;
630 struct encoding_state;
632 /** \addtogroup compat */
634 /** \brief Compatibility mode options */
635 enum _Gedcom_compat {
636 COMPAT_ALLOW_OUT_OF_CONTEXT = 0x01
637 /**< In some compatibility cases, tags are coming out-of-order, i.e. their
638 start element callback would have to come after the end element callback
639 of the parent tag. E.g. instead of the standard GEDCOM
644 the genealogy program has generated something like:
649 This can give a problem if your end element callbacks free some
652 If your program can handle elements out of context, you can enable this
653 option. By default it is disabled, and so the values of these
654 out-of-context tags are lost (the parser generates a warning if this is
659 /** \brief Compatibility mode options */
660 typedef enum _Gedcom_compat Gedcom_compat;
663 /**************************************************************************/
664 /*** Things meant to be internal, susceptible to changes ***/
665 /*** Use the GEDCOM_STRING/GEDCOM_DATE interface instead of relying ***/
667 /**************************************************************************/
669 /* Update strings in interface.c if this changes */
670 typedef enum _GEDCOM_VAL_TYPE {
673 GV_DATE_VALUE = 0x04,
678 union _Gedcom_val_union {
680 struct date_value date_val;
681 struct age_value age_val;
682 struct xref_value *xref_val;
685 typedef struct _Gedcom_val_struct {
686 Gedcom_val_type type;
687 union _Gedcom_val_union value;
690 void gedcom_cast_error(const char* file, int line,
691 Gedcom_val_type tried_type,
692 Gedcom_val_type real_type);
694 extern struct date_value def_date_val;
695 extern struct age_value def_age_val;
696 extern struct xref_value def_xref_val;
698 #define GV_CHECK_CAST(VAL, TYPE, MEMBER, DEFVAL) \
699 (((VAL)->type == TYPE) ? \
700 (VAL)->value.MEMBER : \
701 (gedcom_cast_error(__FILE__,__LINE__, TYPE, (VAL)->type), DEFVAL))
703 #define GV_IS_TYPE(VAL, TYPE) \
704 ((VAL)->type == TYPE)
706 /**************************************************************************/
707 /*** Function interface ***/
708 /**************************************************************************/
710 /** \brief Parsed value
713 Type for the parsed value. The struct type Gedcom_val_struct should
714 be seen as internal: the Gedcom_val should be handled using the macros
717 typedef Gedcom_val_struct* Gedcom_val;
719 struct Gedcom_write_struct;
720 /** \brief Write handle
723 Handle for writing Gedcom files. The struct type Gedcom_write_struct
724 should be seen as internal: only the handle should be used.
726 typedef struct Gedcom_write_struct* Gedcom_write_hndl;
728 /* Check to determine whether there is a parsed value or not */
729 #define GEDCOM_IS_NULL(VAL) \
730 GV_IS_TYPE(VAL, GV_NULL)
732 /* This returns the char* from a Gedcom_val, if appropriate */
733 /* It gives a gedcom_warning if the cast is not correct */
734 #define GEDCOM_STRING(VAL) \
735 GV_CHECK_CAST(VAL, GV_CHAR_PTR, string_val, "<error>")
736 #define GEDCOM_IS_STRING(VAL) \
737 GV_IS_TYPE(VAL, GV_CHAR_PTR)
739 /* This returns the struct date_value from a Gedcom_val, if appropriate */
740 /* It gives a gedcom_warning if the cast is not correct */
741 #define GEDCOM_DATE(VAL) \
742 GV_CHECK_CAST(VAL, GV_DATE_VALUE, date_val, def_date_val)
743 #define GEDCOM_IS_DATE(VAL) \
744 GV_IS_TYPE(VAL, GV_DATE_VALUE)
746 /* This returns the struct age_value from a Gedcom_val, if appropriate */
747 /* It gives a gedcom_warning if the cast is not correct */
748 #define GEDCOM_AGE(VAL) \
749 GV_CHECK_CAST(VAL, GV_AGE_VALUE, age_val, def_age_val)
750 #define GEDCOM_IS_AGE(VAL) \
751 GV_IS_TYPE(VAL, GV_AGE_VALUE)
753 /* This returns the (struct xref_value *) from a Gedcom_val, if appropriate */
754 /* It gives a gedcom_warning if the cast is not correct */
755 #define GEDCOM_XREF_PTR(VAL) \
756 GV_CHECK_CAST(VAL, GV_XREF_PTR, xref_val, &def_xref_val)
757 #define GEDCOM_IS_XREF_PTR(VAL) \
758 GV_IS_TYPE(VAL, GV_XREF_PTR)
760 /** \brief Message handler callback
762 A callback for errors, warnings and messages.
763 \sa gedcom_set_message_handler
765 \param type The message type
766 \param msg For errors, this will have the format
768 Error on line <lineno>: <actual_message>
770 Note that the entire string will be properly internationalized, and
771 encoded in UTF-8 (<a href=encoding.html>Why UTF-8?</a>).
772 Also, no newline is appended, so that
773 the application program can use it in any way it wants. Warnings are
774 similar, but use "Warning" instead of "Error". Messages are plain
775 text, without any prefix.
778 (*Gedcom_msg_handler)
779 (Gedcom_msg_type type, char *msg);
781 /** \brief Record start callback
783 A callback to handle the start of records. A record entry in a GEDCOM
784 file is always of the form <tt>"<level> <xref> <tag> <value>"</tt>, e.g.
786 0 @REC003@ NOTE This is a note
788 The different parameters of the callback return different parts of this
790 \sa gedcom_subscribe_to_record
792 \param rec An enum identifying the record type (see the
793 <a href="interface.html#Record_identifiers">interface details</a>)
794 \param level The GEDCOM level (always 0 for records)
795 \param xref The cross-reference key that identifies the record ("@REC003@"
796 in the example above).
797 \param tag The GEDCOM tag, in string format ("NOTE" in the example above).
798 \param raw_value The value of the record, in string format, encoded as
799 UTF-8 ("This is a note" in the example above)
800 \param tag_value The GEDCOM tag, as symbolic value (e.g. \c TAG_NOTE in the
801 example). These values are defined in the header \c gedcom-tags.h that is
802 installed, and included via \c gedcom.h (so no need to include
803 \c gedcom-tags.h yourself).
804 \param parsed_value The value of the record, in parsed format.
806 \return A context to be used for this record (equivalent to a void
807 pointer). This context will be passed
808 in all callbacks for direct child elements, and in the end callback for the
812 (*Gedcom_rec_start_cb)
813 (Gedcom_rec rec, int level, Gedcom_val xref, char *tag,
814 char *raw_value, int tag_value, Gedcom_val parsed_value);
815 /** \brief Record end callback
817 A callback to handle the end of records, i.e. this callback is called when
818 all sub-elements of a record have been processed.
819 \sa gedcom_subscribe_to_record
821 \param rec An enum identifying the record type (see the
822 <a href="interface.html#Record_identifiers">interface details</a>)
823 \param self The context as was given via the start callback.
824 \param parsed_value The value of the record, in parsed format. Here it is
825 used to pass 'complete' values, e.g. the full text of a note including
830 (Gedcom_rec rec, Gedcom_ctxt self, Gedcom_val parsed_value);
832 /** \brief Element start callback
834 A callback to handle the start of elements. An element in a GEDCOM
835 file is part of a record, and is always of the form
836 <tt>"<level> <tag> <value>"</tt>, e.g.
840 The different parameters of the callback return different parts of this
842 \sa gedcom_subscribe_to_element
844 \param elt An enum identifying the element type (see the
845 <a href="interface.html#Element_identifiers">interface details</a>)
846 \param parent The context of the parent element or record
847 \param level The GEDCOM level (always bigger than 0 for elements)
848 \param tag The GEDCOM tag, in string format ("DATE" in the example above).
849 \param raw_value The value of the record, in string format, encoded as
850 UTF-8 ("1 JAN 1998" in the example above)
851 \param tag_value The GEDCOM tag, as symbolic value (e.g. \c TAG_DATE in the
852 example). These values are defined in the header \c gedcom-tags.h that is
853 installed, and included via \c gedcom.h (so no need to include
854 \c gedcom-tags.h yourself).
855 \param parsed_value The value of the record, in parsed format.
857 \return A context to be used for this element (equivalent to a void
858 pointer). This context will be passed
859 in all callbacks for direct child elements, and in the end callback for the
863 (*Gedcom_elt_start_cb)
864 (Gedcom_elt elt, Gedcom_ctxt parent,
865 int level, char *tag, char *raw_value,
866 int tag_value, Gedcom_val parsed_value);
867 /** \brief Element end callback
869 A callback to handle the end of element, i.e. this callback is called when
870 all sub-elements of an element have been processed.
871 \sa gedcom_subscribe_to_element
873 \param elt An enum identifying the element type (see the
874 <a href="interface.html#Element_identifiers">interface details</a>)
875 \param parent The context of the parent element or record.
876 \param self The context as was given via the start callback of the element.
877 \param parsed_value The value of the element, in parsed format. Here it is
878 used to pass 'complete' values, e.g. the full text of a note including
883 (Gedcom_elt elt, Gedcom_ctxt parent, Gedcom_ctxt self,
884 Gedcom_val parsed_value);
886 /** \brief Default callback
888 The default callback, i.e. this callback is called when no specific
889 callback has been registered.
890 \sa gedcom_set_default_callback
892 \param elt An enum identifying the element type (see the
893 <a href="interface.html#Element_identifiers">interface details</a>)
894 \param parent The context of the parent element or record.
895 \param level The GEDCOM level (always bigger than 0 for elements)
896 \param tag The GEDCOM tag, in string format.
897 \param raw_value The value of the record, in string format, encoded as
899 \param tag_value The GEDCOM tag, as symbolic value. These values are
900 defined in the header \c gedcom-tags.h that is
901 installed, and included via \c gedcom.h (so no need to include
902 \c gedcom-tags.h yourself).
906 (Gedcom_elt elt, Gedcom_ctxt parent, int level, char *tag,
907 char *raw_value, int tag_value);
909 /** \addtogroup maingedcom */
911 /** \brief Initializes the Gedcom parser library */
913 /** \brief Parses an existing Gedcom file */
914 int gedcom_parse_file(const char* file_name);
915 /** \brief Starts a new Gedcom model */
916 int gedcom_new_model();
919 /** \addtogroup error */
921 /** \brief Sets the error handler callback */
922 void gedcom_set_message_handler(Gedcom_msg_handler func);
923 /** \brief Determine what happens on an error */
924 void gedcom_set_error_handling(Gedcom_err_mech mechanism);
927 /** \addtogroup debug */
929 /** \brief Set the debugging level */
930 void gedcom_set_debug_level(int level, FILE* trace_output);
933 /** \addtogroup compat */
935 /** \brief Enable or disable compatibility mode */
936 void gedcom_set_compat_handling(int enable_compat);
937 /** \brief Set some options for the compatibility mode */
938 void gedcom_set_compat_options(Gedcom_compat options);
941 /** \addtogroup defcb */
943 /** \brief Set the default callback */
944 void gedcom_set_default_callback(Gedcom_def_cb func);
947 /** \addtogroup start_end */
949 /** \brief Subscribe to records, with given start and end callback */
950 void gedcom_subscribe_to_record(Gedcom_rec rec,
951 Gedcom_rec_start_cb cb_start,
952 Gedcom_rec_end_cb cb_end);
953 /** \brief Subscribe to elements, with given start and end callback */
954 void gedcom_subscribe_to_element(Gedcom_elt elt,
955 Gedcom_elt_start_cb cb_start,
956 Gedcom_elt_end_cb cb_end);
959 /* Separate value parsing functions */
960 /** \addtogroup parsed_date */
962 /** \brief Parse the given string into a date value */
963 struct date_value gedcom_parse_date(const char* line_value);
964 /** \brief Convert the given date value into a string */
965 char* gedcom_date_to_string(const struct date_value* val);
966 /** \brief Create a new date value */
967 struct date_value* gedcom_new_date_value(const struct date_value* copy_from);
968 /** \brief Normalize the given date value */
969 int gedcom_normalize_date(Date_input compute_from, struct date_value *val);
972 /** \addtogroup parsed_age */
974 /** \brief Parse the given string into an age value */
975 struct age_value gedcom_parse_age(const char* line_value);
976 /** \brief Convert the given age value into a string */
977 char* gedcom_age_to_string(const struct age_value* val);
978 /** \brief Create a new age value */
979 struct age_value* gedcom_new_age_value(const struct age_value* copy_from);
982 /** \addtogroup parsed_xref */
984 /** \brief Retrieve an xref_value using the cross-reference key */
985 struct xref_value *gedcom_get_by_xref(const char *key);
986 /** \brief Add a cross-reference */
987 struct xref_value *gedcom_add_xref(Xref_type type, const char* xrefstr,
989 /** \brief Link via a cross-reference */
990 struct xref_value *gedcom_link_xref(Xref_type type, const char* xrefstr);
991 /** \brief Remove a link via a cross-reference */
992 struct xref_value *gedcom_unlink_xref(Xref_type type, const char* xrefstr);
993 /** \brief Delete a cross-reference */
994 int gedcom_delete_xref(const char* xrefstr);
997 /** \addtogroup write */
999 /** \brief Open a file for writing GEDCOM */
1000 Gedcom_write_hndl gedcom_write_open(const char* filename);
1001 /** \brief Close the file */
1002 int gedcom_write_close(Gedcom_write_hndl hndl, int *total_conv_fails);
1003 /** \brief Set the encoding for writing GEDCOM files */
1004 int gedcom_write_set_encoding(Enc_from from,
1005 const char* charset, Encoding width,
1007 /** \brief Set the line terminator for writing GEDCOM files */
1008 int gedcom_write_set_line_terminator(Enc_from from, Enc_line_end end);
1010 /** \brief Write a record line */
1011 int gedcom_write_record_str(Gedcom_write_hndl hndl,
1012 Gedcom_rec rec, const char* xrefstr,
1015 /** \brief Write an element line, with string value */
1016 int gedcom_write_element_str(Gedcom_write_hndl hndl, Gedcom_elt elt,
1017 int parsed_tag, int parent_rec_or_elt,
1019 /** \brief Write an element line, with cross-reference value */
1020 int gedcom_write_element_xref(Gedcom_write_hndl hndl, Gedcom_elt elt,
1021 int parsed_tag, int parent_rec_or_elt,
1022 const struct xref_value* val);
1024 /** \brief Write an element line, with date value */
1025 int gedcom_write_element_date(Gedcom_write_hndl hndl,
1026 Gedcom_elt elt, int tag, int parent_rec_or_elt,
1027 const struct date_value* val);
1028 /** \brief Write an element line, with age value */
1029 int gedcom_write_element_age(Gedcom_write_hndl hndl,
1030 Gedcom_elt elt, int tag, int parent_rec_or_elt,
1031 const struct age_value* val);
1033 /** \brief Write an user defined element line, with string value */
1034 int gedcom_write_user_str(Gedcom_write_hndl hndl, int level, const char* tag,
1035 const char* xrefstr, const char* value);
1036 /** \brief Write an user defined element line, with cross-reference value */
1037 int gedcom_write_user_xref(Gedcom_write_hndl hndl, int level, const char* tag,
1038 const char* xrefstr, const struct xref_value* val);
1041 /* For use in gom */
1042 int gedcom_error(const char* s, ...);
1043 int gedcom_warning(const char* s, ...);
1044 int gedcom_message(const char* s, ...);
1045 int gedcom_debug_print(const char* s, ...);
1051 #endif /* __GEDCOM_H */