summaryrefslogtreecommitdiffstats
path: root/src/lng.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2005-06-26 17:51:43 +0000
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2005-06-26 17:51:43 +0000
commitc60519ab50b32dc282b385b3bbb2df319279f655 (patch)
tree001c2f9653029878da1eee01d19636221a5ad268 /src/lng.c
parent3aa2acb1aa6931d9a5cab87fe9bef94086e25d16 (diff)
downloadlibrcc-c60519ab50b32dc282b385b3bbb2df319279f655.tar.gz
librcc-c60519ab50b32dc282b385b3bbb2df319279f655.tar.bz2
librcc-c60519ab50b32dc282b385b3bbb2df319279f655.tar.xz
librcc-c60519ab50b32dc282b385b3bbb2df319279f655.zip
26.06.2005
Diffstat (limited to 'src/lng.c')
-rw-r--r--src/lng.c68
1 files changed, 24 insertions, 44 deletions
diff --git a/src/lng.c b/src/lng.c
index 607c69d..053e7d0 100644
--- a/src/lng.c
+++ b/src/lng.c
@@ -1,16 +1,23 @@
#include <stdio.h>
#include <string.h>
-#include <locale.h>
-#include <librcd.h>
-#include "librcc.h"
+#include "internal.h"
+#include "config.h"
+#include "rcclocale.h"
-const char *rccGetLanguageName(rcc_context *ctx, rcc_language_id language_id) {
+rcc_language_ptr rccGetLanguagePointer(rcc_context ctx, rcc_language_id language_id) {
if ((!ctx)||(language_id<0)||(language_id>=ctx->n_languages)) return NULL;
- return ctx->languages[language_id]->sn;
+ return ctx->languages[language_id];
}
-language_id rccGetLanguageByName(rcc_context *ctx, const char *name) {
+const char *rccGetLanguageName(rcc_context ctx, rcc_language_id language_id) {
+ rcc_language_ptr language;
+ language = rccGetLanguagePointer(ctx, language_id);
+ if (!language) return NULL;
+ return language->sn;
+}
+
+rcc_language_id rccGetLanguageByName(rcc_context ctx, const char *name) {
unsigned int i;
if ((!ctx)||(!name)) return 0;
@@ -20,41 +27,14 @@ language_id rccGetLanguageByName(rcc_context *ctx, const char *name) {
return 0;
}
-static int rccGetLocaleLanguage(char *result, const char *lv, unsigned int n) {
- charset_list_t *enc;
- char *l;
-
- if (!lv) return -1;
-
- l = setlocale(lv, NULL);
- if (!l) return -1;
- else if ((strcmp(l,"C")==0)||(strcmp(l,"POSIX")==0)) return -1;
-
- for (i=0;((l[i])&&(l[i]!='.'));i++);
-
- for (i=0;rcc_default_aliases[i].alias;i++)
- if (strncmp(l,rcc_default_aliases[i].alias,i)==0) {
- l = rcc_default_aliases[i].alias;
- break;
- }
-
- for (i=0;((l[i])&&(l[i]!='.')&&(l[i]!='_'));i++);
- if (i>=n) return -1;
-
- strncpy(result,l,i);
- result[i]=0;
-
- return 0;
-}
-
-static rcc_language_id rccGetDefaultLanguage(rc_context *ctx) {
+static rcc_language_id rccGetDefaultLanguage(rcc_context ctx) {
int err;
unsigned int i;
char stmp[RCC_MAX_LANGUAGE_CHARS+1];
if (!ctx) return -1;
- err = rccGetLocaleLanguage(stmp, ctx->locale_variable, RCC_MAX_LANGUAGE_CHARS);
+ err = rccLocaleGetLanguage(stmp, ctx->locale_variable, RCC_MAX_LANGUAGE_CHARS);
if (err) {
if (ctx->n_languages>1) return 1;
return -1;
@@ -67,25 +47,25 @@ static rcc_language_id rccGetDefaultLanguage(rc_context *ctx) {
return -1;
}
-rcc_language_id rccGetRealLanguage(rcc_context *ctx, rcc_language_id language_id) {
+rcc_language_id rccGetRealLanguage(rcc_context ctx, rcc_language_id language_id) {
if ((!ctx)||(language_id<0)||(language_id>=ctx->n_languages)) return -1;
if (language_id) return language_id;
return rccGetDefaultLanguage(ctx);
}
-const char *rccGetRealLanguageName(rcc_context *ctx, rcc_language_id language_id) {
+const char *rccGetRealLanguageName(rcc_context ctx, rcc_language_id language_id) {
language_id = rccGetRealLanguage(ctx, language_id);
if (language_id<0) return NULL;
return rccGetLanguageName(ctx, language_id);
}
-rcc_language_id rccGetSelectedLanguage(rcc_context *ctx) {
- if (!ctx) return NULL;
+rcc_language_id rccGetSelectedLanguage(rcc_context ctx) {
+ if (!ctx) return -1;
return ctx->current_language;
}
-const char *rccGetSelectedLanguageName(rcc_context *ctx) {
+const char *rccGetSelectedLanguageName(rcc_context ctx) {
rcc_language_id language_id;
language_id = rccGetSelectedLanguage(ctx);
@@ -94,12 +74,12 @@ const char *rccGetSelectedLanguageName(rcc_context *ctx) {
return rccGetLanguageName(ctx, language_id);
}
-rcc_language_id rccGetCurrentLanguage(rcc_context *ctx) {
+rcc_language_id rccGetCurrentLanguage(rcc_context ctx) {
if (!ctx) return -1;
return rccGetRealLanguage(ctx, ctx->current_language);
}
-const char *rccGetCurrentLanguageName(rcc_context *ctx) {
+const char *rccGetCurrentLanguageName(rcc_context ctx) {
rcc_language_id language_id;
language_id = rccGetCurrentLanguage(ctx);
@@ -109,7 +89,7 @@ const char *rccGetCurrentLanguageName(rcc_context *ctx) {
}
-int rccSetLanguage(rcc_context *ctx, rcc_language_id language_id) {
+int rccSetLanguage(rcc_context ctx, rcc_language_id language_id) {
rcc_language_config config;
if ((!ctx)||(language_id < 0)||(language_id >= ctx->n_languages)) return -1;
@@ -125,7 +105,7 @@ int rccSetLanguage(rcc_context *ctx, rcc_language_id language_id) {
}
}
-int rccSetLanguageByName(rcc_context *ctx, const char *name) {
+int rccSetLanguageByName(rcc_context ctx, const char *name) {
rcc_language_id language_id;
language_id = rccGetLanguageByName(ctx, name);