summaryrefslogtreecommitdiffstats
path: root/src/engine.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-08 14:45:55 +0000
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-08 14:45:55 +0000
commitfdfe5b42f687fbf3d4537541cc1b0bd9b8c2c090 (patch)
tree81d199b6fbbb11d3f310668e5bdabf9129e5f41f /src/engine.c
parent232dbc756390d30a86ae6de0cc84600eddb1c0b2 (diff)
downloadlibrcc-fdfe5b42f687fbf3d4537541cc1b0bd9b8c2c090.tar.gz
librcc-fdfe5b42f687fbf3d4537541cc1b0bd9b8c2c090.tar.bz2
librcc-fdfe5b42f687fbf3d4537541cc1b0bd9b8c2c090.tar.xz
librcc-fdfe5b42f687fbf3d4537541cc1b0bd9b8c2c090.zip
08.07.2005
Diffstat (limited to 'src/engine.c')
-rw-r--r--src/engine.c93
1 files changed, 90 insertions, 3 deletions
diff --git a/src/engine.c b/src/engine.c
index 5f7a3ff..5bb8b7a 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -2,8 +2,95 @@
#include <string.h>
#include "internal.h"
+#include "plugin.h"
+#include "rccconfig.h"
-int rccEngineInit(rcc_engine_context engine_ctx, rcc_context ctx) {
+#include "engine.h"
+
+#ifdef RCC_RCD_SUPPORT
+# ifdef RCC_RCD_DYNAMIC
+# include "fake_rcd.h"
+# else
+# include <librcd.h>
+# endif /* RCC_RCD_DYNAMIC */
+#endif /* RCC_RCD_SUPPORT */
+
+static rcc_library_handle rcd_handle = NULL;
+
+rcc_charset_id rccAutoengineRussian(rcc_engine_context ctx, const char *buf, int len) {
+#ifdef RCC_RCD_SUPPORT
+ rcc_charset_id id;
+# ifdef RCC_RCD_DYNAMIC
+ if (!rcdGetRussianCharset) return (rcc_charset_id)-1;
+# endif /* RCC_RCD_DYNAMIC */
+ return (rcc_charset_id)rcdGetRussianCharset(buf,len);
+#else /* RCC_RCD_SUPPORT */
+ return (rcc_charset_id)-1;
+#endif /* RCC_RCD_SUPPORT */
+}
+
+
+static int rccRCDLibraryLoad() {
+#ifdef RCC_RCD_DYNAMIC
+ if (rcd_handle) return 0;
+
+ rcd_handle = rccLibraryOpen(RCC_RCD_LIB);
+ if (!rcd_handle) return -1;
+
+ rcdGetRussianCharset = rccLibraryFind(rcd_handle,"rcdGetRussianCharset");
+ if (!rcdGetRussianCharset) {
+ rccLibraryClose(rcd_handle);
+ rcd_handle = NULL;
+# ifdef RCC_DEBUG
+ perror( "rccRCD. Incomplete function set in library" );
+# endif /* RCC_DEBUG */
+ return -1;
+ }
+#endif /* RCC_RCD_DYNAMIC */
+
+ return 0;
+}
+
+static void rccRCDLibraryUnload() {
+#ifdef RCC_RCD_DYNAMIC
+ if (rcd_handle) {
+ rccLibraryClose(rcd_handle);
+ rcd_handle = NULL;
+ }
+#endif /* RCC_RCD_DYNAMIC */
+}
+
+int rccEngineInit() {
+#ifdef RCC_RCD_DYNAMIC
+ int err;
+ unsigned int i,j,flag;
+ rcc_engine **engines;
+ int *charsets;
+
+ err = rccRCDLibraryLoad();
+ if (err) {
+ for (i=0;rcc_default_languages[i].sn;i++) {
+ engines = rcc_default_languages[i].engines;
+ for (flag=0,j=0;engines[j];j++) {
+ if (flag) engines[j-1] = engines[j];
+ else if (engines[j] == &rcc_russian_engine) flag=1;
+ }
+ if (flag) engines[j-1] = NULL;
+ }
+ }
+#endif /* RCC_RCD_DYNAMIC */
+
+ return rccEncaInit();
+}
+
+void rccEngineFree() {
+ rccEncaFree();
+#ifdef RCC_RCD_DYNAMIC
+ rccRCDLibraryUnload();
+#endif /* RCC_RCD_DYNAMIC */
+}
+
+int rccEngineInitContext(rcc_engine_context engine_ctx, rcc_context ctx) {
if ((!ctx)||(!engine_ctx)) return -1;
engine_ctx->ctx = ctx;
@@ -12,7 +99,7 @@ int rccEngineInit(rcc_engine_context engine_ctx, rcc_context ctx) {
return 0;
}
-void rccEngineFree(rcc_engine_context engine_ctx) {
+void rccEngineFreeContext(rcc_engine_context engine_ctx) {
if (!engine_ctx) return;
if (engine_ctx->free_func) {
@@ -31,7 +118,7 @@ int rccEngineConfigure(rcc_engine_context ctx) {
if ((!ctx)||(!ctx->ctx)) return -1;
- rccEngineFree(ctx);
+ rccEngineFreeContext(ctx);
language_id = rccGetCurrentLanguage(ctx->ctx);
if (language_id == (rcc_language_id)-1) return -1;