Completed the calling of callbacks.
[gedcom-parse.git] / gedcom / interface.c
index 265c28f9dbf5886dd012ef8cf6423b2bbd4ed4e6..0ac773bdb689c617d90ef9318e5ce8ab8b551c39 100644 (file)
 #include "gedcom_internal.h"
 #include "interface.h"
 
-static Gedcom_rec_start_cb record_start_callback [LAST_REC] = { NULL };
-static Gedcom_rec_end_cb   record_end_callback   [LAST_REC] = { NULL };
-static Gedcom_elt_start_cb element_start_callback[LAST_ELT] = { NULL };
-static Gedcom_elt_end_cb   element_end_callback  [LAST_ELT] = { NULL };
-static Gedcom_def_cb       default_cb                       = NULL;
+static Gedcom_rec_start_cb record_start_callback [NR_OF_RECS] = { NULL };
+static Gedcom_rec_end_cb   record_end_callback   [NR_OF_RECS] = { NULL };
+static Gedcom_elt_start_cb element_start_callback[NR_OF_ELTS] = { NULL };
+static Gedcom_elt_end_cb   element_end_callback  [NR_OF_ELTS] = { NULL };
+static Gedcom_def_cb       default_cb                         = NULL;
 
 void gedcom_set_default_callback(Gedcom_def_cb func)
 {
@@ -89,3 +89,15 @@ void end_element(Gedcom_elt elt, Gedcom_ctxt parent, Gedcom_ctxt self,
     (*cb)(parent, self, parsed_value);
 }
 
+char* val_type_str[] = { N_("null value"),
+                        N_("character string"),
+                        N_("date") };
+
+void gedcom_cast_error(char* file, int line,
+                      Gedcom_val_type tried_type,
+                      Gedcom_val_type real_type)
+{
+  gedcom_warning
+    (_("Wrong cast of value in file %s, at line %d: %s instead of %s"),
+     file, line, _(val_type_str[tried_type]), _(val_type_str[real_type]));
+}