summaryrefslogtreecommitdiff
path: root/apps/plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugin.c')
-rw-r--r--apps/plugin.c60
1 files changed, 13 insertions, 47 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index 10daeaf325..194ec34484 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -50,18 +50,6 @@
50#include "widgets.h" 50#include "widgets.h"
51#endif 51#endif
52 52
53#ifdef SIMULATOR
54 #include <debug.h>
55 #ifdef WIN32
56 #include "plugin-win32.h"
57 #else
58 #include <dlfcn.h>
59 #endif
60 #define PREFIX(_x_) sim_ ## _x_
61#else
62#define PREFIX(_x_) _x_
63#endif
64
65#if MEM >= 32 53#if MEM >= 32
66#define PLUGIN_BUFFER_SIZE 0xC0000 54#define PLUGIN_BUFFER_SIZE 0xC0000
67#else 55#else
@@ -70,7 +58,9 @@
70 58
71#ifdef SIMULATOR 59#ifdef SIMULATOR
72static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE]; 60static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE];
61void *sim_plugin_load(char *plugin, int *fd);
73#else 62#else
63#define sim_plugin_close(x)
74extern unsigned char pluginbuf[]; 64extern unsigned char pluginbuf[];
75#include "bitswap.h" 65#include "bitswap.h"
76#endif 66#endif
@@ -142,16 +132,16 @@ static const struct plugin_api rockbox_api = {
142 132
143 /* file */ 133 /* file */
144 (open_func)PREFIX(open), 134 (open_func)PREFIX(open),
145 PREFIX(close), 135 close,
146 (read_func)read, 136 (read_func)read,
147 lseek, 137 lseek,
148 (creat_func)PREFIX(creat), 138 (creat_func)PREFIX(creat),
149 (write_func)write, 139 (write_func)write,
150 PREFIX(remove), 140 PREFIX(remove),
151 PREFIX(rename), 141 PREFIX(rename),
152 ftruncate, 142 PREFIX(ftruncate),
153 PREFIX(filesize), 143 PREFIX(filesize),
154 fprintf, 144 fdprintf,
155 read_line, 145 read_line,
156 settings_parseline, 146 settings_parseline,
157#ifndef SIMULATOR 147#ifndef SIMULATOR
@@ -189,6 +179,9 @@ static const struct plugin_api rockbox_api = {
189 memcpy, 179 memcpy,
190 _ctype_, 180 _ctype_,
191 atoi, 181 atoi,
182 strchr,
183 strcat,
184 memcmp,
192 185
193 /* sound */ 186 /* sound */
194 mpeg_sound_set, 187 mpeg_sound_set,
@@ -201,7 +194,7 @@ static const struct plugin_api rockbox_api = {
201#endif 194#endif
202 195
203 /* playback control */ 196 /* playback control */
204 mpeg_play, 197 PREFIX(mpeg_play),
205 mpeg_stop, 198 mpeg_stop,
206 mpeg_pause, 199 mpeg_pause,
207 mpeg_resume, 200 mpeg_resume,
@@ -264,10 +257,6 @@ static const struct plugin_api rockbox_api = {
264 257
265 /* new stuff at the end, sort into place next time 258 /* new stuff at the end, sort into place next time
266 the API gets incompatible */ 259 the API gets incompatible */
267
268 strchr,
269 strcat,
270 memcmp
271}; 260};
272 261
273int plugin_load(const char* plugin, void* parameter) 262int plugin_load(const char* plugin, void* parameter)
@@ -275,12 +264,8 @@ int plugin_load(const char* plugin, void* parameter)
275 enum plugin_status (*plugin_start)(struct plugin_api* api, void* param); 264 enum plugin_status (*plugin_start)(struct plugin_api* api, void* param);
276 int rc; 265 int rc;
277 char buf[64]; 266 char buf[64];
278#ifdef SIMULATOR
279 void* pd;
280 char path[256];
281#else
282 int fd; 267 int fd;
283#endif 268
284#ifdef HAVE_LCD_BITMAP 269#ifdef HAVE_LCD_BITMAP
285 int xm,ym; 270 int xm,ym;
286#endif 271#endif
@@ -301,26 +286,9 @@ int plugin_load(const char* plugin, void* parameter)
301 lcd_clear_display(); 286 lcd_clear_display();
302#endif 287#endif
303#ifdef SIMULATOR 288#ifdef SIMULATOR
304 snprintf(path, sizeof path, "archos%s", plugin); 289 plugin_start = sim_plugin_load(plugin, &fd);
305 290 if(!plugin_start)
306 pd = dlopen(path, RTLD_NOW);
307 if (!pd) {
308 snprintf(buf, sizeof buf, str(LANG_PLUGIN_CANT_OPEN), plugin);
309 splash(HZ*2, true, buf);
310 DEBUGF("dlopen(%s): %s\n",path,dlerror());
311 dlclose(pd);
312 return -1; 291 return -1;
313 }
314
315 plugin_start = dlsym(pd, "plugin_start");
316 if (!plugin_start) {
317 plugin_start = dlsym(pd, "_plugin_start");
318 if (!plugin_start) {
319 splash(HZ*2, true, "Can't find entry point");
320 dlclose(pd);
321 return -1;
322 }
323 }
324#else 292#else
325 fd = open(plugin, O_RDONLY); 293 fd = open(plugin, O_RDONLY);
326 if (fd < 0) { 294 if (fd < 0) {
@@ -379,9 +347,7 @@ int plugin_load(const char* plugin, void* parameter)
379 break; 347 break;
380 } 348 }
381 349
382#ifdef SIMULATOR 350 sim_plugin_close(fd);
383 dlclose(pd);
384#endif
385 351
386#ifdef HAVE_LCD_BITMAP 352#ifdef HAVE_LCD_BITMAP
387 /* restore margins */ 353 /* restore margins */