Use complete concatenated text instead of concatenating the texts itself.
[gedcom-parse.git] / gom / gom.c
index cc388ee2be9dbd7484d4a5d55e9ed3b4a26eea72..1770efdbd3690f6c328b5e426c7730137aec1df0 100644 (file)
--- a/gom/gom.c
+++ b/gom/gom.c
@@ -115,6 +115,20 @@ int gom_new_model()
   return gedcom_new_model();
 }
 
+int gom_write_file(const char* file_name, int *total_conv_fails)
+{
+  Gedcom_write_hndl hndl;
+  int result = 1;
+
+  hndl = gedcom_write_open(file_name);
+  if (hndl) {
+    result = write_header(hndl);
+    result |= gedcom_write_close(hndl, total_conv_fails);
+  }
+
+  return result;
+}
+
 Gom_ctxt make_gom_ctxt(int ctxt_type, OBJ_TYPE obj_type, void *ctxt_ptr)
 {
   Gom_ctxt ctxt   = (Gom_ctxt)malloc(sizeof(struct Gom_ctxt_struct));
@@ -171,7 +185,8 @@ void gom_default_callback (Gedcom_elt elt UNUSED, Gedcom_ctxt parent UNUSED,
                  level, tag, raw_value);
 }
 
-void def_rec_end(Gedcom_rec rec UNUSED, Gedcom_ctxt self)
+void def_rec_end(Gedcom_rec rec UNUSED, Gedcom_ctxt self,
+                Gedcom_val parsed_value UNUSED)
 {
   Gom_ctxt ctxt = (Gom_ctxt)self;
   destroy_gom_ctxt(ctxt);
@@ -206,31 +221,6 @@ void set_xref_type(struct xref_value* xr, const char *str)
     xr->type = XREF_ANY;
 }
 
-char* concat_strings(NL_TYPE type, char *str1, const char *str2)
-{
-  if (str1 != NULL && str2 != NULL) {
-    char *newp;
-    char *wp;
-    size_t len1 = strlen(str1);
-    size_t len2 = strlen(str2);
-    size_t len  = len1 + len2 + 1;
-    if (type == WITH_NL)
-      len++;
-    newp = (char*) realloc(str1, len);
-    if (newp == NULL)
-      return NULL;
-    wp   = newp + len1;
-    str1 = newp;
-    if (type == WITH_NL)
-      *wp++ = '\n';
-    wp = memcpy (wp, str2, len2);
-    wp += len2;
-    *wp++ = '\0';
-  }
-
-  return str1;
-}
-
 struct date_value* dup_date(struct date_value dv)
 {
   struct date_value* dv_ptr;