+ (*cb)(elt, parent, self, parsed_value);
+}
+
+const char* val_type_str[] = { N_("null value"),
+ N_("character string"),
+ N_("date"),
+ N_("age"),
+ N_("cross-reference") };
+
+void gedcom_cast_error(const char* file, int line,
+ Gedcom_val_type tried_type,
+ Gedcom_val_type real_type)
+{
+ int tried_bit=0, real_bit=0;
+ while (tried_type && tried_type % 2 == 0) {
+ tried_bit++;
+ tried_type >>= 1;
+ }
+ while (real_type && real_type % 2 == 0) {
+ real_bit++;
+ real_type >>= 1;
+ }
+ gedcom_warning
+ (_("Wrong cast of value in file %s, at line %d: %s instead of %s"),
+ file, line, _(val_type_str[tried_bit]), _(val_type_str[real_bit]));
+}
+
+/** This function allows to customize what happens on an error. It doesn't
+ influence the generation of error or warning messages, only the behaviour
+ of the parser and its return code.
+ \param mechanism The mechanism to be used; see \ref Gedcom_err_mech
+ for the possible mechanisms.
+ */
+void gedcom_set_error_handling(Gedcom_err_mech mechanism)
+{
+ error_mechanism = mechanism;
+}
+
+/** This function allows to change the debug level.
+
+ \param level The debug level, one of the following values:
+ - 0: no debugging information (this is the default)
+ - 1: only debugging information from libgedcom itself
+ - 2: debugging information from libgedcom and yacc
+
+ \param f A file handle (which must be open) to write debugging information
+ to; if \c NULL is passed, \c stderr will be used.
+*/
+void gedcom_set_debug_level(int level, FILE* f)
+{
+ if (f != NULL)
+ trace_output = f;
+ else
+ trace_output = stderr;
+ if (level > 0) {
+ gedcom_high_level_debug = 1;
+ }
+ if (level > 1) {
+ gedcom_enable_internal_debug();
+ }