From 081011f386915bd037a3569e46ed5e4f10c490da Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Tue, 28 Jun 2005 23:44:19 +0000 Subject: 29.06.2005 --- src/Makefile.am | 8 +-- src/config.c | 106 --------------------------------- src/config.h | 17 ------ src/enca.c | 173 ------------------------------------------------------ src/enca.h | 19 ------ src/librcc.c | 4 +- src/lng.c | 2 +- src/lngconfig.c | 2 +- src/plugin.h | 7 ++- src/rccconfig.c | 96 ++++++++++++++++++++++++++++++ src/rccconfig.h | 17 ++++++ src/rccenca.c | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/rccenca.h | 26 +++++++++ src/rcclocale.c | 2 +- src/recode.c | 2 +- src/xml.c | 2 + 16 files changed, 332 insertions(+), 328 deletions(-) delete mode 100644 src/config.c delete mode 100644 src/config.h delete mode 100644 src/enca.c delete mode 100644 src/enca.h create mode 100644 src/rccconfig.c create mode 100644 src/rccconfig.h create mode 100644 src/rccenca.c create mode 100644 src/rccenca.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index a0ad875..01a7da1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,9 +3,9 @@ librcc_la_SOURCES = librcc.c \ rcclocale.c rcclocale.h \ lng.c lng.h \ lngconfig.c lngconfig.h \ - config.c config.h \ + rccconfig.c rccconfig.h \ plugin.c plugin.h \ - enca.c enca.h \ + rccenca.c rccenca.h \ engine.c engine.h \ rccstring.c rccstring.h \ xml.c xml.h \ @@ -14,7 +14,7 @@ librcc_la_SOURCES = librcc.c \ internal.h include_HEADERS = librcc.h -INCLUDES = @XML_INCLUDES@ -librcc_la_LIBADD = @XML_LIBS@ +INCLUDES = @XML_INCLUDES@ @RCD_INCLUDES@ @ENCA_INCLUDES@ +librcc_la_LIBADD = @XML_LIBS@ @RCD_LIBS@ @ENCA_LIBS@ librcc_la_LDFLAGS = -version-info @LIBRCC_VERSION_INFO@ diff --git a/src/config.c b/src/config.c deleted file mode 100644 index 89a8bde..0000000 --- a/src/config.c +++ /dev/null @@ -1,106 +0,0 @@ -#include -#include - -#include "config.h" - -static rcc_charset_id rcc_autoengine_russian(rcc_engine_context ctx, char *buf, int len) { - return (int)get_russian_charset(buf,len); -} - -rcc_language_alias rcc_default_aliases[] = { - { "cs_SK", "sk" }, - { "ru_UA", "uk" }, - { NULL, NULL} -}; - -const char rcc_engine_nonconfigured[] = "NonConfigured"; - -rcc_engine rcc_default_engine = { - "Off", NULL, NULL, NULL, {NULL} -}; - -rcc_engine rcc_russian_engine = { - "Russian", NULL, NULL, &rcc_autoengine_russian, {"CP1251","KOI8-R","UTF-8","IBM866", NULL} -}; - -rcc_language rcc_default_languages[] = { -{"default", "Autodetect", {"Default", NULL}, { - &rcc_default_engine, - NULL -}}, -{"off", "Dissable", {"Default", NULL}, { - &rcc_default_engine, - NULL -}}, -{"ru","Russian", {"Default","KOI8-R","CP1251","UTF-8","IBM866","MACCYRILLIC","ISO8859-5", NULL}, { - &rcc_russian_engine, - &rcc_default_engine, - NULL -}}, -{"uk","Ukrainian", {"Default","KOI8-U","CP1251","UTF-8","IBM855","MACCYRILLIC","ISO8859-5","CP1125", NULL}, { - &rcc_russian_engine, - &rcc_default_engine, - NULL -}}, -{"be","Belarussian",{"Default", "UTF-8", "CP1251", "IBM866", "ISO-8859-5", "KOI8-UNI", "maccyr" "IBM855", NULL},{ - &rcc_default_engine, - NULL -}}, -{"bg","Bulgarian",{"Default", "UTF-8", "CP1251", "ISO-8859-5", "IBM855", "maccyr", "ECMA-113", NULL},{ - &rcc_default_engine, - NULL -}}, -{"cz","Czech",{"Default", "UTF-8", "ISO-8859-2", "CP1250", "IBM852", "KEYBCS2", "macce", "KOI-8_CS_2", "CORK", NULL},{ - &rcc_default_engine, - NULL -}}, -{"es","Estonian",{"Default", "UTF-8", "ISO-8859-4", "CP1257", "IBM775", "ISO-8859-13", "macce", "baltic", NULL},{ - &rcc_default_engine, - NULL -}}, -{"hr","Croatian",{"Default", "UTF-8", "CP1250", "ISO-8859-2", "IBM852", "macce", "CORK", NULL},{ - &rcc_default_engine, - NULL -}}, -{"hu","Hungarian",{"Default", "UTF-8", "ISO-8859-2", "CP1250", "IBM852", "macce", "CORK", NULL},{ - &rcc_default_engine, - NULL -}}, -{"lt","Lithuanian",{"Default", "UTF-8", "CP1257", "ISO-8859-4", "IBM775", "ISO-8859-13", "macce", "baltic", NULL},{ - &rcc_default_engine, - NULL -}}, -{"lv","Latvian",{"Default", "UTF-8", "CP1257", "ISO-8859-4", "IBM775", "ISO-8859-13", "macce", "baltic", NULL},{ - &rcc_default_engine, - NULL -}}, -{"pl","Polish",{"Default", "UTF-8", "ISO-8859-2", "CP1250", "IBM852", "macce", "ISO-8859-13", "ISO-8859-16", "baltic", "CORK", NULL},{ - &rcc_default_engine, - NULL -}}, -{"sk","Slovak",{"Default", "UTF-8", "CP1250", "ISO-8859-2", "IBM852", "KEYBCS2", "macce", "KOI-8_CS_2", "CORK", NULL},{ - &rcc_default_engine, - NULL -}}, -{"sl","Slovenian",{"Default", "UTF-8", "ISO-8859-2", "CP1250", "IBM852", "macce", "CORK", NULL},{ - &rcc_default_engine, - NULL -}}, -{"zh","Chinese",{"Default", "UTF-8", "GB2312", "GBK", "GB18030", "BIG5", NULL},{ - &rcc_default_engine, - NULL -}}, -{NULL} -}; - -/* -const charset_list_t charset_list_default = { "Default", NULL }; -charset_t *charset_list=(charset_t*)charset_list_default; -#define autocharset_list_ni_default 1 -autocharset_list_t autocharset_list_default = { - {"Off", NULL, {NULL}} -}; - -int autocharset_list_ni=autocharset_list_ni_default; -autocharset_t *autocharset_list=(autocharset_t*)autocharset_list_default; -*/ \ No newline at end of file diff --git a/src/config.h b/src/config.h deleted file mode 100644 index ac74dbe..0000000 --- a/src/config.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _RCC_CONFIG_H -#define _RCC_CONFIG_H -#include "librcc.h" - -#undef RCC_DEBUG -#define RCC_LOCALE_VARIABLE "LC_CTYPE" - -extern rcc_language_alias rcc_default_aliases[]; - -extern const char rcc_engine_nonconfigured[]; - -extern rcc_engine rcc_default_engine; -extern rcc_engine rcc_russian_engine; - -extern rcc_language rcc_default_languages[]; - -#endif /* _RCC_CONFIG_H */ diff --git a/src/enca.c b/src/enca.c deleted file mode 100644 index 0bb4470..0000000 --- a/src/enca.c +++ /dev/null @@ -1,173 +0,0 @@ -#include - -#include "internal.h" -#include "plugin.h" -#include "engine.h" -#include "config.h" - -#include "enca.h" -#ifdef RCC_ENCA_DYNAMIC -# include "fake_enca.h" -#endif /* RCC_ENCA_DYNAMIC */ - -static rcc_library_handle enca_handle = NULL; -static rcc_engine *enca_engines = NULL; - -rcc_engine_internal rccEncaInitContext(rcc_engine_context ctx) { -#ifdef RCC_ENCA_SUPPORT - EncaAnalyser enca; - - if ((!ctx)||(!ctx->language)) return NULL; - - enca = enca_analyser_alloc(ctx->language->sn); - if (!enca) return NULL; - - enca_set_threshold(enca, 1); - enca_set_multibyte(enca, 1); - enca_set_ambiguity(enca, 1); - enca_set_garbage_test(enca, 0); - enca_set_filtering(enca, 0); - enca_set_significant(enca,1); - enca_set_termination_strictness(enca,0); - - return (rcc_engine_internal)enca; -#else /* RCC_ENCA_SUPPORT */ - return NULL; -#endif /* RCC_ENCA_SUPPORT */ -} - -void rccEncaFreeContext(rcc_engine_context ctx) { - rcc_engine_internal internal; -#ifdef RCC_ENCA_SUPPORT - internal = rccEngineGetInternal(ctx); - if (internal) - enca_analyser_free(internal); -#endif /* RCC_ENCA_SUPPORT */ -} - -rcc_charset_id rccEnca(rcc_engine_context ctx, char *buf, int len) { -#ifdef RCC_ENCA_SUPPORT - rcc_engine_internal internal; - const char *charset; - EncaEncoding ee; - - internal = rccEngineGetInternal(ctx); - if ((!internal)||(!buf)) return -1; - - - len = STRLEN(buf, len); - - ee = enca_analyse_const((EncaAnalyser)ctx->internal,buf,len); - if (ee.charset<0) return -1; - - charset = enca_charset_name(ee.charset, ENCA_NAME_STYLE_ICONV); - return rccGetAutoCharsetByName(ctx->ctx, charset); -#else /* RCC_ENCA_SUPPORT */ - return -1; -#endif /* RCC_ENCA_SUPPORT */ -} - -rcc_engine rcc_enca_engine = { - "Enca Library", &rccEncaInitContext, &rccEncaFreeContext, &rccEnca, {"UTF-8", NULL} -}; - - -static int rccEncaLibraryLoad() { -#ifdef RCC_ENCA_DYNAMIC - if (enca_handle) return 0; - - enca_handle = rccLibraryOpen(RCC_ENCA_LIB); - if (!enca_handle) return -1; - - enca_set_multibyte=rccLibraryFind(enca_handle,"enca_set_multibyte"); - enca_set_interpreted_surfaces=rccLibraryFind(enca_handle,"enca_set_interpreted_surfaces"); - enca_set_ambiguity=rccLibraryFind(enca_handle,"enca_set_ambiguity"); - enca_set_filtering=rccLibraryFind(enca_handle,"enca_set_filtering"); - enca_set_garbage_test=rccLibraryFind(enca_handle,"enca_set_garbage_test"); - enca_set_termination_strictness=rccLibraryFind(enca_handle,"enca_set_termination_strictness"); - enca_set_significant=rccLibraryFind(enca_handle,"enca_set_significant"); - enca_set_threshold=rccLibraryFind(enca_handle,"enca_set_threshold"); - enca_charset_name=rccLibraryFind(enca_handle,"enca_charset_name"); - enca_get_language_charsets=rccLibraryFind(enca_handle,"enca_get_language_charsets"); - enca_analyser_alloc=rccLibraryFind(enca_handle,"enca_analyser_alloc"); - enca_analyser_free=rccLibraryFind(enca_handle,"enca_analyser_free"); - enca_analyse_const=rccLibraryFind(enca_handle,"enca_analyse_const"); - - if ((!enca_set_multibyte)||(!enca_set_interpreted_surfaces)||(!enca_set_ambiguity)|| - (!enca_set_filtering)||(!enca_set_garbage_test)||(!enca_set_termination_strictness)|| - (!enca_set_significant)||(!enca_set_threshold)||(!enca_charset_name)|| - (!enca_get_language_charsets)||(!enca_analyser_alloc)||(!enca_analyser_free)|| - (!enca_analyse_const)) { - rccLibraryClose(enca_handle); - enca_handle = NULL; -# ifdef RCC_DEBUG - perror( "rccEnca. Incomplete function set in library" ); -# endif /* RCC_DEBUG */ - } - -#endif /* RCC_ENCA_DYNAMIC */ - return 0; -} - -static void rccEncaLibraryUnload() { -#ifdef RCC_ENCA_DYNAMIC - if (enca_handle) { - rccLibraryUnload(enca_handle); - enca_handle = NULL; - } -#endif /* RCC_ENCA_DYNAMIC */ -} - -int rccEncaInit() { - int err; - unsigned int i,j,k,l; - - rcc_engine **engines; - - int *charsets; - size_t n_charsets; - -#ifdef RCC_ENCA_SUPPORT - if (enca_engines) return -1; - for (i=0;rcc_default_languages[i].sn;i++); - enca_engines = (rcc_engine*)malloc(i*sizeof(rcc_engine)); - if (!enca_engines) return -1; - - err = rccEncaLibraryLoad(); - if (err) return err; - - for (i=0;rcc_default_languages[i].sn;i++) { - engines = rcc_default_languages[i].engines; - for (j=0;engines[j];j++) - if (j >= RCC_MAX_ENGINES) continue; - - charsets = enca_get_language_charsets(rcc_default_languages[i].sn, &n_charsets); - if (charsets) { - memcpy(enca_engines+i, &rcc_enca_engine, sizeof(rcc_engine)); - for (k=0;enca_engines[i].charsets[k];k++); - if (n_charsets+k>=RCC_MAX_CHARSETS) n_charsets = RCC_MAX_CHARSETS-k; - - for (l=0;l #include "internal.h" -#include "config.h" -#include "enca.h" +#include "rccconfig.h" +#include "rccenca.h" int rccInit() { diff --git a/src/lng.c b/src/lng.c index 053e7d0..a365615 100644 --- a/src/lng.c +++ b/src/lng.c @@ -2,7 +2,7 @@ #include #include "internal.h" -#include "config.h" +#include "rccconfig.h" #include "rcclocale.h" rcc_language_ptr rccGetLanguagePointer(rcc_context ctx, rcc_language_id language_id) { diff --git a/src/lngconfig.c b/src/lngconfig.c index 32f454b..b7c40c4 100644 --- a/src/lngconfig.c +++ b/src/lngconfig.c @@ -2,7 +2,7 @@ #include #include "internal.h" -#include "config.h" +#include "rccconfig.h" #include "rcclocale.h" rcc_engine_ptr rccConfigGetEnginePointer(rcc_language_config config, rcc_engine_id engine_id) { diff --git a/src/plugin.h b/src/plugin.h index c6ed7b1..1325f03 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -1,10 +1,11 @@ #ifndef _RCC_PLUGIN_H #define _RCC_PLUGIN_H -#include "enca.h" +#include "../config.h" -#ifdef RCC_ENCA_DYNAMIC + +#ifdef HAVE_DLOPEN # define RCC_PLUGINS -#endif /* RCC_ENCA_DYNAMIC */ +#endif /* HAVE_DLOPEN */ typedef void *rcc_library_handle; diff --git a/src/rccconfig.c b/src/rccconfig.c new file mode 100644 index 0000000..7caabea --- /dev/null +++ b/src/rccconfig.c @@ -0,0 +1,96 @@ +#include +#include + +#include "internal.h" +#include "rccconfig.h" + +static rcc_charset_id rcc_autoengine_russian(rcc_engine_context ctx, const char *buf, int len) { + return (rcc_charset_id)rcdGetRussianCharset(buf,len); +} + +rcc_language_alias rcc_default_aliases[] = { + { "cs_SK", "sk" }, + { "ru_UA", "uk" }, + { NULL, NULL} +}; + +const char rcc_engine_nonconfigured[] = "NonConfigured"; + +rcc_engine rcc_default_engine = { + "Off", NULL, NULL, NULL, {NULL} +}; + +rcc_engine rcc_russian_engine = { + "Russian", NULL, NULL, &rcc_autoengine_russian, {"CP1251","KOI8-R","UTF-8","IBM866", NULL} +}; + +rcc_language rcc_default_languages[] = { +{"default", "Autodetect", {"Default", NULL}, { + &rcc_default_engine, + NULL +}}, +{"off", "Dissable", {"Default", NULL}, { + &rcc_default_engine, + NULL +}}, +{"ru","Russian", {"Default","KOI8-R","CP1251","UTF-8","IBM866","MACCYRILLIC","ISO8859-5", NULL}, { + &rcc_russian_engine, + &rcc_default_engine, + NULL +}}, +{"uk","Ukrainian", {"Default","KOI8-U","CP1251","UTF-8","IBM855","MACCYRILLIC","ISO8859-5","CP1125", NULL}, { + &rcc_russian_engine, + &rcc_default_engine, + NULL +}}, +{"be","Belarussian",{"Default", "UTF-8", "CP1251", "IBM866", "ISO-8859-5", "KOI8-UNI", "maccyr" "IBM855", NULL},{ + &rcc_default_engine, + NULL +}}, +{"bg","Bulgarian",{"Default", "UTF-8", "CP1251", "ISO-8859-5", "IBM855", "maccyr", "ECMA-113", NULL},{ + &rcc_default_engine, + NULL +}}, +{"cz","Czech",{"Default", "UTF-8", "ISO-8859-2", "CP1250", "IBM852", "KEYBCS2", "macce", "KOI-8_CS_2", "CORK", NULL},{ + &rcc_default_engine, + NULL +}}, +{"es","Estonian",{"Default", "UTF-8", "ISO-8859-4", "CP1257", "IBM775", "ISO-8859-13", "macce", "baltic", NULL},{ + &rcc_default_engine, + NULL +}}, +{"hr","Croatian",{"Default", "UTF-8", "CP1250", "ISO-8859-2", "IBM852", "macce", "CORK", NULL},{ + &rcc_default_engine, + NULL +}}, +{"hu","Hungarian",{"Default", "UTF-8", "ISO-8859-2", "CP1250", "IBM852", "macce", "CORK", NULL},{ + &rcc_default_engine, + NULL +}}, +{"lt","Lithuanian",{"Default", "UTF-8", "CP1257", "ISO-8859-4", "IBM775", "ISO-8859-13", "macce", "baltic", NULL},{ + &rcc_default_engine, + NULL +}}, +{"lv","Latvian",{"Default", "UTF-8", "CP1257", "ISO-8859-4", "IBM775", "ISO-8859-13", "macce", "baltic", NULL},{ + &rcc_default_engine, + NULL +}}, +{"pl","Polish",{"Default", "UTF-8", "ISO-8859-2", "CP1250", "IBM852", "macce", "ISO-8859-13", "ISO-8859-16", "baltic", "CORK", NULL},{ + &rcc_default_engine, + NULL +}}, +{"sk","Slovak",{"Default", "UTF-8", "CP1250", "ISO-8859-2", "IBM852", "KEYBCS2", "macce", "KOI-8_CS_2", "CORK", NULL},{ + &rcc_default_engine, + NULL +}}, +{"sl","Slovenian",{"Default", "UTF-8", "ISO-8859-2", "CP1250", "IBM852", "macce", "CORK", NULL},{ + &rcc_default_engine, + NULL +}}, +{"zh","Chinese",{"Default", "UTF-8", "GB2312", "GBK", "GB18030", "BIG5", NULL},{ + &rcc_default_engine, + NULL +}}, +{NULL} +}; + diff --git a/src/rccconfig.h b/src/rccconfig.h new file mode 100644 index 0000000..ac74dbe --- /dev/null +++ b/src/rccconfig.h @@ -0,0 +1,17 @@ +#ifndef _RCC_CONFIG_H +#define _RCC_CONFIG_H +#include "librcc.h" + +#undef RCC_DEBUG +#define RCC_LOCALE_VARIABLE "LC_CTYPE" + +extern rcc_language_alias rcc_default_aliases[]; + +extern const char rcc_engine_nonconfigured[]; + +extern rcc_engine rcc_default_engine; +extern rcc_engine rcc_russian_engine; + +extern rcc_language rcc_default_languages[]; + +#endif /* _RCC_CONFIG_H */ diff --git a/src/rccenca.c b/src/rccenca.c new file mode 100644 index 0000000..d01e3d8 --- /dev/null +++ b/src/rccenca.c @@ -0,0 +1,177 @@ +#include + +#include "internal.h" +#include "plugin.h" +#include "engine.h" +#include "rccconfig.h" + +#include "rccenca.h" +#ifdef RCC_ENCA_SUPPORT +# ifdef RCC_ENCA_DYNAMIC +# include "fake_enca.h" +# else +# include +# endif /* RCC_ENCA_DYNAMIC */ +#endif /* RCC_ENCA_SUPPORT */ + +static rcc_library_handle enca_handle = NULL; +static rcc_engine *enca_engines = NULL; + +rcc_engine_internal rccEncaInitContext(rcc_engine_context ctx) { +#ifdef RCC_ENCA_SUPPORT + EncaAnalyser enca; + + if ((!ctx)||(!ctx->language)) return NULL; + + enca = enca_analyser_alloc(ctx->language->sn); + if (!enca) return NULL; + + enca_set_threshold(enca, 1); + enca_set_multibyte(enca, 1); + enca_set_ambiguity(enca, 1); + enca_set_garbage_test(enca, 0); + enca_set_filtering(enca, 0); + enca_set_significant(enca,1); + enca_set_termination_strictness(enca,0); + + return (rcc_engine_internal)enca; +#else /* RCC_ENCA_SUPPORT */ + return NULL; +#endif /* RCC_ENCA_SUPPORT */ +} + +void rccEncaFreeContext(rcc_engine_context ctx) { + rcc_engine_internal internal; +#ifdef RCC_ENCA_SUPPORT + internal = rccEngineGetInternal(ctx); + if (internal) + enca_analyser_free(internal); +#endif /* RCC_ENCA_SUPPORT */ +} + +rcc_charset_id rccEnca(rcc_engine_context ctx, char *buf, int len) { +#ifdef RCC_ENCA_SUPPORT + rcc_engine_internal internal; + const char *charset; + EncaEncoding ee; + + internal = rccEngineGetInternal(ctx); + if ((!internal)||(!buf)) return -1; + + + len = STRLEN(buf, len); + + ee = enca_analyse_const((EncaAnalyser)ctx->internal,buf,len); + if (ee.charset<0) return -1; + + charset = enca_charset_name(ee.charset, ENCA_NAME_STYLE_ICONV); + return rccGetAutoCharsetByName(ctx->ctx, charset); +#else /* RCC_ENCA_SUPPORT */ + return -1; +#endif /* RCC_ENCA_SUPPORT */ +} + +rcc_engine rcc_enca_engine = { + "Enca Library", &rccEncaInitContext, &rccEncaFreeContext, &rccEnca, {"UTF-8", NULL} +}; + + +static int rccEncaLibraryLoad() { +#ifdef RCC_ENCA_DYNAMIC + if (enca_handle) return 0; + + enca_handle = rccLibraryOpen(RCC_ENCA_LIB); + if (!enca_handle) return -1; + + enca_set_multibyte=rccLibraryFind(enca_handle,"enca_set_multibyte"); + enca_set_interpreted_surfaces=rccLibraryFind(enca_handle,"enca_set_interpreted_surfaces"); + enca_set_ambiguity=rccLibraryFind(enca_handle,"enca_set_ambiguity"); + enca_set_filtering=rccLibraryFind(enca_handle,"enca_set_filtering"); + enca_set_garbage_test=rccLibraryFind(enca_handle,"enca_set_garbage_test"); + enca_set_termination_strictness=rccLibraryFind(enca_handle,"enca_set_termination_strictness"); + enca_set_significant=rccLibraryFind(enca_handle,"enca_set_significant"); + enca_set_threshold=rccLibraryFind(enca_handle,"enca_set_threshold"); + enca_charset_name=rccLibraryFind(enca_handle,"enca_charset_name"); + enca_get_language_charsets=rccLibraryFind(enca_handle,"enca_get_language_charsets"); + enca_analyser_alloc=rccLibraryFind(enca_handle,"enca_analyser_alloc"); + enca_analyser_free=rccLibraryFind(enca_handle,"enca_analyser_free"); + enca_analyse_const=rccLibraryFind(enca_handle,"enca_analyse_const"); + + if ((!enca_set_multibyte)||(!enca_set_interpreted_surfaces)||(!enca_set_ambiguity)|| + (!enca_set_filtering)||(!enca_set_garbage_test)||(!enca_set_termination_strictness)|| + (!enca_set_significant)||(!enca_set_threshold)||(!enca_charset_name)|| + (!enca_get_language_charsets)||(!enca_analyser_alloc)||(!enca_analyser_free)|| + (!enca_analyse_const)) { + rccLibraryClose(enca_handle); + enca_handle = NULL; +# ifdef RCC_DEBUG + perror( "rccEnca. Incomplete function set in library" ); +# endif /* RCC_DEBUG */ + } + +#endif /* RCC_ENCA_DYNAMIC */ + return 0; +} + +static void rccEncaLibraryUnload() { +#ifdef RCC_ENCA_DYNAMIC + if (enca_handle) { + rccLibraryUnload(enca_handle); + enca_handle = NULL; + } +#endif /* RCC_ENCA_DYNAMIC */ +} + +int rccEncaInit() { + int err; + unsigned int i,j,k,l; + + rcc_engine **engines; + + int *charsets; + size_t n_charsets; + +#ifdef RCC_ENCA_SUPPORT + if (enca_engines) return -1; + for (i=0;rcc_default_languages[i].sn;i++); + enca_engines = (rcc_engine*)malloc(i*sizeof(rcc_engine)); + if (!enca_engines) return -1; + + err = rccEncaLibraryLoad(); + if (err) return err; + + for (i=0;rcc_default_languages[i].sn;i++) { + engines = rcc_default_languages[i].engines; + for (j=0;engines[j];j++) + if (j >= RCC_MAX_ENGINES) continue; + + charsets = enca_get_language_charsets(rcc_default_languages[i].sn, &n_charsets); + if (charsets) { + memcpy(enca_engines+i, &rcc_enca_engine, sizeof(rcc_engine)); + for (k=0;enca_engines[i].charsets[k];k++); + if (n_charsets+k>=RCC_MAX_CHARSETS) n_charsets = RCC_MAX_CHARSETS-k; + + for (l=0;l #include -#include "config.h" +#include "rccconfig.h" static int rccLocaleGetClassByName(const char *locale) { if (!strcmp(locale, "LC_CTYPE")) return LC_CTYPE; diff --git a/src/recode.c b/src/recode.c index 0f6b865..be4d98c 100644 --- a/src/recode.c +++ b/src/recode.c @@ -9,7 +9,7 @@ #include "fs.h" #include "lng.h" #include "rccstring.h" -#include "config.h" +#include "rccconfig.h" static void rccIConvCopySymbol(char **in_buf, int *in_left, char **out_buf, int *out_left) { diff --git a/src/xml.c b/src/xml.c index f5d7b5e..40bb3d4 100644 --- a/src/xml.c +++ b/src/xml.c @@ -1,10 +1,12 @@ #include #include "internal.h" +/* pass programm name */ int rccSave(rcc_context ctx) { return 0; } +/* Load and Then Save */ int rccLoad(rcc_context ctx) { return 0; } -- cgit v1.2.3