First check-in of gedcom object model.
authorPeter Verthez <Peter.Verthez@advalvas.be>
Mon, 9 Sep 2002 16:24:59 +0000 (16:24 +0000)
committerPeter Verthez <Peter.Verthez@advalvas.be>
Mon, 9 Sep 2002 16:24:59 +0000 (16:24 +0000)
57 files changed:
Makefile.am
configure.in
gom/.cvsignore [new file with mode: 0644]
gom/Makefile.am [new file with mode: 0644]
gom/address.c [new file with mode: 0644]
gom/address.h [new file with mode: 0644]
gom/association.c [new file with mode: 0644]
gom/association.h [new file with mode: 0644]
gom/change_date.c [new file with mode: 0644]
gom/change_date.h [new file with mode: 0644]
gom/event.c [new file with mode: 0644]
gom/event.h [new file with mode: 0644]
gom/family.c [new file with mode: 0644]
gom/family.h [new file with mode: 0644]
gom/family_link.c [new file with mode: 0644]
gom/family_link.h [new file with mode: 0644]
gom/gom.c [new file with mode: 0644]
gom/gom_internal.h [new file with mode: 0644]
gom/header.c [new file with mode: 0644]
gom/header.h [new file with mode: 0644]
gom/individual.c [new file with mode: 0644]
gom/individual.h [new file with mode: 0644]
gom/lds_event.c [new file with mode: 0644]
gom/lds_event.h [new file with mode: 0644]
gom/multimedia.c [new file with mode: 0644]
gom/multimedia.h [new file with mode: 0644]
gom/multimedia_link.c [new file with mode: 0644]
gom/multimedia_link.h [new file with mode: 0644]
gom/note.c [new file with mode: 0644]
gom/note.h [new file with mode: 0644]
gom/note_sub.c [new file with mode: 0644]
gom/note_sub.h [new file with mode: 0644]
gom/personal_name.c [new file with mode: 0644]
gom/personal_name.h [new file with mode: 0644]
gom/place.c [new file with mode: 0644]
gom/place.h [new file with mode: 0644]
gom/repository.c [new file with mode: 0644]
gom/repository.h [new file with mode: 0644]
gom/source.c [new file with mode: 0644]
gom/source.h [new file with mode: 0644]
gom/source_citation.c [new file with mode: 0644]
gom/source_citation.h [new file with mode: 0644]
gom/source_description.c [new file with mode: 0644]
gom/source_description.h [new file with mode: 0644]
gom/source_event.c [new file with mode: 0644]
gom/source_event.h [new file with mode: 0644]
gom/submission.c [new file with mode: 0644]
gom/submission.h [new file with mode: 0644]
gom/submitter.c [new file with mode: 0644]
gom/submitter.h [new file with mode: 0644]
gom/user_rec.c [new file with mode: 0644]
gom/user_rec.h [new file with mode: 0644]
gom/user_ref.c [new file with mode: 0644]
gom/user_ref.h [new file with mode: 0644]
include/Makefile.am
include/gom.h [new file with mode: 0644]
t/Makefile.am

index f8c7be90874807d5370781a7bd6c721f1d6f755a..099b6e95033a6f3fd9d0a7a477f29ada5da90af3 100644 (file)
@@ -1,7 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 # $Id$
 # $Name$
-SUBDIRS = intl ansel gedcom include . t doc po
+SUBDIRS = intl ansel gedcom gom include . t doc po
 
 pkgdata_DATA = gedcom.enc
 
@@ -12,6 +12,3 @@ include $(top_srcdir)/Makefile.inc
 
 dist-hook:
        $(replace-VERSION)
-
-clean-local:
-       rm -f testgedcom.out
index e1f5f734ba17e55bb02977911bc5e304ec2c2547..9312b32b1ea94dd8d109e0afeb05fe6dec4c9c0d 100644 (file)
@@ -38,12 +38,21 @@ if test "$YACC" = "bison -y"; then
 else
   AC_MSG_ERROR([Sorry, bison is needed])
 fi
+
 AM_WITH_DMALLOC
+
+dnl == Make statically linked test program for dmalloc tests
+if test "$with_dmalloc" = "yes"; then
+  EXTRA_PROGS=gomtest_static
+fi
+AC_SUBST(EXTRA_PROGS)
+
 AM_GNU_GETTEXT
 
 AC_OUTPUT(Makefile
          gedcom/Makefile
          gedcom/calendar/Makefile
+         gom/Makefile
          ansel/Makefile
          t/Makefile
          t/input/Makefile
diff --git a/gom/.cvsignore b/gom/.cvsignore
new file mode 100644 (file)
index 0000000..70845e0
--- /dev/null
@@ -0,0 +1 @@
+Makefile.in
diff --git a/gom/Makefile.am b/gom/Makefile.am
new file mode 100644 (file)
index 0000000..f4ba020
--- /dev/null
@@ -0,0 +1,59 @@
+## Process this file with automake to produce Makefile.in
+# $Id$
+# $Name$
+
+INCLUDES = -I $(srcdir)/../intl -I $(srcdir)/../include
+CFLAGS   = -g -O2 -W -Wall -Wno-unused-parameter -pedantic
+
+lib_LTLIBRARIES = libgedcom_gom.la
+libgedcom_gom_la_SOURCES = gom.c \
+                          header.c \
+                          submission.c \
+                          submitter.c \
+                          family.c \
+                          individual.c \
+                          multimedia.c \
+                          note.c \
+                          repository.c \
+                          source.c \
+                          address.c \
+                          event.c \
+                          place.c \
+                          source_citation.c \
+                          note_sub.c \
+                          multimedia_link.c \
+                          lds_event.c \
+                          user_ref.c \
+                          change_date.c \
+                          personal_name.c \
+                          family_link.c \
+                          association.c \
+                          source_event.c \
+                          source_description.c \
+                          user_rec.c
+noinst_HEADERS = header.h \
+                submission.h \
+                submitter.h \
+                family.h \
+                individual.h \
+                multimedia.h \
+                note.h \
+                repository.h \
+                source.h \
+                address.h \
+                event.h \
+                place.h \
+                source_citation.h \
+                note_sub.h \
+                multimedia_link.h \
+                lds_event.h \
+                user_ref.h \
+                change_date.h \
+                personal_name.h \
+                family_link.h \
+                association.h \
+                source_event.h \
+                source_description.h \
+                user_rec.h
+
+libgedcom_gom_la_LDFLAGS = -version-info $(LIBVERSION)
diff --git a/gom/address.c b/gom/address.c
new file mode 100644 (file)
index 0000000..03da991
--- /dev/null
@@ -0,0 +1,155 @@
+/* Address sub-structure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "gom_internal.h"
+#include "header.h"
+#include "event.h"
+#include "address.h"
+#include "repository.h"
+#include "submitter.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+
+Gedcom_ctxt sub_addr_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct address *addr = (struct address *)malloc(sizeof(struct address));
+  char *str = GEDCOM_STRING(parsed_value);
+  
+  memset (addr, 0, sizeof(struct address));
+  addr->full_label = strdup(str);
+
+  if (ctxt) {
+    switch (ctxt->ctxt_type) {
+      case ELT_HEAD_SOUR_CORP:
+       header_add_address(ctxt, addr); break;
+      case ELT_SUB_FAM_EVT:
+      case ELT_SUB_FAM_EVT_EVEN:
+      case ELT_SUB_INDIV_ATTR:
+      case ELT_SUB_INDIV_RESI:
+      case ELT_SUB_INDIV_BIRT:
+      case ELT_SUB_INDIV_GEN:
+      case ELT_SUB_INDIV_ADOP:
+      case ELT_SUB_INDIV_EVEN:
+       event_add_address(ctxt, addr); break;
+      case REC_REPO:
+       repository_add_address(ctxt, addr); break;
+      case REC_SUBM:
+       submitter_add_address(ctxt, addr); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+  
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, address, addr);
+}
+
+Gedcom_ctxt sub_addr_cont_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct address *addr = SAFE_CTXT_CAST(address, ctxt);
+  char *str = GEDCOM_STRING(parsed_value);
+  addr->full_label = concat_strings (WITH_NL, addr->full_label, str);
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, address, addr);
+}
+
+STRING_CB(address, sub_addr_adr1_start, line1)
+STRING_CB(address, sub_addr_adr2_start, line2)
+STRING_CB(address, sub_addr_city_start, city)
+STRING_CB(address, sub_addr_stae_start, state)
+STRING_CB(address, sub_addr_post_start, postal)
+STRING_CB(address, sub_addr_ctry_start, country)
+
+Gedcom_ctxt sub_phon_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+
+  if (ctxt) {
+    char *str = GEDCOM_STRING(parsed_value);
+    switch (ctxt->ctxt_type) {
+      case ELT_HEAD_SOUR_CORP:
+       header_add_phone(ctxt, str); break;
+      case ELT_SUB_FAM_EVT:
+      case ELT_SUB_INDIV_ATTR:
+      case ELT_SUB_INDIV_RESI:
+      case ELT_SUB_INDIV_BIRT:
+      case ELT_SUB_INDIV_GEN:
+      case ELT_SUB_INDIV_ADOP:
+      case ELT_SUB_INDIV_EVEN:
+       event_add_phone(ctxt, str); break;
+      case REC_REPO:
+       repository_add_phone(ctxt, str); break;
+      case REC_SUBM:
+       submitter_add_phone(ctxt, str); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+    return (Gedcom_ctxt) make_gom_ctxt(elt, ctxt->obj_type, ctxt->ctxt_ptr);
+  }
+  else
+    return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, NULL, NULL);
+}
+
+void address_subscribe()
+{
+  gedcom_subscribe_to_element(ELT_SUB_ADDR, sub_addr_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_ADDR_CONT,
+                             sub_addr_cont_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_ADDR_ADR1,
+                             sub_addr_adr1_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_ADDR_ADR2,
+                             sub_addr_adr2_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_ADDR_CITY,
+                             sub_addr_city_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_ADDR_STAE,
+                             sub_addr_stae_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_ADDR_POST,
+                             sub_addr_post_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_ADDR_CTRY,
+                             sub_addr_ctry_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_PHON, sub_phon_start, def_elt_end);
+}
+
+void address_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct address *obj = SAFE_CTXT_CAST(address, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void address_cleanup(struct address *address)
+{
+  if (address) {
+    SAFE_FREE(address->full_label);
+    SAFE_FREE(address->line1);
+    SAFE_FREE(address->line2);
+    SAFE_FREE(address->city);
+    SAFE_FREE(address->state);
+    SAFE_FREE(address->postal);
+    SAFE_FREE(address->country);
+    DESTROY_CHAIN_ELTS(user_data, address->extra, user_data_cleanup)
+  }
+  SAFE_FREE(address);
+}
diff --git a/gom/address.h b/gom/address.h
new file mode 100644 (file)
index 0000000..6676241
--- /dev/null
@@ -0,0 +1,33 @@
+/* Include file for the address substructure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __ADDRESS_H
+#define __ADDRESS_H
+
+#include "gom.h"
+
+void address_subscribe();
+void address_cleanup(struct address *address);
+void address_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __ADDRESS_H */
diff --git a/gom/association.c b/gom/association.c
new file mode 100644 (file)
index 0000000..b42d481
--- /dev/null
@@ -0,0 +1,104 @@
+/* Association sub-structure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "association.h"
+#include "individual.h"
+#include "note_sub.h"
+#include "source_citation.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+Gedcom_ctxt sub_assoc_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct association *assoc = NULL;
+
+  if (ctxt) {
+    assoc = (struct association *)malloc(sizeof(struct association));
+    memset (assoc, 0, sizeof(struct association));
+    assoc->to = GEDCOM_XREF_PTR(parsed_value);
+
+    switch (ctxt->ctxt_type) {
+      case REC_INDI:
+       individual_add_association(ctxt, assoc);
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, association, assoc);
+}
+
+STRING_CB(association, sub_assoc_rela_start, relation)
+     
+Gedcom_ctxt sub_assoc_type_start(_ELT_PARAMS_)
+{
+  char *str = GEDCOM_STRING(parsed_value);
+  struct association *obj = SAFE_CTXT_CAST(association, (Gom_ctxt)parent);
+  if (obj)
+    obj->type = strdup(str);
+  set_xref_type(obj->to, str);
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, association, obj);
+}
+
+void association_subscribe()
+{
+  gedcom_subscribe_to_element(ELT_SUB_ASSO, sub_assoc_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_ASSO_TYPE, sub_assoc_type_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_ASSO_RELA, sub_assoc_rela_start,
+                             def_elt_end);
+}
+
+void association_add_note(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct association *assoc = SAFE_CTXT_CAST(association, ctxt);
+  LINK_CHAIN_ELT(note_sub, assoc->note, note)
+}
+
+void association_add_citation(Gom_ctxt ctxt, struct source_citation* cit)
+{
+  struct association *assoc = SAFE_CTXT_CAST(association, ctxt);
+  LINK_CHAIN_ELT(source_citation, assoc->citation, cit)
+}
+
+void association_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct association *obj = SAFE_CTXT_CAST(association, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void association_cleanup(struct association* assoc)
+{
+  if (assoc) {
+    SAFE_FREE(assoc->type);
+    SAFE_FREE(assoc->relation);
+    DESTROY_CHAIN_ELTS(note_sub, assoc->note, note_sub_cleanup)
+    DESTROY_CHAIN_ELTS(source_citation, assoc->citation, citation_cleanup)
+    DESTROY_CHAIN_ELTS(user_data, assoc->extra, user_data_cleanup)
+  }
+}
diff --git a/gom/association.h b/gom/association.h
new file mode 100644 (file)
index 0000000..8c0c640
--- /dev/null
@@ -0,0 +1,36 @@
+/* Include file for the association substructure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __ASSOCIATION_H
+#define __ASSOCIATION_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void association_subscribe();
+void association_cleanup(struct association* assoc);
+void association_add_note(Gom_ctxt ctxt, struct note_sub* note);
+void association_add_citation(Gom_ctxt ctxt, struct source_citation* cit);
+void association_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __ASSOCIATION_H */
diff --git a/gom/change_date.c b/gom/change_date.c
new file mode 100644 (file)
index 0000000..9bcb616
--- /dev/null
@@ -0,0 +1,104 @@
+/* Change date sub-structure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "change_date.h"
+#include "family.h"
+#include "individual.h"
+#include "note_sub.h"
+#include "multimedia.h"
+#include "note.h"
+#include "repository.h"
+#include "source.h"
+#include "submitter.h"
+#include "user_rec.h"
+#include "gom_internal.h"
+#include "gom.h"
+#include "gedcom.h"
+
+Gedcom_ctxt sub_chan_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct change_date *chan
+    = (struct change_date *)malloc(sizeof(struct change_date));
+  memset (chan, 0, sizeof(struct change_date));
+
+  if (ctxt) {
+    switch (ctxt->ctxt_type) {
+      case REC_FAM:
+       family_set_change_date(ctxt, chan); break;
+      case REC_INDI:
+       individual_set_change_date(ctxt, chan); break;
+      case REC_OBJE:
+       multimedia_set_change_date(ctxt, chan); break;
+      case REC_NOTE:
+       note_set_change_date(ctxt, chan); break;
+      case REC_REPO:
+       repository_set_change_date(ctxt, chan); break;
+      case REC_SOUR:
+       source_set_change_date(ctxt, chan); break;
+      case REC_SUBM:
+       submitter_set_change_date(ctxt, chan); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+  
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, change_date, chan);
+}
+
+DATE_CB(change_date, sub_chan_date_start, date)
+STRING_CB(change_date, sub_chan_time_start, time)
+
+void change_date_subscribe()
+{
+  gedcom_subscribe_to_element(ELT_SUB_CHAN, sub_chan_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_CHAN_DATE, sub_chan_date_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_CHAN_TIME, sub_chan_time_start,
+                             def_elt_end);
+}
+
+void change_date_add_note(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct change_date *chan = SAFE_CTXT_CAST(change_date, ctxt);
+  LINK_CHAIN_ELT(note_sub, chan->note, note)
+}
+
+void change_date_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct change_date *obj = SAFE_CTXT_CAST(change_date, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void change_date_cleanup(struct change_date *chan)
+{
+  if (chan) {
+    SAFE_FREE(chan->date);
+    SAFE_FREE(chan->time);
+    DESTROY_CHAIN_ELTS(note_sub, chan->note, note_sub_cleanup)
+    DESTROY_CHAIN_ELTS(user_data, chan->extra, user_data_cleanup)
+  }
+  SAFE_FREE(chan);
+}
diff --git a/gom/change_date.h b/gom/change_date.h
new file mode 100644 (file)
index 0000000..15d7684
--- /dev/null
@@ -0,0 +1,35 @@
+/* Include file for the change date substructure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __CHANGE_DATE_H
+#define __CHANGE_DATE_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void change_date_subscribe();
+void change_date_cleanup(struct change_date *chan);
+void change_date_add_note(Gom_ctxt ctxt, struct note_sub* note);
+void change_date_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __CHANGE_DATE_H */
diff --git a/gom/event.c b/gom/event.c
new file mode 100644 (file)
index 0000000..e19fd37
--- /dev/null
@@ -0,0 +1,226 @@
+/* Event sub-structure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "family.h"
+#include "individual.h"
+#include "event.h"
+#include "place.h"
+#include "address.h"
+#include "source_citation.h"
+#include "multimedia_link.h"
+#include "note_sub.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+Gedcom_ctxt sub_evt_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct event *evt = NULL;
+
+  if (ctxt) {
+    evt = (struct event *)malloc(sizeof(struct event));
+    memset (evt, 0, sizeof(struct event));
+    evt->event = parsed_tag;
+    evt->event_name = strdup(tag);
+    if (GEDCOM_IS_STRING(parsed_value))
+      evt->val = strdup(GEDCOM_STRING(parsed_value));
+
+    switch (ctxt->ctxt_type) {
+      case REC_FAM:
+       family_add_event(ctxt, evt); break;
+      case REC_INDI:
+       individual_add_event(ctxt, evt); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, event, evt);
+}
+
+Gedcom_ctxt sub_attr_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct event *evt = NULL;
+
+  if (ctxt) {
+    evt = (struct event *)malloc(sizeof(struct event));
+    memset (evt, 0, sizeof(struct event));
+    evt->event = parsed_tag;
+    evt->event_name = strdup(tag);
+    if (GEDCOM_IS_STRING(parsed_value))
+      evt->val = strdup(GEDCOM_STRING(parsed_value));
+    switch (ctxt->ctxt_type) {
+      case REC_INDI:
+       individual_add_attribute(ctxt, evt); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, event, evt);
+}
+
+STRING_CB(event, sub_evt_type_start, type)
+DATE_CB(event, sub_evt_date_start, date)
+AGE_CB(event, sub_evt_age_start, age)
+STRING_CB(event, sub_evt_agnc_start, agency)
+STRING_CB(event, sub_evt_caus_start, cause)
+NULL_CB(event, sub_fam_evt_husb_wife_start)
+XREF_CB(event, sub_evt_famc_start, family, make_family_record)
+STRING_CB(event, sub_evt_famc_adop_start, adoption_parent)
+     
+Gedcom_ctxt sub_fam_evt_age_start(_ELT_PARAMS_)
+{
+  struct age_value age = GEDCOM_AGE(parsed_value);
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct event *evt = NULL;
+  if (ctxt) {
+    evt = SAFE_CTXT_CAST(event, ctxt);
+    switch (ctxt->ctxt_type) {
+      case ELT_SUB_FAM_EVT_HUSB:
+       evt->husband_age = dup_age(age); break;
+      case ELT_SUB_FAM_EVT_WIFE:
+       evt->wife_age = dup_age(age); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, event, evt);
+}
+
+void event_add_place(Gom_ctxt ctxt, struct place* place)
+{
+  struct event *evt = SAFE_CTXT_CAST(event, ctxt);
+  evt->place = place;
+}
+
+void event_add_address(Gom_ctxt ctxt, struct address* address)
+{
+  struct event *evt = SAFE_CTXT_CAST(event, ctxt);
+  evt->address = address;
+}
+
+void event_add_phone(Gom_ctxt ctxt, char *phone)
+{
+  struct event *evt = SAFE_CTXT_CAST(event, ctxt);
+  if (! evt->phone[0])
+    evt->phone[0] = strdup(phone);
+  else if (! evt->phone[1])
+    evt->phone[1] = strdup(phone);
+  else if (! evt->phone[2])
+    evt->phone[2] = strdup(phone);
+}
+
+void event_add_citation(Gom_ctxt ctxt, struct source_citation* cit)
+{
+  struct event *evt = SAFE_CTXT_CAST(event, ctxt);
+  LINK_CHAIN_ELT(source_citation, evt->citation, cit)    
+}
+
+void event_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* mm)
+{
+  struct event *evt = SAFE_CTXT_CAST(event, ctxt);
+  LINK_CHAIN_ELT(multimedia_link, evt->mm_link, mm)    
+}
+
+void event_add_note(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct event *evt = SAFE_CTXT_CAST(event, ctxt);
+  LINK_CHAIN_ELT(note_sub, evt->note, note)    
+}
+
+void event_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct event *obj = SAFE_CTXT_CAST(event, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void event_subscribe()
+{
+  gedcom_subscribe_to_element(ELT_SUB_FAM_EVT, sub_evt_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_FAM_EVT_EVEN,
+                             sub_evt_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_INDIV_ATTR,
+                             sub_attr_start, def_elt_end);  
+  gedcom_subscribe_to_element(ELT_SUB_INDIV_RESI,
+                             sub_attr_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_INDIV_BIRT,
+                             sub_evt_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_INDIV_BIRT_FAMC,
+                             sub_evt_famc_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_INDIV_GEN,
+                             sub_evt_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_INDIV_ADOP,
+                             sub_evt_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_INDIV_ADOP_FAMC,
+                             sub_evt_famc_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_INDIV_ADOP_FAMC_ADOP,
+                             sub_evt_famc_adop_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_INDIV_EVEN,
+                             sub_evt_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_FAM_EVT_HUSB,
+                             sub_fam_evt_husb_wife_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_FAM_EVT_WIFE,
+                             sub_fam_evt_husb_wife_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_FAM_EVT_AGE,
+                             sub_fam_evt_age_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_EVT_TYPE,
+                             sub_evt_type_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_EVT_DATE,
+                             sub_evt_date_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_EVT_AGE,
+                             sub_evt_age_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_EVT_AGNC,
+                             sub_evt_agnc_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_EVT_CAUS,
+                             sub_evt_caus_start, def_elt_end);
+}
+
+void event_cleanup(struct event* evt)
+{
+  if (evt) {
+    SAFE_FREE(evt->event_name);
+    SAFE_FREE(evt->val);
+    SAFE_FREE(evt->type);
+    SAFE_FREE(evt->date);
+    place_cleanup(evt->place);
+    address_cleanup(evt->address);
+    SAFE_FREE(evt->phone[0]);
+    SAFE_FREE(evt->phone[1]);
+    SAFE_FREE(evt->phone[2]);
+    SAFE_FREE(evt->age);
+    SAFE_FREE(evt->agency);
+    SAFE_FREE(evt->cause);
+    DESTROY_CHAIN_ELTS(source_citation, evt->citation, citation_cleanup)
+    DESTROY_CHAIN_ELTS(multimedia_link, evt->mm_link, multimedia_link_cleanup)
+    DESTROY_CHAIN_ELTS(note_sub, evt->note, note_sub_cleanup)
+    SAFE_FREE(evt->husband_age);
+    SAFE_FREE(evt->wife_age);
+    SAFE_FREE(evt->adoption_parent);
+    DESTROY_CHAIN_ELTS(user_data, evt->extra, user_data_cleanup)
+  }
+}
diff --git a/gom/event.h b/gom/event.h
new file mode 100644 (file)
index 0000000..ef799d2
--- /dev/null
@@ -0,0 +1,40 @@
+/* Include file for the event substructure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __EVENT_H
+#define __EVENT_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void event_subscribe();
+void event_cleanup(struct event* evt);
+void event_add_place(Gom_ctxt ctxt, struct place* place);
+void event_add_address(Gom_ctxt ctxt, struct address* address);
+void event_add_phone(Gom_ctxt ctxt, char *phone);
+void event_add_citation(Gom_ctxt ctxt, struct source_citation* cit);
+void event_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* mm);
+void event_add_note(Gom_ctxt ctxt, struct note_sub* note);
+void event_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __EVENT_H */
diff --git a/gom/family.c b/gom/family.c
new file mode 100644 (file)
index 0000000..34a5c5a
--- /dev/null
@@ -0,0 +1,148 @@
+/* Family object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "family.h"
+#include "individual.h"
+#include "submitter.h"
+#include "event.h"
+#include "lds_event.h"
+#include "source_citation.h"
+#include "multimedia_link.h"
+#include "note_sub.h"
+#include "user_ref.h"
+#include "change_date.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+struct family* gom_first_family = NULL;
+
+REC_CB(family, fam_start, make_family_record)
+GET_REC_BY_XREF(family, XREF_FAM, gom_get_family_by_xref)
+XREF_CB(family, fam_husb_start, husband, make_individual_record)
+XREF_CB(family, fam_wife_start, wife, make_individual_record)
+STRING_CB(family, fam_nchi_start, nr_of_children)
+XREF_LIST_CB(family, fam_chil_start, children, make_individual_record)
+XREF_LIST_CB(family, fam_subm_start, submitters, make_submitter_record)
+
+void family_subscribe()
+{
+  gedcom_subscribe_to_record(REC_FAM, fam_start, def_rec_end);
+  gedcom_subscribe_to_element(ELT_FAM_HUSB, fam_husb_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_FAM_WIFE, fam_wife_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_FAM_CHIL, fam_chil_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_FAM_NCHI, fam_nchi_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_FAM_SUBM, fam_subm_start, def_elt_end);
+}
+
+void family_add_event(Gom_ctxt ctxt, struct event* evt)
+{
+  struct family *fam = SAFE_CTXT_CAST(family, ctxt);
+  LINK_CHAIN_ELT(event, fam->event, evt)
+}
+
+void family_add_lss(Gom_ctxt ctxt, struct lds_event* lss)
+{
+  struct family *fam = SAFE_CTXT_CAST(family, ctxt);
+  LINK_CHAIN_ELT(lds_event, fam->lds_spouse_sealing, lss)
+}
+
+void family_add_citation(Gom_ctxt ctxt, struct source_citation* cit)
+{
+  struct family *fam = SAFE_CTXT_CAST(family, ctxt);
+  LINK_CHAIN_ELT(source_citation, fam->citation, cit)
+}
+
+void family_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link)
+{
+  struct family *fam = SAFE_CTXT_CAST(family, ctxt);
+  LINK_CHAIN_ELT(multimedia_link, fam->mm_link, link)
+}
+
+void family_add_note(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct family *fam = SAFE_CTXT_CAST(family, ctxt);
+  LINK_CHAIN_ELT(note_sub, fam->note, note)
+}
+
+void family_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref)
+{
+  struct family *fam = SAFE_CTXT_CAST(family, ctxt);
+  LINK_CHAIN_ELT(user_ref_number, fam->ref, ref)
+}
+
+void family_set_record_id(Gom_ctxt ctxt, char *rin)
+{
+  struct family *fam = SAFE_CTXT_CAST(family, ctxt);
+  fam->record_id = strdup(rin);
+}
+
+void family_set_change_date(Gom_ctxt ctxt, struct change_date* chan)
+{
+  struct family *fam = SAFE_CTXT_CAST(family, ctxt);
+  fam->change_date = chan;
+}
+
+void family_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct family *obj = SAFE_CTXT_CAST(family, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void family_cleanup(struct family* fam)
+{
+  SAFE_FREE(fam->xrefstr);
+  DESTROY_CHAIN_ELTS(event, fam->event, event_cleanup)  
+  DESTROY_CHAIN_ELTS(xref_list, fam->children, NULL_DESTROY)
+  SAFE_FREE(fam->nr_of_children);
+  DESTROY_CHAIN_ELTS(xref_list, fam->submitters, NULL_DESTROY)
+  DESTROY_CHAIN_ELTS(lds_event, fam->lds_spouse_sealing, lds_event_cleanup)
+  DESTROY_CHAIN_ELTS(source_citation, fam->citation, citation_cleanup)
+  DESTROY_CHAIN_ELTS(multimedia_link, fam->mm_link, multimedia_link_cleanup)
+  DESTROY_CHAIN_ELTS(note_sub, fam->note, note_sub_cleanup)
+  DESTROY_CHAIN_ELTS(user_ref_number, fam->ref, user_ref_cleanup)
+  SAFE_FREE(fam->record_id);
+  change_date_cleanup(fam->change_date);
+  DESTROY_CHAIN_ELTS(user_data, fam->extra, user_data_cleanup)
+}
+
+void families_cleanup()
+{
+  DESTROY_CHAIN_ELTS(family, gom_first_family, family_cleanup);
+}
+
+struct family* gom_get_first_family()
+{
+  return gom_first_family;
+}
+
+struct family* make_family_record(char* xrefstr)
+{
+  struct family* fam;
+  MAKE_CHAIN_ELT(family, gom_first_family, fam);
+  fam->xrefstr = strdup(xrefstr);
+  return fam;
+}
diff --git a/gom/family.h b/gom/family.h
new file mode 100644 (file)
index 0000000..3e218b4
--- /dev/null
@@ -0,0 +1,43 @@
+/* Include file for the family object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __FAMILY_H
+#define __FAMILY_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void family_subscribe();
+void families_cleanup();
+struct family* make_family_record(char* xref);
+void family_add_event(Gom_ctxt ctxt, struct event* evt);
+void family_add_lss(Gom_ctxt ctxt, struct lds_event* lss);
+void family_add_citation(Gom_ctxt ctxt, struct source_citation* cit);
+void family_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link);
+void family_add_note(Gom_ctxt ctxt, struct note_sub* note);
+void family_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
+void family_set_record_id(Gom_ctxt ctxt, char *rin);
+void family_set_change_date(Gom_ctxt ctxt, struct change_date* chan);
+void family_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __FAMILY_H */
diff --git a/gom/family_link.c b/gom/family_link.c
new file mode 100644 (file)
index 0000000..dfffbd5
--- /dev/null
@@ -0,0 +1,101 @@
+/* Family link sub-structure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "family_link.h"
+#include "individual.h"
+#include "note_sub.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+Gedcom_ctxt sub_fam_link_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct family_link *link = NULL;
+
+  if (ctxt) {
+    link = (struct family_link *)malloc(sizeof(struct family_link));
+    memset (link, 0, sizeof(struct family_link));
+    link->family = GEDCOM_XREF_PTR(parsed_value);
+
+    switch (ctxt->ctxt_type) {
+      case REC_INDI:
+       individual_add_family_link(ctxt, elt, link); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, family_link, link);
+}
+
+Gedcom_ctxt sub_fam_link_pedi_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct family_link *link = SAFE_CTXT_CAST(family_link, ctxt);
+  struct pedigree *ped;
+  MAKE_CHAIN_ELT(pedigree, link->pedigree, ped);
+  ped->pedigree = strdup(GEDCOM_STRING(parsed_value));
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, pedigree, ped);
+}
+
+void family_link_subscribe()
+{
+  gedcom_subscribe_to_element(ELT_SUB_FAMC, sub_fam_link_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_FAMS, sub_fam_link_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_FAMC_PEDI, sub_fam_link_pedi_start,
+                             def_elt_end);
+}
+
+void family_link_add_note(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct family_link *link = SAFE_CTXT_CAST(family_link, ctxt);
+  LINK_CHAIN_ELT(note_sub, link->note, note)
+}
+
+void family_link_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct family_link *obj = SAFE_CTXT_CAST(family_link, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void pedigree_cleanup(struct pedigree* ped)
+{
+  if (ped) {
+    SAFE_FREE(ped->pedigree);
+  }
+}
+
+void family_link_cleanup(struct family_link *link)
+{
+  if (link) {
+    DESTROY_CHAIN_ELTS(pedigree, link->pedigree, pedigree_cleanup)
+    DESTROY_CHAIN_ELTS(note_sub, link->note, note_sub_cleanup)
+    DESTROY_CHAIN_ELTS(user_data, link->extra, user_data_cleanup)
+  }
+}
diff --git a/gom/family_link.h b/gom/family_link.h
new file mode 100644 (file)
index 0000000..64b323d
--- /dev/null
@@ -0,0 +1,35 @@
+/* Include file for the family link substructure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __FAMILY_LINK_H
+#define __FAMILY_LINK_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void family_link_subscribe();
+void family_link_cleanup(struct family_link* link);
+void family_link_add_note(Gom_ctxt ctxt, struct note_sub* note);
+void family_link_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __FAMILY_LINK_H */
diff --git a/gom/gom.c b/gom/gom.c
new file mode 100644 (file)
index 0000000..2ddbb55
--- /dev/null
+++ b/gom/gom.c
@@ -0,0 +1,220 @@
+/* Main file for building the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "gedcom.h"
+#include "header.h"
+#include "submitter.h"
+#include "submission.h"
+#include "family.h"
+#include "individual.h"
+#include "multimedia.h"
+#include "note.h"
+#include "repository.h"
+#include "source.h"
+#include "user_rec.h"
+#include "address.h"
+#include "event.h"
+#include "place.h"
+#include "source_citation.h"
+#include "multimedia_link.h"
+#include "note_sub.h"
+#include "lds_event.h"
+#include "user_ref.h"
+#include "change_date.h"
+#include "personal_name.h"
+#include "family_link.h"
+#include "association.h"
+#include "source_event.h"
+#include "source_description.h"
+#include "gom.h"
+#include "gom_internal.h"
+
+void gom_default_callback (Gedcom_elt elt, Gedcom_ctxt parent, int level, char* tag,
+                          char* raw_value, int parsed_tag);
+
+void gom_cleanup()
+{
+  header_cleanup();
+  submission_cleanup();
+  families_cleanup();
+  individuals_cleanup();
+  multimedias_cleanup();
+  notes_cleanup();
+  repositories_cleanup();
+  sources_cleanup();
+  submitters_cleanup();
+  user_recs_cleanup();
+}
+
+int gom_parse_file(char* file_name)
+{
+  gedcom_set_default_callback(gom_default_callback);
+  header_subscribe();
+  submission_subscribe();
+  family_subscribe();
+  individual_subscribe();
+  multimedia_subscribe();
+  note_subscribe();
+  repository_subscribe();
+  source_subscribe();
+  submitter_subscribe();
+  user_rec_subscribe();
+  
+  address_subscribe();
+  event_subscribe();
+  place_subscribe();
+  citation_subscribe();
+  note_sub_subscribe();
+  multimedia_link_subscribe();
+  lds_event_subscribe();
+  user_ref_subscribe();
+  change_date_subscribe();
+  name_subscribe();
+  family_link_subscribe();
+  association_subscribe();
+  source_event_subscribe();
+  source_description_subscribe();
+
+  atexit(gom_cleanup);
+  return gedcom_parse_file(file_name);
+}
+
+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));
+  ctxt->ctxt_type = ctxt_type;
+  ctxt->obj_type  = obj_type;
+  ctxt->ctxt_ptr  = ctxt_ptr;
+  return ctxt;
+}
+
+void NULL_DESTROY(void* anything)
+{
+}
+
+void destroy_gom_ctxt(Gom_ctxt ctxt)
+{
+  free(ctxt);
+}
+
+void gom_cast_error(char* file, int line, OBJ_TYPE expected, OBJ_TYPE found)
+{
+  fprintf(stderr,
+         "Wrong gom ctxt cast at %s, line %d: expected %d, found %d\n",
+         file, line, expected, found);
+  abort();
+}
+
+void gom_unexpected_context(char* file, int line, OBJ_TYPE found)
+{
+  gedcom_warning(_("Internal error: Unexpected context at %s, line %d: %d"),
+                file, line, found);
+}
+
+void gom_default_callback (Gedcom_elt elt, Gedcom_ctxt parent, int level, char* tag,
+                          char* raw_value, int parsed_tag)
+{
+  gedcom_warning(_("Data loss in import: \"%d %s %s\""),
+                 level, tag, raw_value);
+}
+
+void def_rec_end(Gedcom_rec rec, Gedcom_ctxt self)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)self;
+  destroy_gom_ctxt(ctxt);
+}
+
+void def_elt_end(Gedcom_elt elt, Gedcom_ctxt parent, Gedcom_ctxt self,
+                Gedcom_val parsed_value)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)self;
+  destroy_gom_ctxt(ctxt);
+}
+
+void set_xref_type(struct xref_value* xr, char *str)
+{
+  if (!strcasecmp(str, "FAM"))
+    xr->type = XREF_FAM;
+  else if (!strcasecmp(str, "INDI"))
+    xr->type = XREF_INDI;
+  else if (!strcasecmp(str, "NOTE"))
+    xr->type = XREF_NOTE;
+  else if (!strcasecmp(str, "OBJE"))
+    xr->type = XREF_OBJE;
+  else if (!strcasecmp(str, "REPO"))
+    xr->type = XREF_REPO;
+  else if (!strcasecmp(str, "SOUR"))
+    xr->type = XREF_SOUR;
+  else if (!strcasecmp(str, "SUBM"))
+    xr->type = XREF_SUBM;
+  else if (!strcasecmp(str, "SUBN"))
+    xr->type = XREF_SUBN;
+  else
+    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) {
+      free (str1);
+      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;
+  dv_ptr = (struct date_value*) malloc(sizeof(struct date_value));
+  memcpy(dv_ptr, &dv, sizeof(struct date_value));
+  return dv_ptr;
+}
+
+struct age_value* dup_age(struct age_value age)
+{
+  struct age_value* age_ptr;
+  age_ptr = (struct age_value*) malloc(sizeof(struct age_value));
+  memcpy(age_ptr, &age, sizeof(struct age_value));
+  return age_ptr;
+}
diff --git a/gom/gom_internal.h b/gom/gom_internal.h
new file mode 100644 (file)
index 0000000..b24c289
--- /dev/null
@@ -0,0 +1,225 @@
+/* General header for the Gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __GOM_INTERNAL_H
+#define __GOM_INTERNAL_H
+
+#include <stdlib.h>
+#include <string.h>
+#include <libintl.h>
+#include "gom.h"
+#include "gedcom.h"
+#ifdef WITH_DMALLOC
+#include <dmalloc.h>
+#endif
+      
+#define _(string) gettext(string)
+#define N_(string) (string)
+
+typedef enum {
+  T_NULL,
+  
+  T_header, T_submission, T_submitter, T_family, T_individual,
+  T_multimedia, T_note, T_repository, T_source, T_user_rec,
+  
+  T_address, T_event, T_place, T_source_citation, T_text,
+  T_note_sub, T_multimedia_link, T_lds_event, T_user_ref_number,
+  T_change_date, T_personal_name, T_family_link, T_pedigree,
+  T_association, T_source_event, T_source_description
+} OBJ_TYPE;
+
+struct Gom_ctxt_struct {
+  int ctxt_type;
+  OBJ_TYPE obj_type;
+  void* ctxt_ptr;
+};
+
+typedef struct Gom_ctxt_struct *Gom_ctxt;
+
+Gom_ctxt make_gom_ctxt(int ctxt_type, OBJ_TYPE obj_type, void *ctxt_ptr);
+void destroy_gom_ctxt(Gom_ctxt ctxt);
+void gom_cast_error(char* file, int line, OBJ_TYPE expected, OBJ_TYPE found);
+void gom_unexpected_context(char* file, int line, OBJ_TYPE found);
+
+#define MAKE_GOM_CTXT(CTXT_TYPE, STRUCTTYPE, CTXT_PTR)                        \
+  make_gom_ctxt(CTXT_TYPE, T_ ## STRUCTTYPE, CTXT_PTR)
+
+#define SAFE_CTXT_CAST(STRUCTTYPE, VAL)                                       \
+  (((VAL)->obj_type == T_ ## STRUCTTYPE) ?                                    \
+   (VAL)->ctxt_ptr :                                                          \
+   (gom_cast_error(__FILE__, __LINE__, T_ ## STRUCTTYPE, (VAL)->obj_type),    \
+    (VAL)->ctxt_ptr))
+
+#define SAFE_FREE(PTR)                                                        \
+  if (PTR) {                                                                  \
+    free(PTR);                                                                \
+    PTR = NULL;                                                               \
+  }
+
+#define UNEXPECTED_CONTEXT(CTXT_TYPE)                                         \
+  gom_unexpected_context(__FILE__, __LINE__, CTXT_TYPE)
+
+void def_rec_end(Gedcom_rec rec, Gedcom_ctxt self);
+void def_elt_end(Gedcom_elt elt, Gedcom_ctxt parent, Gedcom_ctxt self,
+                Gedcom_val parsed_value);
+void set_xref_type(struct xref_value *xr, char* str);
+
+typedef enum {
+  WITHOUT_NL,
+  WITH_NL
+} NL_TYPE;
+
+char* concat_strings(NL_TYPE type, char *str1, const char *str2);
+struct date_value* dup_date(struct date_value dv);
+struct age_value*  dup_age(struct age_value age);
+
+/* Doubly-linked list, but last rec->next is NULL (doesn't go to first rec) */
+#define LINK_CHAIN_ELT(STRUCTTYPE, FIRSTVAL, VAL)                             \
+  {                                                                           \
+    struct STRUCTTYPE *_local_obj = VAL;                                      \
+    if (! FIRSTVAL) {                                                         \
+      VAL->next = NULL;                                                       \
+      VAL->previous = _local_obj;                                             \
+      FIRSTVAL = VAL;                                                         \
+    }                                                                         \
+    else {                                                                    \
+      VAL->next = NULL;                                                       \
+      FIRSTVAL->previous->next = VAL;                                         \
+      VAL->previous = FIRSTVAL->previous;                                     \
+      FIRSTVAL->previous = VAL;                                               \
+    }                                                                         \
+  }
+
+#define MAKE_CHAIN_ELT(STRUCTTYPE, FIRSTVAL, VAL)                             \
+  {                                                                           \
+    VAL = (struct STRUCTTYPE*) malloc(sizeof(struct STRUCTTYPE));             \
+    memset (VAL, 0, sizeof(struct STRUCTTYPE));                               \
+    LINK_CHAIN_ELT(STRUCTTYPE, FIRSTVAL, VAL)                                 \
+  }
+
+void NULL_DESTROY(void* anything);
+
+#define DESTROY_CHAIN_ELTS(STRUCTTYPE, FIRSTVAL, DESTROYFUNC)                 \
+  {                                                                           \
+    if (FIRSTVAL) {                                                           \
+      struct STRUCTTYPE *runner, *next;                                       \
+      runner = FIRSTVAL;                                                      \
+      while (runner) {                                                        \
+       next = runner->next;                                                  \
+        DESTROYFUNC(runner);                                                  \
+        SAFE_FREE(runner);                                                    \
+       runner = next;                                                        \
+      }                                                                       \
+    }                                                                         \
+  }
+
+#define _REC_PARAMS_ Gedcom_rec rec, int level, Gedcom_val xref, char *tag,   \
+                     char *raw_value, int parsed_tag, Gedcom_val parsed_value
+
+#define _ELT_PARAMS_ Gedcom_elt elt, Gedcom_ctxt parent, int level, char *tag,\
+                     char *raw_value, int parsed_tag, Gedcom_val parsed_value
+
+#define REC_CB(STRUCTTYPE,CB_NAME,FUNC)                                       \
+  Gedcom_ctxt CB_NAME(_REC_PARAMS_)                                           \
+  {                                                                           \
+    struct xref_value* xr = GEDCOM_XREF_PTR(xref);                            \
+    if (! xr->object)                                                         \
+      xr->object = (Gedcom_ctxt) FUNC(xr->string);                            \
+    return (Gedcom_ctxt) MAKE_GOM_CTXT(rec, STRUCTTYPE, xr->object);          \
+  }
+
+#define GET_REC_BY_XREF(STRUCTTYPE,XREF_TYPE,FUNC_NAME)                       \
+  struct STRUCTTYPE *FUNC_NAME(char *xrefstr)                                 \
+  {                                                                           \
+    struct xref_value* xr = gedcom_get_by_xref(xrefstr);                      \
+    if (xr && (xr->type == XREF_TYPE) && xr->object)                          \
+      return (struct STRUCTTYPE*)(xr->object);                                \
+    else                                                                      \
+      return NULL;                                                            \
+  }
+
+#define STRING_CB(STRUCTTYPE,CB_NAME,FIELD)                                   \
+  Gedcom_ctxt CB_NAME(_ELT_PARAMS_)                                           \
+  {                                                                           \
+    char *str = GEDCOM_STRING(parsed_value);                                  \
+    struct STRUCTTYPE *obj                                                    \
+      = SAFE_CTXT_CAST(STRUCTTYPE, (Gom_ctxt)parent);                         \
+    if (obj) obj->FIELD = strdup(str);                                        \
+    return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, STRUCTTYPE, obj);                 \
+  }
+
+#define DATE_CB(STRUCTTYPE,CB_NAME,FIELD)                                     \
+  Gedcom_ctxt CB_NAME(_ELT_PARAMS_)                                           \
+  {                                                                           \
+    struct date_value dv = GEDCOM_DATE(parsed_value);                         \
+    struct STRUCTTYPE *obj                                                    \
+      = SAFE_CTXT_CAST(STRUCTTYPE, (Gom_ctxt)parent);                         \
+    if (obj) obj->FIELD = dup_date(dv);                                       \
+    return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, STRUCTTYPE, obj);                 \
+  }
+
+#define AGE_CB(STRUCTTYPE,CB_NAME,FIELD)                                      \
+  Gedcom_ctxt CB_NAME(_ELT_PARAMS_)                                           \
+  {                                                                           \
+    struct age_value age = GEDCOM_AGE(parsed_value);                          \
+    struct STRUCTTYPE *obj                                                    \
+      = SAFE_CTXT_CAST(STRUCTTYPE, (Gom_ctxt)parent);                         \
+    if (obj) obj->FIELD = dup_age(age);                                       \
+    return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, STRUCTTYPE, obj);                 \
+  }
+
+#define XREF_CB(STRUCTTYPE,CB_NAME,FIELD,FUNC)                                \
+  Gedcom_ctxt CB_NAME(_ELT_PARAMS_)                                           \
+  {                                                                           \
+    struct xref_value *xr = GEDCOM_XREF_PTR(parsed_value);                    \
+    struct STRUCTTYPE *obj                                                    \
+      = SAFE_CTXT_CAST(STRUCTTYPE, (Gom_ctxt)parent);                         \
+    if (! xr->object)                                                         \
+      xr->object = (Gedcom_ctxt) FUNC(xr->string);                            \
+    if (obj) obj->FIELD = xr;                                                 \
+    return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, STRUCTTYPE, obj);                 \
+  }
+
+#define XREF_LIST_CB(STRUCTTYPE,CB_NAME,FIELD,FUNC)                           \
+  Gedcom_ctxt CB_NAME(_ELT_PARAMS_)                                           \
+  {                                                                           \
+    struct xref_value *xr = GEDCOM_XREF_PTR(parsed_value);                    \
+    struct STRUCTTYPE *obj                                                    \
+      = SAFE_CTXT_CAST(STRUCTTYPE, (Gom_ctxt)parent);                         \
+    struct xref_list *xrl;                                                    \
+    if (! xr->object)                                                         \
+      xr->object = (Gedcom_ctxt) FUNC(xr->string);                            \
+    MAKE_CHAIN_ELT(xref_list, obj->FIELD, xrl);                               \
+    xrl->xref = xr;                                                           \
+    return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, STRUCTTYPE, obj);                 \
+  }
+
+#define NULL_CB(STRUCTTYPE,CB_NAME)                                           \
+  Gedcom_ctxt CB_NAME(_ELT_PARAMS_)                                           \
+  {                                                                           \
+    struct STRUCTTYPE *obj                                                    \
+      = SAFE_CTXT_CAST(STRUCTTYPE, (Gom_ctxt)parent);                         \
+    return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, STRUCTTYPE, obj);                 \
+  }
+
+#endif /* __GOM_INTERNAL_H */
diff --git a/gom/header.c b/gom/header.c
new file mode 100644 (file)
index 0000000..ddc2589
--- /dev/null
@@ -0,0 +1,165 @@
+/* Header object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include "header.h"
+#include "submission.h"
+#include "submitter.h"
+#include "address.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+struct header gom_header;
+
+Gedcom_ctxt head_start(_REC_PARAMS_)
+{
+  /* Nothing special */
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(rec, header, &gom_header);
+}
+
+STRING_CB(header, head_sour_start, source.id)
+STRING_CB(header, head_sour_name_start, source.name)
+STRING_CB(header, head_sour_vers_start, source.version)
+STRING_CB(header, head_sour_corp_start, source.corporation.name)
+STRING_CB(header, head_sour_data_start, source.data.name)
+DATE_CB(header, head_sour_data_date_start, source.data.date)
+STRING_CB(header, head_sour_data_copr_start, source.data.copyright)
+STRING_CB(header, head_dest_start, destination)
+XREF_CB(header, head_subm_start, submitter, make_submitter_record)
+XREF_CB(header, head_subn_start, submission, make_submission_record)
+DATE_CB(header, head_date_start, date)
+STRING_CB(header, head_date_time_start, time)
+STRING_CB(header, head_file_start, filename)
+STRING_CB(header, head_copr_start, copyright)
+NULL_CB(header, head_gedc_start)
+STRING_CB(header, head_gedc_vers_start, gedcom.version)
+STRING_CB(header, head_gedc_form_start, gedcom.form)
+STRING_CB(header, head_char_start, charset.name)
+STRING_CB(header, head_char_vers_start, charset.version)
+STRING_CB(header, head_lang_start, language)
+NULL_CB(header, head_plac_start)
+STRING_CB(header, head_plac_form_start, place_hierarchy)
+STRING_CB(header, head_note_start, note)
+     
+void header_add_address(Gom_ctxt ctxt, struct address* addr)
+{
+  struct header *head = SAFE_CTXT_CAST(header, ctxt);
+  head->source.corporation.address = addr;
+}
+
+void header_add_phone(Gom_ctxt ctxt, char* phone)
+{
+  struct header *head = SAFE_CTXT_CAST(header, ctxt);
+  struct header_corporation *corp = &(head->source.corporation);
+  if (! corp->phone[0])
+    corp->phone[0] = strdup(phone);
+  else if (! corp->phone[1])
+    corp->phone[1] = strdup(phone);
+  else if (! corp->phone[2])
+    corp->phone[2] = strdup(phone);
+}
+
+void header_add_to_note(NL_TYPE type, Gom_ctxt ctxt, char* str)
+{
+  struct header *head = SAFE_CTXT_CAST(header, ctxt);
+  head->note = concat_strings (type, head->note, str);
+}
+
+void header_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct header *head = SAFE_CTXT_CAST(header, ctxt);
+  LINK_CHAIN_ELT(user_data, head->extra, data)
+}
+
+void header_subscribe()
+{
+  gedcom_subscribe_to_record(REC_HEAD, head_start, def_rec_end);
+  gedcom_subscribe_to_element(ELT_HEAD_SOUR, head_sour_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_SOUR_NAME, head_sour_name_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_SOUR_VERS, head_sour_vers_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_SOUR_CORP, head_sour_corp_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_SOUR_DATA, head_sour_data_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_SOUR_DATA_DATE,
+                             head_sour_data_date_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_SOUR_DATA_COPR,
+                             head_sour_data_copr_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_DEST, head_dest_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_DATE, head_date_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_DATE_TIME,
+                             head_date_time_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_SUBM, head_subm_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_SUBN, head_subn_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_FILE, head_file_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_COPR, head_copr_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_GEDC, head_gedc_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_GEDC_VERS,
+                             head_gedc_vers_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_GEDC_FORM,
+                             head_gedc_form_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_CHAR, head_char_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_CHAR_VERS,
+                             head_char_vers_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_LANG, head_lang_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_PLAC, head_plac_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_PLAC_FORM,
+                             head_plac_form_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_HEAD_NOTE, head_note_start, def_elt_end);
+}
+
+void header_cleanup()
+{
+  SAFE_FREE(gom_header.source.id);
+  SAFE_FREE(gom_header.source.name);
+  SAFE_FREE(gom_header.source.version);
+  SAFE_FREE(gom_header.source.corporation.name);
+  address_cleanup(gom_header.source.corporation.address);
+  SAFE_FREE(gom_header.source.corporation.phone[0]);
+  SAFE_FREE(gom_header.source.corporation.phone[1]);
+  SAFE_FREE(gom_header.source.corporation.phone[2]);
+  SAFE_FREE(gom_header.source.data.name);
+  SAFE_FREE(gom_header.source.data.date);
+  SAFE_FREE(gom_header.source.data.copyright);
+  SAFE_FREE(gom_header.destination);
+  SAFE_FREE(gom_header.date);
+  SAFE_FREE(gom_header.time);
+  SAFE_FREE(gom_header.filename);
+  SAFE_FREE(gom_header.copyright);
+  SAFE_FREE(gom_header.gedcom.version);
+  SAFE_FREE(gom_header.gedcom.form);
+  SAFE_FREE(gom_header.charset.name);
+  SAFE_FREE(gom_header.charset.version);
+  SAFE_FREE(gom_header.language);
+  SAFE_FREE(gom_header.place_hierarchy);
+  SAFE_FREE(gom_header.note);
+  DESTROY_CHAIN_ELTS(user_data, gom_header.extra, user_data_cleanup)
+}
+
+struct header* gom_get_header()
+{
+  return &gom_header;
+}
diff --git a/gom/header.h b/gom/header.h
new file mode 100644 (file)
index 0000000..3caf8c0
--- /dev/null
@@ -0,0 +1,37 @@
+/* Include file for the header object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __HEADER_H
+#define __HEADER_H
+
+#include "gom_internal.h"
+#include "gom.h"
+
+void header_subscribe();
+void header_cleanup();
+void header_add_address(Gom_ctxt header, struct address* addr);
+void header_add_phone  (Gom_ctxt header, char* phone);
+void header_add_to_note(NL_TYPE type, Gom_ctxt header, char* str);
+void header_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __HEADER_H */
diff --git a/gom/individual.c b/gom/individual.c
new file mode 100644 (file)
index 0000000..df279d9
--- /dev/null
@@ -0,0 +1,203 @@
+/* Individual object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "individual.h"
+#include "event.h"
+#include "personal_name.h"
+#include "lds_event.h"
+#include "family_link.h"
+#include "association.h"
+#include "submitter.h"
+#include "source_citation.h"
+#include "multimedia_link.h"
+#include "note_sub.h"
+#include "user_ref.h"
+#include "change_date.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+struct individual* gom_first_individual = NULL;
+
+REC_CB(individual, indi_start, make_individual_record)
+GET_REC_BY_XREF(individual, XREF_INDI, gom_get_individual_by_xref)
+STRING_CB(individual, indi_resn_start, restriction_notice)
+STRING_CB(individual, indi_sex_start, sex)
+XREF_LIST_CB(individual, indi_subm_start, submitters, make_submitter_record)
+XREF_LIST_CB(individual, indi_alia_start, alias, make_individual_record)
+XREF_LIST_CB(individual, indi_anci_start, ancestor_interest,
+            make_submitter_record)
+XREF_LIST_CB(individual, indi_desi_start, descendant_interest,
+            make_submitter_record)
+STRING_CB(individual, indi_rfn_start, record_file_nr)
+STRING_CB(individual, indi_afn_start, ancestral_file_nr)
+
+void individual_subscribe()
+{
+  gedcom_subscribe_to_record(REC_INDI, indi_start, def_rec_end);
+  gedcom_subscribe_to_element(ELT_INDI_RESN, indi_resn_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_INDI_SEX, indi_sex_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_INDI_SUBM, indi_subm_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_INDI_ALIA, indi_alia_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_INDI_ANCI, indi_anci_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_INDI_DESI, indi_desi_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_INDI_RFN, indi_rfn_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_INDI_AFN, indi_afn_start, def_elt_end);
+}
+
+void individual_add_event(Gom_ctxt ctxt, struct event* evt)
+{
+  struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
+  LINK_CHAIN_ELT(event, indiv->event, evt)
+}
+
+void individual_add_attribute(Gom_ctxt ctxt, struct event* evt)
+{
+  struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
+  LINK_CHAIN_ELT(event, indiv->attribute, evt)
+}
+
+void individual_add_name(Gom_ctxt ctxt, struct personal_name* name)
+{
+  struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
+  LINK_CHAIN_ELT(personal_name, indiv->name, name)
+}
+
+void individual_add_lio(Gom_ctxt ctxt, struct lds_event* evt)
+{
+  struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
+  LINK_CHAIN_ELT(lds_event, indiv->lds_individual_ordinance, evt)
+}
+
+void individual_add_family_link(Gom_ctxt ctxt, int ctxt_type,
+                               struct family_link* link)
+{
+  struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
+  switch (ctxt_type) {
+    case ELT_SUB_FAMC:
+      LINK_CHAIN_ELT(family_link, indiv->child_to_family, link)
+      break;
+    case ELT_SUB_FAMS:
+      LINK_CHAIN_ELT(family_link, indiv->spouse_to_family, link)
+      break;
+    default:
+      UNEXPECTED_CONTEXT(ctxt_type);
+  }
+}
+
+void individual_add_association(Gom_ctxt ctxt, struct association* assoc)
+{
+  struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
+  LINK_CHAIN_ELT(association, indiv->association, assoc)
+}
+
+void individual_add_citation(Gom_ctxt ctxt, struct source_citation* cit)
+{
+  struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
+  LINK_CHAIN_ELT(source_citation, indiv->citation, cit)
+}
+
+void individual_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link)
+{
+  struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
+  LINK_CHAIN_ELT(multimedia_link, indiv->mm_link, link)
+}
+
+void individual_add_note(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
+  LINK_CHAIN_ELT(note_sub, indiv->note, note)
+}
+
+void individual_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref)
+{
+  struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
+  LINK_CHAIN_ELT(user_ref_number, indiv->ref, ref)
+}
+
+void individual_set_record_id(Gom_ctxt ctxt, char *rin)
+{
+  struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
+  indiv->record_id = strdup(rin);
+}
+
+void individual_set_change_date(Gom_ctxt ctxt, struct change_date* chan)
+{
+  struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
+  indiv->change_date = chan;
+}
+
+void individual_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct individual *obj = SAFE_CTXT_CAST(individual, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void individual_cleanup(struct individual* indiv)
+{
+  SAFE_FREE(indiv->xrefstr);
+  SAFE_FREE(indiv->restriction_notice);
+  DESTROY_CHAIN_ELTS(personal_name, indiv->name, name_cleanup)
+  SAFE_FREE(indiv->sex);
+  DESTROY_CHAIN_ELTS(event, indiv->event, event_cleanup)
+  DESTROY_CHAIN_ELTS(event, indiv->attribute, event_cleanup)
+  DESTROY_CHAIN_ELTS(lds_event, indiv->lds_individual_ordinance,
+                    lds_event_cleanup)
+  DESTROY_CHAIN_ELTS(family_link, indiv->child_to_family, family_link_cleanup)
+  DESTROY_CHAIN_ELTS(family_link, indiv->spouse_to_family, family_link_cleanup)
+  DESTROY_CHAIN_ELTS(xref_list, indiv->submitters, NULL_DESTROY)
+  DESTROY_CHAIN_ELTS(association, indiv->association, association_cleanup)  
+  DESTROY_CHAIN_ELTS(xref_list, indiv->alias, NULL_DESTROY)
+  DESTROY_CHAIN_ELTS(xref_list, indiv->ancestor_interest, NULL_DESTROY)
+  DESTROY_CHAIN_ELTS(xref_list, indiv->descendant_interest, NULL_DESTROY)
+  DESTROY_CHAIN_ELTS(source_citation, indiv->citation, citation_cleanup)
+  DESTROY_CHAIN_ELTS(multimedia_link, indiv->mm_link, multimedia_link_cleanup)
+  DESTROY_CHAIN_ELTS(note_sub, indiv->note, note_sub_cleanup)
+  SAFE_FREE(indiv->record_file_nr);
+  SAFE_FREE(indiv->ancestral_file_nr);
+  DESTROY_CHAIN_ELTS(user_ref_number, indiv->ref, user_ref_cleanup)
+  SAFE_FREE(indiv->record_id);
+  change_date_cleanup(indiv->change_date);
+  DESTROY_CHAIN_ELTS(user_data, indiv->extra, user_data_cleanup)
+}
+
+void individuals_cleanup()
+{
+  DESTROY_CHAIN_ELTS(individual, gom_first_individual, individual_cleanup);
+}
+
+struct individual* gom_get_first_individual()
+{
+  return gom_first_individual;
+}
+
+struct individual* make_individual_record(char* xrefstr)
+{
+  struct individual* indiv;
+  MAKE_CHAIN_ELT(individual, gom_first_individual, indiv);
+  indiv->xrefstr = strdup(xrefstr);
+  return indiv;
+}
diff --git a/gom/individual.h b/gom/individual.h
new file mode 100644 (file)
index 0000000..9e17527
--- /dev/null
@@ -0,0 +1,48 @@
+/* Include file for the individual object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __INDIVIDUAL_H
+#define __INDIVIDUAL_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void individual_subscribe();
+void individuals_cleanup();
+struct individual* make_individual_record(char* xref);
+void individual_add_event(Gom_ctxt ctxt, struct event* evt);
+void individual_add_attribute(Gom_ctxt ctxt, struct event* evt);
+void individual_add_name(Gom_ctxt ctxt, struct personal_name* name);
+void individual_add_lio(Gom_ctxt ctxt, struct lds_event* evt);
+void individual_add_family_link(Gom_ctxt ctxt, int ctxt_type,
+                               struct family_link* link);
+void individual_add_association(Gom_ctxt ctxt, struct association* assoc);
+void individual_add_citation(Gom_ctxt ctxt, struct source_citation* cit);
+void individual_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link);
+void individual_add_note(Gom_ctxt ctxt, struct note_sub* note);
+void individual_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
+void individual_set_record_id(Gom_ctxt ctxt, char *rin);
+void individual_set_change_date(Gom_ctxt ctxt, struct change_date* chan);
+void individual_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __INDIVIDUAL_H */
diff --git a/gom/lds_event.c b/gom/lds_event.c
new file mode 100644 (file)
index 0000000..578c0c8
--- /dev/null
@@ -0,0 +1,121 @@
+/* LDS spouse sealing sub-structure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "lds_event.h"
+#include "family.h"
+#include "individual.h"
+#include "note_sub.h"
+#include "source_citation.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+Gedcom_ctxt sub_lds_event_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct lds_event *lds_evt = NULL;
+
+  if (ctxt) {
+    lds_evt = (struct lds_event*)malloc(sizeof(struct lds_event));
+    memset (lds_evt, 0, sizeof(struct lds_event));
+
+    switch (ctxt->ctxt_type) {
+      case REC_FAM:
+       family_add_lss(ctxt, lds_evt); break;
+      case REC_INDI:
+       individual_add_lio(ctxt, lds_evt); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, lds_event, lds_evt);
+}
+
+STRING_CB(lds_event, sub_lds_event_stat_start, date_status)
+DATE_CB(lds_event, sub_lds_event_date_start, date)
+STRING_CB(lds_event, sub_lds_event_temp_start, temple_code)
+STRING_CB(lds_event, sub_lds_event_plac_start, place_living_ordinance)
+XREF_CB(lds_event, sub_lds_event_famc_start, family, make_family_record)
+     
+void lds_event_subscribe()
+{
+  gedcom_subscribe_to_element(ELT_SUB_LSS_SLGS,
+                             sub_lds_event_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_LIO_BAPL,
+                             sub_lds_event_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_LIO_SLGC,
+                             sub_lds_event_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_LSS_SLGS_STAT,
+                             sub_lds_event_stat_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_LIO_BAPL_STAT,
+                             sub_lds_event_stat_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_LSS_SLGS_DATE,
+                             sub_lds_event_date_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_LIO_BAPL_DATE,
+                             sub_lds_event_date_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_LSS_SLGS_TEMP,
+                             sub_lds_event_temp_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_LIO_BAPL_TEMP,
+                             sub_lds_event_temp_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_LSS_SLGS_PLAC,
+                             sub_lds_event_plac_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_LIO_BAPL_PLAC,
+                             sub_lds_event_plac_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_LIO_SLGC_FAMC,
+                             sub_lds_event_famc_start, def_elt_end);
+}
+
+void lds_event_add_note(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct lds_event *lds = SAFE_CTXT_CAST(lds_event, ctxt);
+  LINK_CHAIN_ELT(note_sub, lds->note, note)    
+}
+
+void lds_event_add_citation(Gom_ctxt ctxt, struct source_citation* cit)
+{
+  struct lds_event *lds = SAFE_CTXT_CAST(lds_event, ctxt);
+  LINK_CHAIN_ELT(source_citation, lds->citation, cit)    
+}
+
+void lds_event_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct lds_event *obj = SAFE_CTXT_CAST(lds_event, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void lds_event_cleanup(struct lds_event* lds)
+{
+  if (lds) {
+    SAFE_FREE(lds->date_status);
+    SAFE_FREE(lds->date);
+    SAFE_FREE(lds->temple_code);
+    SAFE_FREE(lds->place_living_ordinance);
+    DESTROY_CHAIN_ELTS(source_citation, lds->citation, citation_cleanup)  
+    DESTROY_CHAIN_ELTS(note_sub, lds->note, note_sub_cleanup)
+    DESTROY_CHAIN_ELTS(user_data, lds->extra, user_data_cleanup)
+  }
+}
diff --git a/gom/lds_event.h b/gom/lds_event.h
new file mode 100644 (file)
index 0000000..fde8b35
--- /dev/null
@@ -0,0 +1,37 @@
+/* Include file for the LDS event substructure in the gedcom object
+   model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __LDS_EVENT_H
+#define __LDS_EVENT_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void lds_event_subscribe();
+void lds_event_cleanup(struct lds_event* mm);
+void lds_event_add_note(Gom_ctxt ctxt, struct note_sub* note);
+void lds_event_add_citation(Gom_ctxt ctxt, struct source_citation* cit);
+void lds_event_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __LDS_EVENT_H */
diff --git a/gom/multimedia.c b/gom/multimedia.c
new file mode 100644 (file)
index 0000000..43dd6b7
--- /dev/null
@@ -0,0 +1,126 @@
+/* Multimedia object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "multimedia.h"
+#include "note_sub.h"
+#include "user_ref.h"
+#include "change_date.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+struct multimedia* gom_first_multimedia = NULL;
+
+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)     
+XREF_CB(multimedia, obje_obje_start, continued, make_multimedia_record)
+
+Gedcom_ctxt obje_blob_cont_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
+  char *str = GEDCOM_STRING(parsed_value);
+  if (obj->data)
+    obj->data = concat_strings (WITHOUT_NL, obj->data, str);
+  else
+    obj->data = strdup(str);
+  return (Gedcom_ctxt) make_gom_ctxt(elt, ctxt->obj_type, ctxt->ctxt_ptr);
+}
+
+void multimedia_subscribe()
+{
+  gedcom_subscribe_to_record(REC_OBJE, obje_start, def_rec_end);
+  gedcom_subscribe_to_element(ELT_OBJE_FORM, obje_form_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_OBJE_TITL, obje_titl_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_OBJE_BLOB, obje_blob_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_OBJE_BLOB_CONT, obje_blob_cont_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_OBJE_OBJE, obje_obje_start, def_elt_end);
+}
+
+void multimedia_add_note(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct multimedia* obj = SAFE_CTXT_CAST(multimedia, ctxt);
+  LINK_CHAIN_ELT(note_sub, obj->note, note)
+}
+
+void multimedia_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref)
+{
+  struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
+  LINK_CHAIN_ELT(user_ref_number, obj->ref, ref)
+}
+
+void multimedia_set_record_id(Gom_ctxt ctxt, char *rin)
+{
+  struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
+  obj->record_id = strdup(rin);
+}
+
+void multimedia_set_change_date(Gom_ctxt ctxt, struct change_date* chan)
+{
+  struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
+  obj->change_date = chan;
+}
+
+void multimedia_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void multimedia_cleanup(struct multimedia* obj)
+{
+  SAFE_FREE(obj->xrefstr);
+  SAFE_FREE(obj->form);
+  SAFE_FREE(obj->title);
+  DESTROY_CHAIN_ELTS(note_sub, obj->note, note_sub_cleanup)
+  SAFE_FREE(obj->data);
+  DESTROY_CHAIN_ELTS(user_ref_number, obj->ref, user_ref_cleanup)
+  SAFE_FREE(obj->record_id);
+  change_date_cleanup(obj->change_date);
+  DESTROY_CHAIN_ELTS(user_data, obj->extra, user_data_cleanup)
+}
+
+void multimedias_cleanup()
+{
+  DESTROY_CHAIN_ELTS(multimedia, gom_first_multimedia, multimedia_cleanup);
+}
+
+struct multimedia* gom_get_first_multimedia()
+{
+  return gom_first_multimedia;
+}
+
+struct multimedia* make_multimedia_record(char* xrefstr)
+{
+  struct multimedia* multi;
+  MAKE_CHAIN_ELT(multimedia, gom_first_multimedia, multi);
+  multi->xrefstr = strdup(xrefstr);
+  return multi;
+}
diff --git a/gom/multimedia.h b/gom/multimedia.h
new file mode 100644 (file)
index 0000000..5284126
--- /dev/null
@@ -0,0 +1,39 @@
+/* Include file for the multimedia object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __MULTIMEDIA_H
+#define __MULTIMEDIA_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void multimedia_subscribe();
+void multimedias_cleanup();
+struct multimedia* make_multimedia_record(char* xref);
+void multimedia_add_note(Gom_ctxt ctxt, struct note_sub* note);
+void multimedia_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
+void multimedia_set_record_id(Gom_ctxt ctxt, char *rin);
+void multimedia_set_change_date(Gom_ctxt ctxt, struct change_date* chan);
+void multimedia_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __MULTIMEDIA_H */
diff --git a/gom/multimedia_link.c b/gom/multimedia_link.c
new file mode 100644 (file)
index 0000000..d16b2dc
--- /dev/null
@@ -0,0 +1,115 @@
+/* Multimedia link sub-structure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "multimedia_link.h"
+#include "event.h"
+#include "source_citation.h"
+#include "note_sub.h"
+#include "family.h"
+#include "individual.h"
+#include "source.h"
+#include "submitter.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+Gedcom_ctxt sub_obje_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct multimedia_link *mm = NULL;
+
+  if (ctxt) {
+    mm = (struct multimedia_link *)malloc(sizeof(struct multimedia_link));
+    memset (mm, 0, sizeof(struct multimedia_link));
+    if (GEDCOM_IS_XREF_PTR(parsed_value))
+      mm->reference = GEDCOM_XREF_PTR(parsed_value);
+
+    switch (ctxt->ctxt_type) {
+      case ELT_SUB_FAM_EVT:
+      case ELT_SUB_FAM_EVT_EVEN:
+      case ELT_SUB_INDIV_ATTR:
+      case ELT_SUB_INDIV_RESI:
+      case ELT_SUB_INDIV_BIRT:
+      case ELT_SUB_INDIV_GEN:
+      case ELT_SUB_INDIV_ADOP:
+      case ELT_SUB_INDIV_EVEN:
+       event_add_mm_link(ctxt, mm); break;
+      case ELT_SUB_SOUR:
+       citation_add_mm_link(ctxt, mm); break;
+      case REC_FAM:
+       family_add_mm_link(ctxt, mm); break;
+      case REC_INDI:
+       individual_add_mm_link(ctxt, mm); break;
+      case REC_SOUR:
+       source_add_mm_link(ctxt, mm); break;
+      case REC_SUBM:
+       submitter_add_mm_link(ctxt, mm); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, multimedia_link, mm);
+}
+
+STRING_CB(multimedia_link, sub_obje_form_start, form)
+STRING_CB(multimedia_link, sub_obje_titl_start, title)
+STRING_CB(multimedia_link, sub_obje_file_start, file)
+     
+void multimedia_link_subscribe()
+{
+  gedcom_subscribe_to_element(ELT_SUB_MULTIM_OBJE,
+                             sub_obje_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_MULTIM_OBJE_FORM,
+                             sub_obje_form_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_MULTIM_OBJE_TITL,
+                             sub_obje_titl_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_MULTIM_OBJE_FILE,
+                             sub_obje_file_start, def_elt_end);
+}
+
+void multimedia_link_add_note(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct multimedia_link *mm = SAFE_CTXT_CAST(multimedia_link, ctxt);
+  LINK_CHAIN_ELT(note_sub, mm->note, note)    
+}
+
+void multimedia_link_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct multimedia_link *obj = SAFE_CTXT_CAST(multimedia_link, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void multimedia_link_cleanup(struct multimedia_link* mm)
+{
+  if (mm) {
+    SAFE_FREE(mm->form);
+    SAFE_FREE(mm->title);
+    SAFE_FREE(mm->file);
+    DESTROY_CHAIN_ELTS(note_sub, mm->note, note_sub_cleanup)
+    DESTROY_CHAIN_ELTS(user_data, mm->extra, user_data_cleanup)
+  }
+}
diff --git a/gom/multimedia_link.h b/gom/multimedia_link.h
new file mode 100644 (file)
index 0000000..5ee0035
--- /dev/null
@@ -0,0 +1,36 @@
+/* Include file for the multimedia link substructure in the gedcom object
+   model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __MULTIMEDIA_LINK_H
+#define __MULTIMEDIA_LINK_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void multimedia_link_subscribe();
+void multimedia_link_cleanup(struct multimedia_link* mm);
+void multimedia_link_add_note(Gom_ctxt ctxt, struct note_sub* note);
+void multimedia_link_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __MULTIMEDIA_LINK_H */
diff --git a/gom/note.c b/gom/note.c
new file mode 100644 (file)
index 0000000..46e88e3
--- /dev/null
@@ -0,0 +1,157 @@
+/* Note sub-structure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "header.h"
+#include "source_citation.h"
+#include "note.h"
+#include "note_sub.h"
+#include "user_ref.h"
+#include "change_date.h"
+#include "source.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+struct note* gom_first_note = NULL;
+
+Gedcom_ctxt note_start(_REC_PARAMS_)
+{
+  struct xref_value* xr = GEDCOM_XREF_PTR(xref);
+  struct note* note = (struct note*) xr->object;
+  if (! xr->object) {
+    note = make_note_record(xr->string);
+    xr->object = (Gedcom_ctxt) note;
+  }
+  note->text = strdup(GEDCOM_STRING(parsed_value));
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(rec, note, xr->object);
+}
+
+GET_REC_BY_XREF(note, XREF_NOTE, gom_get_note_by_xref)
+     
+Gedcom_ctxt sub_cont_conc_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+
+  if (ctxt) {
+    char *str = GEDCOM_STRING(parsed_value);
+    NL_TYPE type = (elt == ELT_SUB_CONT ? WITH_NL : WITHOUT_NL);
+    switch (ctxt->ctxt_type) {
+      case ELT_HEAD_NOTE:
+       header_add_to_note(type, ctxt, str); break;
+      case ELT_SUB_SOUR:
+       citation_add_to_desc(type, ctxt, str); break;
+      case ELT_SUB_SOUR_TEXT:
+       citation_add_to_text(type, ctxt, str); break;
+      case ELT_SUB_NOTE:
+       note_sub_add_to_note(type, ctxt, str); break;
+      case REC_NOTE:
+       note_add_to_note(type, ctxt, str); break;
+      case ELT_SOUR_AUTH:
+      case ELT_SOUR_TITL:
+      case ELT_SOUR_PUBL:
+      case ELT_SOUR_TEXT:
+       source_add_to_value(type, ctxt, str); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+    return (Gedcom_ctxt) make_gom_ctxt(elt, ctxt->obj_type, ctxt->ctxt_ptr);
+  }
+  else {
+    return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, NULL, NULL);
+  }
+}
+
+void note_subscribe()
+{
+  gedcom_subscribe_to_record(REC_NOTE, note_start, def_rec_end);
+  gedcom_subscribe_to_element(ELT_SUB_CONT, sub_cont_conc_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_CONC, sub_cont_conc_start, def_elt_end);
+}
+
+void note_add_to_note(NL_TYPE type, Gom_ctxt ctxt, char* str)
+{
+  struct note *note = SAFE_CTXT_CAST(note, ctxt);
+  note->text = concat_strings (type, note->text, str);
+}
+
+void note_add_citation(Gom_ctxt ctxt, struct source_citation* cit)
+{
+  struct note *note = SAFE_CTXT_CAST(note, ctxt);
+  LINK_CHAIN_ELT(source_citation, note->citation, cit)    
+}
+
+void note_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref)
+{
+  struct note *note = SAFE_CTXT_CAST(note, ctxt);
+  LINK_CHAIN_ELT(user_ref_number, note->ref, ref)
+}
+
+void note_set_record_id(Gom_ctxt ctxt, char *rin)
+{
+  struct note *note = SAFE_CTXT_CAST(note, ctxt);
+  note->record_id = strdup(rin);
+}
+
+void note_set_change_date(Gom_ctxt ctxt, struct change_date* chan)
+{
+  struct note *note = SAFE_CTXT_CAST(note, ctxt);
+  note->change_date = chan;
+}
+
+void note_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct note *obj = SAFE_CTXT_CAST(note, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void note_cleanup(struct note* note)
+{
+  SAFE_FREE(note->xrefstr);
+  SAFE_FREE(note->text);
+  DESTROY_CHAIN_ELTS(source_citation, note->citation, citation_cleanup)
+  DESTROY_CHAIN_ELTS(user_ref_number, note->ref, user_ref_cleanup)
+  SAFE_FREE(note->record_id);
+  change_date_cleanup(note->change_date);
+  DESTROY_CHAIN_ELTS(user_data, note->extra, user_data_cleanup)
+}
+
+void notes_cleanup()
+{
+  DESTROY_CHAIN_ELTS(note, gom_first_note, note_cleanup);
+}
+
+struct note* gom_get_first_note()
+{
+  return gom_first_note;
+}
+
+struct note* make_note_record(char* xrefstr)
+{
+  struct note* note;
+  MAKE_CHAIN_ELT(note, gom_first_note, note);
+  note->xrefstr = strdup(xrefstr);
+  return note;
+}
diff --git a/gom/note.h b/gom/note.h
new file mode 100644 (file)
index 0000000..b47b3b0
--- /dev/null
@@ -0,0 +1,40 @@
+/* Include file for the note substructure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __NOTE_H
+#define __NOTE_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void note_subscribe();
+void notes_cleanup();
+struct note* make_note_record(char* xref);
+void note_add_to_note(NL_TYPE type, Gom_ctxt ctxt, char* str);
+void note_add_citation(Gom_ctxt ctxt, struct source_citation* cit);
+void note_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
+void note_set_record_id(Gom_ctxt ctxt, char *rin);
+void note_set_change_date(Gom_ctxt ctxt, struct change_date* chan);
+void note_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __NOTE_H */
diff --git a/gom/note_sub.c b/gom/note_sub.c
new file mode 100644 (file)
index 0000000..4f3aaec
--- /dev/null
@@ -0,0 +1,141 @@
+/* Note sub-structure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "note.h"
+#include "note_sub.h"
+#include "place.h"
+#include "event.h"
+#include "source_citation.h"
+#include "multimedia_link.h"
+#include "lds_event.h"
+#include "family.h"
+#include "change_date.h"
+#include "personal_name.h"
+#include "family_link.h"
+#include "association.h"
+#include "individual.h"
+#include "multimedia.h"
+#include "repository.h"
+#include "source.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+Gedcom_ctxt sub_note_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct note_sub *note = NULL;
+
+  if (ctxt) {
+    note = (struct note_sub *)malloc(sizeof(struct note_sub));
+    memset (note, 0, sizeof(struct note_sub));
+    if (GEDCOM_IS_STRING(parsed_value))
+      note->text = strdup(GEDCOM_STRING(parsed_value));
+    else if (GEDCOM_IS_XREF_PTR(parsed_value))
+      note->reference = GEDCOM_XREF_PTR(parsed_value);
+
+    switch (ctxt->ctxt_type) {
+      case ELT_SUB_PLAC:
+       place_add_note(ctxt, note); break;
+      case ELT_SUB_FAM_EVT:
+      case ELT_SUB_FAM_EVT_EVEN:
+      case ELT_SUB_INDIV_ATTR:
+      case ELT_SUB_INDIV_RESI:
+      case ELT_SUB_INDIV_BIRT:
+      case ELT_SUB_INDIV_GEN:
+      case ELT_SUB_INDIV_ADOP:
+      case ELT_SUB_INDIV_EVEN:
+       event_add_note(ctxt, note); break;
+      case ELT_SUB_SOUR:
+       citation_add_note(ctxt, note); break;
+      case ELT_SUB_MULTIM_OBJE:
+       multimedia_link_add_note(ctxt, note); break;
+      case ELT_SUB_LSS_SLGS:
+      case ELT_SUB_LIO_BAPL:
+      case ELT_SUB_LIO_SLGC:
+       lds_event_add_note(ctxt, note); break;
+      case REC_FAM:
+       family_add_note(ctxt, note); break;
+      case ELT_SUB_CHAN:
+       change_date_add_note(ctxt, note); break;
+      case ELT_SUB_PERS_NAME:
+       name_add_note(ctxt, note); break;
+      case ELT_SUB_FAMC: 
+      case ELT_SUB_FAMS:
+       family_link_add_note(ctxt, note); break;
+      case ELT_SUB_ASSO:
+       association_add_note(ctxt, note); break;
+      case REC_INDI:
+       individual_add_note(ctxt, note); break;
+      case REC_OBJE:
+       multimedia_add_note(ctxt, note); break;
+      case REC_REPO:
+       repository_add_note(ctxt, note); break;
+      case ELT_SOUR_DATA:
+       source_add_note_to_data(ctxt, note); break;
+      case ELT_SUB_REPO:
+       source_add_note_to_repo(ctxt, note); break;
+      case REC_SOUR:
+       source_add_note(ctxt, note); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, note_sub, note);
+}
+
+void note_sub_subscribe()
+{
+  gedcom_subscribe_to_element(ELT_SUB_NOTE, sub_note_start, def_elt_end);
+}
+
+void note_sub_add_citation(Gom_ctxt ctxt, struct source_citation* cit)
+{
+  struct note_sub *note = SAFE_CTXT_CAST(note_sub, ctxt);
+  LINK_CHAIN_ELT(source_citation, note->citation, cit)    
+}
+
+void note_sub_add_to_note(NL_TYPE type, Gom_ctxt ctxt, char* str)
+{
+  struct note_sub *note = SAFE_CTXT_CAST(note_sub, ctxt);
+  note->text = concat_strings (type, note->text, str);
+}
+
+void note_sub_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct note_sub *obj = SAFE_CTXT_CAST(note_sub, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void note_sub_cleanup(struct note_sub* note)
+{
+  if (note) {
+    SAFE_FREE(note->text);
+    DESTROY_CHAIN_ELTS(source_citation, note->citation, citation_cleanup)
+    DESTROY_CHAIN_ELTS(user_data, note->extra, user_data_cleanup)
+  }
+}
diff --git a/gom/note_sub.h b/gom/note_sub.h
new file mode 100644 (file)
index 0000000..8368d52
--- /dev/null
@@ -0,0 +1,36 @@
+/* Include file for the note substructure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __NOTE_SUB_H
+#define __NOTE_SUB_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void note_sub_subscribe();
+void note_sub_cleanup(struct note_sub* note);
+void note_sub_add_citation(Gom_ctxt ctxt, struct source_citation* cit);
+void note_sub_add_to_note(NL_TYPE type, Gom_ctxt ctxt, char* str);
+void note_sub_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __NOTE_SUB_H */
diff --git a/gom/personal_name.c b/gom/personal_name.c
new file mode 100644 (file)
index 0000000..b859ba7
--- /dev/null
@@ -0,0 +1,112 @@
+/* Personal name sub-structure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "personal_name.h"
+#include "source_citation.h"
+#include "note_sub.h"
+#include "individual.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+Gedcom_ctxt sub_name_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct personal_name *name = NULL;
+
+  if (ctxt) {
+    name = (struct personal_name *)malloc(sizeof(struct personal_name));
+    memset (name, 0, sizeof(struct personal_name));
+    name->name = strdup(GEDCOM_STRING(parsed_value));
+
+    switch (ctxt->ctxt_type) {
+      case REC_INDI:
+       individual_add_name(ctxt, name); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, personal_name, name);
+}
+
+STRING_CB(personal_name, sub_name_npfx_start, prefix)
+STRING_CB(personal_name, sub_name_givn_start, given)
+STRING_CB(personal_name, sub_name_nick_start, nickname)
+STRING_CB(personal_name, sub_name_spfx_start, surname_prefix)
+STRING_CB(personal_name, sub_name_surn_start, surname)
+STRING_CB(personal_name, sub_name_nsfx_start, suffix)
+
+void name_add_citation(Gom_ctxt ctxt, struct source_citation* cit)
+{
+  struct personal_name *name = SAFE_CTXT_CAST(personal_name, ctxt);
+  LINK_CHAIN_ELT(source_citation, name->citation, cit)  
+}
+
+void name_add_note(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct personal_name *name = SAFE_CTXT_CAST(personal_name, ctxt);
+  LINK_CHAIN_ELT(note_sub, name->note, note)  
+}
+
+void name_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct personal_name *obj = SAFE_CTXT_CAST(personal_name, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void name_subscribe()
+{
+  gedcom_subscribe_to_element(ELT_SUB_PERS_NAME, sub_name_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_PERS_NAME_NPFX, sub_name_npfx_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_PERS_NAME_GIVN, sub_name_givn_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_PERS_NAME_NICK, sub_name_nick_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_PERS_NAME_SPFX, sub_name_spfx_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_PERS_NAME_SURN, sub_name_surn_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_PERS_NAME_NSFX, sub_name_nsfx_start,
+                             def_elt_end);
+}
+
+void name_cleanup(struct personal_name* name)
+{
+  if (name) {
+    SAFE_FREE(name->name);
+    SAFE_FREE(name->prefix);
+    SAFE_FREE(name->given);
+    SAFE_FREE(name->nickname);
+    SAFE_FREE(name->surname_prefix);
+    SAFE_FREE(name->surname);
+    SAFE_FREE(name->suffix);
+    DESTROY_CHAIN_ELTS(source_citation, name->citation, citation_cleanup)
+    DESTROY_CHAIN_ELTS(note_sub, name->note, note_sub_cleanup)
+    DESTROY_CHAIN_ELTS(user_data, name->extra, user_data_cleanup)
+  }
+}
diff --git a/gom/personal_name.h b/gom/personal_name.h
new file mode 100644 (file)
index 0000000..2cc36d1
--- /dev/null
@@ -0,0 +1,36 @@
+/* Include file for the name substructure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __PERSONAL_NAME_H
+#define __PERSONAL_NAME_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void name_subscribe();
+void name_cleanup(struct personal_name* name);
+void name_add_citation(Gom_ctxt ctxt, struct source_citation* cit);
+void name_add_note(Gom_ctxt ctxt, struct note_sub* note);
+void name_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __PERSONAL_NAME_H */
diff --git a/gom/place.c b/gom/place.c
new file mode 100644 (file)
index 0000000..a77ff91
--- /dev/null
@@ -0,0 +1,101 @@
+/* Place sub-structure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "place.h"
+#include "address.h"
+#include "event.h"
+#include "source_citation.h"
+#include "note_sub.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+Gedcom_ctxt sub_place_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct place *place = NULL;
+
+  if (ctxt) {
+    place = (struct place *)malloc(sizeof(struct place));
+    memset (place, 0, sizeof(struct place));
+    place->value = strdup(GEDCOM_STRING(parsed_value));
+
+    switch (ctxt->ctxt_type) {
+      case ELT_SUB_FAM_EVT:
+      case ELT_SUB_FAM_EVT_EVEN:
+      case ELT_SUB_INDIV_ATTR:
+      case ELT_SUB_INDIV_RESI:
+      case ELT_SUB_INDIV_BIRT:
+      case ELT_SUB_INDIV_GEN:
+      case ELT_SUB_INDIV_ADOP:
+      case ELT_SUB_INDIV_EVEN:
+       event_add_place(ctxt, place); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, place, place);
+}
+
+STRING_CB(place, sub_place_form_start, place_hierarchy)
+
+void place_add_citation(Gom_ctxt ctxt, struct source_citation* cit)
+{
+  struct place *place = SAFE_CTXT_CAST(place, ctxt);
+  LINK_CHAIN_ELT(source_citation, place->citation, cit)  
+}
+
+void place_add_note(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct place *place = SAFE_CTXT_CAST(place, ctxt);
+  LINK_CHAIN_ELT(note_sub, place->note, note)  
+}
+
+void place_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct place *obj = SAFE_CTXT_CAST(place, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void place_subscribe()
+{
+  gedcom_subscribe_to_element(ELT_SUB_PLAC, sub_place_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_PLAC_FORM,
+                             sub_place_form_start, def_elt_end);
+}
+
+void place_cleanup(struct place* place)
+{
+  if (place) {
+    SAFE_FREE(place->value);
+    SAFE_FREE(place->place_hierarchy);
+    DESTROY_CHAIN_ELTS(source_citation, place->citation, citation_cleanup)  
+    DESTROY_CHAIN_ELTS(note_sub, place->note, note_sub_cleanup)
+    DESTROY_CHAIN_ELTS(user_data, place->extra, user_data_cleanup)
+  }
+  SAFE_FREE(place);
+}
diff --git a/gom/place.h b/gom/place.h
new file mode 100644 (file)
index 0000000..9e00869
--- /dev/null
@@ -0,0 +1,36 @@
+/* Include file for the place substructure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __PLACE_H
+#define __PLACE_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void place_subscribe();
+void place_cleanup(struct place* place);
+void place_add_citation(Gom_ctxt ctxt, struct source_citation* cit);
+void place_add_note(Gom_ctxt ctxt, struct note_sub* note);
+void place_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __PLACE_H */
diff --git a/gom/repository.c b/gom/repository.c
new file mode 100644 (file)
index 0000000..5fd8883
--- /dev/null
@@ -0,0 +1,126 @@
+/* Repository object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "repository.h"
+#include "address.h"
+#include "note_sub.h"
+#include "user_ref.h"
+#include "change_date.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+struct repository* gom_first_repository = NULL;
+
+REC_CB(repository, repo_start, make_repository_record)
+GET_REC_BY_XREF(repository, XREF_REPO, gom_get_repository_by_xref)
+STRING_CB(repository, repo_name_start, name)
+
+void repository_subscribe()
+{
+  gedcom_subscribe_to_record(REC_REPO, repo_start, def_rec_end);
+  gedcom_subscribe_to_element(ELT_REPO_NAME, repo_name_start, def_elt_end);
+}
+
+void repository_add_address(Gom_ctxt ctxt, struct address* address)
+{
+  struct repository *repo = SAFE_CTXT_CAST(repository, ctxt);
+  repo->address = address;
+}
+
+void repository_add_phone(Gom_ctxt ctxt, char *phone)
+{
+  struct repository *repo = SAFE_CTXT_CAST(repository, ctxt);
+  if (! repo->phone[0])
+    repo->phone[0] = strdup(phone);
+  else if (! repo->phone[1])
+    repo->phone[1] = strdup(phone);
+  else if (! repo->phone[2])
+    repo->phone[2] = strdup(phone);
+}
+
+void repository_add_note(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct repository *repo = SAFE_CTXT_CAST(repository, ctxt);
+  LINK_CHAIN_ELT(note_sub, repo->note, note)
+}
+
+void repository_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref)
+{
+  struct repository *repo = SAFE_CTXT_CAST(repository, ctxt);
+  LINK_CHAIN_ELT(user_ref_number, repo->ref, ref)
+}
+
+void repository_set_record_id(Gom_ctxt ctxt, char *rin)
+{
+  struct repository *repo = SAFE_CTXT_CAST(repository, ctxt);
+  repo->record_id = strdup(rin);
+}
+
+void repository_set_change_date(Gom_ctxt ctxt, struct change_date* chan)
+{
+  struct repository *repo = SAFE_CTXT_CAST(repository, ctxt);
+  repo->change_date = chan;
+}
+
+void repository_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct repository *obj = SAFE_CTXT_CAST(repository, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void repository_cleanup(struct repository* repo)
+{
+  SAFE_FREE(repo->xrefstr);
+  SAFE_FREE(repo->name);
+  address_cleanup(repo->address);
+  SAFE_FREE(repo->phone[0]);
+  SAFE_FREE(repo->phone[1]);
+  SAFE_FREE(repo->phone[2]);
+  DESTROY_CHAIN_ELTS(note_sub, repo->note, note_sub_cleanup)
+  DESTROY_CHAIN_ELTS(user_ref_number, repo->ref, user_ref_cleanup)
+  SAFE_FREE(repo->record_id);
+  change_date_cleanup(repo->change_date);
+  DESTROY_CHAIN_ELTS(user_data, repo->extra, user_data_cleanup)
+}
+
+void repositories_cleanup()
+{
+  DESTROY_CHAIN_ELTS(repository, gom_first_repository, repository_cleanup);
+}
+
+struct repository* gom_get_first_repository()
+{
+  return gom_first_repository;
+}
+
+struct repository* make_repository_record(char* xrefstr)
+{
+  struct repository* repo;
+  MAKE_CHAIN_ELT(repository, gom_first_repository, repo);
+  repo->xrefstr = strdup(xrefstr);
+  return repo;
+}
diff --git a/gom/repository.h b/gom/repository.h
new file mode 100644 (file)
index 0000000..cee45fe
--- /dev/null
@@ -0,0 +1,41 @@
+/* Include file for the repository object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __REPOSITORY_H
+#define __REPOSITORY_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void repository_subscribe();
+void repositories_cleanup();
+struct repository* make_repository_record(char* xref);
+void repository_add_address(Gom_ctxt ctxt, struct address* address);
+void repository_add_phone(Gom_ctxt ctxt, char *phone);
+void repository_add_note(Gom_ctxt ctxt, struct note_sub* note);
+void repository_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
+void repository_set_record_id(Gom_ctxt ctxt, char *rin);
+void repository_set_change_date(Gom_ctxt ctxt, struct change_date* chan);
+void repository_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __REPOSITORY_H */
diff --git a/gom/source.c b/gom/source.c
new file mode 100644 (file)
index 0000000..f306784
--- /dev/null
@@ -0,0 +1,181 @@
+/* Source object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "source.h"
+#include "source_event.h"
+#include "note_sub.h"
+#include "source_description.h"
+#include "repository.h"
+#include "multimedia_link.h"
+#include "user_ref.h"
+#include "change_date.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+struct source* gom_first_source = NULL;
+
+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)
+STRING_CB(source, sour_abbr_start, abbreviation)
+STRING_CB(source, sour_publ_start, publication)
+STRING_CB(source, sour_text_start, text)
+XREF_CB(source, sour_repo_start, repository.link, make_repository_record)
+
+void source_subscribe()
+{
+  gedcom_subscribe_to_record(REC_SOUR, sour_start, def_rec_end);
+  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_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_SUB_REPO, sour_repo_start, def_elt_end);
+}
+
+void source_add_event(Gom_ctxt ctxt, struct source_event* evt)
+{
+  struct source *sour = SAFE_CTXT_CAST(source, ctxt);
+  LINK_CHAIN_ELT(source_event, sour->data.event, evt)  
+}
+
+void source_add_note_to_data(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct source *sour = SAFE_CTXT_CAST(source, ctxt);
+  LINK_CHAIN_ELT(note_sub, sour->data.note, note)  
+}
+
+void source_add_note_to_repo(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct source *sour = SAFE_CTXT_CAST(source, ctxt);
+  LINK_CHAIN_ELT(note_sub, sour->repository.note, note)  
+}
+
+void source_add_description(Gom_ctxt ctxt, struct source_description* desc)
+{
+  struct source *sour = SAFE_CTXT_CAST(source, ctxt);
+  LINK_CHAIN_ELT(source_description, sour->repository.description, desc)  
+}
+
+void source_add_to_value(NL_TYPE type, Gom_ctxt ctxt, char* str)
+{
+  struct source *sour = SAFE_CTXT_CAST(source, ctxt);
+  switch (ctxt->ctxt_type) {
+    case ELT_SOUR_AUTH:
+      sour->author = concat_strings (type, sour->author, str); break;
+    case ELT_SOUR_TITL:
+      sour->title = concat_strings (type, sour->title, str); break;
+    case ELT_SOUR_PUBL:
+      sour->publication = concat_strings (type, sour->publication, str); break;
+    case ELT_SOUR_TEXT:
+      sour->text = concat_strings (type, sour->text, str); 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);
+  LINK_CHAIN_ELT(multimedia_link, sour->mm_link, link)
+}
+
+void source_add_note(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct source *sour = SAFE_CTXT_CAST(source, ctxt);
+  LINK_CHAIN_ELT(note_sub, sour->note, note)
+}
+
+void source_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref)
+{
+  struct source *sour = SAFE_CTXT_CAST(source, ctxt);
+  LINK_CHAIN_ELT(user_ref_number, sour->ref, ref)
+}
+
+void source_set_record_id(Gom_ctxt ctxt, char *rin)
+{
+  struct source *sour = SAFE_CTXT_CAST(source, ctxt);
+  sour->record_id = strdup(rin);
+}
+
+void source_set_change_date(Gom_ctxt ctxt, struct change_date* chan)
+{
+  struct source *sour = SAFE_CTXT_CAST(source, ctxt);
+  sour->change_date = chan;
+}
+
+void source_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct source *obj = SAFE_CTXT_CAST(source, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void source_cleanup(struct source* sour)
+{
+  SAFE_FREE(sour->xrefstr);
+  DESTROY_CHAIN_ELTS(source_event, sour->data.event, source_event_cleanup)
+  SAFE_FREE(sour->data.agency)
+  DESTROY_CHAIN_ELTS(note_sub, sour->data.note, note_sub_cleanup)
+  SAFE_FREE(sour->author);
+  SAFE_FREE(sour->title);
+  SAFE_FREE(sour->abbreviation);
+  SAFE_FREE(sour->publication);
+  SAFE_FREE(sour->text);
+  DESTROY_CHAIN_ELTS(note_sub, sour->repository.note, note_sub_cleanup)
+  DESTROY_CHAIN_ELTS(source_description, sour->repository.description,
+                    source_description_cleanup)
+  DESTROY_CHAIN_ELTS(multimedia_link, sour->mm_link, multimedia_link_cleanup)
+  DESTROY_CHAIN_ELTS(note_sub, sour->note, note_sub_cleanup)
+  DESTROY_CHAIN_ELTS(user_ref_number, sour->ref, user_ref_cleanup)
+  SAFE_FREE(sour->record_id);
+  change_date_cleanup(sour->change_date);
+  DESTROY_CHAIN_ELTS(user_data, sour->extra, user_data_cleanup)
+}
+
+void sources_cleanup()
+{
+  DESTROY_CHAIN_ELTS(source, gom_first_source, source_cleanup);
+}
+
+struct source* gom_get_first_source()
+{
+  return gom_first_source;
+}
+
+struct source* make_source_record(char* xrefstr)
+{
+  struct source* src;
+  MAKE_CHAIN_ELT(source, gom_first_source, src);
+  src->xrefstr = strdup(xrefstr);
+  return src;
+}
diff --git a/gom/source.h b/gom/source.h
new file mode 100644 (file)
index 0000000..a7e71ab
--- /dev/null
@@ -0,0 +1,45 @@
+/* Include file for the source object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __SOURCE_H
+#define __SOURCE_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void source_subscribe();
+void sources_cleanup();
+struct source* make_source_record(char* xref);
+void source_add_event(Gom_ctxt ctxt, struct source_event* evt);
+void source_add_note_to_data(Gom_ctxt ctxt, struct note_sub* note);
+void source_add_to_value(NL_TYPE type, Gom_ctxt ctxt, char* str);
+void source_add_note_to_repo(Gom_ctxt ctxt, struct note_sub* note);
+void source_add_description(Gom_ctxt ctxt, struct source_description* desc);
+void source_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link);
+void source_add_note(Gom_ctxt ctxt, struct note_sub* note);
+void source_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
+void source_set_record_id(Gom_ctxt ctxt, char *rin);
+void source_set_change_date(Gom_ctxt ctxt, struct change_date* chan);
+void source_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __SOURCE_H */
diff --git a/gom/source_citation.c b/gom/source_citation.c
new file mode 100644 (file)
index 0000000..4708129
--- /dev/null
@@ -0,0 +1,178 @@
+/* Source citation sub-structure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "source_citation.h"
+#include "place.h"
+#include "event.h"
+#include "note_sub.h"
+#include "multimedia_link.h"
+#include "lds_event.h"
+#include "family.h"
+#include "personal_name.h"
+#include "individual.h"
+#include "association.h"
+#include "note.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+Gedcom_ctxt sub_citation_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct source_citation *cit = NULL;
+
+  if (ctxt) {
+    cit = (struct source_citation *)malloc(sizeof(struct source_citation));
+    memset (cit, 0, sizeof(struct source_citation));
+    if (GEDCOM_IS_STRING(parsed_value))
+      cit->description = strdup(GEDCOM_STRING(parsed_value));
+    else if (GEDCOM_IS_XREF_PTR(parsed_value))
+      cit->reference = GEDCOM_XREF_PTR(parsed_value);
+
+    switch (ctxt->ctxt_type) {
+      case ELT_SUB_PLAC:
+       place_add_citation(ctxt, cit); break;
+      case ELT_SUB_FAM_EVT:
+      case ELT_SUB_FAM_EVT_EVEN:
+      case ELT_SUB_INDIV_ATTR:
+      case ELT_SUB_INDIV_RESI:
+      case ELT_SUB_INDIV_BIRT:
+      case ELT_SUB_INDIV_GEN:
+      case ELT_SUB_INDIV_ADOP:
+      case ELT_SUB_INDIV_EVEN:
+       event_add_citation(ctxt, cit); break;
+      case ELT_SUB_NOTE:
+       note_sub_add_citation(ctxt, cit); break;
+      case ELT_SUB_LSS_SLGS:
+      case ELT_SUB_LIO_BAPL:
+      case ELT_SUB_LIO_SLGC:
+       lds_event_add_citation(ctxt, cit); break;
+      case REC_FAM:
+       family_add_citation(ctxt, cit); break;
+      case ELT_SUB_PERS_NAME:
+       name_add_citation(ctxt, cit); break;
+      case REC_INDI:
+       individual_add_citation(ctxt, cit); break;
+      case ELT_SUB_ASSO:
+       association_add_citation(ctxt, cit); break;
+      case REC_NOTE:
+       note_add_citation(ctxt, cit); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, source_citation, cit);
+}
+
+Gedcom_ctxt sub_cit_text_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct source_citation *cit = SAFE_CTXT_CAST(source_citation, ctxt);
+  struct text *t;
+  MAKE_CHAIN_ELT(text, cit->text, t);
+  t->text = strdup(GEDCOM_STRING(parsed_value));
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, text, t);
+}
+
+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)
+     
+void citation_subscribe()
+{
+  gedcom_subscribe_to_element(ELT_SUB_SOUR, sub_citation_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_SOUR_PAGE, sub_cit_page_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_SOUR_EVEN, sub_cit_even_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_SOUR_EVEN_ROLE, sub_cit_even_role_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_SOUR_DATA, sub_cit_data_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_SOUR_DATA_DATE, sub_cit_data_date_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_SOUR_TEXT, sub_cit_text_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_SOUR_QUAY, sub_cit_quay_start,
+                             def_elt_end);
+}
+
+void citation_add_note(Gom_ctxt ctxt, struct note_sub* note)
+{
+  struct source_citation *cit = SAFE_CTXT_CAST(source_citation, ctxt);
+  LINK_CHAIN_ELT(note_sub, cit->note, note)    
+}
+
+void citation_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* mm)
+{
+  struct source_citation *cit = SAFE_CTXT_CAST(source_citation, ctxt);
+  LINK_CHAIN_ELT(multimedia_link, cit->mm_link, mm)    
+}
+
+void citation_add_to_desc(NL_TYPE type, Gom_ctxt ctxt, char* str)
+{
+  struct source_citation *cit = SAFE_CTXT_CAST(source_citation, ctxt);
+  cit->description = concat_strings (type, cit->description, str);
+}
+
+void citation_add_to_text(NL_TYPE type, Gom_ctxt ctxt, char* str)
+{
+  struct text *t = SAFE_CTXT_CAST(text, ctxt);
+  t->text = concat_strings (type, t->text, str);
+}
+
+void citation_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct source_citation *obj = SAFE_CTXT_CAST(source_citation, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void text_cleanup(struct text* t)
+{
+  if (t) {
+    SAFE_FREE(t->text);
+  }
+}
+
+void citation_cleanup(struct source_citation* cit)
+{
+  if (cit) {
+    SAFE_FREE(cit->description);
+    SAFE_FREE(cit->page);
+    SAFE_FREE(cit->event);
+    SAFE_FREE(cit->role);
+    SAFE_FREE(cit->date);
+    DESTROY_CHAIN_ELTS(text, cit->text, text_cleanup)
+    SAFE_FREE(cit->quality);
+    DESTROY_CHAIN_ELTS(multimedia_link, cit->mm_link, multimedia_link_cleanup)
+    DESTROY_CHAIN_ELTS(note_sub, cit->note, note_sub_cleanup)
+    DESTROY_CHAIN_ELTS(user_data, cit->extra, user_data_cleanup)
+  }
+}
diff --git a/gom/source_citation.h b/gom/source_citation.h
new file mode 100644 (file)
index 0000000..da5f02a
--- /dev/null
@@ -0,0 +1,39 @@
+/* Include file for the source citation substructure in the gedcom object
+   model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __SOURCE_CITATION_H
+#define __SOURCE_CITATION_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void citation_subscribe();
+void citation_cleanup(struct source_citation* cit);
+void citation_add_note(Gom_ctxt ctxt, struct note_sub* note);
+void citation_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* mm);
+void citation_add_to_desc(NL_TYPE type, Gom_ctxt ctxt, char* str);
+void citation_add_to_text(NL_TYPE type, Gom_ctxt ctxt, char* str);
+void citation_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __SOURCE_CITATION_H */
diff --git a/gom/source_description.c b/gom/source_description.c
new file mode 100644 (file)
index 0000000..6dea145
--- /dev/null
@@ -0,0 +1,78 @@
+/* Source description sub-structure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "source_description.h"
+#include "source.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+Gedcom_ctxt sub_sour_caln_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct source_description *desc = NULL;
+
+  if (ctxt) {
+    desc
+      = (struct source_description *)malloc(sizeof(struct source_description));
+    memset (desc, 0, sizeof(struct source_description));
+    desc->call_number = strdup(GEDCOM_STRING(parsed_value));
+
+    switch (ctxt->ctxt_type) {
+      case ELT_SUB_REPO:
+       source_add_description(ctxt, desc); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, source_description, desc);
+}
+
+STRING_CB(source_description, sub_sour_caln_medi_start, media)
+     
+void source_description_subscribe()
+{
+  gedcom_subscribe_to_element(ELT_SUB_REPO_CALN, sub_sour_caln_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_REPO_CALN_MEDI,
+                             sub_sour_caln_medi_start, def_elt_end);
+}
+
+void source_description_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct source_description *obj = SAFE_CTXT_CAST(source_description, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void source_description_cleanup(struct source_description* desc)
+{
+  if (desc) {
+    SAFE_FREE(desc->call_number);
+    SAFE_FREE(desc->media);
+    DESTROY_CHAIN_ELTS(user_data, desc->extra, user_data_cleanup)
+  }
+}
diff --git a/gom/source_description.h b/gom/source_description.h
new file mode 100644 (file)
index 0000000..b944b73
--- /dev/null
@@ -0,0 +1,35 @@
+/* Include file for the source description substructure in the gedcom object
+   model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __SOURCE_DESCRIPTION_H
+#define __SOURCE_DESCRIPTION_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void source_description_subscribe();
+void source_description_cleanup(struct source_description* desc);
+void source_description_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __SOURCE_DESCRIPTION_H */
diff --git a/gom/source_event.c b/gom/source_event.c
new file mode 100644 (file)
index 0000000..c351384
--- /dev/null
@@ -0,0 +1,81 @@
+/* Source event sub-structure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "source_event.h"
+#include "source.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+Gedcom_ctxt sub_sour_even_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct source_event *evt = NULL;
+
+  if (ctxt) {
+    evt = (struct source_event *)malloc(sizeof(struct source_event));
+    memset (evt, 0, sizeof(struct source_event));
+    evt->recorded_events = strdup(GEDCOM_STRING(parsed_value));
+
+    switch (ctxt->ctxt_type) {
+      case ELT_SOUR_DATA:
+       source_add_event(ctxt, evt); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, source_event, evt);
+}
+
+DATE_CB(source_event, sub_sour_even_date_start, date_period)
+STRING_CB(source_event, sub_sour_even_plac_start, jurisdiction)
+     
+void source_event_subscribe()
+{
+  gedcom_subscribe_to_element(ELT_SOUR_DATA_EVEN, sub_sour_even_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SOUR_DATA_EVEN_DATE,
+                             sub_sour_even_date_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SOUR_DATA_EVEN_PLAC,
+                             sub_sour_even_plac_start, def_elt_end);
+}
+
+void source_event_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct source_event *obj = SAFE_CTXT_CAST(source_event, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void source_event_cleanup(struct source_event* evt)
+{
+  if (evt) {
+    SAFE_FREE(evt->recorded_events);
+    SAFE_FREE(evt->date_period);
+    SAFE_FREE(evt->jurisdiction);
+    DESTROY_CHAIN_ELTS(user_data, evt->extra, user_data_cleanup)
+  }
+}
diff --git a/gom/source_event.h b/gom/source_event.h
new file mode 100644 (file)
index 0000000..554b414
--- /dev/null
@@ -0,0 +1,34 @@
+/* Include file for the source event substructure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __SOURCE_EVENT_H
+#define __SOURCE_EVENT_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void source_event_subscribe();
+void source_event_cleanup(struct source_event* evt);
+void source_event_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __SOURCE_EVENT_H */
diff --git a/gom/submission.c b/gom/submission.c
new file mode 100644 (file)
index 0000000..1c84088
--- /dev/null
@@ -0,0 +1,91 @@
+/* Submission object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "submission.h"
+#include "submitter.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+struct submission* gom_submission = NULL;
+
+REC_CB(submission, subn_start, make_submission_record)
+XREF_CB(submission, subn_subm_start, submitter, make_submitter_record)
+STRING_CB(submission, subn_famf_start, family_file)
+STRING_CB(submission, subn_temp_start, temple_code)
+STRING_CB(submission, subn_ance_start, nr_of_ancestor_gens)
+STRING_CB(submission, subn_desc_start, nr_of_descendant_gens)
+STRING_CB(submission, subn_ordi_start, ordinance_process_flag)
+STRING_CB(submission, subn_rin_start, record_id)
+     
+void submission_subscribe()
+{
+  gedcom_subscribe_to_record(REC_SUBN, subn_start, def_rec_end);
+  gedcom_subscribe_to_element(ELT_SUBN_SUBM, subn_subm_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUBN_FAMF, subn_famf_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUBN_TEMP, subn_temp_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUBN_ANCE, subn_ance_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUBN_DESC, subn_desc_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUBN_ORDI, subn_ordi_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUBN_RIN, subn_rin_start, def_elt_end);  
+}
+
+void submission_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct submission *obj = SAFE_CTXT_CAST(submission, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void submission_cleanup()
+{
+  if (gom_submission) {
+    SAFE_FREE(gom_submission->xrefstr);
+    SAFE_FREE(gom_submission->family_file);
+    SAFE_FREE(gom_submission->temple_code);
+    SAFE_FREE(gom_submission->nr_of_ancestor_gens);
+    SAFE_FREE(gom_submission->nr_of_descendant_gens);
+    SAFE_FREE(gom_submission->ordinance_process_flag);
+    SAFE_FREE(gom_submission->record_id);
+    DESTROY_CHAIN_ELTS(user_data, gom_submission->extra, user_data_cleanup)
+    SAFE_FREE(gom_submission);
+  }
+}
+
+struct submission* gom_get_submission()
+{
+  return gom_submission;
+}
+
+struct submission* make_submission_record(char* xref)
+{
+  if (! gom_submission) {
+    gom_submission = (struct submission*)malloc(sizeof(struct submission));
+    memset(gom_submission, 0, sizeof(struct submission));
+    gom_submission->xrefstr = strdup(xref);
+  }
+  
+  return gom_submission;
+}
diff --git a/gom/submission.h b/gom/submission.h
new file mode 100644 (file)
index 0000000..44863d0
--- /dev/null
@@ -0,0 +1,35 @@
+/* Include file for the submission object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __SUBMISSION_H
+#define __SUBMISSION_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void submission_subscribe();
+void submission_cleanup();
+struct submission* make_submission_record(char* xref);
+void submission_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __SUBMISSION_H */
diff --git a/gom/submitter.c b/gom/submitter.c
new file mode 100644 (file)
index 0000000..b33914d
--- /dev/null
@@ -0,0 +1,137 @@
+/* Submitter object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "submitter.h"
+#include "address.h"
+#include "multimedia_link.h"
+#include "change_date.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+struct submitter* gom_first_submitter = NULL;
+
+REC_CB(submitter, subm_start, make_submitter_record)
+GET_REC_BY_XREF(submitter, XREF_SUBM, gom_get_submitter_by_xref)
+STRING_CB(submitter, subm_name_start, name)
+STRING_CB(submitter, subm_rfn_start, record_file_nr)
+STRING_CB(submitter, subm_rin_start, record_id)
+
+Gedcom_ctxt subm_lang_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct submitter *subm = SAFE_CTXT_CAST(submitter, ctxt);
+  char *str = GEDCOM_STRING(parsed_value);
+  
+  if (! subm->language[0])
+    subm->language[0] = strdup(str);
+  else if (! subm->language[1])
+    subm->language[1] = strdup(str);
+  else if (! subm->language[2])
+    subm->language[2] = strdup(str);
+  
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, submitter, subm);
+}
+
+void submitter_subscribe()
+{
+  gedcom_subscribe_to_record(REC_SUBM, subm_start, def_rec_end);
+  gedcom_subscribe_to_element(ELT_SUBM_NAME, subm_name_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUBM_LANG, subm_lang_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUBM_RFN, subm_rfn_start, def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUBM_RIN, subm_rin_start, def_elt_end);
+}
+
+void submitter_add_address(Gom_ctxt ctxt, struct address* address)
+{
+  struct submitter *subm = SAFE_CTXT_CAST(submitter, ctxt);
+  subm->address = address;
+}
+
+void submitter_add_phone(Gom_ctxt ctxt, char *phone)
+{
+  struct submitter *subm = SAFE_CTXT_CAST(submitter, ctxt);
+  if (! subm->phone[0])
+    subm->phone[0] = strdup(phone);
+  else if (! subm->phone[1])
+    subm->phone[1] = strdup(phone);
+  else if (! subm->phone[2])
+    subm->phone[2] = strdup(phone);
+}
+
+void submitter_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link)
+{
+  struct submitter *subm = SAFE_CTXT_CAST(submitter, ctxt);
+  LINK_CHAIN_ELT(multimedia_link, subm->mm_link, link)
+}
+
+void submitter_set_change_date(Gom_ctxt ctxt, struct change_date* chan)
+{
+  struct submitter *subm = SAFE_CTXT_CAST(submitter, ctxt);
+  subm->change_date = chan;
+}
+
+void submitter_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct submitter *obj = SAFE_CTXT_CAST(submitter, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void submitter_cleanup(struct submitter* rec)
+{
+  SAFE_FREE(rec->xrefstr);
+  SAFE_FREE(rec->name);
+  address_cleanup(rec->address);
+  SAFE_FREE(rec->phone[0]);
+  SAFE_FREE(rec->phone[1]);
+  SAFE_FREE(rec->phone[2]);
+  DESTROY_CHAIN_ELTS(multimedia_link, rec->mm_link, multimedia_link_cleanup)
+  SAFE_FREE(rec->language[0]);
+  SAFE_FREE(rec->language[1]);
+  SAFE_FREE(rec->language[2]);
+  SAFE_FREE(rec->record_file_nr);
+  SAFE_FREE(rec->record_id);
+  change_date_cleanup(rec->change_date);
+  DESTROY_CHAIN_ELTS(user_data, rec->extra, user_data_cleanup)
+}
+
+void submitters_cleanup()
+{
+  DESTROY_CHAIN_ELTS(submitter, gom_first_submitter, submitter_cleanup);
+}
+
+struct submitter* gom_get_first_submitter()
+{
+  return gom_first_submitter;
+}
+
+struct submitter* make_submitter_record(char* xrefstr)
+{
+  struct submitter* subm;
+  MAKE_CHAIN_ELT(submitter, gom_first_submitter, subm);
+  subm->xrefstr = strdup(xrefstr);
+  return subm;
+}
diff --git a/gom/submitter.h b/gom/submitter.h
new file mode 100644 (file)
index 0000000..813c36c
--- /dev/null
@@ -0,0 +1,39 @@
+/* Include file for the submitter object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __SUBMITTER_H
+#define __SUBMITTER_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void submitter_subscribe();
+void submitters_cleanup();
+struct submitter* make_submitter_record(char* xref);
+void submitter_add_address(Gom_ctxt ctxt, struct address* address);
+void submitter_add_phone(Gom_ctxt ctxt, char *phone);
+void submitter_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link);
+void submitter_set_change_date(Gom_ctxt ctxt, struct change_date* chan);
+void submitter_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __SUBMITTER_H */
diff --git a/gom/user_rec.c b/gom/user_rec.c
new file mode 100644 (file)
index 0000000..6581c8a
--- /dev/null
@@ -0,0 +1,203 @@
+/* User record object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "header.h"
+#include "submission.h"
+#include "submitter.h"
+#include "family.h"
+#include "individual.h"
+#include "multimedia.h"
+#include "note.h"
+#include "repository.h"
+#include "source.h"
+#include "address.h"
+#include "event.h"
+#include "place.h"
+#include "source_citation.h"
+#include "note_sub.h"
+#include "multimedia_link.h"
+#include "lds_event.h"
+#include "user_ref.h"
+#include "change_date.h"
+#include "personal_name.h"
+#include "family_link.h"
+#include "association.h"
+#include "source_event.h"
+#include "source_description.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+struct user_rec* gom_first_user_rec = NULL;
+
+Gedcom_ctxt user_rec_start(_REC_PARAMS_)
+{
+  struct user_rec* user = NULL;
+  struct xref_value* xr = NULL;
+  Gedcom_ctxt ctxt = NULL;
+  if (GEDCOM_IS_XREF_PTR(xref))
+    xr = GEDCOM_XREF_PTR(xref);
+  if (xr) {
+    if (! xr->object) {
+      user = make_user_record(xr->string);
+      xr->object = (Gedcom_ctxt) user;
+    }
+    ctxt = xr->object;
+    if (ctxt) {
+      user = (struct user_rec*) ctxt;
+    }
+  }
+  else {
+    user = make_user_record(NULL);
+    ctxt = (Gedcom_ctxt) user;
+  }
+  
+  user->tag = strdup(tag);
+  if (GEDCOM_IS_STRING(parsed_value))
+    user->str_value = strdup(GEDCOM_STRING(parsed_value));
+  else if (GEDCOM_IS_XREF_PTR(parsed_value))
+    user->xref_value = GEDCOM_XREF_PTR(parsed_value);
+  
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(rec, user_rec, ctxt);
+}
+
+GET_REC_BY_XREF(user_rec, XREF_USER, gom_get_user_rec_by_xref)
+
+Gedcom_ctxt user_elt_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct user_data *data = (struct user_data *)malloc(sizeof(struct user_data));
+  memset (data, 0, sizeof(struct user_data));
+
+  data->level = level;
+  data->tag = strdup(tag);
+  if (GEDCOM_IS_STRING(parsed_value))
+    data->str_value = strdup(GEDCOM_STRING(parsed_value));
+  else if (GEDCOM_IS_XREF_PTR(parsed_value))
+    data->xref_value = GEDCOM_XREF_PTR(parsed_value);
+
+  if (ctxt) {
+    switch (ctxt->obj_type) {
+      case T_header:
+       header_add_user_data(ctxt, data); break;
+      case T_submission:
+       submission_add_user_data(ctxt, data); break;
+      case T_submitter:
+       submitter_add_user_data(ctxt, data); break;
+      case T_family:
+       family_add_user_data(ctxt, data); break;
+      case T_individual:
+       individual_add_user_data(ctxt, data); break;
+      case T_multimedia:
+       multimedia_add_user_data(ctxt, data); break;
+      case T_note:
+       note_add_user_data(ctxt, data); break;
+      case T_repository:
+       repository_add_user_data(ctxt, data); break;
+      case T_source:
+       source_add_user_data(ctxt, data); break;
+      case T_user_rec:
+       user_rec_add_user_data(ctxt, data); break;
+      case T_address:
+       address_add_user_data(ctxt, data); break;
+      case T_event:
+       event_add_user_data(ctxt, data); break;
+      case T_place:
+       place_add_user_data(ctxt, data); break;
+      case T_source_citation:
+       citation_add_user_data(ctxt, data); break;
+      case T_note_sub:
+       note_sub_add_user_data(ctxt, data); break;
+      case T_multimedia_link:
+       multimedia_link_add_user_data(ctxt, data); break;
+      case T_lds_event:
+       lds_event_add_user_data(ctxt, data); break;
+      case T_user_ref_number:
+       user_ref_add_user_data(ctxt, data); break;
+      case T_change_date:
+       change_date_add_user_data(ctxt, data); break;
+      case T_personal_name:
+       name_add_user_data(ctxt, data); break;
+      case T_family_link:
+       family_link_add_user_data(ctxt, data); break;
+      case T_association:
+       association_add_user_data(ctxt, data); break;
+      case T_source_event:
+       source_event_add_user_data(ctxt, data); break;
+      case T_source_description:
+       source_description_add_user_data(ctxt, data); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+  
+  return (Gedcom_ctxt) make_gom_ctxt(elt, ctxt->obj_type, ctxt->ctxt_ptr);
+}
+
+void user_rec_subscribe()
+{
+  gedcom_subscribe_to_record(REC_USER, user_rec_start, def_rec_end);
+  gedcom_subscribe_to_element(ELT_USER, user_elt_start, def_elt_end);
+}
+
+void user_rec_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct user_rec *obj = SAFE_CTXT_CAST(user_rec, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void user_data_cleanup(struct user_data* data)
+{
+  SAFE_FREE(data->tag);
+  SAFE_FREE(data->str_value);
+}
+
+void user_rec_cleanup(struct user_rec* rec)
+{
+  SAFE_FREE(rec->xrefstr);
+  SAFE_FREE(rec->tag);
+  SAFE_FREE(rec->str_value);
+  DESTROY_CHAIN_ELTS(user_data, rec->extra, user_data_cleanup);
+}
+
+void user_recs_cleanup()
+{
+  DESTROY_CHAIN_ELTS(user_rec, gom_first_user_rec, user_rec_cleanup);
+}
+
+struct user_rec* gom_get_first_user_rec()
+{
+  return gom_first_user_rec;
+}
+
+struct user_rec* make_user_record(char* xrefstr)
+{
+  struct user_rec* rec;
+  MAKE_CHAIN_ELT(user_rec, gom_first_user_rec, rec);
+  if (xrefstr)
+    rec->xrefstr = strdup(xrefstr);
+  return rec;
+}
diff --git a/gom/user_rec.h b/gom/user_rec.h
new file mode 100644 (file)
index 0000000..5b54990
--- /dev/null
@@ -0,0 +1,36 @@
+/* Include file for the user record object in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __USER_REC_H
+#define __USER_REC_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void user_rec_subscribe();
+void user_recs_cleanup();
+struct user_rec* make_user_record(char* xref);
+void user_data_cleanup(struct user_data* data);
+void user_rec_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __USER_REC_H */
diff --git a/gom/user_ref.c b/gom/user_ref.c
new file mode 100644 (file)
index 0000000..d0bcc7e
--- /dev/null
@@ -0,0 +1,120 @@
+/* User reference number sub-structure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "user_ref.h"
+#include "family.h"
+#include "individual.h"
+#include "multimedia.h"
+#include "note.h"
+#include "repository.h"
+#include "source.h"
+#include "user_rec.h"
+#include "gom.h"
+#include "gedcom.h"
+#include "gom_internal.h"
+
+Gedcom_ctxt sub_user_ref_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  struct user_ref_number *refn = NULL;
+
+  if (ctxt) {
+    refn = (struct user_ref_number *)malloc(sizeof(struct user_ref_number));
+    memset (refn, 0, sizeof(struct user_ref_number));
+    refn->value = strdup(GEDCOM_STRING(parsed_value));
+
+    switch (ctxt->ctxt_type) {
+      case REC_FAM:
+       family_add_user_ref(ctxt, refn); break;
+      case REC_INDI:
+       individual_add_user_ref(ctxt, refn); break;
+      case REC_OBJE:
+       multimedia_add_user_ref(ctxt, refn); break;
+      case REC_NOTE:
+       note_add_user_ref(ctxt, refn); break;
+      case REC_REPO:
+       repository_add_user_ref(ctxt, refn); break;
+      case REC_SOUR:
+       source_add_user_ref(ctxt, refn); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+
+  return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, user_ref_number, refn);
+}
+
+STRING_CB(user_ref_number, sub_user_ref_type_start, type)
+     
+Gedcom_ctxt sub_user_rin_start(_ELT_PARAMS_)
+{
+  Gom_ctxt ctxt = (Gom_ctxt)parent;
+  if (ctxt) {
+    char *str = GEDCOM_STRING(parsed_value);
+
+    switch (ctxt->ctxt_type) {
+      case REC_FAM:
+       family_set_record_id(ctxt, str); break;
+      case REC_INDI:
+       individual_set_record_id(ctxt, str); break;
+      case REC_OBJE:
+       multimedia_set_record_id(ctxt, str); break;
+      case REC_NOTE:
+       note_set_record_id(ctxt, str); break;
+      case REC_REPO:
+       repository_set_record_id(ctxt, str); break;
+      case REC_SOUR:
+       source_set_record_id(ctxt, str); break;
+      default:
+       UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+    }
+  }
+  return (Gedcom_ctxt) make_gom_ctxt(elt, ctxt->obj_type, ctxt->ctxt_ptr);
+}
+
+void user_ref_subscribe()
+{
+  gedcom_subscribe_to_element(ELT_SUB_IDENT_REFN, sub_user_ref_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_IDENT_REFN_TYPE, sub_user_ref_type_start,
+                             def_elt_end);
+  gedcom_subscribe_to_element(ELT_SUB_IDENT_RIN, sub_user_rin_start,
+                             def_elt_end);
+}
+
+void user_ref_add_user_data(Gom_ctxt ctxt, struct user_data* data)
+{
+  struct user_ref_number *obj = SAFE_CTXT_CAST(user_ref_number, ctxt);
+  LINK_CHAIN_ELT(user_data, obj->extra, data)
+}
+
+void user_ref_cleanup(struct user_ref_number* refn)
+{
+  if (refn) {
+    SAFE_FREE(refn->value);
+    SAFE_FREE(refn->type);
+    DESTROY_CHAIN_ELTS(user_data, refn->extra, user_data_cleanup)
+  }
+}
diff --git a/gom/user_ref.h b/gom/user_ref.h
new file mode 100644 (file)
index 0000000..04fb971
--- /dev/null
@@ -0,0 +1,34 @@
+/* Include file for the user ref substructure in the gedcom object model.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __USER_REF_H
+#define __USER_REF_H
+
+#include "gom.h"
+#include "gom_internal.h"
+
+void user_ref_subscribe();
+void user_ref_cleanup(struct user_ref_number* refn);
+void user_ref_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+
+#endif /* __USER_REF_H */
index 5b9bb0a3a05baac55f95a34a9d93fca2bfbb6bf0..56b84acfd065268b7a0db76497838af156c6ae55 100644 (file)
@@ -2,11 +2,12 @@
 # $Id$
 # $Name$
 include_HEADERS = gedcom.h \
-                 gedcom-tags.h
+                 gedcom-tags.h \
+                 gom.h
 BUILT_SOURCES = gedcom.h \
                gedcom-tags.h
 EXTRA_DIST = gedcom.h.in
 
-gedcom-tags.h: $(srcdir)/../gedcom/gedcom.tab.h
+gedcom-tags.h: $(srcdir)/../gedcom/gedcom.tabgen.h
        grep "TAG_\|USERTAG" $< > $@
 
diff --git a/include/gom.h b/include/gom.h
new file mode 100644 (file)
index 0000000..a87c665
--- /dev/null
@@ -0,0 +1,443 @@
+/* External header for the Gedcom parser library.
+   Copyright (C) 2002 The Genes Development Team
+   This file is part of the Gedcom parser library.
+   Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
+
+   The Gedcom parser library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The Gedcom parser library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the Gedcom parser library; if not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __GEDCOM_GOM_H
+#define __GEDCOM_GOM_H
+
+__BEGIN_DECLS
+
+/* Sub-structures */
+
+struct user_data {
+  int level;
+  char *tag;
+  char *str_value;
+  struct xref_value *xref_value;
+  struct user_data *next;
+  struct user_data *previous;
+};
+
+struct address {
+  char *full_label;
+  char *line1;
+  char *line2;
+  char *city;
+  char *state;
+  char *postal;
+  char *country;
+  struct user_data *extra;
+};
+
+struct text {
+  char *text;
+  struct user_data *extra;
+  struct text *next;
+  struct text *previous;
+};
+
+struct source_citation {
+  char *description;
+  struct xref_value *reference;
+  char *page;
+  char *event;
+  char *role;
+  struct date_value* date;
+  struct text *text;
+  char *quality;
+  struct multimedia_link *mm_link;
+  struct note_sub *note;
+  struct user_data *extra;
+  struct source_citation *next;
+  struct source_citation *previous;
+};
+
+struct note_sub {
+  char *text;
+  struct xref_value *reference;
+  struct source_citation *citation;
+  struct user_data *extra;
+  struct note_sub *next;
+  struct note_sub *previous;
+};
+
+struct place {
+  char *value;
+  char *place_hierarchy;
+  struct user_data *extra;
+  struct source_citation *citation;
+  struct note_sub *note;
+};
+
+struct multimedia_link {
+  struct xref_value *reference;
+  char *form;
+  char *title;
+  char *file;
+  struct note_sub *note;
+  struct user_data *extra;
+  struct multimedia_link *next;
+  struct multimedia_link *previous;
+};
+
+struct lds_event {
+  char *date_status;
+  struct date_value *date;
+  char *temple_code;
+  char *place_living_ordinance;
+  struct xref_value *family;
+  struct source_citation *citation;
+  struct note_sub *note;
+  struct user_data *extra;
+  struct lds_event *next;
+  struct lds_event *previous;
+};
+
+struct user_ref_number {
+  char *value;
+  char *type;
+  struct user_data *extra;
+  struct user_ref_number *next;
+  struct user_ref_number *previous;
+};
+
+struct change_date {
+  struct date_value *date;
+  char *time;
+  struct note_sub *note;
+  struct user_data *extra;
+};
+
+struct event {
+  int event;
+  char *event_name;
+  char *val;
+  char *type;
+  struct date_value *date;
+  struct place *place;
+  struct address *address;
+  char *phone[3];
+  struct age_value *age;
+  char *agency;
+  char *cause;
+  struct source_citation *citation;
+  struct multimedia_link *mm_link;
+  struct note_sub *note;
+  struct age_value *husband_age;
+  struct age_value *wife_age;
+  struct xref_value *family;
+  char *adoption_parent;
+  struct user_data *extra;
+  struct event *next;
+  struct event *previous;
+};
+
+struct xref_list {
+  struct xref_value *xref;
+  struct user_data *extra;
+  struct xref_list *next;
+  struct xref_list *previous;
+};
+
+struct personal_name {
+  char *name;
+  char *prefix;
+  char *given;
+  char *nickname;
+  char *surname_prefix;
+  char *surname;
+  char *suffix;
+  struct source_citation *citation;
+  struct note_sub *note;
+  struct user_data *extra;
+  struct personal_name *next;
+  struct personal_name *previous;
+};
+
+struct pedigree {
+  char *pedigree;
+  struct user_data *extra;
+  struct pedigree *next;
+  struct pedigree *previous;
+};
+
+struct family_link {
+  struct xref_value *family;
+  struct pedigree *pedigree;
+  struct note_sub *note;
+  struct user_data *extra;
+  struct family_link *next;
+  struct family_link *previous;
+};
+
+struct association {
+  struct xref_value *to;
+  char *type;
+  char *relation;
+  struct source_citation *citation;
+  struct note_sub *note;
+  struct user_data *extra;
+  struct association *next;
+  struct association *previous;
+};
+
+struct source_event {
+  char *recorded_events;
+  struct date_value *date_period;
+  char *jurisdiction;
+  struct user_data *extra;
+  struct source_event *next;
+  struct source_event *previous;
+};
+
+struct source_description {
+  char *call_number;
+  char *media;
+  struct user_data *extra;
+  struct source_description *next;
+  struct source_description *previous;
+};
+
+/* Main structures */
+
+struct header {
+  struct header_source {
+    char *id;
+    char *name;
+    char *version;
+    struct header_corporation {
+      char *name;
+      struct address *address;
+      char *phone[3];
+    } corporation;
+    struct header_data {
+      char* name;
+      struct date_value* date;
+      char* copyright;
+    } data;
+  } source;
+  char* destination;
+  struct date_value* date;
+  char* time;
+  struct xref_value* submitter;
+  struct xref_value* submission;
+  char* filename;
+  char* copyright;
+  struct header_gedcom {
+    char* version;
+    char* form;
+  } gedcom;
+  struct header_charset {
+    char* name;
+    char* version;
+  } charset;
+  char* language;
+  char* place_hierarchy;
+  char* note;
+  struct user_data *extra;
+};
+
+struct submission {
+  char* xrefstr;
+  struct xref_value* submitter;
+  char* family_file;
+  char* temple_code;
+  char* nr_of_ancestor_gens;
+  char* nr_of_descendant_gens;
+  char* ordinance_process_flag;
+  char* record_id;
+  struct user_data *extra;
+};
+
+struct family {
+  char* xrefstr;
+  struct event* event;
+  struct xref_value* husband;
+  struct xref_value* wife;
+  struct xref_list* children;
+  char* nr_of_children;
+  struct xref_list* submitters;
+  struct lds_event* lds_spouse_sealing;
+  struct source_citation *citation;
+  struct multimedia_link *mm_link;
+  struct note_sub *note;
+  struct user_ref_number *ref;
+  char* record_id;
+  struct change_date* change_date;
+  struct user_data *extra;
+  struct family* next;
+  struct family* previous;
+};
+
+struct individual {
+  char* xrefstr;
+  char* restriction_notice;
+  struct personal_name* name;
+  char* sex;
+  struct event* event;
+  struct event* attribute;
+  struct lds_event* lds_individual_ordinance;
+  struct family_link* child_to_family;
+  struct family_link* spouse_to_family;
+  struct xref_list* submitters;
+  struct association* association;
+  struct xref_list* alias;
+  struct xref_list* ancestor_interest;
+  struct xref_list* descendant_interest;
+  struct source_citation *citation;
+  struct multimedia_link *mm_link;
+  struct note_sub *note;
+  char* record_file_nr;
+  char* ancestral_file_nr;
+  struct user_ref_number *ref;
+  char* record_id;
+  struct change_date* change_date;
+  struct user_data *extra;
+  struct individual* next;
+  struct individual* previous;
+};
+
+struct multimedia {
+  char* xrefstr;
+  char* form;
+  char* title;
+  struct note_sub *note;
+  char* data;
+  struct xref_value* continued;
+  struct user_ref_number *ref;
+  char* record_id;
+  struct change_date* change_date;
+  struct user_data *extra;
+  struct multimedia* next;
+  struct multimedia* previous;
+};
+
+struct note {
+  char* xrefstr;
+  char* text;
+  struct source_citation *citation;
+  struct user_ref_number *ref;
+  char* record_id;
+  struct change_date* change_date;
+  struct user_data *extra;
+  struct note* next;
+  struct note* previous;
+};
+
+struct repository {
+  char* xrefstr;
+  char* name;
+  struct address *address;
+  char *phone[3];
+  struct note_sub *note;
+  struct user_ref_number *ref;
+  char* record_id;
+  struct change_date* change_date;
+  struct user_data *extra;
+  struct repository* next;
+  struct repository* previous;
+};
+
+struct source {
+  char* xrefstr;
+  struct source_data {
+    struct source_event *event;
+    char *agency;
+    struct note_sub *note;
+  } data;
+  char* author;
+  char* title;
+  char* abbreviation;
+  char* publication;
+  char* text;
+  struct repo_link {
+    struct xref_value *link;
+    struct note_sub *note;
+    struct source_description *description;
+  } repository;
+  struct multimedia_link *mm_link;
+  struct note_sub *note;
+  struct user_ref_number *ref;
+  char* record_id;
+  struct change_date* change_date;
+  struct user_data *extra;
+  struct source* next;
+  struct source* previous;
+};
+
+struct submitter {
+  char* xrefstr;
+  char* name;
+  struct address* address;
+  char *phone[3];
+  struct multimedia_link *mm_link;
+  char *language[3];
+  char* record_file_nr;
+  char* record_id;
+  struct change_date* change_date;
+  struct user_data *extra;
+  struct submitter* next;
+  struct submitter* previous;
+};
+
+struct user_rec {
+  char* xrefstr;
+  char* tag;
+  char* str_value;
+  struct xref_value* xref_value;
+  struct user_data* extra;
+  struct user_rec* next;
+  struct user_rec* previous;
+};
+
+int  gom_parse_file(char* file_name);
+
+struct header*     gom_get_header();
+struct submission* gom_get_submission();
+
+struct family*     gom_get_first_family();
+struct family*     gom_get_family_by_xref(char *xref);
+
+struct individual* gom_get_first_individual();
+struct individual* gom_get_individual_by_xref(char *xref);
+
+struct multimedia* gom_get_first_multimedia();
+struct multimedia* gom_get_multimedia_by_xref(char *xref);
+
+struct note*       gom_get_first_note();
+struct note*       gom_get_note_by_xref(char *xref);
+
+struct repository* gom_get_first_repository();
+struct repository* gom_get_repository_by_xref(char *xref);
+
+struct source*     gom_get_first_source();
+struct source*     gom_get_source_by_xref(char *xref);
+
+struct submitter*  gom_get_first_submitter();
+struct submitter*  gom_get_submitter_by_xref(char *xref);
+
+struct user_rec*   gom_get_first_user_rec();
+struct user_rec*   gom_get_user_rec_by_xref(char *xref);
+
+__END_DECLS
+
+#endif /* __GEDCOM_GOM_H */
index 9ed85d9e6bc562d33b7b3b7778434caae05fe55e..626019e8cfbd36496694cf4f857474702dd57b7f 100644 (file)
@@ -6,7 +6,8 @@ SUBDIRS=input
 INCLUDES = -DPKGDATADIR=\"$(pkgdatadir)\" -I $(srcdir)/../include
 CFLAGS   = -g -O2
 
-noinst_PROGRAMS = testgedcom pathtest
+noinst_PROGRAMS = testgedcom pathtest gomtest @EXTRA_PROGS@
+EXTRA_PROGRAMS  = gomtest_static
 
 testgedcom_SOURCES = standalone.c utf8-locale.c
 noinst_HEADERS     = utf8-locale.h
@@ -16,18 +17,38 @@ testgedcom_LDADD  = @INTLLIBS@
 pathtest_SOURCES = pathtest.c
 pathtest_LDFLAGS = -L ../gedcom/.libs -lgedcom
 
-TEST_SCRIPT=test_script
+gomtest_SOURCES = gomtest.c
+gomtest_LDFLAGS = -L ../gedcom/.libs -L ../gom/.libs -lgedcom_gom -lgedcom
+
+gomtest_static_SOURCES = gomtest.c
+gomtest_static_LDADD = ../gedcom/.libs/libgedcom.a ../gom/.libs/libgedcom_gom.a
+
+TEST_SCRIPT=test_script test_gom test_gom_static
 TESTS := $(wildcard $(srcdir)/*.test)
 
 EXTRA_DIST=$(TEST_SCRIPT) $(TESTS)
 
 all-local:
-       rm -f ../testgedcom.out ./testgedcom.out
+       @rm -f testgedcom.out dmalloc.log
 
-check-% :      %.test
+check-% :      %.test all-local
        @srcdir=$(srcdir); export srcdir; \
         if $(TESTS_ENVIRONMENT) ./$<; then \
          echo "Test succeeded"; \
        else \
          echo "Test failed"; \
        fi
+
+check-dmalloc-%:       %.test all-local
+       @if [ "@EXTRA_PROGS@" = "" ]; then \
+         echo "Please run './configure --with-dmalloc' first"; \
+         exit; \
+       fi; \
+       srcdir=$(srcdir); export srcdir; \
+       GOM_DMALLOC_TEST=1; export GOM_DMALLOC_TEST; \
+        if $(TESTS_ENVIRONMENT) ./$<; then \
+         echo "Test succeeded"; \
+       else \
+         echo "Test failed"; \
+       fi
+