From: Peter Verthez Date: Sun, 25 Aug 2002 11:17:34 +0000 (+0000) Subject: Added extra argument to callback functions: the record/element identifier. X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=610f424e2c0eb060719d84ffa05d55264d7af1d3;p=gedcom-parse.git Added extra argument to callback functions: the record/element identifier. --- diff --git a/gedcom/interface.c b/gedcom/interface.c index 74d2e91..7556667 100644 --- a/gedcom/interface.c +++ b/gedcom/interface.c @@ -61,7 +61,8 @@ Gedcom_ctxt start_record(Gedcom_rec rec, { Gedcom_rec_start_cb cb = record_start_callback[rec]; if (cb != NULL) - return (*cb)(level, xref, tag.string, raw_value, tag.value, parsed_value); + return (*cb)(rec, level, xref, tag.string, raw_value, tag.value, + parsed_value); else return NULL; } @@ -70,7 +71,7 @@ void end_record(Gedcom_rec rec, Gedcom_ctxt self) { Gedcom_rec_end_cb cb = record_end_callback[rec]; if (cb != NULL) - (*cb)(self); + (*cb)(rec, self); } Gedcom_ctxt start_element(Gedcom_elt elt, Gedcom_ctxt parent, @@ -80,10 +81,10 @@ Gedcom_ctxt start_element(Gedcom_elt elt, Gedcom_ctxt parent, Gedcom_elt_start_cb cb = element_start_callback[elt]; Gedcom_ctxt ctxt = parent; if (cb != NULL) - ctxt = (*cb)(parent, level, tag.string, raw_value, + ctxt = (*cb)(elt, parent, level, tag.string, raw_value, tag.value, parsed_value); else if (default_cb != NULL && parent != NULL) - (*default_cb)(parent, level, tag.string, raw_value, tag.value); + (*default_cb)(elt, parent, level, tag.string, raw_value, tag.value); return ctxt; } @@ -92,7 +93,7 @@ void end_element(Gedcom_elt elt, Gedcom_ctxt parent, Gedcom_ctxt self, { Gedcom_elt_end_cb cb = element_end_callback[elt]; if (cb != NULL) - (*cb)(parent, self, parsed_value); + (*cb)(elt, parent, self, parsed_value); } char* val_type_str[] = { N_("null value"), diff --git a/t/standalone.c b/t/standalone.c index 008b514..68ebb18 100644 --- a/t/standalone.c +++ b/t/standalone.c @@ -83,7 +83,7 @@ void header_end(Gedcom_ctxt self) char family_xreftags[100][255]; int family_nr = 1; -Gedcom_ctxt family_start(int level, Gedcom_val xref, char *tag, +Gedcom_ctxt family_start(Gedcom_rec rec, int level, Gedcom_val xref, char *tag, char *raw_value, int tag_value, Gedcom_val parsed_value) { @@ -94,7 +94,7 @@ Gedcom_ctxt family_start(int level, Gedcom_val xref, char *tag, return (Gedcom_ctxt)(family_nr++); } -Gedcom_ctxt rec_start(int level, Gedcom_val xref, char *tag, +Gedcom_ctxt rec_start(Gedcom_rec rec, int level, Gedcom_val xref, char *tag, char *raw_value, int tag_value, Gedcom_val parsed_value) { @@ -105,7 +105,7 @@ Gedcom_ctxt rec_start(int level, Gedcom_val xref, char *tag, return (Gedcom_ctxt)tag_value; } -Gedcom_ctxt note_start(int level, Gedcom_val xref, char *tag, +Gedcom_ctxt note_start(Gedcom_rec rec, int level, Gedcom_val xref, char *tag, char *raw_value, int tag_value, Gedcom_val parsed_value) { @@ -115,12 +115,12 @@ Gedcom_ctxt note_start(int level, Gedcom_val xref, char *tag, return (Gedcom_ctxt)tag_value; } -void family_end(Gedcom_ctxt self) +void family_end(Gedcom_rec rec, Gedcom_ctxt self) { output(1, "Family end, xref is %s\n", family_xreftags[(int)self]); } -Gedcom_ctxt submit_start(int level, Gedcom_val xref, char *tag, +Gedcom_ctxt submit_start(Gedcom_rec rec, int level, Gedcom_val xref, char *tag, char *raw_value, int tag_value, Gedcom_val parsed_value) { @@ -128,8 +128,8 @@ Gedcom_ctxt submit_start(int level, Gedcom_val xref, char *tag, return (Gedcom_ctxt)10000; } -Gedcom_ctxt source_start(Gedcom_ctxt parent, int level, char *tag, - char* raw_value, +Gedcom_ctxt source_start(Gedcom_elt elt, Gedcom_ctxt parent, int level, + char *tag, char* raw_value, int tag_value, Gedcom_val parsed_value) { Gedcom_ctxt self = (Gedcom_ctxt)((int) parent + 1000); @@ -138,13 +138,14 @@ Gedcom_ctxt source_start(Gedcom_ctxt parent, int level, char *tag, return self; } -void source_end(Gedcom_ctxt parent, Gedcom_ctxt self, Gedcom_val parsed_value) +void source_end(Gedcom_elt elt, Gedcom_ctxt parent, Gedcom_ctxt self, + Gedcom_val parsed_value) { output(1, "Source context %d in parent %d\n", (int)self, (int)parent); } -Gedcom_ctxt date_start(Gedcom_ctxt parent, int level, char *tag, - char* raw_value, +Gedcom_ctxt date_start(Gedcom_elt elt, Gedcom_ctxt parent, int level, + char *tag, char* raw_value, int tag_value, Gedcom_val parsed_value) { struct date_value dv; @@ -173,8 +174,8 @@ Gedcom_ctxt date_start(Gedcom_ctxt parent, int level, char *tag, return self; } -void default_cb(Gedcom_ctxt ctxt, int level, char *tag, char *raw_value, - int tag_value) +void default_cb(Gedcom_elt elt, Gedcom_ctxt ctxt, int level, char *tag, + char *raw_value, int tag_value) { char *converted = NULL; int conv_fails = 0;