Completed writing of strings and xrefs.
authorPeter Verthez <Peter.Verthez@advalvas.be>
Sun, 15 Dec 2002 09:46:30 +0000 (09:46 +0000)
committerPeter Verthez <Peter.Verthez@advalvas.be>
Sun, 15 Dec 2002 09:46:30 +0000 (09:46 +0000)
53 files changed:
gedcom/tag_data.h
gedcom/write.c
gom/address.c
gom/address.h
gom/association.c
gom/association.h
gom/change_date.c
gom/change_date.h
gom/event.c
gom/event.h
gom/family.c
gom/family.h
gom/family_link.c
gom/family_link.h
gom/gom.c
gom/gom_internal.h
gom/header.c
gom/individual.c
gom/individual.h
gom/lds_event.c
gom/lds_event.h
gom/multimedia.c
gom/multimedia.h
gom/multimedia_link.c
gom/multimedia_link.h
gom/note.c
gom/note.h
gom/note_sub.c
gom/note_sub.h
gom/personal_name.c
gom/personal_name.h
gom/place.c
gom/place.h
gom/repository.c
gom/repository.h
gom/source.c
gom/source.h
gom/source_citation.c
gom/source_citation.h
gom/source_description.c
gom/source_description.h
gom/source_event.c
gom/source_event.h
gom/submission.c
gom/submission.h
gom/submitter.c
gom/submitter.h
gom/user_rec.c
gom/user_rec.h
gom/user_ref.c
gom/user_ref.h
include/gedcom.h.in
include/gom.h

index 052a226bc3321361c27afc6e2128337e68c48c13..0e4d3ee4af29ab287f10b67ed5f99563471e39c8 100644 (file)
 /* $Name$ */
 
 #include "gedcom.h"
+#include "gedcom.tabgen.h"
+
+/* TODO: should be auto-generated */
+
+#define TAG_NUM_START TAG_ABBR
+#define TAG_NUM_END   TAG_WILL
+char* tag_name[] =
+{
+  /* 265 */         "ABBR", "ADDR", "ADR1", "ADR2", "ADOP", "AFN" , "AGE",
+  /* 272 */ "AGNC", "ALIA", "ANCE", "ANCI", "ANUL", "ASSO", "AUTH", "BAPL",
+  /* 280 */ "BAPM", "BARM", "BASM", "BIRT", "BLES", "BLOB", "BURI", "CALN",
+  /* 288 */ "CAST", "CAUS", "CENS", "CHAN", "CHAR", "CHIL", "CHR" , "CHRA",
+  /* 296 */ "CITY", "CONC", "CONF", "CONL", "CONT", "COPR", "CORP", "CREM",
+  /* 304 */ "CTRY", "DATA", "DATE", "DEAT", "DESC", "DESI", "DEST", "DIV",
+  /* 312 */ "DIVF", "DSCR", "EDUC", "EMIG", "ENDL", "ENGA", "EVEN", "FAM",
+  /* 320 */ "FAMC", "FAMF", "FAMS", "FCOM", "FILE", "FORM", "GEDC", "GIVN",
+  /* 328 */ "GRAD", "HEAD", "HUSB", "IDNO", "IMMI", "INDI", "LANG", "LEGA",
+  /* 336 */ "MARB", "MARC", "MARL", "MARR", "MARS", "MEDI", "NAME", "NATI",
+  /* 344 */ "NATU", "NCHI", "NICK", "NMR",  "NOTE", "NPFX", "NSFX", "OBJE",
+  /* 352 */ "OCCU", "ORDI", "ORDN", "PAGE", "PEDI", "PHON", "PLAC", "POST",
+  /* 360 */ "PROB", "PROP", "PUBL", "QUAY", "REFN", "RELA", "RELI", "REPO",
+  /* 368 */ "RESI", "RESN", "RETI", "RFN",  "RIN",  "ROLE", "SEX",  "SLGC",
+  /* 376 */ "SLGS", "SOUR", "SPFX", "SSN",  "STAE", "STAT", "SUBM", "SUBN",
+  /* 384 */ "SURN", "TEMP", "TEXT", "TIME", "TITL", "TRLR", "TYPE", "VERS",
+  /* 392 */ "WIFE", "WILL", 0
+};
 
 typedef enum _OPT {
   OPT_CONC = 0x01,
-  OPT_CONT = 0x02
+  OPT_CONT = 0x02,
+  OPT_CONT_AS_CONC = 0x04
 } Opt;
 
 struct tag_data {
   char *elt_name;
-  char *tag_name;
+  int   tag;
   int   allowed_types;
   Opt   options;
 };
@@ -38,101 +65,463 @@ struct tag_data {
 struct tag_data tag_data[NR_OF_ELTS] =
 {
   /* REC_HEAD */
-  { "REC_HEAD", "HEAD", GV_NULL, 0 },
+  { "REC_HEAD", TAG_HEAD, GV_NULL, 0 },
 
   /* REC_FAM */
-  { "REC_FAM", "FAM", GV_NULL, 0 },
+  { "REC_FAM", TAG_FAM, GV_NULL, 0 },
 
   /* REC_INDI */
-  { "REC_INDI", "INDI", GV_NULL, 0 },
+  { "REC_INDI", TAG_INDI, GV_NULL, 0 },
 
   /* REC_OBJE */
-  { "REC_OBJE", "OBJE", GV_NULL, 0 },
+  { "REC_OBJE", TAG_OBJE, GV_NULL, 0 },
 
   /* REC_NOTE */
-  { "REC_NOTE", "NOTE", GV_CHAR_PTR, 0 },
+  { "REC_NOTE", TAG_NOTE, GV_CHAR_PTR, OPT_CONC | OPT_CONT },
 
   /* REC_REPO */
-  { "REC_REPO", "REPO", GV_NULL, 0 },
+  { "REC_REPO", TAG_REPO, GV_NULL, 0 },
 
   /* REC_SOUR */
-  { "REC_SOUR", "SOUR", GV_NULL, 0 },
+  { "REC_SOUR", TAG_SOUR, GV_NULL, 0 },
 
   /* REC_SUBN */
-  { "REC_SUBN", "SUBN", GV_NULL, 0 },
+  { "REC_SUBN", TAG_SUBN, GV_NULL, 0 },
 
   /* REC_SUBM */
-  { "REC_SUBM", "SUBM", GV_NULL, 0 },
+  { "REC_SUBM", TAG_SUBM, GV_NULL, 0 },
 
   /* REC_USER */
-  { "REC_USER", NULL,   GV_NULL | GV_CHAR_PTR | GV_XREF_PTR, 0 },
+  { "REC_USER", 0, GV_NULL | GV_CHAR_PTR | GV_XREF_PTR, 0 },
 
   /* ELT_HEAD_SOUR */
-  { "ELT_HEAD_SOUR", "SOUR", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_SOUR", TAG_SOUR, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_SOUR_VERS */
-  { "ELT_HEAD_SOUR_VERS", "VERS", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_SOUR_VERS", TAG_VERS, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_SOUR_NAME */
-  { "ELT_HEAD_SOUR_NAME", "NAME", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_SOUR_NAME", TAG_NAME, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_SOUR_CORP */
-  { "ELT_HEAD_SOUR_CORP", "CORP", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_SOUR_CORP", TAG_CORP, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_SOUR_DATA */
-  { "ELT_HEAD_SOUR_DATA", "DATA", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_SOUR_DATA", TAG_DATA, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_SOUR_DATA_DATE */
-  { "ELT_HEAD_SOUR_DATA_DATE", "DATE", GV_DATE_VALUE, 0 },
+  { "ELT_HEAD_SOUR_DATA_DATE", TAG_DATE, GV_DATE_VALUE, 0 },
 
   /* ELT_HEAD_SOUR_DATA_COPR */
-  { "ELT_HEAD_SOUR_DATA_COPR", "COPR", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_SOUR_DATA_COPR", TAG_COPR, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_DEST */
-  { "ELT_HEAD_DEST", "DEST", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_DEST", TAG_DEST, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_DATE */
-  { "ELT_HEAD_DATE", "DATE", GV_DATE_VALUE, 0 },
+  { "ELT_HEAD_DATE", TAG_DATE, GV_DATE_VALUE, 0 },
 
   /* ELT_HEAD_DATE_TIME */
-  { "ELT_HEAD_DATE_TIME", "TIME", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_DATE_TIME", TAG_TIME, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_SUBM */
-  { "ELT_HEAD_SUBM", "SUBM", GV_XREF_PTR, 0 },
+  { "ELT_HEAD_SUBM", TAG_SUBM, GV_XREF_PTR, 0 },
 
   /* ELT_HEAD_SUBN */
-  { "ELT_HEAD_SUBN", "SUBN", GV_XREF_PTR, 0 },
+  { "ELT_HEAD_SUBN", TAG_SUBN, GV_XREF_PTR, 0 },
 
   /* ELT_HEAD_FILE */
-  { "ELT_HEAD_FILE", "FILE", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_FILE", TAG_FILE, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_COPR */
-  { "ELT_HEAD_COPR", "COPR", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_COPR", TAG_COPR, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_GEDC */
-  { "ELT_HEAD_GEDC", "GEDC", GV_NULL, 0 },
+  { "ELT_HEAD_GEDC", TAG_GEDC, GV_NULL, 0 },
 
   /* ELT_HEAD_GEDC_VERS */
-  { "ELT_HEAD_GEDC_VERS", "VERS", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_GEDC_VERS", TAG_VERS, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_GEDC_FORM */
-  { "ELT_HEAD_GEDC_FORM", "FORM", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_GEDC_FORM", TAG_FORM, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_CHAR */
-  { "ELT_HEAD_CHAR", "CHAR", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_CHAR", TAG_CHAR, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_CHAR_VERS */
-  { "ELT_HEAD_CHAR_VERS", "VERS", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_CHAR_VERS", TAG_VERS, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_LANG */
-  { "ELT_HEAD_LANG", "LANG", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_LANG", TAG_LANG, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_PLAC */
-  { "ELT_HEAD_PLAC", "PLAC", GV_NULL, 0 },
+  { "ELT_HEAD_PLAC", TAG_PLAC, GV_NULL, 0 },
 
   /* ELT_HEAD_PLAC_FORM */
-  { "ELT_HEAD_PLAC_FORM", "FORM", GV_CHAR_PTR, 0 },
+  { "ELT_HEAD_PLAC_FORM", TAG_FORM, GV_CHAR_PTR, 0 },
 
   /* ELT_HEAD_NOTE */
-  { "ELT_HEAD_NOTE", "NOTE", GV_CHAR_PTR, OPT_CONC | OPT_CONT }
+  { "ELT_HEAD_NOTE", TAG_NOTE, GV_CHAR_PTR, OPT_CONC | OPT_CONT },
+
+  /* ELT_FAM_HUSB */
+  { "ELT_FAM_HUSB", TAG_HUSB, GV_XREF_PTR, 0 },
+
+  /* ELT_FAM_WIFE */
+  { "ELT_FAM_WIFE", TAG_WIFE, GV_XREF_PTR, 0 },
+
+  /* ELT_FAM_CHIL */
+  { "ELT_FAM_CHIL", TAG_CHIL, GV_XREF_PTR, 0 },
+
+  /* ELT_FAM_NCHI */
+  { "ELT_FAM_NCHI", TAG_NCHI, GV_CHAR_PTR, 0 },
+
+  /* ELT_FAM_SUBM */
+  { "ELT_FAM_SUBM", TAG_SUBM, GV_XREF_PTR, 0 },
+  
+  /* ELT_INDI_RESN */
+  { "ELT_INDI_RESN", TAG_RESN, GV_CHAR_PTR, 0 },
+  
+  /* ELT_INDI_SEX */
+  { "ELT_INDI_SEX", TAG_SEX, GV_CHAR_PTR, 0 },
+  
+  /* ELT_INDI_SUBM */
+  { "ELT_INDI_SUBM", TAG_SUBM, GV_XREF_PTR, 0 },
+  
+  /* ELT_INDI_ALIA */
+  { "ELT_INDI_ALIA", TAG_ALIA, GV_XREF_PTR, 0 },
+  
+  /* ELT_INDI_ANCI */
+  { "ELT_INDI_ANCI", TAG_ANCI, GV_XREF_PTR, 0 },
+  
+  /* ELT_INDI_DESI */
+  { "ELT_INDI_DESI", TAG_DESI, GV_XREF_PTR, 0 },
+  
+  /* ELT_INDI_RFN */
+  { "ELT_INDI_RFN", TAG_RFN, GV_CHAR_PTR, 0 },
+  
+  /* ELT_INDI_AFN */
+  { "ELT_INDI_AFN", TAG_AFN, GV_CHAR_PTR, 0 },
+  
+  /* ELT_OBJE_FORM */
+  { "ELT_OBJE_FORM", TAG_FORM, GV_CHAR_PTR, 0 },
+  
+  /* ELT_OBJE_TITL */
+  { "ELT_OBJE_TITL", TAG_TITL, GV_CHAR_PTR, 0 },
+  
+  /* ELT_OBJE_BLOB */
+  { "ELT_OBJE_BLOB", TAG_BLOB, GV_NULL, OPT_CONT_AS_CONC },
+  
+  /* ELT_OBJE_BLOB_CONT */
+  { "ELT_OBJE_BLOB_CONT", TAG_CONT, GV_CHAR_PTR, 0 },
+  
+  /* ELT_OBJE_OBJE */
+  { "ELT_OBJE_OBJE", TAG_OBJE, GV_XREF_PTR, 0 },
+  
+  /* ELT_REPO_NAME */
+  { "ELT_REPO_NAME", TAG_NAME, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SOUR_DATA */
+  { "ELT_SOUR_DATA", TAG_DATA, GV_NULL, 0 },
+  
+  /* ELT_SOUR_DATA_EVEN */
+  { "ELT_SOUR_DATA_EVEN", TAG_EVEN, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SOUR_DATA_EVEN_DATE */
+  { "ELT_SOUR_DATA_EVEN_DATE", TAG_DATE, GV_DATE_VALUE, 0 },
+  
+  /* ELT_SOUR_DATA_EVEN_PLAC */
+  { "ELT_SOUR_DATA_EVEN_PLAC", TAG_PLAC, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SOUR_DATA_AGNC */
+  { "ELT_SOUR_DATA_AGNC", TAG_AGNC, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SOUR_AUTH */
+  { "ELT_SOUR_AUTH", TAG_AUTH, GV_CHAR_PTR, OPT_CONC | OPT_CONT },
+  
+  /* ELT_SOUR_TITL */
+  { "ELT_SOUR_TITL", TAG_TITL, GV_CHAR_PTR, OPT_CONC | OPT_CONT },
+  
+  /* ELT_SOUR_ABBR */
+  { "ELT_SOUR_ABBR", TAG_ABBR, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SOUR_PUBL */
+  { "ELT_SOUR_PUBL", TAG_PUBL, GV_CHAR_PTR, OPT_CONC | OPT_CONT },
+  
+  /* ELT_SOUR_TEXT */
+  { "ELT_SOUR_TEXT", TAG_TEXT, GV_CHAR_PTR, OPT_CONC | OPT_CONT },
+  
+  /* ELT_SUBN_SUBM */
+  { "ELT_SUBN_SUBM", TAG_SUBM, GV_XREF_PTR, 0 },
+  
+  /* ELT_SUBN_FAMF */
+  { "ELT_SUBN_FAMF", TAG_FAMF, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUBN_TEMP */
+  { "ELT_SUBN_TEMP", TAG_TEMP, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUBN_ANCE */
+  { "ELT_SUBN_ANCE", TAG_ANCE, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUBN_DESC */
+  { "ELT_SUBN_DESC", TAG_DESC, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUBN_ORDI */
+  { "ELT_SUBN_ORDI", TAG_ORDI, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUBN_RIN */
+  { "ELT_SUBN_RIN", TAG_RIN, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUBM_NAME */
+  { "ELT_SUBM_NAME", TAG_NAME, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUBM_LANG */
+  { "ELT_SUBM_LANG", TAG_LANG, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUBM_RFN */
+  { "ELT_SUBM_RFN", TAG_RFN, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUBM_RIN */
+  { "ELT_SUBM_RIN", TAG_RIN, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_ADDR */
+  { "ELT_SUB_ADDR", TAG_ADDR, GV_CHAR_PTR, OPT_CONT },
+  
+  /* ELT_SUB_ADDR_CONT */
+  { "ELT_SUB_ADDR_CONT", TAG_CONT, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_ADDR_ADR1 */
+  { "ELT_SUB_ADDR_ADR1", TAG_ADR1, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_ADDR_ADR2 */
+  { "ELT_SUB_ADDR_ADR2", TAG_ADR2, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_ADDR_CITY */
+  { "ELT_SUB_ADDR_CITY", TAG_CITY, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_ADDR_STAE */
+  { "ELT_SUB_ADDR_STAE", TAG_STAE, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_ADDR_POST */
+  { "ELT_SUB_ADDR_POST", TAG_POST, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_ADDR_CTRY */
+  { "ELT_SUB_ADDR_CTRY", TAG_CTRY, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_PHON */
+  { "ELT_SUB_PHON", TAG_PHON, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_ASSO */
+  { "ELT_SUB_ASSO", TAG_ASSO, GV_XREF_PTR, 0 },
+  
+  /* ELT_SUB_ASSO_TYPE */
+  { "ELT_SUB_ASSO_TYPE", TAG_TYPE, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_ASSO_RELA */
+  { "ELT_SUB_ASSO_RELA", TAG_RELA, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_CHAN */
+  { "ELT_SUB_CHAN", TAG_CHAN, GV_NULL, 0 },
+  
+  /* ELT_SUB_CHAN_DATE */
+  { "ELT_SUB_CHAN_DATE", TAG_DATE, GV_DATE_VALUE, 0 },
+  
+  /* ELT_SUB_CHAN_TIME */
+  { "ELT_SUB_CHAN_TIME", TAG_TIME, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_FAMC */
+  { "ELT_SUB_FAMC", TAG_FAMC, GV_XREF_PTR, 0 },
+  
+  /* ELT_SUB_FAMC_PEDI */
+  { "ELT_SUB_FAMC_PEDI", TAG_PEDI, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_CONT */
+  { "ELT_SUB_CONT", TAG_CONT, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_CONC */
+  { "ELT_SUB_CONC", TAG_CONC, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_EVT_TYPE */
+  { "ELT_SUB_EVT_TYPE", TAG_TYPE, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_EVT_DATE */
+  { "ELT_SUB_EVT_DATE", TAG_DATE, GV_DATE_VALUE, 0 },
+  
+  /* ELT_SUB_EVT_AGE */
+  { "ELT_SUB_EVT_AGE", TAG_AGE, GV_AGE_VALUE, 0 },
+  
+  /* ELT_SUB_EVT_AGNC */
+  { "ELT_SUB_EVT_AGNC", TAG_AGNC, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_EVT_CAUS */
+  { "ELT_SUB_EVT_CAUS", TAG_CAUS, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_FAM_EVT */
+  { "ELT_SUB_FAM_EVT", 0, GV_NULL | GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_FAM_EVT_HUSB */
+  { "ELT_SUB_FAM_EVT_HUSB", TAG_HUSB, GV_NULL, 0 },
+  
+  /* ELT_SUB_FAM_EVT_WIFE */
+  { "ELT_SUB_FAM_EVT_WIFE", TAG_WIFE, GV_NULL, 0 },
+  
+  /* ELT_SUB_FAM_EVT_AGE */
+  { "ELT_SUB_FAM_EVT_AGE", TAG_AGE, GV_AGE_VALUE, 0 },
+  
+  /* ELT_SUB_FAM_EVT_EVEN */
+  { "ELT_SUB_FAM_EVT_EVEN", TAG_EVEN, GV_NULL, 0 },
+  
+  /* ELT_SUB_IDENT_REFN */
+  { "ELT_SUB_IDENT_REFN", TAG_REFN, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_IDENT_REFN_TYPE */
+  { "ELT_SUB_IDENT_REFN_TYPE", TAG_TYPE, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_IDENT_RIN */
+  { "ELT_SUB_IDENT_RIN", TAG_RIN, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_INDIV_ATTR */
+  { "ELT_SUB_INDIV_ATTR", 0, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_INDIV_RESI */
+  { "ELT_SUB_INDIV_RESI", TAG_RESI, GV_NULL, 0 },
+  
+  /* ELT_SUB_INDIV_BIRT */
+  { "ELT_SUB_INDIV_BIRT", 0, GV_NULL | GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_INDIV_BIRT_FAMC */
+  { "ELT_SUB_INDIV_BIRT_FAMC", TAG_FAMC, GV_XREF_PTR, 0 },
+  
+  /* ELT_SUB_INDIV_GEN */
+  { "ELT_SUB_INDIV_GEN", 0, GV_NULL | GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_INDIV_ADOP */
+  { "ELT_SUB_INDIV_ADOP", TAG_ADOP, GV_NULL | GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_INDIV_ADOP_FAMC */
+  { "ELT_SUB_INDIV_ADOP_FAMC", TAG_FAMC, GV_XREF_PTR, 0 },
+  
+  /* ELT_SUB_INDIV_ADOP_FAMC_ADOP */
+  { "ELT_SUB_INDIV_ADOP_FAMC_ADOP", TAG_ADOP, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_INDIV_EVEN */
+  { "ELT_SUB_INDIV_EVEN", TAG_EVEN, GV_NULL, 0 },
+  
+  /* ELT_SUB_LIO_BAPL */
+  { "ELT_SUB_LIO_BAPL", 0, GV_NULL, 0 },
+  
+  /* ELT_SUB_LIO_BAPL_STAT */
+  { "ELT_SUB_LIO_BAPL_STAT", TAG_STAT, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_LIO_BAPL_DATE */
+  { "ELT_SUB_LIO_BAPL_DATE", TAG_DATE, GV_DATE_VALUE, 0 },
+  
+  /* ELT_SUB_LIO_BAPL_TEMP */
+  { "ELT_SUB_LIO_BAPL_TEMP", TAG_TEMP, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_LIO_BAPL_PLAC */
+  { "ELT_SUB_LIO_BAPL_PLAC", TAG_PLAC, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_LIO_SLGC */
+  { "ELT_SUB_LIO_SLGC", TAG_SLGC, GV_NULL, 0 },
+  
+  /* ELT_SUB_LIO_SLGC_FAMC */
+  { "ELT_SUB_LIO_SLGC_FAMC", TAG_FAMC, GV_XREF_PTR, 0 },
+  
+  /* ELT_SUB_LSS_SLGS */
+  { "ELT_SUB_LSS_SLGS", TAG_SLGS, GV_NULL, 0 },
+  
+  /* ELT_SUB_LSS_SLGS_STAT */
+  { "ELT_SUB_LSS_SLGS_STAT", TAG_STAT, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_LSS_SLGS_DATE */
+  { "ELT_SUB_LSS_SLGS_DATE", TAG_DATE, GV_DATE_VALUE, 0 },
+  
+  /* ELT_SUB_LSS_SLGS_TEMP */
+  { "ELT_SUB_LSS_SLGS_TEMP", TAG_TEMP, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_LSS_SLGS_PLAC */
+  { "ELT_SUB_LSS_SLGS_PLAC", TAG_PLAC, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_MULTIM_OBJE */
+  { "ELT_SUB_MULTIM_OBJE", TAG_OBJE, GV_NULL | GV_XREF_PTR, 0 },
+  
+  /* ELT_SUB_MULTIM_OBJE_FORM */
+  { "ELT_SUB_MULTIM_OBJE_FORM", TAG_FORM, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_MULTIM_OBJE_TITL */
+  { "ELT_SUB_MULTIM_OBJE_TITL", TAG_TITL, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_MULTIM_OBJE_FILE */
+  { "ELT_SUB_MULTIM_OBJE_FILE", TAG_FILE, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_NOTE */
+  { "ELT_SUB_NOTE", TAG_NOTE, GV_NULL | GV_CHAR_PTR | GV_XREF_PTR,
+    OPT_CONT | OPT_CONC },
+  
+  /* ELT_SUB_PERS_NAME */
+  { "ELT_SUB_PERS_NAME", TAG_NAME, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_PERS_NAME_NPFX */
+  { "ELT_SUB_PERS_NAME_NPFX", TAG_NPFX, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_PERS_NAME_GIVN */
+  { "ELT_SUB_PERS_NAME_GIVN", TAG_GIVN, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_PERS_NAME_NICK */
+  { "ELT_SUB_PERS_NAME_NICK", TAG_NICK, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_PERS_NAME_SPFX */
+  { "ELT_SUB_PERS_NAME_SPFX", TAG_SPFX, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_PERS_NAME_SURN */
+  { "ELT_SUB_PERS_NAME_SURN", TAG_SURN, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_PERS_NAME_NSFX */
+  { "ELT_SUB_PERS_NAME_NSFX", TAG_NSFX, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_PLAC */
+  { "ELT_SUB_PLAC", TAG_PLAC, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_PLAC_FORM */
+  { "ELT_SUB_PLAC_FORM", TAG_FORM, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_SOUR */
+  { "ELT_SUB_SOUR", TAG_SOUR, GV_CHAR_PTR | GV_XREF_PTR, OPT_CONT | OPT_CONC },
+  
+  /* ELT_SUB_SOUR_PAGE */
+  { "ELT_SUB_SOUR_PAGE", TAG_PAGE, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_SOUR_EVEN */
+  { "ELT_SUB_SOUR_EVEN", TAG_EVEN, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_SOUR_EVEN_ROLE */
+  { "ELT_SUB_SOUR_EVEN_ROLE", TAG_ROLE, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_SOUR_DATA */
+  { "ELT_SUB_SOUR_DATA", TAG_DATA, GV_NULL, 0 },
+  
+  /* ELT_SUB_SOUR_DATA_DATE */
+  { "ELT_SUB_SOUR_DATA_DATE", TAG_DATE, GV_DATE_VALUE, 0 },
+  
+  /* ELT_SUB_SOUR_TEXT */
+  { "ELT_SUB_SOUR_TEXT", TAG_TEXT, GV_CHAR_PTR, OPT_CONT | OPT_CONC },
+  
+  /* ELT_SUB_SOUR_QUAY */
+  { "ELT_SUB_SOUR_QUAY", TAG_QUAY, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_REPO */
+  { "ELT_SUB_REPO", TAG_REPO, GV_XREF_PTR, 0 },
+  
+  /* ELT_SUB_REPO_CALN */
+  { "ELT_SUB_REPO_CALN", TAG_CALN, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_REPO_CALN_MEDI */
+  { "ELT_SUB_REPO_CALN_MEDI", TAG_MEDI, GV_CHAR_PTR, 0 },
+  
+  /* ELT_SUB_FAMS */
+  { "ELT_SUB_FAMS", TAG_FAMS, GV_XREF_PTR, 0 },
+  
+  /* ELT_USER */
+  { "ELT_USER", 0, GV_NULL | GV_CHAR_PTR | GV_XREF_PTR, 0 },
+  
 };
index fbcff1d29e107e4217faa2ff9de51c5a981faf47..aba4195be34c88f9dadeb63fc13a999dfe9badc3 100644 (file)
@@ -32,6 +32,8 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
+#define MAXWRITELEN MAXGEDCLINELEN
+
 const char* encoding = "ASCII";
 int write_encoding_details = ONE_BYTE;
 /* SYS_NEWLINE is defined in config.h */
@@ -102,8 +104,10 @@ int write_simple(Gedcom_write_hndl hndl,
       converted = convert_from_utf8(hndl->conv, get_buf_string(&write_buffer),
                                    &conv_fails, &outlen);
       
-      if (converted && (conv_fails == 0))
+      if (converted && (conv_fails == 0)) {
+       line_no++;
        write(hndl->filedesc, converted, outlen);
+      }
       else {
        hndl->total_conv_fails += conv_fails;
        gedcom_error
@@ -124,6 +128,7 @@ int write_long(Gedcom_write_hndl hndl, int elt_or_rec,
               int level, char* xref, char* tag, char* value)
 {
   int prefix_len, value_len, term_len;
+  char* nl_pos = strchr(value, '\n');
 
   prefix_len = utf8_strlen(tag) + 3;  /* for e.g. "0 INDI " */
   if (level > 9) prefix_len++;
@@ -131,28 +136,31 @@ int write_long(Gedcom_write_hndl hndl, int elt_or_rec,
   value_len  = utf8_strlen(value);
   term_len   = strlen(hndl->term);
 
-  if (prefix_len + value_len + term_len <= MAXGEDCLINELEN)
+  if (!nl_pos && prefix_len + value_len + term_len <= MAXWRITELEN)
     write_simple(hndl, level, xref, tag, value);
   else {
     char* value_ptr = value;
-    char* nl_pos = strchr(value, '\n');
-    if (nl_pos && !supports_continuation(elt_or_rec, OPT_CONT)) {
+    int cont_supported = supports_continuation(elt_or_rec, OPT_CONT);
+    int cont_as_conc   = supports_continuation(elt_or_rec, OPT_CONT_AS_CONC);
+    if (nl_pos && !cont_supported) {
       gedcom_error (_("The tag %s doesn't support newlines\n"), tag);
       return 1;
     }
     else {
-      char value_part[MAXGEDCLINELEN];
+      char value_part[MAXWRITELEN];
       int cont_prefix_len, write_level = level;
       cont_prefix_len = utf8_strlen("CONT") + 3;
       if (level + 1 > 9) cont_prefix_len++;
 
       while (value_ptr) {
        char* cont_tag = "CONT";
-       int line_len = (nl_pos ? nl_pos - value_ptr : value_len);
+       int line_len = (nl_pos && cont_supported
+                       ? nl_pos - value_ptr : value_len);
 
-       if (prefix_len + line_len + term_len > MAXGEDCLINELEN) {
-         line_len = MAXGEDCLINELEN - prefix_len - term_len;
-         cont_tag = "CONC";
+       if (prefix_len + line_len + term_len > MAXWRITELEN) {
+         line_len = MAXWRITELEN - prefix_len - term_len;
+         if (!cont_as_conc)
+           cont_tag = "CONC";
        }
        
        memset(value_part, 0, sizeof(value_part));
@@ -275,14 +283,19 @@ int gedcom_write_close(Gedcom_write_hndl hndl, int* total_conv_fails)
   return result;
 }
 
-char* get_tag_string(int elt_or_rec, char* tag)
+char* get_tag_string(int elt_or_rec, int tag)
 {
-  char* result = tag_data[elt_or_rec].tag_name;
+  int tagnum = tag_data[elt_or_rec].tag;
+  if (!tagnum) tagnum = tag;
 
-  if (result)
-    return result;
-  else if (tag)
-    return tag;
+  if (tagnum) {
+    if (tagnum >= TAG_NUM_START && tagnum <= TAG_NUM_END)
+      return tag_name[tagnum - TAG_NUM_START];
+    else {
+      gedcom_error(_("Not a valid tag: %d"), tagnum);
+      return NULL;
+    }
+  }
   else {
     gedcom_error(_("The element or record type '%s' requires a specific tag"
                   "for writing"),
@@ -345,47 +358,82 @@ char* convert_at(const char* input)
     return NULL;
 }
 
-int gedcom_write_record_str(Gedcom_write_hndl hndl,
-                           Gedcom_rec rec, char* tag,
-                           struct xref_value* xref, char* val)
+int _gedcom_write_val(Gedcom_write_hndl hndl,
+                     int rec_or_elt, int tag, int parent_rec_or_elt,
+                     char* xrefstr, char* val)
 {
   int result = 1;
   int level = 0;
   char* tag_str = NULL;
-  char* xref_str = NULL;
 
-  tag_str = get_tag_string(rec, tag);
-  level   = get_level(hndl, rec, -1);
-  if (tag_str && check_type(rec, (val ? GV_CHAR_PTR : GV_NULL))) {
-    if (xref)
-      xref_str = xref->string;
-    if (supports_continuation(rec, OPT_CONT | OPT_CONC))
-      result = write_long(hndl, rec, level, xref_str, tag_str,
-                         convert_at(val));
+  tag_str = get_tag_string(rec_or_elt, tag);
+  level   = get_level(hndl, rec_or_elt, parent_rec_or_elt);
+  if (tag_str && (level != -1)) {
+    if (supports_continuation(rec_or_elt, OPT_CONT|OPT_CONC|OPT_CONT_AS_CONC))
+      result = write_long(hndl, rec_or_elt, level, xrefstr, tag_str, val);
     else
-      result = write_simple(hndl, level, xref_str, tag_str, convert_at(val));
+      result = write_simple(hndl, level, xrefstr, tag_str, val);
   }
 
   return result;
 }
 
+int gedcom_write_record_str(Gedcom_write_hndl hndl,
+                           Gedcom_rec rec, int tag,
+                           char* xrefstr, char* val)
+{
+  int result = 1;
+  if (check_type(rec, (val ? GV_CHAR_PTR : GV_NULL)))
+    result = _gedcom_write_val(hndl, rec, tag, -1, xrefstr, convert_at(val));
+  return result;
+}
+
 int gedcom_write_element_str(Gedcom_write_hndl hndl,
-                            Gedcom_elt elt, char* tag, int parent_rec_or_elt,
+                            Gedcom_elt elt, int tag, int parent_rec_or_elt,
                             char* val)
 {
   int result = 1;
-  int level  = -1;
-  char* tag_str = NULL;
+  if (check_type(elt, (val ? GV_CHAR_PTR : GV_NULL)))
+    result = _gedcom_write_val(hndl, elt, tag, parent_rec_or_elt, NULL,
+                              convert_at(val));
+  return result;
+}
 
-  tag_str = get_tag_string(elt, tag);
-  level   = get_level(hndl, elt, parent_rec_or_elt);
-  if (tag_str && (level != -1)
-      && check_type(elt, (val ? GV_CHAR_PTR : GV_NULL))) {
-    if (supports_continuation(elt, OPT_CONT | OPT_CONC))
-      result = write_long(hndl, elt, level, NULL, tag_str, convert_at(val));
-    else
-      result = write_simple(hndl, level, NULL, tag_str, convert_at(val));
-  }
+int gedcom_write_record_xref(Gedcom_write_hndl hndl,
+                            Gedcom_rec rec, int tag,
+                            char* xrefstr, struct xref_value* val)
+{
+  int result = 1;
+  if (check_type(rec, (val ? GV_XREF_PTR : GV_NULL)))
+    result = _gedcom_write_val(hndl, rec, tag, -1, xrefstr, val->string);
+  return result;
+}
 
+int gedcom_write_element_xref(Gedcom_write_hndl hndl,
+                             Gedcom_elt elt, int tag, int parent_rec_or_elt,
+                             struct xref_value* val)
+{
+  int result = 1;
+  if (check_type(elt, (val ? GV_XREF_PTR : GV_NULL)))
+    result = _gedcom_write_val(hndl, elt, tag, parent_rec_or_elt, NULL,
+                              val->string);
+  return result;
+}
+
+int gedcom_write_user_str(Gedcom_write_hndl hndl, int level, char* tag,
+                         char* xrefstr, char* value)
+{
+  int result = 1;
+  if (tag && tag[0] == '_')
+    result = write_simple(hndl, level, xrefstr, tag, convert_at(value));
+  return result;
+}
+
+int gedcom_write_user_xref(Gedcom_write_hndl hndl, int level, char* tag,
+                          char* xrefstr, struct xref_value* val)
+{
+  int result = 1;
+  if (tag && tag[0] == '_')
+    result = write_simple(hndl, level, xrefstr, tag, val->string);
   return result;
 }
index 1766d937164677dc659b34dcbddfd9a9b157e896..6c0332a64a89727d4f1fa3ab61a2a9541c3703c3 100644 (file)
@@ -165,3 +165,36 @@ void address_cleanup(struct address *address)
   }
   SAFE_FREE(address);
 }
+
+int write_address(Gedcom_write_hndl hndl, int parent, struct address *address)
+{
+  int result = 0;
+
+  if (!address) return 1;
+  
+  if (address->full_label)
+    result |= gedcom_write_element_str(hndl, ELT_SUB_ADDR, 0, parent,
+                                      address->full_label);
+  if (address->line1)
+    result |= gedcom_write_element_str(hndl, ELT_SUB_ADDR_ADR1, 0,
+                                      ELT_SUB_ADDR, address->line1);
+  if (address->line2)
+    result |= gedcom_write_element_str(hndl, ELT_SUB_ADDR_ADR2, 0,
+                                      ELT_SUB_ADDR, address->line2);
+  if (address->city)
+    result |= gedcom_write_element_str(hndl, ELT_SUB_ADDR_CITY, 0,
+                                      ELT_SUB_ADDR, address->city);
+  if (address->state)
+    result |= gedcom_write_element_str(hndl, ELT_SUB_ADDR_STAE, 0,
+                                      ELT_SUB_ADDR, address->state);
+  if (address->postal)
+    result |= gedcom_write_element_str(hndl, ELT_SUB_ADDR_POST, 0,
+                                      ELT_SUB_ADDR, address->postal);
+  if (address->country)
+    result |= gedcom_write_element_str(hndl, ELT_SUB_ADDR_CTRY, 0,
+                                      ELT_SUB_ADDR, address->country);
+  if (address->extra)
+    result |= write_user_data(hndl, address->extra);
+
+  return result;
+}
index 6676241bd1b6b5f3a8ca7a24c366192ce2e0c966..cc814bb5b5d7a9df2e305f712cefcf6b97d3107c 100644 (file)
@@ -29,5 +29,6 @@
 void address_subscribe();
 void address_cleanup(struct address *address);
 void address_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+int write_address(Gedcom_write_hndl hndl, int parent, struct address *address);
 
 #endif /* __ADDRESS_H */
index fdd833baa97dd94f8a3819bba35462ee7df60c55..2a5bf39c1a403b3ab22052844bceff805616b389 100644 (file)
@@ -126,3 +126,31 @@ void association_cleanup(struct association* assoc)
     DESTROY_CHAIN_ELTS(user_data, assoc->extra, user_data_cleanup);
   }
 }
+
+int write_associations(Gedcom_write_hndl hndl, int parent,
+                      struct association *assoc)
+{
+  int result = 0;
+  struct association* obj;
+
+  if (!assoc) return 1;
+
+  for (obj = assoc; obj; obj = obj->next) {
+    result |= gedcom_write_element_xref(hndl, ELT_SUB_ASSO, 0, parent,
+                                       obj->to);
+    if (obj->type)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_ASSO_TYPE, 0, parent,
+                                        obj->type);
+    if (obj->relation)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_ASSO_RELA, 0, parent,
+                                        obj->relation);
+    if (obj->citation)
+      result |= write_citations(hndl, ELT_SUB_ASSO, obj->citation);
+    if (obj->note)
+      result |= write_note_subs(hndl, ELT_SUB_ASSO, obj->note);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);
+  }
+
+  return result;
+}
index 8c0c6401835f0a7fa2b56435873f5ad25a6646c2..e688d0901e741bacfc28bee655be7a8a6b60a8b4 100644 (file)
@@ -32,5 +32,7 @@ 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);
+int write_associations(Gedcom_write_hndl hndl, int parent,
+                      struct association *assoc);
 
 #endif /* __ASSOCIATION_H */
index cca70675bdd842c0f434e70b105ba1f3c31b5ecb..8dd7fb3a97a166a135efd1a713de14daf1ac35ba 100644 (file)
@@ -113,3 +113,19 @@ void change_date_cleanup(struct change_date *chan)
   }
   SAFE_FREE(chan);
 }
+
+int write_change_date(Gedcom_write_hndl hndl, int parent,
+                     struct change_date *chan)
+{
+  int result = 0;
+
+  if (!chan) return 1;
+
+  result |= gedcom_write_element_str(hndl, ELT_SUB_CHAN, 0, parent, NULL);
+  if (chan->note)
+    result |= write_note_subs(hndl, ELT_SUB_CHAN, chan->note);
+  if (chan->extra)
+    result |= write_user_data(hndl, chan->extra);
+  
+  return result;
+}
index 15d76841be12e224ab866bf4dd93fa934f3f0e21..2a0c4844cc1efbd39ed9706118ce17e9903e164d 100644 (file)
@@ -31,5 +31,7 @@ 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);
+int write_change_date(Gedcom_write_hndl hndl, int parent,
+                     struct change_date *chan);
 
 #endif /* __CHANGE_DATE_H */
index aa15cda2d4d968bc79b08e9cdd496f5cc9a8ebc3..48515b7315b22345b67e7a54951b8940b8929541 100644 (file)
@@ -297,3 +297,108 @@ void event_cleanup(struct event* evt)
     DESTROY_CHAIN_ELTS(user_data, evt->extra, user_data_cleanup);
   }
 }
+
+static int get_gedcom_elt(EventType evt_type, int parsed_tag)
+{
+  int obj_elt = 0;
+  switch (evt_type) {
+    case EVT_TYPE_FAMILY:
+      obj_elt = (parsed_tag == TAG_EVEN ? ELT_SUB_FAM_EVT_EVEN :
+                ELT_SUB_FAM_EVT);
+      break;
+    case EVT_TYPE_INDIV_ATTR:
+      obj_elt = (parsed_tag == TAG_RESI ? ELT_SUB_INDIV_RESI :
+                ELT_SUB_INDIV_ATTR);
+      break;
+    case EVT_TYPE_INDIV_EVT:
+      switch (parsed_tag) {
+       case TAG_BIRT: case TAG_CHR:
+         obj_elt = ELT_SUB_INDIV_BIRT; break;
+       case TAG_DEAT: case TAG_BURI: case TAG_CREM: case TAG_BAPM:
+       case TAG_BARM: case TAG_BASM: case TAG_BLES: case TAG_CHRA:
+       case TAG_CONF: case TAG_FCOM: case TAG_ORDN: case TAG_NATU:
+       case TAG_EMIG: case TAG_IMMI: case TAG_CENS: case TAG_PROB:
+       case TAG_WILL: case TAG_GRAD: case TAG_RETI:
+         obj_elt = ELT_SUB_INDIV_GEN; break;
+       case TAG_ADOP:
+         obj_elt = ELT_SUB_INDIV_ADOP; break;
+       case TAG_EVEN:
+         obj_elt = ELT_SUB_INDIV_EVEN; break;
+       default:
+         gedcom_warning(_("Internal error: unknown evt tag %d"), parsed_tag);
+      }
+      break;
+    default:
+      gedcom_warning(_("Internal error: unknown evt type %d"), evt_type);
+  }
+  return obj_elt;
+}
+
+int get_gedcom_fam_elt(int elt)
+{
+  int fam_obj_elt = 0;
+  switch (elt) {
+    case ELT_SUB_INDIV_BIRT:
+      fam_obj_elt = ELT_SUB_INDIV_BIRT_FAMC;
+      break;
+    case ELT_SUB_INDIV_ADOP:
+      fam_obj_elt = ELT_SUB_INDIV_ADOP_FAMC;
+      break;
+    default:
+      gedcom_warning(_("Internal error: wrong parent for evt->family"));
+  }
+  return fam_obj_elt;
+}
+
+int write_events(Gedcom_write_hndl hndl, int parent, EventType evt_type,
+                struct event* evt)
+{
+  int result = 0;
+  int i;
+  struct event* obj;
+
+  if (!evt) return 1;
+
+  for (obj = evt; obj; obj = obj->next) {
+    int obj_elt = get_gedcom_elt(evt_type, obj->event);
+    result |= gedcom_write_element_str(hndl, obj_elt, obj->event,
+                                      parent, obj->val);
+    if (obj->type)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_EVT_TYPE, 0,
+                                        obj_elt, obj->type);
+    if (obj->place)
+      result |= write_place(hndl, obj_elt, obj->place);
+    if (obj->address)
+      result |= write_address(hndl, obj_elt, obj->address);
+    for (i = 0; i < 3 && obj->phone[i]; i++)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_PHON, 0, obj_elt,
+                                        obj->phone[i]);
+    if (obj->agency)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_EVT_AGNC, 0,
+                                        obj_elt, obj->agency);
+    if (obj->cause)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_EVT_CAUS, 0,
+                                        obj_elt, obj->cause);
+    if (obj->citation)
+      result |= write_citations(hndl, obj_elt, obj->citation);
+    if (obj->mm_link)
+      result |= write_multimedia_links(hndl, obj_elt, obj->mm_link);
+    if (obj->note)
+      result |= write_note_subs(hndl, obj_elt, obj->note);
+    if (obj->family) {
+      int fam_obj_elt = get_gedcom_fam_elt(obj_elt);
+      result |= gedcom_write_element_xref(hndl, fam_obj_elt, 0,
+                                         obj_elt, obj->family);
+      if (obj->adoption_parent) {
+       result |= gedcom_write_element_str(hndl, ELT_SUB_INDIV_ADOP_FAMC_ADOP,
+                                          0, fam_obj_elt,
+                                          obj->adoption_parent);
+      }
+    }
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);
+  }
+  
+  return result;
+}
+  
index ef799d251d703f6645d69e437c01eeb69f42580d..6835dbd4ede074376b00b2e54129c3ef0f65dcb0 100644 (file)
 #include "gom.h"
 #include "gom_internal.h"
 
+typedef enum _EVT_TYPE {
+  EVT_TYPE_FAMILY,
+  EVT_TYPE_INDIV_ATTR,
+  EVT_TYPE_INDIV_EVT
+} EventType;
+
 void event_subscribe();
 void event_cleanup(struct event* evt);
 void event_add_place(Gom_ctxt ctxt, struct place* place);
@@ -36,5 +42,7 @@ 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);
+int write_events(Gedcom_write_hndl hndl, int parent, EventType evt_type,
+                struct event* evt);
 
 #endif /* __EVENT_H */
index 83ad0b1e6d05b0e926c8feeca16cf0c84bf32547..995fd583f1fc0e019d9709d3f1b4f031ac56f3cb 100644 (file)
@@ -162,3 +162,49 @@ struct family* make_family_record(const char* xrefstr)
   }
   return fam;
 }
+
+int write_families(Gedcom_write_hndl hndl)
+{
+  int result = 0;
+  struct family* obj;
+
+  for (obj = gom_first_family; obj; obj = obj->next) {
+    result |= gedcom_write_record_str(hndl, REC_FAM, 0,
+                                     obj->xrefstr, NULL);
+    if (obj->event)
+      result |= write_events(hndl, REC_FAM, EVT_TYPE_FAMILY, obj->event);
+    if (obj->husband)
+      result |= gedcom_write_element_xref(hndl, ELT_FAM_HUSB, 0,
+                                         REC_FAM, obj->husband);
+    if (obj->wife)
+      result |= gedcom_write_element_xref(hndl, ELT_FAM_WIFE, 0,
+                                         REC_FAM, obj->wife);
+    result |= gom_write_xref_list(hndl, ELT_FAM_CHIL, 0,
+                                 REC_FAM, obj->children);
+    if (obj->nr_of_children)
+      result |= gedcom_write_element_str(hndl, ELT_FAM_NCHI, 0,
+                                        REC_FAM, obj->nr_of_children);
+    result |= gom_write_xref_list(hndl, ELT_FAM_SUBM, 0,
+                                 REC_FAM, obj->submitters);
+    if (obj->lds_spouse_sealing)
+      result |= write_lds_events(hndl, REC_FAM, obj->lds_spouse_sealing);
+    if (obj->citation)
+      result |= write_citations(hndl, REC_FAM, obj->citation);
+    if (obj->mm_link)
+      result |= write_multimedia_links(hndl, REC_FAM, obj->mm_link);
+    if (obj->note)
+      result |= write_note_subs(hndl, REC_FAM, obj->note);
+    if (obj->ref)
+      result |= write_user_refs(hndl, REC_FAM, obj->ref);
+    if (obj->record_id)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_IDENT_RIN, 0,
+                                        REC_FAM, obj->record_id);
+    if (obj->change_date)
+      result |= write_change_date(hndl, REC_FAM, obj->change_date);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);
+  }
+  
+  return result;
+}
+
index 61938928035908ccd1697c832675d192a983af96..7fdce9fe5ee7e873a255c9cd38ec03f41c9142ca 100644 (file)
@@ -39,5 +39,6 @@ void family_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
 void family_set_record_id(Gom_ctxt ctxt, const 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);
+int write_families(Gedcom_write_hndl hndl);
 
 #endif /* __FAMILY_H */
index 4c5fa9b0f357d666610c8970ba8b5cd9edc45830..1ab6d4b668b23e7ebd6ff05bd33ec499c6972290 100644 (file)
@@ -126,3 +126,43 @@ void family_link_cleanup(struct family_link *link)
     DESTROY_CHAIN_ELTS(user_data, link->extra, user_data_cleanup);
   }
 }
+
+int write_pedigrees(Gedcom_write_hndl hndl, int parent, struct pedigree* ped)
+{
+  int result = 0;
+  struct pedigree* obj;
+
+  if (!ped) return 1;
+
+  for (obj = ped; obj; obj = obj->next) {
+    result |= gedcom_write_element_str(hndl, ELT_SUB_FAMC_PEDI, 0, parent,
+                                      obj->pedigree);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);  
+  }
+  
+  return result;
+}
+
+int write_family_links(Gedcom_write_hndl hndl, int parent, LinkType type,
+                      struct family_link *link)
+{
+  int result = 0;
+  struct family_link* obj;
+  int elt = (type == LINK_TYPE_CHILD ? ELT_SUB_FAMC : ELT_SUB_FAMS);
+
+  if (!link) return 1;
+
+  for (obj = link; obj; obj = obj->next) {
+    result |= gedcom_write_element_xref(hndl, elt, 0, parent,
+                                       obj->family);
+    if (obj->pedigree)
+      result |= write_pedigrees(hndl, elt, obj->pedigree);
+    if (obj->note)
+      result |= write_note_subs(hndl, elt, obj->note);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);      
+  }
+
+  return result;
+}
index 64b323d496f1ec9180ff0311e5a1c4d6d1aaa279..5444995c915cf8e17aa7a3d11ea4dd79c355a8c3 100644 (file)
 #include "gom.h"
 #include "gom_internal.h"
 
+typedef enum _LINK_TYPE {
+  LINK_TYPE_CHILD,
+  LINK_TYPE_SPOUSE
+} LinkType;
+
 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);
+int write_family_links(Gedcom_write_hndl hndl, int parent, LinkType type,
+                      struct family_link *link);
 
 #endif /* __FAMILY_LINK_H */
index 1770efdbd3690f6c328b5e426c7730137aec1df0..a81777810990eb17b713ebf39fab7d4e9ddabbdf 100644 (file)
--- a/gom/gom.c
+++ b/gom/gom.c
@@ -123,12 +123,34 @@ int gom_write_file(const char* file_name, int *total_conv_fails)
   hndl = gedcom_write_open(file_name);
   if (hndl) {
     result = write_header(hndl);
+    result |= write_submission(hndl);
+    result |= write_submitters(hndl);
+    result |= write_individuals(hndl);
+    result |= write_families(hndl);
+    result |= write_multimedia_recs(hndl);
+    result |= write_notes(hndl);
+    result |= write_repositories(hndl);
+    result |= write_sources(hndl);
+    result |= write_user_recs(hndl);
     result |= gedcom_write_close(hndl, total_conv_fails);
   }
 
   return result;
 }
 
+int gom_write_xref_list(Gedcom_write_hndl hndl,
+                       Gedcom_elt elt, int tag, int parent_rec_or_elt,
+                       struct xref_list* val)
+{
+  int result = 0;
+  struct xref_list* xrl;
+  for (xrl = val; xrl; xrl = xrl->next) {
+    result |= gedcom_write_element_xref(hndl, elt, tag, parent_rec_or_elt,
+                                       xrl->xref);
+  }
+  return result;
+}
+
 Gom_ctxt make_gom_ctxt(int ctxt_type, OBJ_TYPE obj_type, void *ctxt_ptr)
 {
   Gom_ctxt ctxt   = (Gom_ctxt)malloc(sizeof(struct Gom_ctxt_struct));
index b3075501a2541d1c8cc79fbab53904a19a735623..01dde5cad0796b41dd93f5f976505dd18938816c 100644 (file)
@@ -75,6 +75,10 @@ void gom_cast_error(const char* file, int line,
 void gom_no_context(const char* file, int line);
 void gom_unexpected_context(const char* file, int line, OBJ_TYPE found);
 
+int gom_write_xref_list(Gedcom_write_hndl hndl,
+                       Gedcom_elt elt, int tag, int parent_rec_or_elt,
+                       struct xref_list* val);
+
 #define MAKE_GOM_CTXT(CTXT_TYPE, STRUCTTYPE, CTXT_PTR)                        \
   make_gom_ctxt(CTXT_TYPE, T_ ## STRUCTTYPE, CTXT_PTR)
 
index c5360012f37b1acc42cc6ec19f7f8b52cbfbcb41..04b00542ff0865c550e39e0a6ae210cc80e3a818 100644 (file)
@@ -166,72 +166,87 @@ struct header* gom_get_header()
 int write_header(Gedcom_write_hndl hndl)
 {
   int result = 0;
+  int i;
   
-  result |= gedcom_write_record_str(hndl, REC_HEAD, NULL, NULL, NULL);
+  result |= gedcom_write_record_str(hndl, REC_HEAD, 0, NULL, NULL);
+  if (gom_header.charset.name)
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_CHAR, 0,
+                                      REC_HEAD,
+                                      gom_header.charset.name);
+  if (gom_header.charset.version)
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_CHAR_VERS, 0,
+                                      ELT_HEAD_CHAR,
+                                      gom_header.charset.version);
   if (gom_header.source.id)
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_SOUR, NULL, REC_HEAD,
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_SOUR, 0, REC_HEAD,
                                       gom_header.source.id);
   if (gom_header.source.name)
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_SOUR_NAME, NULL,
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_SOUR_NAME, 0,
                                       ELT_HEAD_SOUR,
                                       gom_header.source.name);
   if (gom_header.source.version)
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_SOUR_VERS, NULL,
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_SOUR_VERS, 0,
                                       ELT_HEAD_SOUR,
                                       gom_header.source.version);
   if (gom_header.source.corporation.name)
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_SOUR_CORP, NULL,
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_SOUR_CORP, 0,
                                       ELT_HEAD_SOUR,
                                       gom_header.source.corporation.name);
+  if (gom_header.source.corporation.address)
+    result |= write_address(hndl, ELT_HEAD_SOUR_CORP,
+                           gom_header.source.corporation.address);
+  for (i = 0; i < 3 && gom_header.source.corporation.phone[i]; i++)
+    result |= gedcom_write_element_str(hndl, ELT_SUB_PHON, 0, ELT_HEAD_SOUR_CORP,
+                                      gom_header.source.corporation.phone[i]);
   if (gom_header.source.data.name)
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_SOUR_DATA, NULL,
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_SOUR_DATA, 0,
                                       ELT_HEAD_SOUR,
                                       gom_header.source.data.name);
   if (gom_header.source.data.copyright)
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_SOUR_DATA_COPR, NULL,
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_SOUR_DATA_COPR, 0,
                                       ELT_HEAD_SOUR_DATA,
                                       gom_header.source.data.copyright);
   if (gom_header.destination)
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_DEST, NULL, REC_HEAD,
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_DEST, 0, REC_HEAD,
                                       gom_header.destination);
+  if (gom_header.submitter)
+    result |= gedcom_write_element_xref(hndl, ELT_HEAD_SUBM, 0, REC_HEAD,
+                                       gom_header.submitter);
+  if (gom_header.submission)
+    result |= gedcom_write_element_xref(hndl, ELT_HEAD_SUBN, 0, REC_HEAD,
+                                       gom_header.submission);
   if (gom_header.filename)
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_FILE, NULL, REC_HEAD,
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_FILE, 0, REC_HEAD,
                                       gom_header.filename);
   if (gom_header.copyright)
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_COPR, NULL, REC_HEAD,
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_COPR, 0, REC_HEAD,
                                       gom_header.copyright);
-  result |= gedcom_write_element_str(hndl, ELT_HEAD_GEDC, NULL, REC_HEAD,
+  result |= gedcom_write_element_str(hndl, ELT_HEAD_GEDC, 0, REC_HEAD,
                                     NULL);
   if (gom_header.gedcom.version)
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_GEDC_VERS, NULL,
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_GEDC_VERS, 0,
                                       ELT_HEAD_GEDC,
                                       gom_header.gedcom.version);
   if (gom_header.gedcom.form)
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_GEDC_FORM, NULL,
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_GEDC_FORM, 0,
                                       ELT_HEAD_GEDC,
                                       gom_header.gedcom.form);
-  if (gom_header.charset.name)
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_CHAR, NULL,
-                                      REC_HEAD,
-                                      gom_header.charset.name);
-  if (gom_header.charset.version)
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_CHAR_VERS, NULL,
-                                      ELT_HEAD_CHAR,
-                                      gom_header.charset.version);
   if (gom_header.language)
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_LANG, NULL,
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_LANG, 0,
                                       REC_HEAD,
                                       gom_header.language);
   if (gom_header.place_hierarchy) {
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_PLAC, NULL, REC_HEAD,
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_PLAC, 0, REC_HEAD,
                                       NULL);
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_PLAC_FORM, NULL,
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_PLAC_FORM, 0,
                                       ELT_HEAD_PLAC,
                                       gom_header.place_hierarchy);
   }
   if (gom_header.note)
-    result |= gedcom_write_element_str(hndl, ELT_HEAD_NOTE, NULL,
+    result |= gedcom_write_element_str(hndl, ELT_HEAD_NOTE, 0,
                                       REC_HEAD,
                                       gom_header.note);
+  if (gom_header.extra)
+    result |= write_user_data(hndl, gom_header.extra);
   return result;
 }
index 07e69b1b9af1550d1565446c8c6b9a0b6972095f..958cce8340f5dc797af86eb0d8140ec21ee5dbf9 100644 (file)
@@ -223,3 +223,70 @@ struct individual* make_individual_record(const char* xrefstr)
   }
   return indiv;
 }
+
+int write_individuals(Gedcom_write_hndl hndl)
+{
+  int result = 0;
+  struct individual* obj;
+
+  for (obj = gom_first_individual; obj; obj = obj->next) {
+    result |= gedcom_write_record_str(hndl, REC_INDI, 0,
+                                     obj->xrefstr, NULL);
+    if (obj->restriction_notice)
+      result |= gedcom_write_element_str(hndl, ELT_INDI_RESN, 0,
+                                        REC_INDI, obj->restriction_notice);
+    if (obj->name)
+      result |= write_names(hndl, REC_INDI, obj->name);
+    if (obj->sex)
+      result |= gedcom_write_element_str(hndl, ELT_INDI_SEX, 0,
+                                        REC_INDI, obj->sex);
+    if (obj->event)
+      result |= write_events(hndl, REC_INDI, EVT_TYPE_INDIV_EVT, obj->event);
+    if (obj->attribute)
+      result |= write_events(hndl, REC_INDI, EVT_TYPE_INDIV_ATTR,
+                            obj->attribute);
+    if (obj->lds_individual_ordinance)
+      result |= write_lds_events(hndl, REC_INDI,
+                                obj->lds_individual_ordinance);
+    if (obj->child_to_family)
+      result |= write_family_links(hndl, REC_INDI, LINK_TYPE_CHILD,
+                                  obj->child_to_family);
+    if (obj->spouse_to_family)
+      result |= write_family_links(hndl, REC_INDI, LINK_TYPE_SPOUSE,
+                                  obj->spouse_to_family);
+    result |= gom_write_xref_list(hndl, ELT_INDI_SUBM, 0,
+                                 REC_INDI, obj->submitters);
+    if (obj->association)
+      result |= write_associations(hndl, REC_INDI, obj->association);
+    result |= gom_write_xref_list(hndl, ELT_INDI_ALIA, 0,
+                                 REC_INDI, obj->alias);
+    result |= gom_write_xref_list(hndl, ELT_INDI_ANCI, 0,
+                                 REC_INDI, obj->ancestor_interest);
+    result |= gom_write_xref_list(hndl, ELT_INDI_DESI, 0,
+                                 REC_INDI, obj->descendant_interest);
+    if (obj->citation)
+      result |= write_citations(hndl, REC_INDI, obj->citation);
+    if (obj->mm_link)
+      result |= write_multimedia_links(hndl, REC_INDI, obj->mm_link);
+    if (obj->note)
+      result |= write_note_subs(hndl, REC_INDI, obj->note);
+    if (obj->record_file_nr)
+      result |= gedcom_write_element_str(hndl, ELT_INDI_RFN, 0,
+                                        REC_INDI, obj->record_file_nr);
+    if (obj->ancestral_file_nr)
+      result |= gedcom_write_element_str(hndl, ELT_INDI_AFN, 0,
+                                        REC_INDI, obj->ancestral_file_nr);
+    if (obj->ref)
+      result |= write_user_refs(hndl, REC_INDI, obj->ref);
+    if (obj->record_id)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_IDENT_RIN, 0,
+                                        REC_INDI, obj->record_id);
+    if (obj->change_date)
+      result |= write_change_date(hndl, REC_INDI, obj->change_date);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);
+  }
+  
+  return result;
+}
+
index f9bad2382f1b55b1724a3e4eb7a57c9b3602b31d..51a233ec1709b28aa8d860674d75b50ec1b5a5ee 100644 (file)
@@ -44,5 +44,6 @@ void individual_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
 void individual_set_record_id(Gom_ctxt ctxt, const 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);
+int write_individuals(Gedcom_write_hndl hndl);
 
 #endif /* __INDIVIDUAL_H */
index 5abaa2ec7af4cfd70e4ac68aac573827ba522231..fbd021d9e02266549d37633472e67f8a4465d51f 100644 (file)
@@ -47,16 +47,23 @@ Gedcom_ctxt sub_lds_event_start(_ELT_PARAMS_)
       MEMORY_ERROR;
     else {
       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);
+      lds_evt->event = parsed_tag;
+      lds_evt->event_name = strdup(tag);
+      if (! lds_evt->event_name) {
+       MEMORY_ERROR;
+       free(lds_evt);
+      }
+      else {
+       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);
+       }
+       result = MAKE_GOM_CTXT(elt, lds_event, lds_evt);
       }
-      result = MAKE_GOM_CTXT(elt, lds_event, lds_evt);
     }
   }
 
@@ -121,6 +128,7 @@ void lds_event_add_user_data(Gom_ctxt ctxt, struct user_data* data)
 void lds_event_cleanup(struct lds_event* lds)
 {
   if (lds) {
+    SAFE_FREE(lds->event_name);
     SAFE_FREE(lds->date_status);
     SAFE_FREE(lds->date);
     SAFE_FREE(lds->temple_code);
@@ -130,3 +138,51 @@ void lds_event_cleanup(struct lds_event* lds)
     DESTROY_CHAIN_ELTS(user_data, lds->extra, user_data_cleanup);
   }
 }
+
+static int get_gedcom_elt(int parsed_tag)
+{
+  int obj_elt = 0;
+  switch (parsed_tag) {
+    case TAG_BAPL: case TAG_CONL: case TAG_ENDL:
+      obj_elt = ELT_SUB_LIO_BAPL; break;
+    case TAG_SLGC:
+      obj_elt = ELT_SUB_LIO_SLGC; break;
+    default:
+      gedcom_warning(_("Internal error: unknown evt tag %d"), parsed_tag);
+  }
+  return obj_elt;
+}
+  
+int write_lds_events(Gedcom_write_hndl hndl, int parent, struct lds_event *lds)
+{
+  int result = 0;
+  struct lds_event* obj;
+
+  if (!lds) return 1;
+
+  for (obj = lds; obj; obj = obj->next) {
+    int obj_elt = get_gedcom_elt(obj->event);
+    result |= gedcom_write_element_str(hndl, obj_elt, obj->event,
+                                      parent, NULL);
+    if (obj->date_status)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_LIO_BAPL_STAT, 0,
+                                        parent, obj->date_status);
+    if (obj->temple_code)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_LIO_BAPL_TEMP, 0,
+                                        parent, obj->temple_code);
+    if (obj->place_living_ordinance)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_LIO_BAPL_PLAC, 0,
+                                        parent, obj->place_living_ordinance);
+    if (obj->family)
+      result |= gedcom_write_element_xref(hndl, ELT_SUB_LIO_SLGC_FAMC, 0,
+                                         parent, obj->family);
+    if (obj->citation)
+      result |= write_citations(hndl, obj_elt, obj->citation);
+    if (obj->note)
+      result |= write_note_subs(hndl, obj_elt, obj->note);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);
+  }
+
+  return result;
+}
index fde8b3563054aa603d66d01d65a1e1a5ea5dacc3..48da41aff081f93e7792fce4cd4e694135d4ca58 100644 (file)
@@ -33,5 +33,7 @@ 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);
+int write_lds_events(Gedcom_write_hndl hndl, int parent,
+                    struct lds_event *lds);
 
 #endif /* __LDS_EVENT_H */
index 8ae88023e65c72ddf748d0f47a4ddc4be10b0b14..af97afc79db6c2336fba67d405a1e89f661786fa 100644 (file)
@@ -138,3 +138,40 @@ struct multimedia* make_multimedia_record(const char* xrefstr)
   }
   return multi;
 }
+
+int write_multimedia_recs(Gedcom_write_hndl hndl)
+{
+  int result = 0;
+  struct multimedia* obj;
+
+  for (obj = gom_first_multimedia; obj; obj = obj->next) {
+    result |= gedcom_write_record_str(hndl, REC_OBJE, 0,
+                                     obj->xrefstr, NULL);
+    if (obj->form)
+      result |= gedcom_write_element_str(hndl, ELT_OBJE_FORM, 0,
+                                        REC_OBJE, obj->form);
+    if (obj->title)
+      result |= gedcom_write_element_str(hndl, ELT_OBJE_TITL, 0,
+                                        REC_OBJE, obj->title);
+    if (obj->note)
+      result |= write_note_subs(hndl, REC_OBJE, obj->note);
+    if (obj->data)
+      result |= gedcom_write_element_str(hndl, ELT_OBJE_BLOB, 0,
+                                        REC_OBJE, obj->data);
+    if (obj->continued)
+      result |= gedcom_write_element_xref(hndl, ELT_OBJE_OBJE, 0,
+                                         REC_OBJE, obj->continued);
+    if (obj->ref)
+      result |= write_user_refs(hndl, REC_OBJE, obj->ref);
+    if (obj->record_id)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_IDENT_RIN, 0,
+                                        REC_OBJE, obj->record_id);
+    if (obj->change_date)
+      result |= write_change_date(hndl, REC_OBJE, obj->change_date);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);
+  }
+  
+  return result;
+}
+
index 855eda30a0044d7b6c83b5cc5c664af3e6d302a8..00353dfecc2c2204b01e68985241baaa9f35e22f 100644 (file)
@@ -35,5 +35,6 @@ void multimedia_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
 void multimedia_set_record_id(Gom_ctxt ctxt, const 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);
+int write_multimedia_recs(Gedcom_write_hndl hndl);
 
 #endif /* __MULTIMEDIA_H */
index 2b5a1f13fc36af873dc8356e543b9707b3287135..f6044ff0b1eee43f764df9c2c91ac7075b8ed172 100644 (file)
@@ -123,3 +123,38 @@ void multimedia_link_cleanup(struct multimedia_link* mm)
     DESTROY_CHAIN_ELTS(user_data, mm->extra, user_data_cleanup);
   }
 }
+
+int write_multimedia_links(Gedcom_write_hndl hndl, int parent,
+                          struct multimedia_link* mm)
+{
+  int result = 0;
+  struct multimedia_link* obj;
+
+  if (!mm) return 1;
+
+  for (obj = mm; obj; obj = obj->next) {
+    if (obj->reference) {
+      result |= gedcom_write_element_xref(hndl, ELT_SUB_MULTIM_OBJE, 0,
+                                         parent, obj->reference);
+    }
+    else {
+      result |= gedcom_write_element_str(hndl, ELT_SUB_MULTIM_OBJE, 0,
+                                        parent, NULL);
+      if (obj->form)
+       result |= gedcom_write_element_str(hndl, ELT_SUB_MULTIM_OBJE_FORM, 0,
+                                          ELT_SUB_MULTIM_OBJE, obj->form);
+      if (obj->title)
+       result |= gedcom_write_element_str(hndl, ELT_SUB_MULTIM_OBJE_TITL, 0,
+                                          ELT_SUB_MULTIM_OBJE, obj->title);
+      if (obj->file)
+       result |= gedcom_write_element_str(hndl, ELT_SUB_MULTIM_OBJE_FILE, 0,
+                                          ELT_SUB_MULTIM_OBJE, obj->file);
+      if (obj->note)
+       result |= write_note_subs(hndl, ELT_SUB_MULTIM_OBJE, obj->note);
+      if (obj->extra)
+       result |= write_user_data(hndl, obj->extra);
+    }
+  }
+
+  return result;
+}
index 5ee0035d832d0ce98e89cb8859c728523b889483..4ab26843bfc0b471e28700a2d33e973d0abb79eb 100644 (file)
@@ -32,5 +32,7 @@ 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);
+int write_multimedia_links(Gedcom_write_hndl hndl, int parent,
+                          struct multimedia_link* mm);
 
 #endif /* __MULTIMEDIA_LINK_H */
index 41dab5f5697bb3df1e6d639c6ed36f6e5ea0590d..0dd24430501862bc01cd71f800156e0f1c7caecf 100644 (file)
@@ -144,3 +144,28 @@ struct note* make_note_record(const char* xrefstr)
   }
   return note;
 }
+
+int write_notes(Gedcom_write_hndl hndl)
+{
+  int result = 0;
+  struct note* obj;
+
+  for (obj = gom_first_note; obj; obj = obj->next) {
+    result |= gedcom_write_record_str(hndl, REC_NOTE, 0,
+                                     obj->xrefstr, obj->text);
+    if (obj->citation)
+      result |= write_citations(hndl, REC_NOTE, obj->citation);
+    if (obj->ref)
+      result |= write_user_refs(hndl, REC_NOTE, obj->ref);
+    if (obj->record_id)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_IDENT_RIN, 0,
+                                        REC_NOTE, obj->record_id);
+    if (obj->change_date)
+      result |= write_change_date(hndl, REC_NOTE, obj->change_date);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);
+  }
+  
+  return result;
+}
+
index ffbe3b61125661aab4e8e88da3d40d87be660579..a2f6edad7d0c85207faf0e06778dbe1b248cb830 100644 (file)
@@ -35,5 +35,6 @@ void note_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
 void note_set_record_id(Gom_ctxt ctxt, const 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);
+int write_notes(Gedcom_write_hndl hndl);
 
 #endif /* __NOTE_H */
index 662cf9fd54c80db5124e0688e8eb845fa10933bf..63ef644150a4348dacc569cfbb20d502da1a11bb 100644 (file)
@@ -142,3 +142,28 @@ void note_sub_cleanup(struct note_sub* note)
     DESTROY_CHAIN_ELTS(user_data, note->extra, user_data_cleanup);
   }
 }
+
+int write_note_subs(Gedcom_write_hndl hndl, int parent, struct note_sub* note)
+{
+  int result = 0;
+  struct note_sub* obj;
+
+  if (!note) return 1;
+
+  for (obj = note; obj; obj = obj->next) {
+    if (obj->reference) {
+      result |= gedcom_write_element_xref(hndl, ELT_SUB_NOTE, 0,
+                                         parent, obj->reference);
+    }
+    else {
+      result |= gedcom_write_element_str(hndl, ELT_SUB_NOTE, 0,
+                                        parent, obj->text);
+    }
+    if (obj->citation)
+      result |= write_citations(hndl, ELT_SUB_NOTE, obj->citation);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);
+  }
+
+  return result;
+}
index 630f3d89abb2135106ccdb333d42ad8050dbbc13..b543eb084e4380157aec936fb5228d12b6db4384 100644 (file)
@@ -31,5 +31,6 @@ 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_user_data(Gom_ctxt ctxt, struct user_data* data);
+int write_note_subs(Gedcom_write_hndl hndl, int parent, struct note_sub* note);
 
 #endif /* __NOTE_SUB_H */
index 7efc916b4f9344792774f1e408e0009ea6c1e288..6345b29195aac6fd3bb30138d4632fe7fe5b36a6 100644 (file)
@@ -125,3 +125,43 @@ void name_cleanup(struct personal_name* name)
     DESTROY_CHAIN_ELTS(user_data, name->extra, user_data_cleanup);
   }
 }
+
+int write_names(Gedcom_write_hndl hndl, int parent,
+               struct personal_name *name)
+{
+  int result = 0;
+  struct personal_name* obj;
+
+  if (!name) return 1;
+
+  for (obj = name; obj; obj = obj->next) {
+    result |= gedcom_write_element_str(hndl, ELT_SUB_PERS_NAME, 0,
+                                      parent, obj->name);
+    if (obj->prefix)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_PERS_NAME_NPFX, 0,
+                                        parent, obj->prefix);
+    if (obj->given)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_PERS_NAME_GIVN, 0,
+                                        parent, obj->given);
+    if (obj->nickname)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_PERS_NAME_NICK, 0,
+                                        parent, obj->nickname);
+    if (obj->surname_prefix)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_PERS_NAME_SPFX, 0,
+                                        parent, obj->surname_prefix);
+    if (obj->surname)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_PERS_NAME_SURN, 0,
+                                        parent, obj->surname);
+    if (obj->suffix)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_PERS_NAME_NSFX, 0,
+                                        parent, obj->suffix);
+    if (obj->citation)
+      result |= write_citations(hndl, ELT_SUB_PERS_NAME, obj->citation);
+    if (obj->note)
+      result |= write_note_subs(hndl, ELT_SUB_PERS_NAME, obj->note);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);
+  }
+
+  return result;
+}
index 2cc36d1c7217778495584fa2c2a91e3a3a73f8c6..85587d195db4c1f44be4a344df7d5c582a1d5e11 100644 (file)
@@ -32,5 +32,7 @@ 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);
+int write_names(Gedcom_write_hndl hndl, int parent,
+               struct personal_name *name);
 
 #endif /* __PERSONAL_NAME_H */
index bb6ead6586f43499bea300d1be4047778af01c9c..7385a56f84f1a311a82e621f188c9cc3bc9d5f4c 100644 (file)
@@ -115,3 +115,24 @@ void place_cleanup(struct place* place)
   }
   SAFE_FREE(place);
 }
+
+int write_place(Gedcom_write_hndl hndl, int parent, struct place* place)
+{
+  int result = 0;
+  
+  if (!place) return 1;
+  
+  result |= gedcom_write_element_str(hndl, ELT_SUB_PLAC, 0,
+                                    parent, place->value);
+  if (place->place_hierarchy)
+    result |= gedcom_write_element_str(hndl, ELT_SUB_PLAC_FORM, 0,
+                                      ELT_SUB_PLAC, place->place_hierarchy);
+  if (place->citation)
+    result |= write_citations(hndl, ELT_SUB_PLAC, place->citation);
+  if (place->note)
+    result |= write_note_subs(hndl, ELT_SUB_PLAC, place->note);
+  if (place->extra)
+    result |= write_user_data(hndl, place->extra);
+
+  return result;
+}
index 9e0086962d7f83d916671e76d60c33cef27f0ff8..a2ca02df4f6b116a27c64a582478b3a5a6adc4c4 100644 (file)
@@ -32,5 +32,6 @@ 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);
+int write_place(Gedcom_write_hndl hndl, int parent, struct place* place);
 
 #endif /* __PLACE_H */
index b34081cb84f739a9801e33a0c6961a7b9533ef9a..1cf459505867d30f9cbd32eeb15a243992a8e554 100644 (file)
@@ -139,3 +139,36 @@ struct repository* make_repository_record(const char* xrefstr)
   }
   return repo;
 }
+
+int write_repositories(Gedcom_write_hndl hndl)
+{
+  int result = 0;
+  int i;
+  struct repository* obj;
+
+  for (obj = gom_first_repository; obj; obj = obj->next) {
+    result |= gedcom_write_record_str(hndl, REC_REPO, 0,
+                                     obj->xrefstr, NULL);
+    if (obj->name)
+      result |= gedcom_write_element_str(hndl, ELT_REPO_NAME, 0,
+                                        REC_REPO, obj->name);
+    if (obj->address)
+      result |= write_address(hndl, REC_REPO, obj->address);
+    for (i = 0; i < 3 && obj->phone[i]; i++)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_PHON, 0, REC_REPO,
+                                        obj->phone[i]);
+    if (obj->note)
+      result |= write_note_subs(hndl, REC_REPO, obj->note);
+    if (obj->ref)
+      result |= write_user_refs(hndl, REC_REPO, obj->ref);
+    if (obj->record_id)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_IDENT_RIN, 0,
+                                        REC_REPO, obj->record_id);
+    if (obj->change_date)
+      result |= write_change_date(hndl, REC_REPO, obj->change_date);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);
+  }
+  
+  return result;
+}
index ec3c8662187f5f630d86a13662563c7416fd1a44..066d7408ee04caed478a39237e42117d1b3c7e79 100644 (file)
@@ -37,5 +37,6 @@ void repository_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
 void repository_set_record_id(Gom_ctxt ctxt, const 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);
+int write_repositories(Gedcom_write_hndl hndl);
 
 #endif /* __REPOSITORY_H */
index 57520eda9b1fc6443d38be5c39a2cd5f06169aa9..2f353973d18fae5b840862ac9fca801f8cff23a0 100644 (file)
@@ -183,3 +183,65 @@ struct source* make_source_record(const char* xrefstr)
   }
   return src;
 }
+
+int write_sources(Gedcom_write_hndl hndl)
+{
+  int result = 0;
+  struct source* obj;
+
+  for (obj = gom_first_source; obj; obj = obj->next) {
+    result |= gedcom_write_record_str(hndl, REC_SOUR, 0,
+                                     obj->xrefstr, NULL);
+    if (obj->data.event || obj->data.agency || obj->data.note)
+      result |= gedcom_write_element_str(hndl, ELT_SOUR_DATA, 0,
+                                        REC_SOUR, NULL);
+    if (obj->data.event)
+      result |= write_source_events(hndl, ELT_SOUR_DATA, obj->data.event);
+    if (obj->data.agency)
+      result |= gedcom_write_element_str(hndl, ELT_SOUR_DATA_AGNC, 0,
+                                        ELT_SOUR_DATA, obj->data.agency);
+    if (obj->data.note)
+      result |= write_note_subs(hndl, ELT_SOUR_DATA, obj->data.note);
+    if (obj->author)
+      result |= gedcom_write_element_str(hndl, ELT_SOUR_AUTH, 0,
+                                        REC_SOUR, obj->author);
+    if (obj->title)
+      result |= gedcom_write_element_str(hndl, ELT_SOUR_TITL, 0,
+                                        REC_SOUR, obj->title);
+    if (obj->abbreviation)
+      result |= gedcom_write_element_str(hndl, ELT_SOUR_ABBR, 0,
+                                        REC_SOUR, obj->abbreviation);
+    if (obj->publication)
+      result |= gedcom_write_element_str(hndl, ELT_SOUR_PUBL, 0,
+                                        REC_SOUR, obj->publication);
+    if (obj->text)
+      result |= gedcom_write_element_str(hndl, ELT_SOUR_TEXT, 0,
+                                        REC_SOUR, obj->text);
+    if (obj->repository.link || obj->repository.note
+       || obj->repository.description) {
+      result |= gedcom_write_element_xref(hndl, ELT_SUB_REPO, 0,
+                                         REC_SOUR, obj->repository.link);
+    }
+    if (obj->repository.note)
+      result |= write_note_subs(hndl, ELT_SUB_REPO, obj->repository.note);
+    if (obj->repository.description)
+      result |= write_source_descriptions(hndl, ELT_SUB_REPO,
+                                         obj->repository.description);
+    if (obj->mm_link)
+      result |= write_multimedia_links(hndl, REC_SOUR, obj->mm_link);
+    if (obj->note)
+      result |= write_note_subs(hndl, REC_SOUR, obj->note);
+    if (obj->ref)
+      result |= write_user_refs(hndl, REC_SOUR, obj->ref);
+    if (obj->record_id)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_IDENT_RIN, 0,
+                                        REC_SOUR, obj->record_id);
+    if (obj->change_date)
+      result |= write_change_date(hndl, REC_SOUR, obj->change_date);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);
+  }
+  
+  return result;
+}
+
index 27a4a3961ce569ad3085753a500c159a857fc6c1..15af0d3668e52a2ddb96da9e8304b259340812b2 100644 (file)
@@ -40,5 +40,6 @@ void source_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
 void source_set_record_id(Gom_ctxt ctxt, const 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);
+int write_sources(Gedcom_write_hndl hndl);
 
 #endif /* __SOURCE_H */
index 8aa6b51687a1311ad2bdaf8b9ff82acce69aeb6e..ff479d92972ec68aa56927db46b9fed07a0664b1 100644 (file)
@@ -208,3 +208,67 @@ void citation_cleanup(struct source_citation* cit)
     DESTROY_CHAIN_ELTS(user_data, cit->extra, user_data_cleanup);
   }
 }
+
+int write_texts(Gedcom_write_hndl hndl, int parent, struct text* t)
+{
+  int result = 0;
+  struct text* obj;
+  
+  if (!t) return 1;
+
+  for (obj = t; obj; obj = obj->next) {
+    result |= gedcom_write_element_str(hndl, ELT_SUB_SOUR_TEXT, 0, parent,
+                                      obj->text);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);    
+  }
+  
+  return result;
+}
+
+int write_citations(Gedcom_write_hndl hndl, int parent,
+                   struct source_citation* cit)
+{
+  int result = 0;
+  struct source_citation* obj;
+  
+  if (!cit) return 1;
+
+  for (obj = cit; obj; obj = obj->next) {
+    if (obj->reference) {
+      result |= gedcom_write_element_xref(hndl, ELT_SUB_SOUR, 0, parent,
+                                         obj->reference);
+      if (obj->page)
+       result |= gedcom_write_element_str(hndl, ELT_SUB_SOUR_PAGE, 0,
+                                          ELT_SUB_SOUR, obj->page);
+      if (obj->event)
+       result |= gedcom_write_element_str(hndl, ELT_SUB_SOUR_EVEN, 0,
+                                          ELT_SUB_SOUR, obj->event);
+      if (obj->role)
+       result |= gedcom_write_element_str(hndl, ELT_SUB_SOUR_EVEN_ROLE, 0,
+                                          ELT_SUB_SOUR_EVEN, obj->role);
+      if (obj->date || obj->text)
+       result |= gedcom_write_element_str(hndl, ELT_SUB_SOUR_DATA, 0,
+                                          ELT_SUB_SOUR, NULL);
+      if (obj->text)
+       result |= write_texts(hndl, ELT_SUB_SOUR_DATA, obj->text);
+      if (obj->quality)
+       result |= gedcom_write_element_str(hndl, ELT_SUB_SOUR_QUAY, 0,
+                                          ELT_SUB_SOUR, obj->quality);
+      if (obj->mm_link)
+       result |= write_multimedia_links(hndl, ELT_SUB_SOUR, obj->mm_link);
+    }
+    else {
+      result |= gedcom_write_element_str(hndl, ELT_SUB_SOUR, 0, parent,
+                                        obj->description);
+      if (obj->text)
+       result |= write_texts(hndl, ELT_SUB_SOUR, obj->text);
+    }
+    if (obj->note)
+      result |= write_note_subs(hndl, ELT_SUB_SOUR, obj->note);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);    
+  }
+  
+  return result;
+}
index d5b183ab0ccbb557ef4de0883e3f21de935fa95b..530c22ea860cd6a9e3d86c16d79cb5c0949bcb08 100644 (file)
@@ -33,5 +33,7 @@ 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_user_data(Gom_ctxt ctxt, struct user_data* data);
+int write_citations(Gedcom_write_hndl hndl, int parent,
+                   struct source_citation* cit);
 
 #endif /* __SOURCE_CITATION_H */
index ecec1dc30cb187bcd5f5427c79257ff3ba1b9502..b03e3973541501fe176a7f0c9ee12644e6ad5f2e 100644 (file)
@@ -90,3 +90,24 @@ void source_description_cleanup(struct source_description* desc)
     DESTROY_CHAIN_ELTS(user_data, desc->extra, user_data_cleanup);
   }
 }
+
+int write_source_descriptions(Gedcom_write_hndl hndl, int parent,
+                             struct source_description *desc)
+{
+  int result = 0;
+  struct source_description* obj;
+
+  if (!desc) return 1;
+
+  for (obj = desc; obj; obj = obj->next) {
+    result |= gedcom_write_element_str(hndl, ELT_SUB_REPO_CALN, 0,
+                                      parent, obj->call_number);
+    if (obj->media)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_REPO_CALN_MEDI, 0,
+                                        ELT_SUB_REPO_CALN, obj->media);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);    
+  }
+
+  return result;
+}
index b944b73d82147718308614d2bb4502c9b0402961..087842a69cb2d6dd5bfa6588d131480f7d01ded5 100644 (file)
@@ -31,5 +31,7 @@
 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);
+int write_source_descriptions(Gedcom_write_hndl hndl, int parent,
+                             struct source_description *desc);
 
 #endif /* __SOURCE_DESCRIPTION_H */
index f7c7a8d2a1072dab43f799408fcaa59adbaec56f..fea635184a8c6652d087576837ed7be9a73d7c57 100644 (file)
@@ -94,3 +94,24 @@ void source_event_cleanup(struct source_event* evt)
     DESTROY_CHAIN_ELTS(user_data, evt->extra, user_data_cleanup);
   }
 }
+
+int write_source_events(Gedcom_write_hndl hndl, int parent,
+                       struct source_event *evt)
+{
+  int result = 0;
+  struct source_event* obj;
+
+  if (!evt) return 1;
+
+  for (obj = evt; obj; obj = obj->next) {
+    result |= gedcom_write_element_str(hndl, ELT_SOUR_DATA_EVEN, 0,
+                                      parent, obj->recorded_events);
+    if (obj->jurisdiction)
+      result |= gedcom_write_element_str(hndl, ELT_SOUR_DATA_EVEN_PLAC, 0,
+                                       ELT_SOUR_DATA_EVEN, obj->jurisdiction);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);    
+  }
+
+  return result;
+}
index 554b41442cdc6c90b2fc92c4e86579d740d75892..39e5399d1f97c8c40a566e819cd2d9496934dcb6 100644 (file)
@@ -30,5 +30,7 @@
 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);
+int write_source_events(Gedcom_write_hndl hndl, int parent,
+                       struct source_event *evt);
 
 #endif /* __SOURCE_EVENT_H */
index fcd3c862492be25a90778fc4b1df6997928534d2..3fe9b4041ffaece01f2c45cad5be84ef4cc1c485 100644 (file)
@@ -95,3 +95,38 @@ struct submission* make_submission_record(const char* xref)
   
   return gom_submission;
 }
+
+int write_submission(Gedcom_write_hndl hndl)
+{
+  int result = 0;
+
+  if (gom_submission) {
+    result |= gedcom_write_record_str(hndl, REC_SUBN, 0,
+                                     gom_submission->xrefstr, NULL);
+    if (gom_submission->submitter)
+      result |= gedcom_write_element_xref(hndl, ELT_SUBN_SUBM, 0,
+                                         REC_SUBN, gom_submission->submitter);
+    if (gom_submission->family_file)
+      result |= gedcom_write_element_str(hndl, ELT_SUBN_FAMF, 0, REC_SUBN,
+                                        gom_submission->family_file);
+    if (gom_submission->temple_code)
+      result |= gedcom_write_element_str(hndl, ELT_SUBN_TEMP, 0, REC_SUBN,
+                                        gom_submission->temple_code);
+    if (gom_submission->nr_of_ancestor_gens)
+      result |= gedcom_write_element_str(hndl, ELT_SUBN_ANCE, 0, REC_SUBN,
+                                        gom_submission->nr_of_ancestor_gens);
+    if (gom_submission->nr_of_descendant_gens)
+      result |= gedcom_write_element_str(hndl, ELT_SUBN_DESC, 0, REC_SUBN,
+                                       gom_submission->nr_of_descendant_gens);
+    if (gom_submission->ordinance_process_flag)
+      result |= gedcom_write_element_str(hndl, ELT_SUBN_ORDI, 0, REC_SUBN,
+                                     gom_submission->ordinance_process_flag);
+    if (gom_submission->record_id)
+      result |= gedcom_write_element_str(hndl, ELT_SUBN_RIN, 0, REC_SUBN,
+                                        gom_submission->record_id);
+    if (gom_submission->extra)
+      result |= write_user_data(hndl, gom_submission->extra);
+  }
+  
+  return result;
+}
index 0a5d40d5dc097caafe2535ea0632e8e7c6953cd7..12c2bb45c513dd6aa78af4495e0813a013ea27a1 100644 (file)
@@ -31,5 +31,6 @@ void submission_subscribe();
 void submission_cleanup();
 struct submission* make_submission_record(const char* xref);
 void submission_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+int write_submission(Gedcom_write_hndl hndl);
 
 #endif /* __SUBMISSION_H */
index cbfbcd71fbd7bbce7175d72f04f693e56ee14cfe..107653f2686811db9e0aa531ba0e33fd375e4f1e 100644 (file)
@@ -161,3 +161,41 @@ struct submitter* make_submitter_record(const char* xrefstr)
   }
   return subm;
 }
+
+int write_submitters(Gedcom_write_hndl hndl)
+{
+  int result = 0;
+  int i;
+  struct submitter* obj;
+
+  for (obj = gom_first_submitter; obj; obj = obj->next) {
+    result |= gedcom_write_record_str(hndl, REC_SUBM, 0,
+                                     obj->xrefstr, NULL);
+    if (obj->name)
+      result |= gedcom_write_element_str(hndl, ELT_SUBM_NAME, 0, REC_SUBM,
+                                        obj->name);
+    if (obj->address)
+      result |= write_address(hndl, REC_SUBM, obj->address);
+    for (i = 0; i < 3 && obj->phone[i]; i++)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_PHON, 0, REC_SUBM,
+                                        obj->phone[i]);
+    if (obj->mm_link)
+      result |= write_multimedia_links(hndl, REC_SUBM, obj->mm_link);
+    for (i = 0; i < 3 && obj->language[i]; i++)
+      result |= gedcom_write_element_str(hndl, ELT_SUBM_LANG, 0, REC_SUBM,
+                                        obj->language[i]);
+    if (obj->record_file_nr)
+      result |= gedcom_write_element_str(hndl, ELT_SUBM_RFN, 0, REC_SUBM,
+                                        obj->record_file_nr);
+    if (obj->record_id)
+      result |= gedcom_write_element_str(hndl, ELT_SUBM_RIN, 0, REC_SUBM,
+                                        obj->record_id);
+    if (obj->change_date)
+      result |= write_change_date(hndl, REC_SUBM, obj->change_date);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);
+  }
+  
+  return result;
+}
+
index c1e57ff01347e0e1e51b648d1a55783d425d55fe..7763b8a6dc7eb3c1a1468a7bec8aa10de635cd26 100644 (file)
@@ -35,5 +35,6 @@ void submitter_add_phone(Gom_ctxt ctxt, const 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);
+int write_submitters(Gedcom_write_hndl hndl);
 
 #endif /* __SUBMITTER_H */
index b34e20debe81001d4794d4a5218f98c015f847d9..4ea975ef2fa60405c6810098e25e7e6164c96c73 100644 (file)
@@ -251,3 +251,39 @@ struct user_rec* make_user_record(const char* xrefstr)
   }
   return rec;
 }
+
+int write_user_recs(Gedcom_write_hndl hndl)
+{
+  int result = 0;
+  struct user_rec* obj;
+
+  for (obj = gom_first_user_rec; obj; obj = obj->next) {
+    if (obj->xref_value)
+      result |= gedcom_write_user_xref(hndl, 0, obj->tag, obj->xrefstr,
+                                      obj->xref_value);
+    else
+      result |= gedcom_write_user_str(hndl, 0, obj->tag, obj->xrefstr,
+                                     obj->str_value);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);
+  }
+  return result;  
+}
+
+int write_user_data(Gedcom_write_hndl hndl, struct user_data* data)
+{
+  int result = 0;
+  struct user_data* obj;
+
+  if (!data) return 1;
+
+  for (obj = data; data; data = data->next) {
+    if (obj->xref_value)
+      result |= gedcom_write_user_xref(hndl, obj->level, obj->tag, NULL,
+                                      obj->xref_value);
+    else
+      result |= gedcom_write_user_str(hndl, obj->level, obj->tag, NULL,
+                                     obj->str_value);
+  }
+  return result;
+}
index 2cbeef6dff39b30fb61409e4ee49bc1f23dfad79..7e416d84284664e709c40be1daaa63478cb0ee20 100644 (file)
@@ -32,5 +32,7 @@ void user_recs_cleanup();
 struct user_rec* make_user_record(const char* xref);
 void user_data_cleanup(struct user_data* data);
 void user_rec_add_user_data(Gom_ctxt ctxt, struct user_data* data);
+int write_user_recs(Gedcom_write_hndl hndl);
+int write_user_data(Gedcom_write_hndl hndl, struct user_data* data);
 
 #endif /* __USER_REC_H */
index e83c82db68e8f4df02d6936af38f82815b36457c..27f32bb88818c105892842ccdb06e7e7f3412adc 100644 (file)
@@ -139,3 +139,24 @@ void user_ref_cleanup(struct user_ref_number* refn)
     DESTROY_CHAIN_ELTS(user_data, refn->extra, user_data_cleanup);
   }
 }
+
+int write_user_refs(Gedcom_write_hndl hndl, int parent,
+                   struct user_ref_number *refn)
+{
+  int result = 0;
+  struct user_ref_number* obj;
+
+  if (!refn) return 1;
+
+  for (obj = refn; obj; obj = obj->next) {
+    result |= gedcom_write_element_str(hndl, ELT_SUB_IDENT_REFN, 0,
+                                      parent, obj->value);
+    if (obj->type)
+      result |= gedcom_write_element_str(hndl, ELT_SUB_IDENT_REFN_TYPE, 0,
+                                        ELT_SUB_IDENT_REFN, obj->type);
+    if (obj->extra)
+      result |= write_user_data(hndl, obj->extra);    
+  }
+
+  return result;
+}
index 04fb9711057d40a305e936a0ceb260ba40f01ef4..63e7962dadec76b9c3742768cdfe27b974a870e3 100644 (file)
@@ -30,5 +30,7 @@
 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);
+int write_user_refs(Gedcom_write_hndl hndl, int parent,
+                   struct user_ref_number *refn);
 
 #endif /* __USER_REF_H */
index 424c516a876c4a8de1b96fd1140b6a28a39fa156..87e07ee8fe10c7e0fba4dadf4496a9f78fe69065 100644 (file)
@@ -531,13 +531,26 @@ int  gedcom_write_close(Gedcom_write_hndl hndl, int *total_conv_fails);
 int  gedcom_write_set_encoding(const char* charset, Encoding width,
                                Enc_bom bom);
 int  gedcom_write_set_line_terminator(Enc_line_end end);
+
 int  gedcom_write_record_str(Gedcom_write_hndl hndl,
-                            Gedcom_rec rec, char* tag,
-                            struct xref_value* xref, char* val);
-int  gedcom_write_element_str(Gedcom_write_hndl hndl,
-                             Gedcom_elt elt, char* tag, int parent_rec_or_elt,
+                            Gedcom_rec rec, int parsed_tag,
+                            char* xrefstr, char* val);
+int  gedcom_write_element_str(Gedcom_write_hndl hndl, Gedcom_elt elt,
+                             int parsed_tag, int parent_rec_or_elt,
                              char* val);
 
+int gedcom_write_record_xref(Gedcom_write_hndl hndl,
+                            Gedcom_rec rec, int parsed_tag,
+                            char* xrefstr, struct xref_value* val);
+int gedcom_write_element_xref(Gedcom_write_hndl hndl, Gedcom_elt elt,
+                              int parsed_tag, int parent_rec_or_elt,
+                             struct xref_value* val);
+
+int gedcom_write_user_str(Gedcom_write_hndl hndl, int level, char* tag,
+                         char* xrefstr, char* value);
+int gedcom_write_user_xref(Gedcom_write_hndl hndl, int level, char* tag,
+                          char* xrefstr, struct xref_value* val);
+
 /* For use in gom */
 int        gedcom_error(const char* s, ...);
 int        gedcom_warning(const char* s, ...);
index 15d52a9eea1149cf19c04467802e584bc5fd6e4f..5a706cc74765ff9126b42d889c2b4bbd0a9ac913 100644 (file)
@@ -87,9 +87,9 @@ struct note_sub {                     /* NOTE_STRUCTURE */
 struct place {                        /* PLACE_STRUCTURE */
   char *value;                        /* PLACE_VALUE */
   char *place_hierarchy;              /* PLACE_HIERARCHY */
-  struct user_data *extra;
   struct source_citation *citation;
   struct note_sub *note;
+  struct user_data *extra;
 };
 
 struct multimedia_link {              /* MULTIMEDIA_LINK */
@@ -104,6 +104,8 @@ struct multimedia_link {              /* MULTIMEDIA_LINK */
 };
 
 struct lds_event {                    /* LDS_INDIVIDUAL_ORDINANCE */
+  int event;
+  char *event_name;
   char *date_status;                  /* LDS_BAPTISM_DATE_STATUS */
   struct date_value *date;            /* DATE_LDS_ORD */
   char *temple_code;                  /* TEMPLE_CODE */