summaryrefslogtreecommitdiff
path: root/apps/open_plugin.h
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-10-18 01:23:07 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2021-10-18 23:30:27 -0400
commite1553d860dc42a819fe71913d5a68a77fbf64a6e (patch)
treec29ceec89472e2c249ae3e04ba837de573b6559d /apps/open_plugin.h
parent0f68866ae5b02e3e154f31b6da12b090380db4b0 (diff)
downloadrockbox-e1553d860dc42a819fe71913d5a68a77fbf64a6e.tar.gz
rockbox-e1553d860dc42a819fe71913d5a68a77fbf64a6e.zip
Open_Plugin add checksum on struct offsets
Adding a checksum over the struct offset will allow checking for compatibility across machines rather than using packed structs to ensure compability For any file created by the user from the device this isn't really a concern But for files between machines, across installs (sim v device), possibly even across compilers this at least will alert the user rather than returning junk data Change-Id: Id0531bbaa7013dce24dece270849f0a10ac99c20
Diffstat (limited to 'apps/open_plugin.h')
-rw-r--r--apps/open_plugin.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/apps/open_plugin.h b/apps/open_plugin.h
index e1d49bf329..adfb9a75bc 100644
--- a/apps/open_plugin.h
+++ b/apps/open_plugin.h
@@ -41,19 +41,31 @@ enum {
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_NOT_FOUND = (-1),
44 OPEN_PLUGIN_NEEDS_FLUSHED = (-2) 44 OPEN_PLUGIN_NEEDS_FLUSHED = (-2),
45}; 45};
46 46
47struct open_plugin_entry_t 47struct open_plugin_entry_t
48{ 48{
49/* hash and lang_id need to be the first items */ 49/* hash lang_id checksum need to be the first items */
50 uint32_t hash; 50 uint32_t hash;
51 int32_t lang_id; 51 int32_t lang_id;
52 uint32_t checksum;
52 char name[OPEN_PLUGIN_NAMESZ+1]; 53 char name[OPEN_PLUGIN_NAMESZ+1];
53 /*char key[OPEN_PLUGIN_BUFSZ+1];*/ 54 /*char key[OPEN_PLUGIN_BUFSZ+1];*/
54 char path[OPEN_PLUGIN_BUFSZ+1]; 55 char path[OPEN_PLUGIN_BUFSZ+1];
55 char param[OPEN_PLUGIN_BUFSZ+1]; 56 char param[OPEN_PLUGIN_BUFSZ+1];
56}__attribute__((packed)); 57};
58
59#define OPEN_PLUGIN_CHECKSUM (uint32_t) \
60( \
61 (sizeof(struct open_plugin_entry_t) << 16) + \
62 offsetof(struct open_plugin_entry_t, hash) + \
63 offsetof(struct open_plugin_entry_t, lang_id) + \
64 offsetof(struct open_plugin_entry_t, checksum) + \
65 offsetof(struct open_plugin_entry_t, name) + \
66 /*offsetof(struct open_plugin_entry_t, key)+*/ \
67 offsetof(struct open_plugin_entry_t, path) + \
68 offsetof(struct open_plugin_entry_t, param))
57 69
58inline static void open_plugin_get_hash(const char *key, uint32_t *hash) 70inline static void open_plugin_get_hash(const char *key, uint32_t *hash)
59{ 71{