summaryrefslogtreecommitdiff
path: root/apps/open_plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/open_plugin.c')
-rw-r--r--apps/open_plugin.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/apps/open_plugin.c b/apps/open_plugin.c
index 67b6f6d318..45dd7cdd2c 100644
--- a/apps/open_plugin.c
+++ b/apps/open_plugin.c
@@ -28,7 +28,7 @@
28#include "lang.h" 28#include "lang.h"
29 29
30/* Define LOGF_ENABLE to enable logf output in this file */ 30/* Define LOGF_ENABLE to enable logf output in this file */
31//#define LOGF_ENABLE 31/*#define LOGF_ENABLE*/
32#include "logf.h" 32#include "logf.h"
33 33
34#define ROCK_EXT "rock" 34#define ROCK_EXT "rock"
@@ -60,8 +60,12 @@ static inline void op_clear_entry(struct open_plugin_entry_t *entry)
60 60
61static int op_entry_checksum(struct open_plugin_entry_t *entry) 61static int op_entry_checksum(struct open_plugin_entry_t *entry)
62{ 62{
63 if (entry == NULL || entry->checksum != open_plugin_csum) 63 if (entry == NULL || entry->checksum != open_plugin_csum +
64 (entry->lang_id <= OPEN_PLUGIN_LANG_INVALID ? 0 : LANG_LAST_INDEX_IN_ARRAY))
65 {
66 logf("OP entry bad checksum");
64 return 0; 67 return 0;
68 }
65 return 1; 69 return 1;
66} 70}
67 71
@@ -81,6 +85,14 @@ static int op_find_entry(int fd, struct open_plugin_entry_t *entry,
81 if (entry->lang_id == lang_id || entry->hash == hash || 85 if (entry->lang_id == lang_id || entry->hash == hash ||
82 (lang_id == OPEN_PLUGIN_LANG_IGNOREALL))/* return first entry found */ 86 (lang_id == OPEN_PLUGIN_LANG_IGNOREALL))/* return first entry found */
83 { 87 {
88#if (CONFIG_STORAGE & STORAGE_ATA)
89 /* may have invalid entries but we append the file so continue looking*/
90 if (op_entry_checksum(entry) <= 0)
91 {
92 ret = OPEN_PLUGIN_INVALID_ENTRY;
93 continue;
94 }
95#endif
84 ret = record; 96 ret = record;
85 /* NULL terminate fields NOTE -- all are actually +1 larger */ 97 /* NULL terminate fields NOTE -- all are actually +1 larger */
86 entry->name[OPEN_PLUGIN_NAMESZ] = '\0'; 98 entry->name[OPEN_PLUGIN_NAMESZ] = '\0';
@@ -98,7 +110,12 @@ static int op_find_entry(int fd, struct open_plugin_entry_t *entry,
98 } 110 }
99 111
100 /* sanity check */ 112 /* sanity check */
101 if (ret > OPEN_PLUGIN_NOT_FOUND && op_entry_checksum(entry) <= 0) 113#if (CONFIG_STORAGE & STORAGE_ATA)
114 if (ret == OPEN_PLUGIN_INVALID_ENTRY ||
115#else
116 if(
117#endif
118 (ret > OPEN_PLUGIN_NOT_FOUND && op_entry_checksum(entry) <= 0))
102 { 119 {
103 splash(HZ * 2, "OpenPlugin Invalid entry"); 120 splash(HZ * 2, "OpenPlugin Invalid entry");
104 ret = OPEN_PLUGIN_NOT_FOUND; 121 ret = OPEN_PLUGIN_NOT_FOUND;
@@ -144,7 +161,7 @@ static int op_update_dat(struct open_plugin_entry_t *entry, bool clear)
144 hash_langid_csum[2] == open_plugin_csum) 161 hash_langid_csum[2] == open_plugin_csum)
145 { 162 {
146 logf("OP update *Entry Exists* hash: %x langid: %d", 163 logf("OP update *Entry Exists* hash: %x langid: %d",
147 hash_langid_csum[0], (int32_t)hash_langid[1]); 164 hash_langid_csum[0], (int32_t)hash_langid_csum[1]);
148 lseek(fd, 0-hlc_sz, SEEK_CUR);/* back to the start of record */ 165 lseek(fd, 0-hlc_sz, SEEK_CUR);/* back to the start of record */
149 break; 166 break;
150 } 167 }
@@ -261,7 +278,8 @@ uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *p
261 { 278 {
262 open_plugin_entry.hash = hash; 279 open_plugin_entry.hash = hash;
263 open_plugin_entry.lang_id = lang_id; 280 open_plugin_entry.lang_id = lang_id;
264 open_plugin_entry.checksum = open_plugin_csum; 281 open_plugin_entry.checksum = open_plugin_csum +
282 (lang_id <= OPEN_PLUGIN_LANG_INVALID ? 0 : LANG_LAST_INDEX_IN_ARRAY);
265 /* name */ 283 /* name */
266 if (path_basename(plugin, (const char **)&pos) == 0) 284 if (path_basename(plugin, (const char **)&pos) == 0)
267 pos = "\0"; 285 pos = "\0";
@@ -337,7 +355,7 @@ int open_plugin_get_entry(const char *key, struct open_plugin_entry_t *entry)
337 opret = op_get_entry(hash, lang_id, entry, OPEN_PLUGIN_DAT); 355 opret = op_get_entry(hash, lang_id, entry, OPEN_PLUGIN_DAT);
338 logf("OP entry hash: %x lang id: %d ret: %d key: %s", hash, lang_id, opret, skey); 356 logf("OP entry hash: %x lang id: %d ret: %d key: %s", hash, lang_id, opret, skey);
339 357
340 if (opret == OPEN_PLUGIN_NOT_FOUND && lang_id > OPEN_PLUGIN_LANG_INVALID) 358 if (opret == OPEN_PLUGIN_NOT_FOUND && lang_id > OPEN_PLUGIN_LANG_INVALID)
341 { /* try rb defaults */ 359 { /* try rb defaults */
342 opret = op_get_entry(hash, lang_id, entry, OPEN_RBPLUGIN_DAT); 360 opret = op_get_entry(hash, lang_id, entry, OPEN_RBPLUGIN_DAT);
343 logf("OP rb_entry hash: %x lang id: %d ret: %d key: %s", hash, lang_id, opret, skey); 361 logf("OP rb_entry hash: %x lang id: %d ret: %d key: %s", hash, lang_id, opret, skey);
@@ -364,6 +382,8 @@ int open_plugin_run(const char *key)
364 382
365 if (param[0] == '\0') 383 if (param[0] == '\0')
366 param = NULL; 384 param = NULL;
385 if (path[0] == '\0' && key)
386 path = P2STR((unsigned char *)key);
367 387
368 ret = plugin_load(path, param); 388 ret = plugin_load(path, param);
369 389