Updates.
[gedcom-parse.git] / gom / note.c
index b3ff3700ef9ea159bf2abdf1cdf5bd97580227a8..7f74a3027923815e4d189014f0be54b6ab65d2ef 100644 (file)
@@ -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_)
@@ -167,3 +144,27 @@ struct note* make_note_record(const char* xrefstr)
   }
   return note;
 }
+
+int write_notes(Gedcom_write_hndl hndl)
+{
+  int result = 0;
+  struct note* obj;
+
+  for (obj = gom_first_note; obj; obj = obj->next) {
+    result |= gedcom_write_record_str(hndl, REC_NOTE, obj->xrefstr, obj->text);
+    if (obj->citation)
+      result |= write_citations(hndl, REC_NOTE, obj->citation);
+    if (obj->ref)
+      result |= write_user_refs(hndl, REC_NOTE, obj->ref);
+    if (obj->record_id)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_IDENT_RIN, 0,
+                                        REC_NOTE, obj->record_id);
+    if (obj->change_date)
+      result |= write_change_date(hndl, REC_NOTE, obj->change_date);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);
+  }
+  
+  return result;
+}
+