}
DEFINE_SUB_MAKEFUNC(association)
+DEFINE_SUB_ADDFUNC(association)
+DEFINE_SUB_FINDFUNC(association)
+DEFINE_SUB_REMOVEFUNC(association)
+DEFINE_SUB_MOVEFUNC(association)
DEFINE_STRING_CB(association, sub_assoc_rela_start, relation)
}
DEFINE_SUB_MAKEFUNC(event)
+DEFINE_SUB_ADDFUNC(event)
+DEFINE_SUB_FINDFUNC(event)
+DEFINE_SUB_REMOVEFUNC(event)
+DEFINE_SUB_MOVEFUNC(event)
DEFINE_STRING_CB(event, sub_evt_type_start, type)
DEFINE_DATE_CB(event, sub_evt_date_start, date)
}
DEFINE_SUB_MAKEFUNC(family_link)
+DEFINE_SUB_ADDFUNC(family_link)
+DEFINE_SUB_FINDFUNC(family_link)
+DEFINE_SUB_REMOVEFUNC(family_link)
+DEFINE_SUB_MOVEFUNC(family_link)
DEFINE_ADDFUNC2(family_link, note_sub, note)
DEFINE_ADDFUNC2(family_link, user_data, extra)
}
}
+DEFINE_SUB_MAKEFUNC(pedigree)
+DEFINE_SUB_ADDFUNC(pedigree)
+DEFINE_SUB_FINDFUNC(pedigree)
+DEFINE_SUB_REMOVEFUNC(pedigree)
+DEFINE_SUB_MOVEFUNC(pedigree)
+
void UNREFALLFUNC(family_link)(struct family_link* obj)
{
if (obj) {
#define CLEANFUNC(STRUCTTYPE) STRUCTTYPE ## _cleanup
#define ADDFUNC(STRUCTTYPE) gom_new_ ## STRUCTTYPE
#define SUB_SETFUNC(STRUCTTYPE) gom_set_new_ ## STRUCTTYPE
+#define SUB_ADDFUNC(STRUCTTYPE) gom_add_new_ ## STRUCTTYPE
#define UNREFALLFUNC(STRUCTTYPE) STRUCTTYPE ## _unref_all
#define DELETEFUNC(STRUCTTYPE) gom_delete_ ## STRUCTTYPE
#define SUB_DELETEFUNC(STRUCTTYPE) gom_delete_ ## STRUCTTYPE
+#define SUB_FINDFUNC(STRUCTTYPE) find_ ## STRUCTTYPE
+#define SUB_REMOVEFUNC(STRUCTTYPE) gom_remove_ ## STRUCTTYPE
+#define SUB_MOVEFUNC(STRUCTTYPE) gom_move_ ## STRUCTTYPE
#define ADDFUNC2(T1,T2) T1 ## _add_ ## T2
#define ADDFUNC2_TOVAR(T1,T2,F) T1 ## _add_ ## T2 ## _to_ ## F
#define ADDFUNC2_NOLIST(T1,T2) ADDFUNC2(T1,T2)
return obj; \
}
+#define DEFINE_SUB_ADDFUNC(STRUCTTYPE) \
+ struct STRUCTTYPE *SUB_ADDFUNC(STRUCTTYPE)(struct STRUCTTYPE** addto) \
+ { \
+ struct STRUCTTYPE *obj = NULL; \
+ if (addto) { \
+ MAKE_CHAIN_ELT(STRUCTTYPE, *addto, obj); \
+ } \
+ return obj; \
+ }
+
#define DEFINE_DELETEFUNC(STRUCTTYPE) \
DECLARE_UNREFALLFUNC(STRUCTTYPE); \
int DELETEFUNC(STRUCTTYPE)(struct STRUCTTYPE* obj) \
return result; \
}
+#define DEFINE_SUB_FINDFUNC(STRUCTTYPE) \
+ struct STRUCTTYPE* SUB_FINDFUNC(STRUCTTYPE)(struct STRUCTTYPE** data, \
+ struct STRUCTTYPE* obj) \
+ { \
+ struct STRUCTTYPE* result = NULL; \
+ struct STRUCTTYPE* runner; \
+ for (runner = *data ; runner ; runner = runner->next) { \
+ if (runner == obj) { \
+ result = runner; \
+ break; \
+ } \
+ } \
+ if (! result) \
+ gom_find_error(#STRUCTTYPE); \
+ return result; \
+ }
+
+#define DEFINE_SUB_REMOVEFUNC(STRUCTTYPE) \
+ int SUB_REMOVEFUNC(STRUCTTYPE) (struct STRUCTTYPE** data, \
+ struct STRUCTTYPE* obj) \
+ { \
+ int result = 1; \
+ if (data && obj) { \
+ struct STRUCTTYPE* toremove = SUB_FINDFUNC(STRUCTTYPE)(data, obj); \
+ if (toremove) { \
+ UNLINK_CHAIN_ELT(STRUCTTYPE, *data, toremove); \
+ CLEANFUNC(STRUCTTYPE)(toremove); \
+ SAFE_FREE(toremove); \
+ result = 0; \
+ } \
+ } \
+ return result; \
+ }
+
+#define DEFINE_SUB_MOVEFUNC(STRUCTTYPE) \
+ int SUB_MOVEFUNC(STRUCTTYPE)(Gom_direction dir, struct STRUCTTYPE** data, \
+ struct STRUCTTYPE* obj) \
+ { \
+ int result = 1; \
+ if (data && obj) { \
+ struct STRUCTTYPE* tomove = SUB_FINDFUNC(STRUCTTYPE)(data, obj); \
+ if (tomove) { \
+ MOVE_CHAIN_ELT(STRUCTTYPE, dir, *data, tomove); \
+ result = 0; \
+ } \
+ } \
+ return result; \
+ }
+
#define DEFINE_ADDFUNC2(STRUCTTYPE,T2,FIELD) \
void ADDFUNC2(STRUCTTYPE,T2)(Gom_ctxt ctxt, struct T2* addobj) \
{ \
gedcom_warning(_("Could not move struct of type %s"), type);
}
+void gom_find_error(const char* type)
+{
+ gedcom_warning(_("Could not find struct of type %s in chain"), type);
+}
+
void gom_default_callback (Gedcom_elt elt UNUSED, Gedcom_ctxt parent UNUSED,
int level, char* tag, char* raw_value,
int parsed_tag UNUSED)
void gom_unexpected_context(const char* file, int line, OBJ_TYPE found);
void gom_xref_already_in_use(const char *xrefstr);
void gom_move_error(const char* type);
+void gom_find_error(const char* type);
void unref_xref_value(struct xref_value *xref);
int gom_write_xref_list(Gedcom_write_hndl hndl,
}
DEFINE_SUB_MAKEFUNC(lds_event)
+DEFINE_SUB_ADDFUNC(lds_event)
+DEFINE_SUB_FINDFUNC(lds_event)
+DEFINE_SUB_REMOVEFUNC(lds_event)
+DEFINE_SUB_MOVEFUNC(lds_event)
DEFINE_STRING_CB(lds_event, sub_lds_event_stat_start, date_status)
DEFINE_DATE_CB(lds_event, sub_lds_event_date_start, date)
}
DEFINE_SUB_MAKEFUNC(multimedia_link)
+DEFINE_SUB_ADDFUNC(multimedia_link)
+DEFINE_SUB_FINDFUNC(multimedia_link)
+DEFINE_SUB_REMOVEFUNC(multimedia_link)
+DEFINE_SUB_MOVEFUNC(multimedia_link)
DEFINE_STRING_CB(multimedia_link, sub_obje_form_start, form)
DEFINE_STRING_CB(multimedia_link, sub_obje_titl_start, title)
}
DEFINE_SUB_MAKEFUNC(note_sub)
+DEFINE_SUB_ADDFUNC(note_sub)
+DEFINE_SUB_FINDFUNC(note_sub)
+DEFINE_SUB_REMOVEFUNC(note_sub)
+DEFINE_SUB_MOVEFUNC(note_sub)
DEFINE_ADDFUNC2(note_sub, source_citation, citation)
DEFINE_ADDFUNC2(note_sub, user_data, extra)
}
DEFINE_SUB_MAKEFUNC(personal_name)
+DEFINE_SUB_ADDFUNC(personal_name)
+DEFINE_SUB_FINDFUNC(personal_name)
+DEFINE_SUB_REMOVEFUNC(personal_name)
+DEFINE_SUB_MOVEFUNC(personal_name)
DEFINE_STRING_CB(personal_name, sub_name_npfx_start, prefix)
DEFINE_STRING_CB(personal_name, sub_name_givn_start, given)
}
DEFINE_SUB_MAKEFUNC(source_citation)
+DEFINE_SUB_ADDFUNC(source_citation)
+DEFINE_SUB_FINDFUNC(source_citation)
+DEFINE_SUB_REMOVEFUNC(source_citation)
+DEFINE_SUB_MOVEFUNC(source_citation)
DEFINE_STRING_CB(source_citation, sub_cit_page_start, page)
DEFINE_STRING_CB(source_citation, sub_cit_even_start, event)
}
}
+DEFINE_SUB_MAKEFUNC(text)
+DEFINE_SUB_ADDFUNC(text)
+DEFINE_SUB_FINDFUNC(text)
+DEFINE_SUB_REMOVEFUNC(text)
+DEFINE_SUB_MOVEFUNC(text)
+
void UNREFALLFUNC(source_citation)(struct source_citation* obj)
{
if (obj) {
}
DEFINE_SUB_MAKEFUNC(source_description)
+DEFINE_SUB_ADDFUNC(source_description)
+DEFINE_SUB_FINDFUNC(source_description)
+DEFINE_SUB_REMOVEFUNC(source_description)
+DEFINE_SUB_MOVEFUNC(source_description)
DEFINE_STRING_CB(source_description, sub_sour_caln_medi_start, media)
}
DEFINE_SUB_MAKEFUNC(source_event)
+DEFINE_SUB_ADDFUNC(source_event)
+DEFINE_SUB_FINDFUNC(source_event)
+DEFINE_SUB_REMOVEFUNC(source_event)
+DEFINE_SUB_MOVEFUNC(source_event)
DEFINE_DATE_CB(source_event, sub_sour_even_date_start, date_period)
DEFINE_STRING_CB(source_event, sub_sour_even_plac_start, jurisdiction)
return (Gedcom_ctxt)result;
}
+DEFINE_SUB_MAKEFUNC(user_data)
+DEFINE_SUB_ADDFUNC(user_data)
+DEFINE_SUB_FINDFUNC(user_data)
+DEFINE_SUB_REMOVEFUNC(user_data)
+DEFINE_SUB_MOVEFUNC(user_data)
+
void user_rec_subscribe()
{
gedcom_subscribe_to_record(REC_USER, user_rec_start, def_rec_end);
}
DEFINE_SUB_MAKEFUNC(user_ref_number)
+DEFINE_SUB_ADDFUNC(user_ref_number)
+DEFINE_SUB_FINDFUNC(user_ref_number)
+DEFINE_SUB_REMOVEFUNC(user_ref_number)
+DEFINE_SUB_MOVEFUNC(user_ref_number)
DEFINE_STRING_CB(user_ref_number, sub_user_ref_type_start, type)
} Gom_direction;
struct xref_value* gom_set_xref(struct xref_value** data, const char* xref);
+
struct xref_list* gom_add_xref(struct xref_list** data, const char* xref);
int gom_remove_xref(struct xref_list** data, const char* xref);
int gom_move_xref(Gom_direction dir, struct xref_list** data,
struct address* gom_set_new_address(struct address** obj);
int gom_delete_address(struct address** obj);
-struct place* gom_set_new_place(struct place** obj);
-int gom_delete_place(struct place** obj);
-
+struct association* gom_add_new_association(struct association** data);
+int gom_remove_association(struct association** data,
+ struct association* obj);
+int gom_move_association(Gom_direction dir,
+ struct association** data,
+ struct association* obj);
+
struct change_date* gom_set_new_change_date(struct change_date** obj);
int gom_delete_change_date(struct change_date** obj);
int gom_update_timestamp(struct change_date** obj, time_t t);
+
+struct event* gom_add_new_event(struct event** data);
+int gom_remove_event(struct event** data, struct event* obj);
+int gom_move_event(Gom_direction dir, struct event** data,
+ struct event* obj);
+
+struct family_link* gom_add_new_family_link(struct family_link** data);
+int gom_remove_family_link(struct family_link** data,
+ struct family_link* obj);
+int gom_move_family_link(Gom_direction dir,
+ struct family_link** data,
+ struct family_link* obj);
+
+struct lds_event* gom_add_new_lds_event(struct lds_event** data);
+int gom_remove_lds_event(struct lds_event** data,
+ struct lds_event* obj);
+int gom_move_lds_event(Gom_direction dir,
+ struct lds_event** data,
+ struct lds_event* obj);
+
+struct multimedia_link*
+ gom_add_new_multimedia_link(struct multimedia_link** data);
+int gom_remove_multimedia_link(struct multimedia_link** data,
+ struct multimedia_link* obj);
+int gom_move_multimedia_link(Gom_direction dir,
+ struct multimedia_link** data,
+ struct multimedia_link* obj);
+
+struct note_sub* gom_add_new_note_sub(struct note_sub** data);
+int gom_remove_note_sub(struct note_sub** data,
+ struct note_sub* obj);
+int gom_move_note_sub(Gom_direction dir,
+ struct note_sub** data,
+ struct note_sub* obj);
+
+struct pedigree* gom_add_new_pedigree(struct pedigree** data);
+int gom_remove_pedigree(struct pedigree** data,
+ struct pedigree* obj);
+int gom_move_pedigree(Gom_direction dir,
+ struct pedigree** data,
+ struct pedigree* obj);
+
+struct personal_name* gom_add_new_personal_name(struct personal_name** data);
+int gom_remove_personal_name(struct personal_name** data,
+ struct personal_name* obj);
+int gom_move_personal_name(Gom_direction dir,
+ struct personal_name** data,
+ struct personal_name* obj);
+
+struct place* gom_set_new_place(struct place** obj);
+int gom_delete_place(struct place** obj);
+
+struct source_citation*
+ gom_add_new_source_citation(struct source_citation** data);
+int gom_remove_source_citation(struct source_citation** data,
+ struct source_citation* obj);
+int gom_move_source_citation(Gom_direction dir,
+ struct source_citation** data,
+ struct source_citation* obj);
+
+struct source_description*
+ gom_add_new_source_description(struct source_description** data);
+int gom_remove_source_description(struct source_description** data,
+ struct source_description* obj);
+int gom_move_source_description(Gom_direction dir,
+ struct source_description** data,
+ struct source_description* obj);
+
+struct source_event* gom_add_new_source_event(struct source_event** data);
+int gom_remove_source_event(struct source_event** data,
+ struct source_event* obj);
+int gom_move_source_event(Gom_direction dir,
+ struct source_event** data,
+ struct source_event* obj);
+
+struct text* gom_add_new_text(struct text** data);
+int gom_remove_text(struct text** data,
+ struct text* obj);
+int gom_move_text(Gom_direction dir,
+ struct text** data,
+ struct text* obj);
+
+struct user_data* gom_add_new_user_data(struct user_data** data);
+int gom_remove_user_data(struct user_data** data,
+ struct user_data* obj);
+int gom_move_user_data(Gom_direction dir,
+ struct user_data** data,
+ struct user_data* obj);
+
+struct user_ref_number*
+ gom_add_new_user_ref_number(struct user_ref_number** data);
+int gom_remove_user_ref_number(struct user_ref_number** data,
+ struct user_ref_number* obj);
+int gom_move_user_ref_number(Gom_direction dir,
+ struct user_ref_number** data,
+ struct user_ref_number* obj);
#ifdef __cplusplus
}
User data: 0x<null>
=== INDIVIDUAL (@IND2@) ===
Restriction notice: '(null)'
-names: 0x<null>
+names:
+ Name:
+ Name: 'Testname'
+ Prefix: '(null)'
+ Given: '(null)'
+ Nickname: '(null)'
+ Surname prefix: '(null)'
+ Surname: '(null)'
+ Suffix: '(null)'
+ citations: 0x<null>
+ notes: 0x<null>
+ User data: 0x<null>
Sex: '(null)'
Individual events: 0x<null>
Individual attributes: 0x<null>
return 0;
}
-int test_record_add_delete_functions()
+int test_add_delete_functions()
{
struct family* fam1;
struct individual *ind1, *ind2, *ind3, *ind4;
struct user_rec* user1;
struct xref_value* xr;
struct xref_list* xrl;
+ struct personal_name* name;
int result;
char* value;
const char* new_nr_of_children = "3";
if (!xrl) return 124;
result = gom_move_xref(MOVE_UP, &(fam1->children), ind4->xrefstr);
- if (result != 0) return 127;
+ if (result != 0) return 125;
result = gom_move_xref(MOVE_UP, &(fam1->children), ind4->xrefstr);
- if (result != 0) return 128;
+ if (result != 0) return 126;
result = gom_move_xref(MOVE_UP, &(fam1->children), ind4->xrefstr);
- if (result != 0) return 129;
+ if (result != 0) return 127;
result = gom_move_xref(MOVE_DOWN, &(fam1->children), ind4->xrefstr);
- if (result != 0) return 130;
+ if (result != 0) return 128;
result = gom_remove_xref(&(fam1->children), ind3->xrefstr);
- if (result != 0) return 125;
+ if (result != 0) return 129;
result = gom_remove_xref(&(fam1->children), ind4->xrefstr);
- if (result != 0) return 126;
+ if (result != 0) return 130;
+
+ name = gom_add_new_personal_name(&(ind2->name));
+ if (name == NULL) return 131;
+
+ value = gom_set_string(&(name->name), "Testname");
+ if (value == NULL) return 132;
+
+ name = gom_add_new_personal_name(&(ind2->name));
+ if (name == NULL) return 133;
+
+ value = gom_set_string(&(name->name), "Testname 2");
+ if (value == NULL) return 134;
+
+ result = gom_move_personal_name(MOVE_UP, &(ind2->name), name);
+ if (result != 0) return 135;
+
+ result = gom_remove_personal_name(&(ind2->name), name);
+ if (result != 0) return 136;
output(1, "Intermediate output:\n");
show_data();
if (result == 0)
result |= test_date_functions();
if (result == 0)
- result |= test_record_add_delete_functions();
+ result |= test_add_delete_functions();
if (result == 0) {
output(1, "Test succeeded\n");
}