}
Gedcom_ctxt familia_gedcom_header_source_start(Gedcom_elt elt,
- Gedcom_ctxt parent,
+ Gedcom_ctxt ctxt,
int level,
char* tag,
char* raw_value,
{
char *source = GEDCOM_STRING(parsed_value);
printf("This file was created by %s\n", source);
- return parent;
+ return ctxt;
}
/*
void familia_gedcom_header_source_end(Gedcom_elt elt,
- Gedcom_ctxt parent,
+ Gedcom_ctxt ctxt,
Gedcom_ctxt self,
Gedcom_val parsed_value)
{
*/
Gedcom_ctxt familia_gedcom_header_version_start(Gedcom_elt elt,
- Gedcom_ctxt parent,
+ Gedcom_ctxt ctxt,
int level,
char* tag,
char* raw_value,
{
char *source = GEDCOM_STRING(parsed_value);
printf("Program version: %s (l: %d, tag: %s, raw:%s) \n", source, level, tag, raw_value);
- return parent;
+ return ctxt;
}
/*
void familia_gedcom_header_version_end(Gedcom_elt elt,
- Gedcom_ctxt parent,
+ Gedcom_ctxt ctxt,
Gedcom_ctxt self,
Gedcom_val parsed_value)
{
}
*/
Gedcom_ctxt familia_gedcom_individual_set_first_name(Gedcom_elt elt,
- Gedcom_ctxt parent,
+ Gedcom_ctxt ctxt,
int level,
char* tag,
char* raw_value,
int parsed_tag,
Gedcom_val parsed_value)
{
- familia_individual_set_first_name(parent, GEDCOM_STRING(parsed_value));
- return parent;
+ familia_individual_set_first_name(ctxt, GEDCOM_STRING(parsed_value));
+ return ctxt;
}
/*
void familia_gedcom_individual_first_name_end(Gedcom_elt elt,
- Gedcom_ctxt parent,
+ Gedcom_ctxt ctxt,
Gedcom_ctxt self,
Gedcom_val parsed_value)
{
}
*/
Gedcom_ctxt familia_gedcom_individual_last_name_start(Gedcom_elt elt,
- Gedcom_ctxt parent,
+ Gedcom_ctxt ctxt,
int level,
char* tag,
char* raw_value,
Gedcom_val parsed_value)
{
if (GEDCOM_IS_STRING(parsed_value)) {
- familia_individual_set_last_name(parent, GEDCOM_STRING(parsed_value));
+ familia_individual_set_last_name(ctxt, GEDCOM_STRING(parsed_value));
}
- return parent;
+ return ctxt;
}
/*
void familia_gedcom_individual_last_name_end(Gedcom_elt elt,
- Gedcom_ctxt parent,
+ Gedcom_ctxt ctxt,
Gedcom_ctxt self,
Gedcom_val parsed_value)
{
*/
Gedcom_ctxt familia_gedcom_individual_add_family(Gedcom_elt elt,
- Gedcom_ctxt parent,
+ Gedcom_ctxt ctxt,
int level,
char* tag,
char* raw_value,
int parsed_tag,
Gedcom_val parsed_value)
{
- void * object = NULL;
+ void * family = NULL;
struct xref_value *xr = GEDCOM_XREF_PTR(parsed_value);
- object = familia_memory_stack_find(xr->string, FS_FAMILY);
- familia_individual_add_family(parent, object);
+ family = familia_memory_stack_find(xr->string, FS_FAMILY);
+ familia_individual_add_family(ctxt, family);
- return parent;
+ return ctxt;
+}
+
+/**
+ * Set parents for child
+ */
+Gedcom_ctxt familia_gedcom_individual_set_parents(Gedcom_elt elt,
+ Gedcom_ctxt ctxt,
+ int level,
+ char* tag,
+ char* raw_value,
+ int parsed_tag,
+ Gedcom_val parsed_value)
+{
+ void * child = NULL;
+ /* XREF_PTR(FAM) */
+ struct xref_value *xr = GEDCOM_XREF_PTR(parsed_value);
+
+ child = familia_memory_stack_find(xr->string, FS_INDIVIDUAL);
+ familia_individual_set_parents(child, ctxt);
+
+ return ctxt;
}
/**
* Adds child to the family
*/
Gedcom_ctxt familia_gedcom_family_add_child(Gedcom_elt elt,
- Gedcom_ctxt parent,
+ Gedcom_ctxt ctxt,
int level,
char* tag,
char* raw_value,
int parsed_tag,
Gedcom_val parsed_value)
{
- void * object = NULL;
+ void * family = NULL;
/* XREF_PTR(FAM) */
struct xref_value *xr = GEDCOM_XREF_PTR(parsed_value);
- object = familia_memory_stack_find(xr->string, FS_FAMILY);
- /* parent: REC_INDI */
- familia_family_add_child(object, parent);
+ family = familia_memory_stack_find(xr->string, FS_FAMILY);
+ familia_family_add_child(family, ctxt);
+
+ return ctxt;
+}
+
+/**
+ * Adds first parent to the family
+ * Parent is the first individual in family. It can be e.g. Husband
+ */
+Gedcom_ctxt familia_gedcom_family_set_parent1(Gedcom_elt elt,
+ Gedcom_ctxt ctxt,
+ int level,
+ char* tag,
+ char* raw_value,
+ int parsed_tag,
+ Gedcom_val parsed_value)
+{
+ void * parent = NULL;
+ /* XREF_PTR(INDI) */
+ struct xref_value *xr = GEDCOM_XREF_PTR(parsed_value);
+
+ parent = familia_memory_stack_find(xr->string, FS_FAMILY);
+ /* ctxt: REC_FAM */
+ familia_family_set_parent(ctxt, parent, Individual1);
+
+ return ctxt;
+}
+
+/**
+ * Adds second parent to the family
+ * Parent is the first individual in family. It can be e.g. Wife
+ */
+Gedcom_ctxt familia_gedcom_family_set_parent2(Gedcom_elt elt,
+ Gedcom_ctxt ctxt,
+ int level,
+ char* tag,
+ char* raw_value,
+ int parsed_tag,
+ Gedcom_val parsed_value)
+{
+ void * parent = NULL;
+ /* XREF_PTR(INDI) */
+ struct xref_value *xr = GEDCOM_XREF_PTR(parsed_value);
+
+ parent = familia_memory_stack_find(xr->string, FS_FAMILY);
+ /* ctxt: REC_FAM */
+ familia_family_set_parent(ctxt, parent, Individual2);
- return parent;
+ return ctxt;
}
/*
void familia_gedcom_individual_family_end(Gedcom_elt elt,
- Gedcom_ctxt parent,
+ Gedcom_ctxt ctxt,
Gedcom_ctxt self,
Gedcom_val parsed_value)
{
{
gedcom_set_message_handler(familia_gedcom_error);
- gedcom_subscribe_to_record(REC_HEAD,
- familia_gedcom_header_start,
- familia_gedcom_header_end);
- gedcom_subscribe_to_element(ELT_HEAD_SOUR,
- familia_gedcom_header_source_start,
- NULL);
- gedcom_subscribe_to_element(ELT_HEAD_SOUR_VERS,
- familia_gedcom_header_version_start,
- NULL);
- gedcom_subscribe_to_record(REC_FAM,
- familia_gedcom_family_start,
- NULL);
- gedcom_subscribe_to_record(REC_INDI,
- familia_gedcom_individual_start,
- NULL);
- gedcom_subscribe_to_element(ELT_SUB_PERS_NAME,
- familia_gedcom_individual_set_first_name,
- NULL);
- gedcom_subscribe_to_element(ELT_SUB_PERS_NAME_SURN,
- familia_gedcom_individual_last_name_start,
- NULL);
- gedcom_subscribe_to_element(ELT_SUB_FAMS,
- familia_gedcom_family_add_child,
- NULL);
- gedcom_subscribe_to_element(ELT_SUB_FAMC,
- familia_gedcom_family_add_child,
- NULL);
+ gedcom_subscribe_to_record(REC_HEAD, familia_gedcom_header_start, familia_gedcom_header_end);
+ /* Create and set family as current (set to ctxt) */
+ gedcom_subscribe_to_record(REC_FAM, familia_gedcom_family_start, NULL);
+ /* Create and set individual as current (set to ctxt) */
+ gedcom_subscribe_to_record(REC_INDI, familia_gedcom_individual_start, NULL);
+ gedcom_subscribe_to_element(ELT_HEAD_SOUR, familia_gedcom_header_source_start, NULL);
+ gedcom_subscribe_to_element(ELT_HEAD_SOUR_VERS, familia_gedcom_header_version_start, NULL);
+ /* Set in current individual first name */
+ gedcom_subscribe_to_element(ELT_SUB_PERS_NAME, familia_gedcom_individual_set_first_name, NULL);
+ /* Set in current individual last name */
+ gedcom_subscribe_to_element(ELT_SUB_PERS_NAME_SURN, familia_gedcom_individual_last_name_start, NULL);
+ /* Add to current individual new family */
+ gedcom_subscribe_to_element(ELT_SUB_FAMS, familia_gedcom_individual_add_family, NULL);
+ /* Set current family as parents to child */
+ gedcom_subscribe_to_element(ELT_FAM_CHIL, familia_gedcom_individual_set_parents, NULL);
+ /* Set current individual new parents */
+ gedcom_subscribe_to_element(ELT_SUB_FAMC, familia_gedcom_family_add_child, NULL);
+ /* Set in current family first parent (e.g. husband) */
+ gedcom_subscribe_to_element(ELT_FAM_HUSB, familia_gedcom_family_set_parent1, NULL);
+ /* Set in current family second parent (e.g. wife) */
+ gedcom_subscribe_to_element(ELT_FAM_WIFE, familia_gedcom_family_set_parent2, NULL);
familia_memory_stack_init();
}