/* $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;
};
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 },
+
};
#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 */
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
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++;
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));
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"),
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;
}
}
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;
+}
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 */
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;
+}
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 */
}
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;
+}
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 */
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;
+}
+
#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);
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 */
}
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;
+}
+
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 */
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;
+}
#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 */
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));
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)
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;
}
}
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;
+}
+
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 */
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);
}
}
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);
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;
+}
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 */
}
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;
+}
+
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 */
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;
+}
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 */
}
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;
+}
+
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 */
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;
+}
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 */
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;
+}
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 */
}
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;
+}
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 */
}
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;
+}
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 */
}
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;
+}
+
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 */
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;
+}
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 */
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;
+}
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 */
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;
+}
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 */
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;
+}
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 */
}
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;
+}
+
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 */
}
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;
+}
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 */
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;
+}
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 */
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, ...);
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 */
};
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 */