summaryrefslogtreecommitdiffstats
path: root/src/rccstring.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-14 08:45:46 +0000
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-14 08:45:46 +0000
commitf15620c372b8813a87d07eee169cf2096c99c173 (patch)
treef1c59f41d4a9c9f5f45595695327b0e4a74b1408 /src/rccstring.c
parent7233ff9095194b38586ce438379f08691a0fecdd (diff)
downloadlibrcc-f15620c372b8813a87d07eee169cf2096c99c173.tar.gz
librcc-f15620c372b8813a87d07eee169cf2096c99c173.tar.bz2
librcc-f15620c372b8813a87d07eee169cf2096c99c173.tar.xz
librcc-f15620c372b8813a87d07eee169cf2096c99c173.zip
IConv and DB4
Diffstat (limited to 'src/rccstring.c')
-rw-r--r--src/rccstring.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/rccstring.c b/src/rccstring.c
index 0df20d6..f1f7016 100644
--- a/src/rccstring.c
+++ b/src/rccstring.c
@@ -6,8 +6,8 @@
rcc_string rccCreateString(rcc_language_id language_id, const char *buf, size_t len, size_t *rlen) {
char *res;
- rcc_string_header header = {RCC_STRING_MAGIC, language_id};
-
+ rcc_string_header *header;
+
len = STRNLEN(buf, len);
res = (char*)malloc(len+sizeof(rcc_string_header)+1);
@@ -16,12 +16,45 @@ rcc_string rccCreateString(rcc_language_id language_id, const char *buf, size_t
strncpy(res + sizeof(rcc_string_header), buf, len);
res[sizeof(rcc_string_header) + len] = 0;
- memcpy(res, &header, sizeof(rcc_string_header));
+ memset(res, 0xFF, sizeof(rcc_string_header));
+ header = (rcc_string_header*)res;
+ header->magic = RCC_STRING_MAGIC;
+ header->language_id = language_id;
if (rlen) *rlen = len + sizeof(rcc_string_header);
return (rcc_string)res;
}
+int rccStringSetLang(rcc_string string, const char *sn) {
+ if ((!string)||(!sn)||(strlen(sn)!=2)) return -1;
+ memcpy(&((rcc_string_header*)string)->language,sn,2);
+ return 0;
+}
+
+int rccStringFixID(rcc_string string, rcc_context ctx) {
+ char lang[3];
+ const char *curlang;
+ rcc_language_config config;
+ rcc_language_id language_id;
+ rcc_string_header *header;
+
+ if ((!string)||(!ctx)||(!rccStringCheck(string))) return -1;
+ header = (rcc_string_header*)string;
+
+
+ memcpy(lang, header->language, 2); lang[3] = 0;
+ curlang = rccGetLanguageName(ctx, header->language_id);
+ if ((curlang)&&(!strcasecmp(lang, curlang))) return 0;
+
+ language_id = rccGetLanguageByName(ctx, lang);
+ if ((language_id == (rcc_language_id)-1)||(language_id == 0)) return -1;
+ config = rccGetLanguageConfig(ctx, language_id);
+ if (!config) return -1;
+
+ header->language_id = language_id;
+ return 0;
+}
+
void rccStringFree(rcc_string str) {
if (str) free(str);
}