Changed the title of the HTML page.
[gedcom-parse.git] / gom / note_sub.c
index 221dcfcf2a2f7b14ed41f8f79de976a5b389932a..63ef644150a4348dacc569cfbb20d502da1a11bb 100644 (file)
@@ -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);
@@ -159,3 +142,28 @@ void note_sub_cleanup(struct note_sub* note)
     DESTROY_CHAIN_ELTS(user_data, note->extra, user_data_cleanup);
   }
 }
+
+int write_note_subs(Gedcom_write_hndl hndl, int parent, struct note_sub* note)
+{
+  int result = 0;
+  struct note_sub* obj;
+
+  if (!note) return 1;
+
+  for (obj = note; obj; obj = obj->next) {
+    if (obj->reference) {
+      result |= gedcom_write_element_xref(hndl, ELT_SUB_NOTE, 0,
+                                         parent, obj->reference);
+    }
+    else {
+      result |= gedcom_write_element_str(hndl, ELT_SUB_NOTE, 0,
+                                        parent, obj->text);
+    }
+    if (obj->citation)
+      result |= write_citations(hndl, ELT_SUB_NOTE, obj->citation);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);
+  }
+
+  return result;
+}