+typedef enum _DATE_TYPE {
+ DATE_UNRECOGNIZED, /* Neither jday1 as jday2 are significant */
+ DATE_EXACT, /* Only jday1 is significant */
+ DATE_BOUNDED /* Both jday1 and jday2 are significant */
+} Date_type;
+
+typedef enum _CALENDAR_TYPE {
+ CAL_GREGORIAN,
+ CAL_JULIAN,
+ CAL_HEBREW,
+ CAL_FRENCH_REV,
+ CAL_UNKNOWN
+} Calendar_type;
+
+typedef enum _YEAR_TYPE {
+ YEAR_SINGLE,
+ YEAR_DOUBLE /* In this case, the 'year' indicates the last value */
+} Year_type;
+
+typedef enum _DATE_VAL_MOD {
+ /* Simple date */
+ DV_NO_MODIFIER,
+ /* Range values */
+ DV_BEFORE,
+ DV_AFTER,
+ DV_BETWEEN, /* Two dates are given */
+ /* Period values */
+ DV_FROM,
+ DV_TO,
+ DV_FROM_TO, /* Two dates are given */
+ /* Approx values */
+ DV_ABOUT,
+ DV_CALCULATED,
+ DV_ESTIMATED,
+ /* Other */
+ DV_INTERPRETED, /* One date and a phrase is given */
+ DV_PHRASE /* Only phrase is given */
+} Date_value_type;
+
+#define MAX_DAY_LEN 2
+#define MAX_MONTH_LEN 4
+#define MAX_YEAR_LEN 7
+#define MAX_PHRASE_LEN 35
+
+struct date {
+ Calendar_type cal;
+ char day_str[MAX_DAY_LEN + 1];
+ char month_str[MAX_MONTH_LEN + 1];
+ char year_str[MAX_YEAR_LEN + 1];
+ int day; /* starts at 1 */
+ int month; /* starts at 1 */
+ int year; /* the highest value for double years */
+ Year_type year_type;
+ Date_type type;
+ long int sdn1;
+ long int sdn2;
+};
+
+struct date_value {
+ Date_value_type type;
+ struct date date1;
+ struct date date2;
+ char phrase[MAX_PHRASE_LEN + 1];
+};
+
+/**************************************************************************/
+/*** Things meant to be internal, susceptible to changes ***/
+/*** Use the GEDCOM_STRING/GEDCOM_DATE interface instead of relying ***/
+/*** on this !! ***/
+/**************************************************************************/
+
+typedef enum _GEDCOM_VAL_TYPE {
+ GV_NULL,
+ GV_CHAR_PTR,
+ GV_DATE_VALUE
+} Gedcom_val_type;
+
+union _Gedcom_val_union {
+ char* string_val;
+ struct date_value date_val;
+};
+
+typedef struct _Gedcom_val_struct {
+ Gedcom_val_type type;
+ union _Gedcom_val_union value;
+} Gedcom_val_struct;
+
+void gedcom_cast_error(char* file, int line,
+ Gedcom_val_type tried_type,
+ Gedcom_val_type real_type);
+extern struct date_value def_date_val;
+
+#define GV_CHECK_CAST(VAL, TYPE, MEMBER, DEFVAL) \
+ ((VAL->type == TYPE) ? \
+ VAL->value.MEMBER : \
+ (gedcom_cast_error(__FILE__,__LINE__, TYPE, VAL->type), DEFVAL))
+
+#define GV_IS_TYPE(VAL, TYPE) \
+ (VAL->type == TYPE)
+
+/**************************************************************************/
+/*** Function interface ***/
+/**************************************************************************/
+
+/* Type for context handling, meant to be opaque */