summaryrefslogtreecommitdiff
path: root/amiga
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2011-10-29 13:32:53 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2011-10-29 13:32:53 +0000
commit4a0de7cd5cea9cf209aefb37d8c3b8b3499ee517 (patch)
tree731963e3d2e8c54d1a4f00a8cbb7ff1bdbbf60eb /amiga
parent4e6828e7e16b91308b0969ec0729f2b9cca3c450 (diff)
downloadnetsurf-4a0de7cd5cea9cf209aefb37d8c3b8b3499ee517.tar.gz
netsurf-4a0de7cd5cea9cf209aefb37d8c3b8b3499ee517.tar.bz2
Allow usage of a resource.map file to map resource: requests to other files.
svn path=/trunk/netsurf/; revision=13096
Diffstat (limited to 'amiga')
-rwxr-xr-xamiga/gui.c103
-rw-r--r--amiga/resources/Themes/AISS/Resource.map2
2 files changed, 74 insertions, 31 deletions
diff --git a/amiga/gui.c b/amiga/gui.c
index 0f4733fb9..ee0af84a6 100755
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -209,6 +209,71 @@ STRPTR ami_locale_langs(void)
return acceptlangs;
}
+bool ami_gui_locate_resource_map(char **remapped, const char *path, const char *file)
+{
+ BPTR fh = 0;
+ char mapfile[1024];
+ char buffer[1024];
+ char *realfname;
+ bool found = false;
+
+ strcpy(mapfile, path);
+ path_add_part(mapfile, 1024, "Resource.map");
+
+ if(fh = FOpen(mapfile, MODE_OLDFILE, 0))
+ {
+ while(FGets(fh, buffer, 1024) != 0)
+ {
+ if((buffer[0] == '#') ||
+ (buffer[0] == '\n') ||
+ (buffer[0] == '\0')) continue;
+
+ if(realfname = strchr(buffer, ':'))
+ {
+ if(strncmp(buffer, file, (realfname - buffer)) == 0)
+ {
+ if(realfname[strlen(realfname)-1] == '\n')
+ realfname[strlen(realfname)-1] = '\0';
+ *remapped = strdup(realfname + 1);
+ found = true;
+ break;
+ }
+ }
+ }
+ FClose(fh);
+ }
+
+ if(found == false) *remapped = strdup(file);
+ LOG(("Remapped %s to %s in path %s", file, *remapped, path));
+
+ return found;
+}
+
+bool ami_gui_check_resource(char *fullpath, const char *file)
+{
+ bool free_rmap = false;
+ bool found = false;
+ char *remapped;
+ BPTR lock = 0;
+
+ if(free_rmap = ami_gui_locate_resource_map(&remapped, fullpath, file))
+ path_add_part(fullpath, 1024, remapped);
+ else
+ path_add_part(fullpath, 1024, file);
+
+ if(lock = Lock(fullpath, ACCESS_READ))
+ {
+ UnLock(lock);
+ found = true;
+ }
+
+ if(free_rmap) free(remapped);
+
+ LOG(("Checking for %s : result %ld", fullpath, found));
+
+ return found;
+}
+
bool ami_locate_resource(char *fullpath, const char *file)
{
struct Locale *locale;
@@ -222,13 +287,8 @@ bool ami_locate_resource(char *fullpath, const char *file)
if(option_theme)
{
strcpy(fullpath, option_theme);
- path_add_part(fullpath, 1024, file);
-
- if(lock = Lock(fullpath, ACCESS_READ))
- {
- UnLock(lock);
- return true;
- }
+ found = ami_gui_check_resource(fullpath, file);
+ if(found) return true;
}
/* If not found, start on the user's preferred languages */
@@ -244,23 +304,18 @@ bool ami_locate_resource(char *fullpath, const char *file)
for(i=0;i<10;i++)
{
strcpy(fullpath,"PROGDIR:Resources/");
+
if(locale->loc_PrefLanguages[i])
{
strcat(fullpath,messages_get(locale->loc_PrefLanguages[i]));
+ found = ami_gui_check_resource(fullpath, file);
}
else
{
continue;
}
- strcat(fullpath, "/");
- strcat(fullpath, file);
- if(lock=Lock(fullpath,ACCESS_READ))
- {
- UnLock(lock);
- found = true;
- break;
- }
+ if(found) break;
}
if(!found)
@@ -269,14 +324,7 @@ bool ami_locate_resource(char *fullpath, const char *file)
* might not be in user's preferred languages */
strcpy(fullpath, "PROGDIR:Resources/en/");
- strcat(fullpath, file);
-
- if(lock=Lock(fullpath, ACCESS_READ))
- {
- UnLock(lock);
- found = true;
- }
- else found = false;
+ found = ami_gui_check_resource(fullpath, file);
}
CloseLocale(locale);
@@ -286,14 +334,7 @@ bool ami_locate_resource(char *fullpath, const char *file)
/* Lastly check directly in PROGDIR:Resources */
strcpy(fullpath, "PROGDIR:Resources/");
- strcat(fullpath, file);
-
- if(lock=Lock(fullpath, ACCESS_READ))
- {
- UnLock(lock);
- found = true;
- }
- else found = false;
+ found = ami_gui_check_resource(fullpath, file);
}
return found;
diff --git a/amiga/resources/Themes/AISS/Resource.map b/amiga/resources/Themes/AISS/Resource.map
new file mode 100644
index 000000000..4862cf969
--- /dev/null
+++ b/amiga/resources/Themes/AISS/Resource.map
@@ -0,0 +1,2 @@
+# Resource.map
+favicon.ico:TBimages:list_file