From: Peter Verthez Date: Sun, 8 Dec 2002 13:11:04 +0000 (+0000) Subject: Put common code in gom_internal.h X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=d7e4149f2d99ab6eed88685eeeaac614b7139a01;p=gedcom-parse.git Put common code in gom_internal.h --- diff --git a/gom/header.c b/gom/header.c index 69fb4df..c536001 100644 --- a/gom/header.c +++ b/gom/header.c @@ -61,26 +61,8 @@ STRING_CB(header, head_lang_start, language) NULL_CB(header, head_plac_start) STRING_CB(header, head_plac_form_start, place_hierarchy) NULL_CB(header, head_note_start) /* the end callback will fill the value */ +STRING_END_CB(header, head_note_end, note) -void head_note_end(_ELT_END_PARAMS_) -{ - Gom_ctxt ctxt = (Gom_ctxt)self; - - if (! ctxt) - NO_CONTEXT; - else { - struct header *head = SAFE_CTXT_CAST(header, ctxt); - if (head) { - char *str = GEDCOM_STRING(parsed_value); - char *newvalue = strdup(str); - if (! newvalue) - MEMORY_ERROR; - else - head->note = newvalue; - } - } -} - void header_add_address(Gom_ctxt ctxt, struct address* addr) { struct header *head = SAFE_CTXT_CAST(header, ctxt); diff --git a/gom/multimedia.c b/gom/multimedia.c index 13c8b3e..8ae8802 100644 --- a/gom/multimedia.c +++ b/gom/multimedia.c @@ -38,28 +38,10 @@ REC_CB(multimedia, obje_start, make_multimedia_record) GET_REC_BY_XREF(multimedia, XREF_OBJE, gom_get_multimedia_by_xref) STRING_CB(multimedia, obje_form_start, form) STRING_CB(multimedia, obje_titl_start, title) -NULL_CB(multimedia, obje_blob_start) +NULL_CB(multimedia, obje_blob_start) +STRING_END_CB(multimedia, obje_blob_end, data) XREF_CB(multimedia, obje_obje_start, continued, make_multimedia_record) -void obje_blob_end(_ELT_END_PARAMS_) -{ - Gom_ctxt ctxt = (Gom_ctxt)self; - - if (! ctxt) - NO_CONTEXT; - else { - struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt); - if (obj) { - char *str = GEDCOM_STRING(parsed_value); - char *newvalue = strdup(str); - if (! newvalue) - MEMORY_ERROR; - else - obj->data = newvalue; - } - } -} - Gedcom_ctxt obje_blob_cont_start(_ELT_PARAMS_) { Gom_ctxt ctxt = (Gom_ctxt)parent; diff --git a/gom/note.c b/gom/note.c index b3ff370..41dab5f 100644 --- a/gom/note.c +++ b/gom/note.c @@ -46,35 +46,12 @@ Gedcom_ctxt note_start(_REC_PARAMS_) note = make_note_record(xr->string); xr->object = (Gedcom_ctxt) note; } - if (note) { - note->text = strdup(GEDCOM_STRING(parsed_value)); - if (! note->text) - MEMORY_ERROR; - else - result = MAKE_GOM_CTXT(rec, note, xr->object); - } + if (note) + result = MAKE_GOM_CTXT(rec, note, xr->object); return (Gedcom_ctxt)result; } -void note_end(_REC_END_PARAMS_) -{ - Gom_ctxt ctxt = (Gom_ctxt)self; - - if (! ctxt) - NO_CONTEXT; - else { - struct note *note = SAFE_CTXT_CAST(note, ctxt); - if (note) { - char *str = GEDCOM_STRING(parsed_value); - char *newvalue = strdup(str); - if (! newvalue) - MEMORY_ERROR; - else - note->text = newvalue; - } - } -} - +STRING_END_REC_CB(note, note_end, text) GET_REC_BY_XREF(note, XREF_NOTE, gom_get_note_by_xref) Gedcom_ctxt sub_cont_conc_start(_ELT_PARAMS_) diff --git a/gom/note_sub.c b/gom/note_sub.c index 221dcfc..662cf9f 100644 --- a/gom/note_sub.c +++ b/gom/note_sub.c @@ -113,25 +113,8 @@ Gedcom_ctxt sub_note_start(_ELT_PARAMS_) return (Gedcom_ctxt)result; } -void sub_note_end(_ELT_END_PARAMS_) -{ - Gom_ctxt ctxt = (Gom_ctxt)self; - - if (! ctxt) - NO_CONTEXT; - else { - struct note_sub *note = SAFE_CTXT_CAST(note_sub, ctxt); - if (note) { - char *str = GEDCOM_STRING(parsed_value); - char *newvalue = strdup(str); - if (! newvalue) - MEMORY_ERROR; - else - note->text = newvalue; - } - } -} - +STRING_END_CB(note_sub, sub_note_end, text) + void note_sub_subscribe() { gedcom_subscribe_to_element(ELT_SUB_NOTE, sub_note_start, sub_note_end); diff --git a/gom/source.c b/gom/source.c index 7ecb977..57520ed 100644 --- a/gom/source.c +++ b/gom/source.c @@ -43,88 +43,16 @@ GET_REC_BY_XREF(source, XREF_SOUR, gom_get_source_by_xref) NULL_CB(source, sour_data_start) STRING_CB(source, sour_data_agnc_start, data.agency) NULL_CB(source, sour_auth_start) /* value set by end callback */ +STRING_END_CB(source, sour_auth_end, author) NULL_CB(source, sour_titl_start) /* value set by end callback */ +STRING_END_CB(source, sour_titl_end, title) STRING_CB(source, sour_abbr_start, abbreviation) NULL_CB(source, sour_publ_start) /* value set by end callback */ +STRING_END_CB(source, sour_publ_end, publication) NULL_CB(source, sour_text_start) /* value set by end callback */ +STRING_END_CB(source, sour_text_end, text) XREF_CB(source, sour_repo_start, repository.link, make_repository_record) -void sour_auth_end(_ELT_END_PARAMS_) -{ - Gom_ctxt ctxt = (Gom_ctxt)self; - - if (! ctxt) - NO_CONTEXT; - else { - struct source *sour = SAFE_CTXT_CAST(source, ctxt); - if (sour) { - char *str = GEDCOM_STRING(parsed_value); - char *newvalue = strdup(str); - if (! newvalue) - MEMORY_ERROR; - else - sour->author = newvalue; - } - } -} - -void sour_titl_end(_ELT_END_PARAMS_) -{ - Gom_ctxt ctxt = (Gom_ctxt)self; - - if (! ctxt) - NO_CONTEXT; - else { - struct source *sour = SAFE_CTXT_CAST(source, ctxt); - if (sour) { - char *str = GEDCOM_STRING(parsed_value); - char *newvalue = strdup(str); - if (! newvalue) - MEMORY_ERROR; - else - sour->title = newvalue; - } - } -} - -void sour_publ_end(_ELT_END_PARAMS_) -{ - Gom_ctxt ctxt = (Gom_ctxt)self; - - if (! ctxt) - NO_CONTEXT; - else { - struct source *sour = SAFE_CTXT_CAST(source, ctxt); - if (sour) { - char *str = GEDCOM_STRING(parsed_value); - char *newvalue = strdup(str); - if (! newvalue) - MEMORY_ERROR; - else - sour->publication = newvalue; - } - } -} - -void sour_text_end(_ELT_END_PARAMS_) -{ - Gom_ctxt ctxt = (Gom_ctxt)self; - - if (! ctxt) - NO_CONTEXT; - else { - struct source *sour = SAFE_CTXT_CAST(source, ctxt); - if (sour) { - char *str = GEDCOM_STRING(parsed_value); - char *newvalue = strdup(str); - if (! newvalue) - MEMORY_ERROR; - else - sour->text = newvalue; - } - } -} - void source_subscribe() { gedcom_subscribe_to_record(REC_SOUR, sour_start, def_rec_end); diff --git a/gom/source_citation.c b/gom/source_citation.c index ef03835..8aa6b51 100644 --- a/gom/source_citation.c +++ b/gom/source_citation.c @@ -113,6 +113,7 @@ void sub_citation_end(_ELT_END_PARAMS_) cit->description = newvalue; } } + destroy_gom_ctxt(ctxt); } } @@ -136,33 +137,13 @@ Gedcom_ctxt sub_cit_text_start(_ELT_PARAMS_) return (Gedcom_ctxt)result; } -void sub_cit_text_end(_ELT_END_PARAMS_) -{ - Gom_ctxt ctxt = (Gom_ctxt)self; - - if (! ctxt) - NO_CONTEXT; - else { - if (GEDCOM_IS_STRING(parsed_value)) { - struct text *t = SAFE_CTXT_CAST(text, ctxt); - if (t) { - char *str = GEDCOM_STRING(parsed_value); - char *newvalue = strdup(str); - if (! newvalue) - MEMORY_ERROR; - else - t->text = newvalue; - } - } - } -} - STRING_CB(source_citation, sub_cit_page_start, page) STRING_CB(source_citation, sub_cit_even_start, event) STRING_CB(source_citation, sub_cit_even_role_start, role) NULL_CB(source_citation, sub_cit_data_start) DATE_CB(source_citation, sub_cit_data_date_start, date) STRING_CB(source_citation, sub_cit_quay_start, quality) +STRING_END_CB(text, sub_cit_text_end, text) void citation_subscribe() {