diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/open_plugin.c | 32 | ||||
-rw-r--r-- | apps/open_plugin.h | 5 | ||||
-rw-r--r-- | apps/plugins/open_plugins.c | 31 | ||||
-rw-r--r-- | apps/root_menu.c | 2 |
4 files changed, 50 insertions, 20 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 | ||
61 | static int op_entry_checksum(struct open_plugin_entry_t *entry) | 61 | static 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 | ||
diff --git a/apps/open_plugin.h b/apps/open_plugin.h index d16be2052c..62e3662849 100644 --- a/apps/open_plugin.h +++ b/apps/open_plugin.h | |||
@@ -40,8 +40,9 @@ enum { | |||
40 | OPEN_PLUGIN_LANG_INVALID = (-1), | 40 | OPEN_PLUGIN_LANG_INVALID = (-1), |
41 | OPEN_PLUGIN_LANG_IGNORE = (-2), | 41 | OPEN_PLUGIN_LANG_IGNORE = (-2), |
42 | OPEN_PLUGIN_LANG_IGNOREALL = (-3), | 42 | OPEN_PLUGIN_LANG_IGNOREALL = (-3), |
43 | OPEN_PLUGIN_NOT_FOUND = (-1), | 43 | OPEN_PLUGIN_INVALID_ENTRY = (-1), |
44 | OPEN_PLUGIN_NEEDS_FLUSHED = (-2), | 44 | OPEN_PLUGIN_NOT_FOUND = (-2), |
45 | OPEN_PLUGIN_NEEDS_FLUSHED = (-3), | ||
45 | }; | 46 | }; |
46 | 47 | ||
47 | struct open_plugin_entry_t | 48 | struct open_plugin_entry_t |
diff --git a/apps/plugins/open_plugins.c b/apps/plugins/open_plugins.c index 7230387efb..6deaf80f7d 100644 --- a/apps/plugins/open_plugins.c +++ b/apps/plugins/open_plugins.c | |||
@@ -87,6 +87,15 @@ static size_t pathbasename(const char *name, const char **nameptr) | |||
87 | *nameptr = q; | 87 | *nameptr = q; |
88 | return r - q; | 88 | return r - q; |
89 | } | 89 | } |
90 | static int op_entry_checksum(void) | ||
91 | { | ||
92 | if (op_entry.checksum != open_plugin_csum + | ||
93 | (op_entry.lang_id <= OPEN_PLUGIN_LANG_INVALID ? 0 : LANG_LAST_INDEX_IN_ARRAY)) | ||
94 | { | ||
95 | return 0; | ||
96 | } | ||
97 | return 1; | ||
98 | } | ||
90 | 99 | ||
91 | static bool op_entry_read(int fd, int selected_item, off_t data_sz) | 100 | static bool op_entry_read(int fd, int selected_item, off_t data_sz) |
92 | { | 101 | { |
@@ -94,7 +103,7 @@ static bool op_entry_read(int fd, int selected_item, off_t data_sz) | |||
94 | op_entry.lang_id = -1; | 103 | op_entry.lang_id = -1; |
95 | return ((selected_item >= 0) && | 104 | return ((selected_item >= 0) && |
96 | (rb->lseek(fd, selected_item * op_entry_sz, SEEK_SET) >= 0) && | 105 | (rb->lseek(fd, selected_item * op_entry_sz, SEEK_SET) >= 0) && |
97 | (rb->read(fd, &op_entry, data_sz) == data_sz)); | 106 | (rb->read(fd, &op_entry, data_sz) == data_sz) && op_entry_checksum() > 0); |
98 | } | 107 | } |
99 | 108 | ||
100 | static bool op_entry_read_name(int fd, int selected_item) | 109 | static bool op_entry_read_name(int fd, int selected_item) |
@@ -102,15 +111,6 @@ static bool op_entry_read_name(int fd, int selected_item) | |||
102 | return op_entry_read(fd, selected_item, op_name_sz); | 111 | return op_entry_read(fd, selected_item, op_name_sz); |
103 | } | 112 | } |
104 | 113 | ||
105 | static int op_entry_checksum(void) | ||
106 | { | ||
107 | if (op_entry.checksum != open_plugin_csum) | ||
108 | { | ||
109 | return 0; | ||
110 | } | ||
111 | return 1; | ||
112 | } | ||
113 | |||
114 | static int op_entry_read_opx(const char *path) | 114 | static int op_entry_read_opx(const char *path) |
115 | { | 115 | { |
116 | int ret = -1; | 116 | int ret = -1; |
@@ -174,7 +174,8 @@ failure: | |||
174 | 174 | ||
175 | static void op_entry_set_checksum(void) | 175 | static void op_entry_set_checksum(void) |
176 | { | 176 | { |
177 | op_entry.checksum = open_plugin_csum; | 177 | op_entry.checksum = open_plugin_csum + |
178 | (op_entry.lang_id <= OPEN_PLUGIN_LANG_INVALID ? 0 : LANG_LAST_INDEX_IN_ARRAY); | ||
178 | } | 179 | } |
179 | 180 | ||
180 | static void op_entry_set_name(void) | 181 | static void op_entry_set_name(void) |
@@ -466,7 +467,7 @@ static void op_entry_remove_empty(void) | |||
466 | while (resave == false && | 467 | while (resave == false && |
467 | rb->read(fd_dat, &op_entry, op_entry_sz) == op_entry_sz) | 468 | rb->read(fd_dat, &op_entry, op_entry_sz) == op_entry_sz) |
468 | { | 469 | { |
469 | if (op_entry.hash == 0) | 470 | if (op_entry.hash == 0 || !op_entry_checksum()) |
470 | resave = true; | 471 | resave = true; |
471 | } | 472 | } |
472 | } | 473 | } |
@@ -839,6 +840,12 @@ reopen_datfile: | |||
839 | }/* OP_EXT */ | 840 | }/* OP_EXT */ |
840 | } | 841 | } |
841 | 842 | ||
843 | for (int i = items - 1; i > 0 && !exit; i--) | ||
844 | { | ||
845 | if (!op_entry_read(fd_dat, i, op_entry_sz)) | ||
846 | items--; | ||
847 | } | ||
848 | |||
842 | if (items < 1 && !exit) | 849 | if (items < 1 && !exit) |
843 | { | 850 | { |
844 | char* cur_filename = rb->plugin_get_current_filename(); | 851 | char* cur_filename = rb->plugin_get_current_filename(); |
diff --git a/apps/root_menu.c b/apps/root_menu.c index ae3d1b39b0..c70237fdf7 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c | |||
@@ -730,6 +730,8 @@ static int load_plugin_screen(char *key) | |||
730 | char *param = open_plugin_entry.param; | 730 | char *param = open_plugin_entry.param; |
731 | if (param[0] == '\0') | 731 | if (param[0] == '\0') |
732 | param = NULL; | 732 | param = NULL; |
733 | if (path[0] == '\0' && key) | ||
734 | path = P2STR((unsigned char *)key); | ||
733 | 735 | ||
734 | int ret = plugin_load(path, param); | 736 | int ret = plugin_load(path, param); |
735 | 737 | ||