From 38a93aa4ec4d643e63d797e1bdbf639b1082a4cd Mon Sep 17 00:00:00 2001 From: Peter Verthez Date: Tue, 17 Sep 2002 15:46:43 +0000 Subject: [PATCH] Getting and setting strings. --- gom/gom_modify.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ include/gom.h | 7 ++++++ 2 files changed, 71 insertions(+) create mode 100644 gom/gom_modify.c diff --git a/gom/gom_modify.c b/gom/gom_modify.c new file mode 100644 index 0000000..95bd926 --- /dev/null +++ b/gom/gom_modify.c @@ -0,0 +1,64 @@ +/* Source code for modifying the gedcom object model. + Copyright (C) 2002 The Genes Development Team + This file is part of the Gedcom parser library. + Contributed by Peter Verthez , 2002. + + The Gedcom parser library is free software; you can redistribute it + and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The Gedcom parser library is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the Gedcom parser library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* $Id$ */ +/* $Name$ */ + +#include +#include +#include "utf8-locale.h" +#include "gom.h" +#include "gom_internal.h" + +void gom_set_unknown(const char* unknown) +{ + convert_set_unknown(unknown); +} + +char* gom_get_string(char* data) +{ + return data; +} + +char* gom_get_string_locale(char* data, int* conversion_failures) +{ + return convert_utf8_to_locale(gom_get_string(data), conversion_failures); +} + +char* gom_set_string(char** data, const char* utf8_value) +{ + char* result = NULL; + char* newptr = strdup(utf8_value); + + if (!newptr) + MEMORY_ERROR; + else { + if (*data) free(*data); + *data = newptr; + result = *data; + } + + return result; +} + +char* gom_set_string_locale(char** data, const char* locale_value) +{ + return gom_set_string(data, convert_locale_to_utf8(locale_value)); +} diff --git a/include/gom.h b/include/gom.h index 0af1ee5..f0952e9 100644 --- a/include/gom.h +++ b/include/gom.h @@ -442,6 +442,13 @@ 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(const char *xref); +char* gom_get_string(char* data); +char* gom_set_string(char** data, const char* utf8_value); + +char* gom_get_string_locale(char* data, int* conversion_failures); +char* gom_set_string_locale(char** data, const char* locale_value); +void gom_set_unknown(const char* unknown); + __END_DECLS #endif /* __GEDCOM_GOM_H */ -- 2.30.2