summaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-11-11 05:44:06 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-11-11 05:44:06 +0000
commit3c9be46f96e2ce6bdca9d268f7d477704259fe95 (patch)
tree0065ec92556a1fa460d4a466a5cd0e0b43d0fa88 /module
parent42de9db2762a63f69321fc4e89ea81e16a5a206a (diff)
downloadiconv-3c9be46f96e2ce6bdca9d268f7d477704259fe95.tar.gz
iconv-3c9be46f96e2ce6bdca9d268f7d477704259fe95.tar.bz2
Make module initialisation work sensibly on all platforms.
Use UNICODE_DIR on non-RO as the path to the Unicode resource. Fix a bunch of logging statements that didn't use %zd for size_t. svn path=/trunk/iconv/; revision=5681
Diffstat (limited to 'module')
-rw-r--r--module/module.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/module/module.c b/module/module.c
index c58c6f7..8b7bf8d 100644
--- a/module/module.c
+++ b/module/module.c
@@ -14,9 +14,9 @@
#include "module.h"
#ifdef __riscos__
-#define ALIASES_FILE "Unicode:Files.Aliases"
+#define ALIASES_FILE "Files.Aliases"
#else
-#define ALIASES_FILE "Aliases"
+#define ALIASES_FILE "Files/Aliases"
#endif
static _kernel_oserror ErrorGeneric = { 0x0, "" };
@@ -27,18 +27,39 @@ static int errno_to_iconv_error(int num);
/* Module initialisation */
_kernel_oserror *mod_init(const char *tail, int podule_base, void *pw)
{
+ char *ucpath;
+ int alen;
+ char aliases[4096];
+
UNUSED(tail);
UNUSED(podule_base);
UNUSED(pw);
/* ensure the !Unicode resource exists */
- if (!getenv("Unicode$Path")) {
+#ifdef __riscos__
+ ucpath = getenv("Unicode$Path");
+#else
+ ucpath = getenv("UNICODE_DIR");
+#endif
+
+ if (ucpath == NULL) {
strncpy(ErrorGeneric.errmess, "!Unicode resource not found.",
252);
return &ErrorGeneric;
}
- if (iconv_initialise(ALIASES_FILE) == false) {
+ strncpy(aliases, ucpath, sizeof(aliases));
+ alen = strlen(ucpath);
+#ifndef __riscos__
+ if (aliases[alen - 1] != '/') {
+ strncat(aliases, "/", sizeof(aliases) - alen - 1);
+ alen += 1;
+ }
+#endif
+ strncat(aliases, ALIASES_FILE, sizeof(aliases) - alen - 1);
+ aliases[sizeof(aliases) - 1] = '\0';
+
+ if (iconv_initialise(aliases) == false) {
strncpy(ErrorGeneric.errmess, "Unicode:Files.Aliases not "
"found. Please read the Iconv installation "
"instructions.", 252);