summaryrefslogtreecommitdiffstats
path: root/src/fs.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2005-08-03 18:24:08 +0000
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2005-08-03 18:24:08 +0000
commit50aa5cd62ef4a66da41d68f4a50ddfca97863c38 (patch)
tree43f1bf415e56ace9eb3e19731d3eaffe064c8d68 /src/fs.c
parentdcd966ba50fa18853c5ae06125a5b08b0ee6b10d (diff)
downloadlibrcc-50aa5cd62ef4a66da41d68f4a50ddfca97863c38.tar.gz
librcc-50aa5cd62ef4a66da41d68f4a50ddfca97863c38.tar.bz2
librcc-50aa5cd62ef4a66da41d68f4a50ddfca97863c38.tar.xz
librcc-50aa5cd62ef4a66da41d68f4a50ddfca97863c38.zip
Multithreading
- Multithreaded access to recoding functions using same context - Engine plugin to select between UTF-8 and ISO8859-1 for Western European Languages - Fix: 'rccTo' converting FS classes - FS class support in 'rccConfigSizedToCharset'
Diffstat (limited to 'src/fs.c')
-rw-r--r--src/fs.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/fs.c b/src/fs.c
index fb0a2bc..f8f6094 100644
--- a/src/fs.c
+++ b/src/fs.c
@@ -190,7 +190,7 @@ int rccFS1(rcc_language_config config, const char *fspath, char **prefix, char *
/* Checks if 'prefix/name' is accessible using 'icnv' recoding. In case of
sucess returns pointer on statically allocated memory, and NULL overwise */
-const char *rccFS2(rcc_language_config config, iconv_t icnv, const char *prefix, const char *name) {
+char *rccFS2(rcc_language_config config, iconv_t icnv, const char *prefix, const char *name) {
size_t size;
char *tmpbuffer = config->ctx->tmpbuffer;
@@ -207,9 +207,9 @@ const char *rccFS2(rcc_language_config config, iconv_t icnv, const char *prefix,
/* Tries to find 'name' encoding in 'prefix/name' file. Returns pointer on
statically allocated string with correct filename or NULL. */
-const char *rccFS3(rcc_language_config config, rcc_class_id class_id, const char *prefix, const char *name) {
+char *rccFS3(rcc_language_config config, rcc_class_id class_id, const char *prefix, const char *name) {
unsigned int i;
- const char *result;
+ char *result;
rcc_charset charset;
rcc_language *language;
iconv_t icnv = config->fsiconv;
@@ -251,3 +251,32 @@ const char *rccFS3(rcc_language_config config, rcc_class_id class_id, const char
return result;
}
+
+char *rccFS5(rcc_context ctx, rcc_language_config config, rcc_class_id class_id, const char *utfstring) {
+ int err;
+ char *prefix, *name;
+ char *result;
+
+ if (rccIsASCII(utfstring)) return strdup(utfstring);
+
+ name = NULL;
+ prefix = NULL;
+
+ rccMutexLock(ctx->mutex);
+ rccMutexLock(config->mutex);
+ err = rccFS0(config, NULL, utfstring, &prefix, &name);
+ if (err>=0) {
+ result = rccFS3(config, class_id, prefix, name);
+ rccMutexUnLock(config->mutex);
+ rccMutexUnLock(ctx->mutex);
+ if (!err) {
+ if (prefix) free(prefix);
+ free(name);
+ }
+ return result;
+ }
+ rccMutexUnLock(config->mutex);
+ rccMutexUnLock(ctx->mutex);
+
+ return NULL;
+}