if (!addr)
MEMORY_ERROR;
else {
- char *str = GEDCOM_STRING(parsed_value);
memset (addr, 0, sizeof(struct address));
- addr->full_label = strdup(str);
-
- if (! addr->full_label) {
- MEMORY_ERROR;
- free(addr);
- }
- else {
- switch (ctxt->ctxt_type) {
- case ELT_HEAD_SOUR_CORP:
- header_add_address(ctxt, addr); break;
- case ELT_SUB_FAM_EVT:
- case ELT_SUB_FAM_EVT_EVEN:
- case ELT_SUB_INDIV_ATTR:
- case ELT_SUB_INDIV_RESI:
- case ELT_SUB_INDIV_BIRT:
- case ELT_SUB_INDIV_GEN:
- case ELT_SUB_INDIV_ADOP:
- case ELT_SUB_INDIV_EVEN:
- event_add_address(ctxt, addr); break;
- case REC_REPO:
- repository_add_address(ctxt, addr); break;
- case REC_SUBM:
- submitter_add_address(ctxt, addr); break;
- default:
- UNEXPECTED_CONTEXT(ctxt->ctxt_type);
- }
- result = MAKE_GOM_CTXT(elt, address, addr);
+ switch (ctxt->ctxt_type) {
+ case ELT_HEAD_SOUR_CORP:
+ header_add_address(ctxt, addr); break;
+ case ELT_SUB_FAM_EVT:
+ case ELT_SUB_FAM_EVT_EVEN:
+ case ELT_SUB_INDIV_ATTR:
+ case ELT_SUB_INDIV_RESI:
+ case ELT_SUB_INDIV_BIRT:
+ case ELT_SUB_INDIV_GEN:
+ case ELT_SUB_INDIV_ADOP:
+ case ELT_SUB_INDIV_EVEN:
+ event_add_address(ctxt, addr); break;
+ case REC_REPO:
+ repository_add_address(ctxt, addr); break;
+ case REC_SUBM:
+ submitter_add_address(ctxt, addr); break;
+ default:
+ UNEXPECTED_CONTEXT(ctxt->ctxt_type);
}
+ result = MAKE_GOM_CTXT(elt, address, addr);
}
}
return (Gedcom_ctxt)result;
}
-Gedcom_ctxt sub_addr_cont_start(_ELT_PARAMS_)
+void sub_addr_end(_ELT_END_PARAMS_)
{
- Gom_ctxt ctxt = (Gom_ctxt)parent;
- Gom_ctxt result = NULL;
+ Gom_ctxt ctxt = (Gom_ctxt)self;
+
if (! ctxt)
NO_CONTEXT;
else {
struct address *addr = SAFE_CTXT_CAST(address, ctxt);
if (addr) {
char *str = GEDCOM_STRING(parsed_value);
- char *newvalue = concat_strings (WITH_NL, addr->full_label, str);
+ char *newvalue = strdup(str);
if (! newvalue)
MEMORY_ERROR;
- else {
+ else
addr->full_label = newvalue;
- result = MAKE_GOM_CTXT(elt, address, addr);
- }
}
}
+}
+
+Gedcom_ctxt sub_addr_cont_start(_ELT_PARAMS_)
+{
+ Gom_ctxt ctxt = (Gom_ctxt)parent;
+ Gom_ctxt result = NULL;
+ if (! ctxt)
+ NO_CONTEXT;
+ else {
+ result = make_gom_ctxt(elt, ctxt->ctxt_type, ctxt->ctxt_ptr);
+ }
return (Gedcom_ctxt)result;
}
void address_subscribe()
{
- gedcom_subscribe_to_element(ELT_SUB_ADDR, sub_addr_start, def_elt_end);
+ gedcom_subscribe_to_element(ELT_SUB_ADDR, sub_addr_start, sub_addr_end);
gedcom_subscribe_to_element(ELT_SUB_ADDR_CONT,
sub_addr_cont_start, def_elt_end);
gedcom_subscribe_to_element(ELT_SUB_ADDR_ADR1,
xr->type = XREF_ANY;
}
-char* concat_strings(NL_TYPE type, char *str1, const char *str2)
-{
- if (str1 != NULL && str2 != NULL) {
- char *newp;
- char *wp;
- size_t len1 = strlen(str1);
- size_t len2 = strlen(str2);
- size_t len = len1 + len2 + 1;
- if (type == WITH_NL)
- len++;
- newp = (char*) realloc(str1, len);
- if (newp == NULL)
- return NULL;
- wp = newp + len1;
- str1 = newp;
- if (type == WITH_NL)
- *wp++ = '\n';
- wp = memcpy (wp, str2, len2);
- wp += len2;
- *wp++ = '\0';
- }
-
- return str1;
-}
-
struct date_value* dup_date(struct date_value dv)
{
struct date_value* dv_ptr;
Gedcom_ctxt self, Gedcom_val parsed_value);
void set_xref_type(struct xref_value *xr, const char* str);
-typedef enum {
- WITHOUT_NL,
- WITH_NL
-} NL_TYPE;
-
-char* concat_strings(NL_TYPE type, char *str1, const char *str2);
struct date_value* dup_date(struct date_value dv);
struct age_value* dup_age(struct age_value age);
char *raw_value UNUSED, int parsed_tag UNUSED, \
Gedcom_val parsed_value UNUSED
+#define _REC_END_PARAMS_ Gedcom_rec rec UNUSED, Gedcom_ctxt self UNUSED, \
+ Gedcom_val parsed_value UNUSED
+
#define _ELT_PARAMS_ Gedcom_elt elt UNUSED, Gedcom_ctxt parent UNUSED, \
int level UNUSED, char *tag UNUSED, \
char *raw_value UNUSED, int parsed_tag UNUSED, \
Gedcom_val parsed_value UNUSED
+#define _ELT_END_PARAMS_ Gedcom_elt elt UNUSED, Gedcom_ctxt parent UNUSED, \
+ Gedcom_ctxt self UNUSED, \
+ Gedcom_val parsed_value UNUSED
+
#define REC_CB(STRUCTTYPE,CB_NAME,FUNC) \
Gedcom_ctxt CB_NAME(_REC_PARAMS_) \
{ \
STRING_CB(header, head_lang_start, language)
NULL_CB(header, head_plac_start)
STRING_CB(header, head_plac_form_start, place_hierarchy)
-STRING_CB(header, head_note_start, note)
+NULL_CB(header, head_note_start) /* the end callback will fill the value */
+void head_note_end(_ELT_END_PARAMS_)
+{
+ Gom_ctxt ctxt = (Gom_ctxt)self;
+
+ if (! ctxt)
+ NO_CONTEXT;
+ else {
+ struct header *head = SAFE_CTXT_CAST(header, ctxt);
+ if (head) {
+ char *str = GEDCOM_STRING(parsed_value);
+ char *newvalue = strdup(str);
+ if (! newvalue)
+ MEMORY_ERROR;
+ else
+ head->note = newvalue;
+ }
+ }
+}
+
void header_add_address(Gom_ctxt ctxt, struct address* addr)
{
struct header *head = SAFE_CTXT_CAST(header, ctxt);
}
}
-void header_add_to_note(NL_TYPE type, Gom_ctxt ctxt, const char* str)
-{
- struct header *head = SAFE_CTXT_CAST(header, ctxt);
- if (head) {
- char *newvalue = concat_strings(type, head->note, str);
- if (newvalue)
- head->note = newvalue;
- else
- MEMORY_ERROR;
- }
-}
-
void header_add_user_data(Gom_ctxt ctxt, struct user_data* data)
{
struct header *head = SAFE_CTXT_CAST(header, ctxt);
gedcom_subscribe_to_element(ELT_HEAD_PLAC, head_plac_start, def_elt_end);
gedcom_subscribe_to_element(ELT_HEAD_PLAC_FORM,
head_plac_form_start, def_elt_end);
- gedcom_subscribe_to_element(ELT_HEAD_NOTE, head_note_start, def_elt_end);
+ gedcom_subscribe_to_element(ELT_HEAD_NOTE, head_note_start, head_note_end);
}
void header_cleanup()
void header_cleanup();
void header_add_address(Gom_ctxt header, struct address* addr);
void header_add_phone (Gom_ctxt header, const char* phone);
-void header_add_to_note(NL_TYPE type, Gom_ctxt header, const char* str);
void header_add_user_data(Gom_ctxt ctxt, struct user_data* data);
int write_header(Gedcom_write_hndl hndl);
NULL_CB(multimedia, obje_blob_start)
XREF_CB(multimedia, obje_obje_start, continued, make_multimedia_record)
-Gedcom_ctxt obje_blob_cont_start(_ELT_PARAMS_)
+void obje_blob_end(_ELT_END_PARAMS_)
{
- Gom_ctxt ctxt = (Gom_ctxt)parent;
- Gom_ctxt result = NULL;
+ Gom_ctxt ctxt = (Gom_ctxt)self;
if (! ctxt)
NO_CONTEXT;
struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
if (obj) {
char *str = GEDCOM_STRING(parsed_value);
- if (obj->data) {
- char *newvalue = concat_strings (WITHOUT_NL, obj->data, str);
- if (newvalue)
- obj->data = newvalue;
- else {
- free(obj->data);
- obj->data = NULL;
- }
- }
- else
- obj->data = strdup(str);
-
- if (! obj->data) {
+ char *newvalue = strdup(str);
+ if (! newvalue)
MEMORY_ERROR;
- free(obj);
- }
else
- result = make_gom_ctxt(elt, ctxt->obj_type, ctxt->ctxt_ptr);
+ obj->data = newvalue;
}
}
+}
+
+Gedcom_ctxt obje_blob_cont_start(_ELT_PARAMS_)
+{
+ Gom_ctxt ctxt = (Gom_ctxt)parent;
+ Gom_ctxt result = NULL;
+
+ if (! ctxt)
+ NO_CONTEXT;
+ else
+ result = make_gom_ctxt(elt, ctxt->obj_type, ctxt->ctxt_ptr);
+
return (Gedcom_ctxt)result;
}
gedcom_subscribe_to_record(REC_OBJE, obje_start, def_rec_end);
gedcom_subscribe_to_element(ELT_OBJE_FORM, obje_form_start, def_elt_end);
gedcom_subscribe_to_element(ELT_OBJE_TITL, obje_titl_start, def_elt_end);
- gedcom_subscribe_to_element(ELT_OBJE_BLOB, obje_blob_start, def_elt_end);
+ gedcom_subscribe_to_element(ELT_OBJE_BLOB, obje_blob_start, obje_blob_end);
gedcom_subscribe_to_element(ELT_OBJE_BLOB_CONT, obje_blob_cont_start,
def_elt_end);
gedcom_subscribe_to_element(ELT_OBJE_OBJE, obje_obje_start, def_elt_end);
return (Gedcom_ctxt)result;
}
+void note_end(_REC_END_PARAMS_)
+{
+ Gom_ctxt ctxt = (Gom_ctxt)self;
+
+ if (! ctxt)
+ NO_CONTEXT;
+ else {
+ struct note *note = SAFE_CTXT_CAST(note, ctxt);
+ if (note) {
+ char *str = GEDCOM_STRING(parsed_value);
+ char *newvalue = strdup(str);
+ if (! newvalue)
+ MEMORY_ERROR;
+ else
+ note->text = newvalue;
+ }
+ }
+}
+
GET_REC_BY_XREF(note, XREF_NOTE, gom_get_note_by_xref)
Gedcom_ctxt sub_cont_conc_start(_ELT_PARAMS_)
if (! ctxt)
NO_CONTEXT;
- else {
- char *str = GEDCOM_STRING(parsed_value);
- NL_TYPE type = (elt == ELT_SUB_CONT ? WITH_NL : WITHOUT_NL);
- switch (ctxt->ctxt_type) {
- case ELT_HEAD_NOTE:
- header_add_to_note(type, ctxt, str); break;
- case ELT_SUB_SOUR:
- citation_add_to_desc(type, ctxt, str); break;
- case ELT_SUB_SOUR_TEXT:
- citation_add_to_text(type, ctxt, str); break;
- case ELT_SUB_NOTE:
- note_sub_add_to_note(type, ctxt, str); break;
- case REC_NOTE:
- note_add_to_note(type, ctxt, str); break;
- case ELT_SOUR_AUTH:
- case ELT_SOUR_TITL:
- case ELT_SOUR_PUBL:
- case ELT_SOUR_TEXT:
- source_add_to_value(type, ctxt, str); break;
- default:
- UNEXPECTED_CONTEXT(ctxt->ctxt_type);
- }
+ else
result = make_gom_ctxt(elt, ctxt->obj_type, ctxt->ctxt_ptr);
- }
+
return (Gedcom_ctxt)result;
}
void note_subscribe()
{
- gedcom_subscribe_to_record(REC_NOTE, note_start, def_rec_end);
+ gedcom_subscribe_to_record(REC_NOTE, note_start, note_end);
gedcom_subscribe_to_element(ELT_SUB_CONT, sub_cont_conc_start, def_elt_end);
gedcom_subscribe_to_element(ELT_SUB_CONC, sub_cont_conc_start, def_elt_end);
}
-void note_add_to_note(NL_TYPE type, Gom_ctxt ctxt, const char* str)
-{
- struct note *note = SAFE_CTXT_CAST(note, ctxt);
- if (note) {
- char *newvalue = concat_strings (type, note->text, str);
- if (newvalue)
- note->text = newvalue;
- else
- MEMORY_ERROR;
- }
-}
-
void note_add_citation(Gom_ctxt ctxt, struct source_citation* cit)
{
struct note *note = SAFE_CTXT_CAST(note, ctxt);
void note_subscribe();
void notes_cleanup();
struct note* make_note_record(const char* xref);
-void note_add_to_note(NL_TYPE type, Gom_ctxt ctxt, const char* str);
void note_add_citation(Gom_ctxt ctxt, struct source_citation* cit);
void note_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
void note_set_record_id(Gom_ctxt ctxt, const char *rin);
if (! note)
MEMORY_ERROR;
else {
- int err = 0;
memset (note, 0, sizeof(struct note_sub));
- if (GEDCOM_IS_STRING(parsed_value)) {
- note->text = strdup(GEDCOM_STRING(parsed_value));
- if (! note->text) {
- MEMORY_ERROR;
- free(note);
- err = 1;
- }
- }
- else if (GEDCOM_IS_XREF_PTR(parsed_value))
+ if (GEDCOM_IS_XREF_PTR(parsed_value))
note->reference = GEDCOM_XREF_PTR(parsed_value);
- if (! err) {
- switch (ctxt->ctxt_type) {
- case ELT_SUB_PLAC:
- place_add_note(ctxt, note); break;
- case ELT_SUB_FAM_EVT:
- case ELT_SUB_FAM_EVT_EVEN:
- case ELT_SUB_INDIV_ATTR:
- case ELT_SUB_INDIV_RESI:
- case ELT_SUB_INDIV_BIRT:
- case ELT_SUB_INDIV_GEN:
- case ELT_SUB_INDIV_ADOP:
- case ELT_SUB_INDIV_EVEN:
- event_add_note(ctxt, note); break;
- case ELT_SUB_SOUR:
- citation_add_note(ctxt, note); break;
- case ELT_SUB_MULTIM_OBJE:
- multimedia_link_add_note(ctxt, note); break;
- case ELT_SUB_LSS_SLGS:
- case ELT_SUB_LIO_BAPL:
- case ELT_SUB_LIO_SLGC:
- lds_event_add_note(ctxt, note); break;
- case REC_FAM:
- family_add_note(ctxt, note); break;
- case ELT_SUB_CHAN:
- change_date_add_note(ctxt, note); break;
- case ELT_SUB_PERS_NAME:
- name_add_note(ctxt, note); break;
- case ELT_SUB_FAMC:
- case ELT_SUB_FAMS:
- family_link_add_note(ctxt, note); break;
- case ELT_SUB_ASSO:
- association_add_note(ctxt, note); break;
- case REC_INDI:
- individual_add_note(ctxt, note); break;
- case REC_OBJE:
- multimedia_add_note(ctxt, note); break;
- case REC_REPO:
- repository_add_note(ctxt, note); break;
- case ELT_SOUR_DATA:
- source_add_note_to_data(ctxt, note); break;
- case ELT_SUB_REPO:
- source_add_note_to_repo(ctxt, note); break;
- case REC_SOUR:
- source_add_note(ctxt, note); break;
- default:
- UNEXPECTED_CONTEXT(ctxt->ctxt_type);
- }
- result = MAKE_GOM_CTXT(elt, note_sub, note);
+ switch (ctxt->ctxt_type) {
+ case ELT_SUB_PLAC:
+ place_add_note(ctxt, note); break;
+ case ELT_SUB_FAM_EVT:
+ case ELT_SUB_FAM_EVT_EVEN:
+ case ELT_SUB_INDIV_ATTR:
+ case ELT_SUB_INDIV_RESI:
+ case ELT_SUB_INDIV_BIRT:
+ case ELT_SUB_INDIV_GEN:
+ case ELT_SUB_INDIV_ADOP:
+ case ELT_SUB_INDIV_EVEN:
+ event_add_note(ctxt, note); break;
+ case ELT_SUB_SOUR:
+ citation_add_note(ctxt, note); break;
+ case ELT_SUB_MULTIM_OBJE:
+ multimedia_link_add_note(ctxt, note); break;
+ case ELT_SUB_LSS_SLGS:
+ case ELT_SUB_LIO_BAPL:
+ case ELT_SUB_LIO_SLGC:
+ lds_event_add_note(ctxt, note); break;
+ case REC_FAM:
+ family_add_note(ctxt, note); break;
+ case ELT_SUB_CHAN:
+ change_date_add_note(ctxt, note); break;
+ case ELT_SUB_PERS_NAME:
+ name_add_note(ctxt, note); break;
+ case ELT_SUB_FAMC:
+ case ELT_SUB_FAMS:
+ family_link_add_note(ctxt, note); break;
+ case ELT_SUB_ASSO:
+ association_add_note(ctxt, note); break;
+ case REC_INDI:
+ individual_add_note(ctxt, note); break;
+ case REC_OBJE:
+ multimedia_add_note(ctxt, note); break;
+ case REC_REPO:
+ repository_add_note(ctxt, note); break;
+ case ELT_SOUR_DATA:
+ source_add_note_to_data(ctxt, note); break;
+ case ELT_SUB_REPO:
+ source_add_note_to_repo(ctxt, note); break;
+ case REC_SOUR:
+ source_add_note(ctxt, note); break;
+ default:
+ UNEXPECTED_CONTEXT(ctxt->ctxt_type);
}
+ result = MAKE_GOM_CTXT(elt, note_sub, note);
}
}
return (Gedcom_ctxt)result;
}
+void sub_note_end(_ELT_END_PARAMS_)
+{
+ Gom_ctxt ctxt = (Gom_ctxt)self;
+
+ if (! ctxt)
+ NO_CONTEXT;
+ else {
+ struct note_sub *note = SAFE_CTXT_CAST(note_sub, ctxt);
+ if (note) {
+ char *str = GEDCOM_STRING(parsed_value);
+ char *newvalue = strdup(str);
+ if (! newvalue)
+ MEMORY_ERROR;
+ else
+ note->text = newvalue;
+ }
+ }
+}
+
void note_sub_subscribe()
{
- gedcom_subscribe_to_element(ELT_SUB_NOTE, sub_note_start, def_elt_end);
+ gedcom_subscribe_to_element(ELT_SUB_NOTE, sub_note_start, sub_note_end);
}
void note_sub_add_citation(Gom_ctxt ctxt, struct source_citation* cit)
LINK_CHAIN_ELT(source_citation, note->citation, cit);
}
-void note_sub_add_to_note(NL_TYPE type, Gom_ctxt ctxt, const char* str)
-{
- struct note_sub *note = SAFE_CTXT_CAST(note_sub, ctxt);
- if (note) {
- char *newvalue = concat_strings (type, note->text, str);
- if (newvalue)
- note->text = newvalue;
- else
- MEMORY_ERROR;
- }
-}
-
void note_sub_add_user_data(Gom_ctxt ctxt, struct user_data* data)
{
struct note_sub *obj = SAFE_CTXT_CAST(note_sub, ctxt);
void note_sub_subscribe();
void note_sub_cleanup(struct note_sub* note);
void note_sub_add_citation(Gom_ctxt ctxt, struct source_citation* cit);
-void note_sub_add_to_note(NL_TYPE type, Gom_ctxt ctxt, const char* str);
void note_sub_add_user_data(Gom_ctxt ctxt, struct user_data* data);
#endif /* __NOTE_SUB_H */
GET_REC_BY_XREF(source, XREF_SOUR, gom_get_source_by_xref)
NULL_CB(source, sour_data_start)
STRING_CB(source, sour_data_agnc_start, data.agency)
-STRING_CB(source, sour_auth_start, author)
-STRING_CB(source, sour_titl_start, title)
+NULL_CB(source, sour_auth_start) /* value set by end callback */
+NULL_CB(source, sour_titl_start) /* value set by end callback */
STRING_CB(source, sour_abbr_start, abbreviation)
-STRING_CB(source, sour_publ_start, publication)
-STRING_CB(source, sour_text_start, text)
+NULL_CB(source, sour_publ_start) /* value set by end callback */
+NULL_CB(source, sour_text_start) /* value set by end callback */
XREF_CB(source, sour_repo_start, repository.link, make_repository_record)
+void sour_auth_end(_ELT_END_PARAMS_)
+{
+ Gom_ctxt ctxt = (Gom_ctxt)self;
+
+ if (! ctxt)
+ NO_CONTEXT;
+ else {
+ struct source *sour = SAFE_CTXT_CAST(source, ctxt);
+ if (sour) {
+ char *str = GEDCOM_STRING(parsed_value);
+ char *newvalue = strdup(str);
+ if (! newvalue)
+ MEMORY_ERROR;
+ else
+ sour->author = newvalue;
+ }
+ }
+}
+
+void sour_titl_end(_ELT_END_PARAMS_)
+{
+ Gom_ctxt ctxt = (Gom_ctxt)self;
+
+ if (! ctxt)
+ NO_CONTEXT;
+ else {
+ struct source *sour = SAFE_CTXT_CAST(source, ctxt);
+ if (sour) {
+ char *str = GEDCOM_STRING(parsed_value);
+ char *newvalue = strdup(str);
+ if (! newvalue)
+ MEMORY_ERROR;
+ else
+ sour->title = newvalue;
+ }
+ }
+}
+
+void sour_publ_end(_ELT_END_PARAMS_)
+{
+ Gom_ctxt ctxt = (Gom_ctxt)self;
+
+ if (! ctxt)
+ NO_CONTEXT;
+ else {
+ struct source *sour = SAFE_CTXT_CAST(source, ctxt);
+ if (sour) {
+ char *str = GEDCOM_STRING(parsed_value);
+ char *newvalue = strdup(str);
+ if (! newvalue)
+ MEMORY_ERROR;
+ else
+ sour->publication = newvalue;
+ }
+ }
+}
+
+void sour_text_end(_ELT_END_PARAMS_)
+{
+ Gom_ctxt ctxt = (Gom_ctxt)self;
+
+ if (! ctxt)
+ NO_CONTEXT;
+ else {
+ struct source *sour = SAFE_CTXT_CAST(source, ctxt);
+ if (sour) {
+ char *str = GEDCOM_STRING(parsed_value);
+ char *newvalue = strdup(str);
+ if (! newvalue)
+ MEMORY_ERROR;
+ else
+ sour->text = newvalue;
+ }
+ }
+}
+
void source_subscribe()
{
gedcom_subscribe_to_record(REC_SOUR, sour_start, def_rec_end);
gedcom_subscribe_to_element(ELT_SOUR_DATA, sour_data_start, def_elt_end);
gedcom_subscribe_to_element(ELT_SOUR_DATA_AGNC, sour_data_agnc_start,
def_elt_end);
- gedcom_subscribe_to_element(ELT_SOUR_AUTH, sour_auth_start, def_elt_end);
- gedcom_subscribe_to_element(ELT_SOUR_TITL, sour_titl_start, def_elt_end);
+ gedcom_subscribe_to_element(ELT_SOUR_AUTH, sour_auth_start, sour_auth_end);
+ gedcom_subscribe_to_element(ELT_SOUR_TITL, sour_titl_start, sour_titl_end);
gedcom_subscribe_to_element(ELT_SOUR_ABBR, sour_abbr_start, def_elt_end);
- gedcom_subscribe_to_element(ELT_SOUR_PUBL, sour_publ_start, def_elt_end);
- gedcom_subscribe_to_element(ELT_SOUR_TEXT, sour_text_start, def_elt_end);
+ gedcom_subscribe_to_element(ELT_SOUR_PUBL, sour_publ_start, sour_publ_end);
+ gedcom_subscribe_to_element(ELT_SOUR_TEXT, sour_text_start, sour_text_end);
gedcom_subscribe_to_element(ELT_SUB_REPO, sour_repo_start, def_elt_end);
}
LINK_CHAIN_ELT(source_description, sour->repository.description, desc);
}
-void source_add_to_value(NL_TYPE type, Gom_ctxt ctxt, const char* str)
-{
- struct source *sour = SAFE_CTXT_CAST(source, ctxt);
- if (sour) {
- switch (ctxt->ctxt_type) {
- char *newvalue;
- case ELT_SOUR_AUTH:
- newvalue = concat_strings (type, sour->author, str);
- if (newvalue)
- sour->author = newvalue;
- else
- MEMORY_ERROR;
- break;
- case ELT_SOUR_TITL:
- newvalue = concat_strings (type, sour->title, str);
- if (newvalue)
- sour->title = newvalue;
- else
- MEMORY_ERROR;
- break;
- case ELT_SOUR_PUBL:
- newvalue = concat_strings (type, sour->publication, str);
- if (newvalue)
- sour->publication = newvalue;
- else
- MEMORY_ERROR;
- break;
- case ELT_SOUR_TEXT:
- newvalue = concat_strings (type, sour->text, str);
- if (newvalue)
- sour->text = newvalue;
- else
- MEMORY_ERROR;
- break;
- default:
- UNEXPECTED_CONTEXT(ctxt->ctxt_type);
- }
- }
-}
-
void source_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link)
{
struct source *sour = SAFE_CTXT_CAST(source, ctxt);
struct source* make_source_record(const char* xref);
void source_add_event(Gom_ctxt ctxt, struct source_event* evt);
void source_add_note_to_data(Gom_ctxt ctxt, struct note_sub* note);
-void source_add_to_value(NL_TYPE type, Gom_ctxt ctxt, const char* str);
void source_add_note_to_repo(Gom_ctxt ctxt, struct note_sub* note);
void source_add_description(Gom_ctxt ctxt, struct source_description* desc);
void source_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link);
if (! cit)
MEMORY_ERROR;
else {
- int err = 0;
memset (cit, 0, sizeof(struct source_citation));
- if (GEDCOM_IS_STRING(parsed_value)) {
- cit->description = strdup(GEDCOM_STRING(parsed_value));
- if (! cit->description) {
- MEMORY_ERROR;
- free(cit);
- err = 1;
- }
- }
- else if (GEDCOM_IS_XREF_PTR(parsed_value))
+ if (GEDCOM_IS_XREF_PTR(parsed_value))
cit->reference = GEDCOM_XREF_PTR(parsed_value);
- if (! err) {
- switch (ctxt->ctxt_type) {
- case ELT_SUB_PLAC:
- place_add_citation(ctxt, cit); break;
- case ELT_SUB_FAM_EVT:
- case ELT_SUB_FAM_EVT_EVEN:
- case ELT_SUB_INDIV_ATTR:
- case ELT_SUB_INDIV_RESI:
- case ELT_SUB_INDIV_BIRT:
- case ELT_SUB_INDIV_GEN:
- case ELT_SUB_INDIV_ADOP:
- case ELT_SUB_INDIV_EVEN:
- event_add_citation(ctxt, cit); break;
- case ELT_SUB_NOTE:
- note_sub_add_citation(ctxt, cit); break;
- case ELT_SUB_LSS_SLGS:
- case ELT_SUB_LIO_BAPL:
- case ELT_SUB_LIO_SLGC:
- lds_event_add_citation(ctxt, cit); break;
- case REC_FAM:
- family_add_citation(ctxt, cit); break;
- case ELT_SUB_PERS_NAME:
- name_add_citation(ctxt, cit); break;
- case REC_INDI:
- individual_add_citation(ctxt, cit); break;
- case ELT_SUB_ASSO:
- association_add_citation(ctxt, cit); break;
- case REC_NOTE:
- note_add_citation(ctxt, cit); break;
- default:
- UNEXPECTED_CONTEXT(ctxt->ctxt_type);
- }
- result = MAKE_GOM_CTXT(elt, source_citation, cit);
+ switch (ctxt->ctxt_type) {
+ case ELT_SUB_PLAC:
+ place_add_citation(ctxt, cit); break;
+ case ELT_SUB_FAM_EVT:
+ case ELT_SUB_FAM_EVT_EVEN:
+ case ELT_SUB_INDIV_ATTR:
+ case ELT_SUB_INDIV_RESI:
+ case ELT_SUB_INDIV_BIRT:
+ case ELT_SUB_INDIV_GEN:
+ case ELT_SUB_INDIV_ADOP:
+ case ELT_SUB_INDIV_EVEN:
+ event_add_citation(ctxt, cit); break;
+ case ELT_SUB_NOTE:
+ note_sub_add_citation(ctxt, cit); break;
+ case ELT_SUB_LSS_SLGS:
+ case ELT_SUB_LIO_BAPL:
+ case ELT_SUB_LIO_SLGC:
+ lds_event_add_citation(ctxt, cit); break;
+ case REC_FAM:
+ family_add_citation(ctxt, cit); break;
+ case ELT_SUB_PERS_NAME:
+ name_add_citation(ctxt, cit); break;
+ case REC_INDI:
+ individual_add_citation(ctxt, cit); break;
+ case ELT_SUB_ASSO:
+ association_add_citation(ctxt, cit); break;
+ case REC_NOTE:
+ note_add_citation(ctxt, cit); break;
+ default:
+ UNEXPECTED_CONTEXT(ctxt->ctxt_type);
}
+ result = MAKE_GOM_CTXT(elt, source_citation, cit);
}
}
return (Gedcom_ctxt)result;
}
+void sub_citation_end(_ELT_END_PARAMS_)
+{
+ Gom_ctxt ctxt = (Gom_ctxt)self;
+
+ if (! ctxt)
+ NO_CONTEXT;
+ else {
+ if (GEDCOM_IS_STRING(parsed_value)) {
+ struct source_citation *cit = SAFE_CTXT_CAST(source_citation, ctxt);
+ if (cit) {
+ char *str = GEDCOM_STRING(parsed_value);
+ char *newvalue = strdup(str);
+ if (! newvalue)
+ MEMORY_ERROR;
+ else
+ cit->description = newvalue;
+ }
+ }
+ }
+}
+
Gedcom_ctxt sub_cit_text_start(_ELT_PARAMS_)
{
Gom_ctxt ctxt = (Gom_ctxt)parent;
if (cit) {
struct text *t = NULL;
MAKE_CHAIN_ELT(text, cit->text, t);
+ if (t)
+ result = MAKE_GOM_CTXT(elt, text, t);
+ }
+ }
+
+ return (Gedcom_ctxt)result;
+}
+
+void sub_cit_text_end(_ELT_END_PARAMS_)
+{
+ Gom_ctxt ctxt = (Gom_ctxt)self;
+
+ if (! ctxt)
+ NO_CONTEXT;
+ else {
+ if (GEDCOM_IS_STRING(parsed_value)) {
+ struct text *t = SAFE_CTXT_CAST(text, ctxt);
if (t) {
- t->text = strdup(GEDCOM_STRING(parsed_value));
- if (! t->text) {
+ char *str = GEDCOM_STRING(parsed_value);
+ char *newvalue = strdup(str);
+ if (! newvalue)
MEMORY_ERROR;
- free(t);
- }
else
- result = MAKE_GOM_CTXT(elt, text, t);
+ t->text = newvalue;
}
}
}
-
- return (Gedcom_ctxt)result;
}
STRING_CB(source_citation, sub_cit_page_start, page)
void citation_subscribe()
{
- gedcom_subscribe_to_element(ELT_SUB_SOUR, sub_citation_start, def_elt_end);
+ gedcom_subscribe_to_element(ELT_SUB_SOUR, sub_citation_start,
+ sub_citation_end);
gedcom_subscribe_to_element(ELT_SUB_SOUR_PAGE, sub_cit_page_start,
def_elt_end);
gedcom_subscribe_to_element(ELT_SUB_SOUR_EVEN, sub_cit_even_start,
gedcom_subscribe_to_element(ELT_SUB_SOUR_DATA_DATE, sub_cit_data_date_start,
def_elt_end);
gedcom_subscribe_to_element(ELT_SUB_SOUR_TEXT, sub_cit_text_start,
- def_elt_end);
+ sub_cit_text_end);
gedcom_subscribe_to_element(ELT_SUB_SOUR_QUAY, sub_cit_quay_start,
def_elt_end);
}
LINK_CHAIN_ELT(multimedia_link, cit->mm_link, mm);
}
-void citation_add_to_desc(NL_TYPE type, Gom_ctxt ctxt, const char* str)
-{
- struct source_citation *cit = SAFE_CTXT_CAST(source_citation, ctxt);
- if (cit) {
- char *newvalue = concat_strings (type, cit->description, str);
- if (newvalue)
- cit->description = newvalue;
- else
- MEMORY_ERROR;
- }
-}
-
-void citation_add_to_text(NL_TYPE type, Gom_ctxt ctxt, const char* str)
-{
- struct text *t = SAFE_CTXT_CAST(text, ctxt);
- if (t) {
- char *newvalue = concat_strings (type, t->text, str);
- if (newvalue)
- t->text = newvalue;
- else
- MEMORY_ERROR;
- }
-}
-
void citation_add_user_data(Gom_ctxt ctxt, struct user_data* data)
{
struct source_citation *obj = SAFE_CTXT_CAST(source_citation, ctxt);
void citation_cleanup(struct source_citation* cit);
void citation_add_note(Gom_ctxt ctxt, struct note_sub* note);
void citation_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* mm);
-void citation_add_to_desc(NL_TYPE type, Gom_ctxt ctxt, const char* str);
-void citation_add_to_text(NL_TYPE type, Gom_ctxt ctxt, const char* str);
void citation_add_user_data(Gom_ctxt ctxt, struct user_data* data);
#endif /* __SOURCE_CITATION_H */