LINK_CHAIN_ELT(user_ref_number, fam->ref, ref);
}
-void family_set_record_id(Gom_ctxt ctxt, char *rin)
+void family_set_record_id(Gom_ctxt ctxt, const char *rin)
{
struct family *fam = SAFE_CTXT_CAST(family, ctxt);
if (fam) {
return gom_first_family;
}
-struct family* make_family_record(char* xrefstr)
+struct family* make_family_record(const char* xrefstr)
{
struct family* fam = NULL;
MAKE_CHAIN_ELT(family, gom_first_family, fam);
void family_subscribe();
void families_cleanup();
-struct family* make_family_record(char* xref);
+struct family* make_family_record(const char* xref);
void family_add_event(Gom_ctxt ctxt, struct event* evt);
void family_add_lss(Gom_ctxt ctxt, struct lds_event* lss);
void family_add_citation(Gom_ctxt ctxt, struct source_citation* cit);
void family_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link);
void family_add_note(Gom_ctxt ctxt, struct note_sub* note);
void family_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
-void family_set_record_id(Gom_ctxt ctxt, char *rin);
+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);
user_recs_cleanup();
}
-int gom_parse_file(char* file_name)
+int gom_parse_file(const char* file_name)
{
gedcom_set_default_callback(gom_default_callback);
header_subscribe();
SAFE_FREE(ctxt);
}
-void gom_cast_error(char* file, int line, OBJ_TYPE expected, OBJ_TYPE found)
+void gom_cast_error(const char* file, int line,
+ OBJ_TYPE expected, OBJ_TYPE found)
{
fprintf(stderr,
"Wrong gom ctxt cast at %s, line %d: expected %d, found %d\n",
abort();
}
-void gom_mem_error(char *filename, int line)
+void gom_mem_error(const char *filename, int line)
{
gedcom_error(_("Could not allocate memory at %s, %d"), filename, line);
}
-void gom_unexpected_context(char* file, int line, OBJ_TYPE found)
+void gom_unexpected_context(const char* file, int line, OBJ_TYPE found)
{
gedcom_warning(_("Internal error: Unexpected context at %s, line %d: %d"),
file, line, found);
}
-void gom_no_context(char* file, int line)
+void gom_no_context(const char* file, int line)
{
gedcom_warning(_("Internal error: No context at %s, line %d"),
file, line);
}
-void gom_default_callback (Gedcom_elt elt, Gedcom_ctxt parent, int level, char* tag,
- char* raw_value, int parsed_tag)
+void gom_default_callback (Gedcom_elt elt, Gedcom_ctxt parent, int level,
+ char* tag, char* raw_value, int parsed_tag)
{
gedcom_warning(_("Data loss in import: \"%d %s %s\""),
level, tag, raw_value);
destroy_gom_ctxt(ctxt);
}
-void set_xref_type(struct xref_value* xr, char *str)
+void set_xref_type(struct xref_value* xr, const char *str)
{
if (!strcasecmp(str, "FAM"))
xr->type = XREF_FAM;
}
return age_ptr;
}
+
+char* gom_get_string(char** data)
+{
+ return *data;
+}
+
+char* gom_set_string(char** data, char* newvalue)
+{
+ char* result = NULL;
+ char* newptr = strdup(newvalue);
+
+ if (!newptr)
+ MEMORY_ERROR;
+ else {
+ if (*data) free(*data);
+ *data = newptr;
+ result = *data;
+ }
+
+ return result;
+}
Gom_ctxt make_gom_ctxt(int ctxt_type, OBJ_TYPE obj_type, void *ctxt_ptr);
void destroy_gom_ctxt(Gom_ctxt ctxt);
-void gom_cast_error(char* file, int line, OBJ_TYPE expected, OBJ_TYPE found);
-void gom_no_context(char* file, int line);
-void gom_unexpected_context(char* file, int line, OBJ_TYPE found);
+void gom_cast_error(const char* file, int line,
+ OBJ_TYPE expected, OBJ_TYPE found);
+void gom_no_context(const char* file, int line);
+void gom_unexpected_context(const char* file, int line, OBJ_TYPE found);
#define MAKE_GOM_CTXT(CTXT_TYPE, STRUCTTYPE, CTXT_PTR) \
make_gom_ctxt(CTXT_TYPE, T_ ## STRUCTTYPE, CTXT_PTR)
#define NO_CONTEXT \
gom_no_context(__FILE__, __LINE__)
-void gom_mem_error(char *filename, int line);
+void gom_mem_error(const char *filename, int line);
#define MEMORY_ERROR gom_mem_error(__FILE__, __LINE__)
void def_rec_end(Gedcom_rec rec, Gedcom_ctxt self);
void def_elt_end(Gedcom_elt elt, Gedcom_ctxt parent, Gedcom_ctxt self,
Gedcom_val parsed_value);
-void set_xref_type(struct xref_value *xr, char* str);
+void set_xref_type(struct xref_value *xr, const char* str);
typedef enum {
WITHOUT_NL,
}
#define GET_REC_BY_XREF(STRUCTTYPE,XREF_TYPE,FUNC_NAME) \
- struct STRUCTTYPE *FUNC_NAME(char *xrefstr) \
+ struct STRUCTTYPE *FUNC_NAME(const char *xrefstr) \
{ \
struct xref_value* xr = gedcom_get_by_xref(xrefstr); \
if (xr && (xr->type == XREF_TYPE) && xr->object) \
head->source.corporation.address = addr;
}
-void header_add_phone(Gom_ctxt ctxt, char* phone)
+void header_add_phone(Gom_ctxt ctxt, const char* phone)
{
struct header *head = SAFE_CTXT_CAST(header, ctxt);
if (head) {
}
}
-void header_add_to_note(NL_TYPE type, Gom_ctxt ctxt, char* str)
+void header_add_to_note(NL_TYPE type, Gom_ctxt ctxt, const char* str)
{
struct header *head = SAFE_CTXT_CAST(header, ctxt);
if (head) {
void header_subscribe();
void header_cleanup();
void header_add_address(Gom_ctxt header, struct address* addr);
-void header_add_phone (Gom_ctxt header, char* phone);
-void header_add_to_note(NL_TYPE type, Gom_ctxt header, char* str);
+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);
#endif /* __HEADER_H */
LINK_CHAIN_ELT(user_ref_number, indiv->ref, ref);
}
-void individual_set_record_id(Gom_ctxt ctxt, char *rin)
+void individual_set_record_id(Gom_ctxt ctxt, const char *rin)
{
struct individual *indiv = SAFE_CTXT_CAST(individual, ctxt);
if (indiv) {
return gom_first_individual;
}
-struct individual* make_individual_record(char* xrefstr)
+struct individual* make_individual_record(const char* xrefstr)
{
struct individual* indiv = NULL;
MAKE_CHAIN_ELT(individual, gom_first_individual, indiv);
void individual_subscribe();
void individuals_cleanup();
-struct individual* make_individual_record(char* xref);
+struct individual* make_individual_record(const char* xref);
void individual_add_event(Gom_ctxt ctxt, struct event* evt);
void individual_add_attribute(Gom_ctxt ctxt, struct event* evt);
void individual_add_name(Gom_ctxt ctxt, struct personal_name* name);
void individual_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link);
void individual_add_note(Gom_ctxt ctxt, struct note_sub* note);
void individual_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
-void individual_set_record_id(Gom_ctxt ctxt, char *rin);
+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);
LINK_CHAIN_ELT(user_ref_number, obj->ref, ref);
}
-void multimedia_set_record_id(Gom_ctxt ctxt, char *rin)
+void multimedia_set_record_id(Gom_ctxt ctxt, const char *rin)
{
struct multimedia *obj = SAFE_CTXT_CAST(multimedia, ctxt);
if (obj) {
return gom_first_multimedia;
}
-struct multimedia* make_multimedia_record(char* xrefstr)
+struct multimedia* make_multimedia_record(const char* xrefstr)
{
struct multimedia* multi = NULL;
MAKE_CHAIN_ELT(multimedia, gom_first_multimedia, multi);
void multimedia_subscribe();
void multimedias_cleanup();
-struct multimedia* make_multimedia_record(char* xref);
+struct multimedia* make_multimedia_record(const char* xref);
void multimedia_add_note(Gom_ctxt ctxt, struct note_sub* note);
void multimedia_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
-void multimedia_set_record_id(Gom_ctxt ctxt, char *rin);
+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);
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, char* str)
+void note_add_to_note(NL_TYPE type, Gom_ctxt ctxt, const char* str)
{
struct note *note = SAFE_CTXT_CAST(note, ctxt);
if (note) {
LINK_CHAIN_ELT(user_ref_number, note->ref, ref);
}
-void note_set_record_id(Gom_ctxt ctxt, char *rin)
+void note_set_record_id(Gom_ctxt ctxt, const char *rin)
{
struct note *note = SAFE_CTXT_CAST(note, ctxt);
if (note) {
return gom_first_note;
}
-struct note* make_note_record(char* xrefstr)
+struct note* make_note_record(const char* xrefstr)
{
struct note* note = NULL;
MAKE_CHAIN_ELT(note, gom_first_note, note);
void note_subscribe();
void notes_cleanup();
-struct note* make_note_record(char* xref);
-void note_add_to_note(NL_TYPE type, Gom_ctxt ctxt, char* str);
+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, char *rin);
+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);
LINK_CHAIN_ELT(source_citation, note->citation, cit);
}
-void note_sub_add_to_note(NL_TYPE type, Gom_ctxt ctxt, char* str)
+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) {
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, char* str);
+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 */
repo->address = address;
}
-void repository_add_phone(Gom_ctxt ctxt, char *phone)
+void repository_add_phone(Gom_ctxt ctxt, const char *phone)
{
struct repository *repo = SAFE_CTXT_CAST(repository, ctxt);
if (repo) {
LINK_CHAIN_ELT(user_ref_number, repo->ref, ref);
}
-void repository_set_record_id(Gom_ctxt ctxt, char *rin)
+void repository_set_record_id(Gom_ctxt ctxt, const char *rin)
{
struct repository *repo = SAFE_CTXT_CAST(repository, ctxt);
if (repo) {
return gom_first_repository;
}
-struct repository* make_repository_record(char* xrefstr)
+struct repository* make_repository_record(const char* xrefstr)
{
struct repository* repo = NULL;
MAKE_CHAIN_ELT(repository, gom_first_repository, repo);
void repository_subscribe();
void repositories_cleanup();
-struct repository* make_repository_record(char* xref);
+struct repository* make_repository_record(const char* xref);
void repository_add_address(Gom_ctxt ctxt, struct address* address);
-void repository_add_phone(Gom_ctxt ctxt, char *phone);
+void repository_add_phone(Gom_ctxt ctxt, const char *phone);
void repository_add_note(Gom_ctxt ctxt, struct note_sub* note);
void repository_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
-void repository_set_record_id(Gom_ctxt ctxt, char *rin);
+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);
LINK_CHAIN_ELT(source_description, sour->repository.description, desc);
}
-void source_add_to_value(NL_TYPE type, Gom_ctxt ctxt, char* str)
+void source_add_to_value(NL_TYPE type, Gom_ctxt ctxt, const char* str)
{
struct source *sour = SAFE_CTXT_CAST(source, ctxt);
if (sour) {
LINK_CHAIN_ELT(user_ref_number, sour->ref, ref);
}
-void source_set_record_id(Gom_ctxt ctxt, char *rin)
+void source_set_record_id(Gom_ctxt ctxt, const char *rin)
{
struct source *sour = SAFE_CTXT_CAST(source, ctxt);
if (sour) {
return gom_first_source;
}
-struct source* make_source_record(char* xrefstr)
+struct source* make_source_record(const char* xrefstr)
{
struct source* src = NULL;
MAKE_CHAIN_ELT(source, gom_first_source, src);
void source_subscribe();
void sources_cleanup();
-struct source* make_source_record(char* xref);
+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, char* str);
+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);
void source_add_note(Gom_ctxt ctxt, struct note_sub* note);
void source_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref);
-void source_set_record_id(Gom_ctxt ctxt, char *rin);
+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);
LINK_CHAIN_ELT(multimedia_link, cit->mm_link, mm);
}
-void citation_add_to_desc(NL_TYPE type, Gom_ctxt ctxt, char* str)
+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) {
}
}
-void citation_add_to_text(NL_TYPE type, Gom_ctxt ctxt, char* str)
+void citation_add_to_text(NL_TYPE type, Gom_ctxt ctxt, const char* str)
{
struct text *t = SAFE_CTXT_CAST(text, ctxt);
if (t) {
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, char* str);
-void citation_add_to_text(NL_TYPE type, Gom_ctxt ctxt, char* str);
+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 */
return gom_submission;
}
-struct submission* make_submission_record(char* xref)
+struct submission* make_submission_record(const char* xref)
{
if (! gom_submission) {
gom_submission = (struct submission*)malloc(sizeof(struct submission));
void submission_subscribe();
void submission_cleanup();
-struct submission* make_submission_record(char* xref);
+struct submission* make_submission_record(const char* xref);
void submission_add_user_data(Gom_ctxt ctxt, struct user_data* data);
#endif /* __SUBMISSION_H */
subm->address = address;
}
-void submitter_add_phone(Gom_ctxt ctxt, char *phone)
+void submitter_add_phone(Gom_ctxt ctxt, const char *phone)
{
struct submitter *subm = SAFE_CTXT_CAST(submitter, ctxt);
if (subm) {
return gom_first_submitter;
}
-struct submitter* make_submitter_record(char* xrefstr)
+struct submitter* make_submitter_record(const char* xrefstr)
{
struct submitter* subm = NULL;
MAKE_CHAIN_ELT(submitter, gom_first_submitter, subm);
void submitter_subscribe();
void submitters_cleanup();
-struct submitter* make_submitter_record(char* xref);
+struct submitter* make_submitter_record(const char* xref);
void submitter_add_address(Gom_ctxt ctxt, struct address* address);
-void submitter_add_phone(Gom_ctxt ctxt, char *phone);
+void submitter_add_phone(Gom_ctxt ctxt, const char *phone);
void submitter_add_mm_link(Gom_ctxt ctxt, struct multimedia_link* link);
void submitter_set_change_date(Gom_ctxt ctxt, struct change_date* chan);
void submitter_add_user_data(Gom_ctxt ctxt, struct user_data* data);
return gom_first_user_rec;
}
-struct user_rec* make_user_record(char* xrefstr)
+struct user_rec* make_user_record(const char* xrefstr)
{
struct user_rec* rec = NULL;
MAKE_CHAIN_ELT(user_rec, gom_first_user_rec, rec);
void user_rec_subscribe();
void user_recs_cleanup();
-struct user_rec* make_user_record(char* xref);
+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);
/* Functions */
-int gom_parse_file(char *file_name);
+int gom_parse_file(const char *file_name);
struct header* gom_get_header();
struct submission* gom_get_submission();
struct family* gom_get_first_family();
-struct family* gom_get_family_by_xref(char *xref);
+struct family* gom_get_family_by_xref(const char *xref);
struct individual* gom_get_first_individual();
-struct individual* gom_get_individual_by_xref(char *xref);
+struct individual* gom_get_individual_by_xref(const char *xref);
struct multimedia* gom_get_first_multimedia();
-struct multimedia* gom_get_multimedia_by_xref(char *xref);
+struct multimedia* gom_get_multimedia_by_xref(const char *xref);
struct note* gom_get_first_note();
-struct note* gom_get_note_by_xref(char *xref);
+struct note* gom_get_note_by_xref(const char *xref);
struct repository* gom_get_first_repository();
-struct repository* gom_get_repository_by_xref(char *xref);
+struct repository* gom_get_repository_by_xref(const char *xref);
struct source* gom_get_first_source();
-struct source* gom_get_source_by_xref(char *xref);
+struct source* gom_get_source_by_xref(const char *xref);
struct submitter* gom_get_first_submitter();
-struct submitter* gom_get_submitter_by_xref(char *xref);
+struct submitter* gom_get_submitter_by_xref(const char *xref);
struct user_rec* gom_get_first_user_rec();
-struct user_rec* gom_get_user_rec_by_xref(char *xref);
+struct user_rec* gom_get_user_rec_by_xref(const char *xref);
__END_DECLS