summaryrefslogtreecommitdiffstats
path: root/src/engine.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2007-06-27 09:28:22 +0000
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2007-06-27 09:28:22 +0000
commit35381569403e90b8d34b223f524519521bc81598 (patch)
tree924527ab503a59400cfd96859e101ce8234eabd0 /src/engine.c
parentfd502754926131e3562a2210ff81af111ccaf867 (diff)
downloadlibrcc-35381569403e90b8d34b223f524519521bc81598.tar.gz
librcc-35381569403e90b8d34b223f524519521bc81598.tar.bz2
librcc-35381569403e90b8d34b223f524519521bc81598.tar.xz
librcc-35381569403e90b8d34b223f524519521bc81598.zip
Engines rework
- LibGuess support for far east language autodetection - Support for LibRCD 0.1.9 supporting ISO-8859-1 strings - Fixing wrong encodings names returned by Enca - Engine plugins naming scheme is altered - New API functions: rccEngineGetInfo, rccEngineGetAutoCharsetByName - Most of languages are no more hardcoded, but moved to the configuration - RCD engine is added to Belarusian language (I hope it should work) - Some encoding names are fixed in configuration - Support for external libiconv - Support for libcharset - Find UI interface language from LC_MESSAGES locale - Simple compilation fix (Thanx to D. Panov)
Diffstat (limited to 'src/engine.c')
-rw-r--r--src/engine.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/engine.c b/src/engine.c
index f9c2284..3d3e023 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -125,6 +125,7 @@ int rccEngineConfigure(rcc_engine_context ctx) {
engine = ctx->config->language->engines[engine_id];
+ ctx->id = engine_id;
ctx->free_func = engine->free_func;
ctx->func = engine->func;
@@ -134,6 +135,30 @@ int rccEngineConfigure(rcc_engine_context ctx) {
return 0;
}
+
+rcc_engine *rccEngineGetInfo(rcc_engine_context ctx) {
+ if (!ctx) return NULL;
+ return ctx->config->language->engines[ctx->id];
+}
+
+rcc_autocharset_id rccEngineGetAutoCharsetByName(rcc_engine_context ctx, const char *name) {
+ unsigned int i;
+ rcc_engine *info;
+ rcc_charset *charsets;
+
+ if ((!ctx)||(!name)) return (rcc_autocharset_id)-1;
+
+ info = rccEngineGetInfo(ctx);
+ if (info) {
+ charsets = info->charsets;
+
+ for (i=0;charsets[i];i++)
+ if (!strcasecmp(charsets[i],name)) return (rcc_autocharset_id)i;
+ }
+
+ return (rcc_autocharset_id)-1;
+}
+
rcc_engine_internal rccEngineGetInternal(rcc_engine_context ctx) {
if (!ctx) return NULL;
@@ -186,6 +211,8 @@ static int CheckWestern(const unsigned char *buf, int len) {
rcc_autocharset_id rccEngineDetectCharset(rcc_engine_context ctx, const char *buf, size_t len) {
rcc_autocharset_id utf;
+ /* DS: This should be done directly in autoengines, otherwise we will
+ fail to detect 7bit encodings */
if (CheckWestern(buf, len)) {
utf=rccConfigGetAutoCharsetByName(ctx->config, "UTF-8");
if (utf != (rcc_autocharset_id)-1) return utf;