Moved common code to gom_internal.h
[gedcom-parse.git] / gom / source.c
index edf53eddaa1edad01736f18d2aa179a9481529e2..57520eda9b1fc6443d38be5c39a2cd5f06169aa9 100644 (file)
@@ -42,11 +42,15 @@ REC_CB(source, sour_start, make_source_record)
 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)
-STRING_CB(source, sour_auth_start, author)
-STRING_CB(source, sour_titl_start, title)
+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)
-STRING_CB(source, sour_publ_start, publication)
-STRING_CB(source, sour_text_start, text)
+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 source_subscribe()
@@ -55,11 +59,11 @@ void source_subscribe()
   gedcom_subscribe_to_element(ELT_SOUR_DATA, sour_data_start, def_elt_end);
   gedcom_subscribe_to_element(ELT_SOUR_DATA_AGNC, sour_data_agnc_start,
                              def_elt_end);
-  gedcom_subscribe_to_element(ELT_SOUR_AUTH, sour_auth_start, def_elt_end);
-  gedcom_subscribe_to_element(ELT_SOUR_TITL, sour_titl_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SOUR_AUTH, sour_auth_start, sour_auth_end);
+  gedcom_subscribe_to_element(ELT_SOUR_TITL, sour_titl_start, sour_titl_end);
   gedcom_subscribe_to_element(ELT_SOUR_ABBR, sour_abbr_start, def_elt_end);
-  gedcom_subscribe_to_element(ELT_SOUR_PUBL, sour_publ_start, def_elt_end);
-  gedcom_subscribe_to_element(ELT_SOUR_TEXT, sour_text_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SOUR_PUBL, sour_publ_start, sour_publ_end);
+  gedcom_subscribe_to_element(ELT_SOUR_TEXT, sour_text_start, sour_text_end);
   gedcom_subscribe_to_element(ELT_SUB_REPO, sour_repo_start, def_elt_end);
 }
 
@@ -91,46 +95,6 @@ void source_add_description(Gom_ctxt ctxt, struct source_description* desc)
     LINK_CHAIN_ELT(source_description, sour->repository.description, desc);  
 }
 
-void source_add_to_value(NL_TYPE type, Gom_ctxt ctxt, const char* str)
-{
-  struct source *sour = SAFE_CTXT_CAST(source, ctxt);
-  if (sour) {
-    switch (ctxt->ctxt_type) {
-      char *newvalue;
-      case ELT_SOUR_AUTH:
-       newvalue = concat_strings (type, sour->author, str);
-       if (newvalue)
-         sour->author = newvalue;
-       else
-         MEMORY_ERROR;
-       break;
-      case ELT_SOUR_TITL:
-       newvalue = concat_strings (type, sour->title, str);
-       if (newvalue)
-         sour->title = newvalue;
-       else
-         MEMORY_ERROR;
-       break;
-      case ELT_SOUR_PUBL:
-       newvalue = concat_strings (type, sour->publication, str);
-       if (newvalue)
-         sour->publication = newvalue;
-       else
-         MEMORY_ERROR;
-       break;
-      case ELT_SOUR_TEXT:
-       newvalue = concat_strings (type, sour->text, str);
-       if (newvalue)
-         sour->text = newvalue;
-       else
-         MEMORY_ERROR;
-       break;
-      default:
-       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
-    }
-  }
-}
-
 void source_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link)
 {
   struct source *sour = SAFE_CTXT_CAST(source, ctxt);