diff options
-rw-r--r-- | apps/codecs.c | 8 | ||||
-rw-r--r-- | apps/plugin.c | 21 | ||||
-rw-r--r-- | uisimulator/common/io.c | 42 |
3 files changed, 36 insertions, 35 deletions
diff --git a/apps/codecs.c b/apps/codecs.c index 0301a490d8..804dd2e4e5 100644 --- a/apps/codecs.c +++ b/apps/codecs.c | |||
@@ -55,8 +55,8 @@ | |||
55 | unsigned char codecbuf[CODEC_SIZE]; | 55 | unsigned char codecbuf[CODEC_SIZE]; |
56 | #endif | 56 | #endif |
57 | void *sim_codec_load_ram(char* codecptr, int size, | 57 | void *sim_codec_load_ram(char* codecptr, int size, |
58 | void* ptr2, int bufwrap, int *pd); | 58 | void* ptr2, int bufwrap, void **pd); |
59 | void sim_codec_close(int pd); | 59 | void sim_codec_close(void *pd); |
60 | #else | 60 | #else |
61 | #define sim_codec_close(x) | 61 | #define sim_codec_close(x) |
62 | extern unsigned char codecbuf[]; | 62 | extern unsigned char codecbuf[]; |
@@ -249,10 +249,10 @@ int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap, | |||
249 | return CODEC_ERROR; | 249 | return CODEC_ERROR; |
250 | } | 250 | } |
251 | #else /* SIMULATOR */ | 251 | #else /* SIMULATOR */ |
252 | int pd; | 252 | void *pd; |
253 | 253 | ||
254 | hdr = sim_codec_load_ram(codecptr, size, ptr2, bufwrap, &pd); | 254 | hdr = sim_codec_load_ram(codecptr, size, ptr2, bufwrap, &pd); |
255 | if (pd < 0) | 255 | if (pd == NULL) |
256 | return CODEC_ERROR; | 256 | return CODEC_ERROR; |
257 | 257 | ||
258 | if (hdr == NULL | 258 | if (hdr == NULL |
diff --git a/apps/plugin.c b/apps/plugin.c index 2bf6aa772d..4f6b6e91d7 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -70,8 +70,8 @@ | |||
70 | 70 | ||
71 | #ifdef SIMULATOR | 71 | #ifdef SIMULATOR |
72 | static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE]; | 72 | static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE]; |
73 | void *sim_plugin_load(char *plugin, int *fd); | 73 | void *sim_plugin_load(char *plugin, void **pd); |
74 | void sim_plugin_close(int fd); | 74 | void sim_plugin_close(void *pd); |
75 | void sim_lcd_ex_init(int shades, unsigned long (*getpixel)(int, int)); | 75 | void sim_lcd_ex_init(int shades, unsigned long (*getpixel)(int, int)); |
76 | void sim_lcd_ex_update_rect(int x, int y, int width, int height); | 76 | void sim_lcd_ex_update_rect(int x, int y, int width, int height); |
77 | #else | 77 | #else |
@@ -411,9 +411,12 @@ static const struct plugin_api rockbox_api = { | |||
411 | 411 | ||
412 | int plugin_load(const char* plugin, void* parameter) | 412 | int plugin_load(const char* plugin, void* parameter) |
413 | { | 413 | { |
414 | int fd, rc; | 414 | int rc; |
415 | struct plugin_header *hdr; | 415 | struct plugin_header *hdr; |
416 | #ifndef SIMULATOR | 416 | #ifdef SIMULATOR |
417 | void *pd; | ||
418 | #else | ||
419 | int fd; | ||
417 | ssize_t readsize; | 420 | ssize_t readsize; |
418 | #endif | 421 | #endif |
419 | #ifdef HAVE_LCD_BITMAP | 422 | #ifdef HAVE_LCD_BITMAP |
@@ -436,21 +439,21 @@ int plugin_load(const char* plugin, void* parameter) | |||
436 | gui_syncsplash(0, true, str(LANG_WAIT)); | 439 | gui_syncsplash(0, true, str(LANG_WAIT)); |
437 | 440 | ||
438 | #ifdef SIMULATOR | 441 | #ifdef SIMULATOR |
439 | hdr = sim_plugin_load((char *)plugin, &fd); | 442 | hdr = sim_plugin_load((char *)plugin, &pd); |
440 | if (!fd) { | 443 | if (pd == NULL) { |
441 | gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_CANT_OPEN), plugin); | 444 | gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_CANT_OPEN), plugin); |
442 | return -1; | 445 | return -1; |
443 | } | 446 | } |
444 | if (hdr == NULL | 447 | if (hdr == NULL |
445 | || hdr->magic != PLUGIN_MAGIC | 448 | || hdr->magic != PLUGIN_MAGIC |
446 | || hdr->target_id != TARGET_ID) { | 449 | || hdr->target_id != TARGET_ID) { |
447 | sim_plugin_close(fd); | 450 | sim_plugin_close(pd); |
448 | gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_WRONG_MODEL)); | 451 | gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_WRONG_MODEL)); |
449 | return -1; | 452 | return -1; |
450 | } | 453 | } |
451 | if (hdr->api_version > PLUGIN_API_VERSION | 454 | if (hdr->api_version > PLUGIN_API_VERSION |
452 | || hdr->api_version < PLUGIN_MIN_API_VERSION) { | 455 | || hdr->api_version < PLUGIN_MIN_API_VERSION) { |
453 | sim_plugin_close(fd); | 456 | sim_plugin_close(pd); |
454 | gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_WRONG_VERSION)); | 457 | gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_WRONG_VERSION)); |
455 | return -1; | 458 | return -1; |
456 | } | 459 | } |
@@ -549,7 +552,7 @@ int plugin_load(const char* plugin, void* parameter) | |||
549 | if (pfn_tsr_exit == NULL) | 552 | if (pfn_tsr_exit == NULL) |
550 | plugin_loaded = false; | 553 | plugin_loaded = false; |
551 | 554 | ||
552 | sim_plugin_close(fd); | 555 | sim_plugin_close(pd); |
553 | 556 | ||
554 | switch (rc) { | 557 | switch (rc) { |
555 | case PLUGIN_OK: | 558 | case PLUGIN_OK: |
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c index bf72054b08..56cdb46a6b 100644 --- a/uisimulator/common/io.c +++ b/uisimulator/common/io.c | |||
@@ -308,9 +308,9 @@ int sim_fsync(int fd) | |||
308 | #endif | 308 | #endif |
309 | 309 | ||
310 | void *sim_codec_load_ram(char* codecptr, int size, | 310 | void *sim_codec_load_ram(char* codecptr, int size, |
311 | void* ptr2, int bufwrap, int *pd_fd) | 311 | void* ptr2, int bufwrap, void **pd) |
312 | { | 312 | { |
313 | void *pd, *hdr; | 313 | void *hdr; |
314 | const char *path = "archos/_temp_codec.dll"; | 314 | const char *path = "archos/_temp_codec.dll"; |
315 | int fd; | 315 | int fd; |
316 | int copy_n; | 316 | int copy_n; |
@@ -318,7 +318,7 @@ void *sim_codec_load_ram(char* codecptr, int size, | |||
318 | char buf[256]; | 318 | char buf[256]; |
319 | #endif | 319 | #endif |
320 | 320 | ||
321 | *pd_fd = 0; | 321 | *pd = NULL; |
322 | 322 | ||
323 | /* We have to create the dynamic link library file from ram | 323 | /* We have to create the dynamic link library file from ram |
324 | so we could simulate the codec loading. */ | 324 | so we could simulate the codec loading. */ |
@@ -351,8 +351,8 @@ void *sim_codec_load_ram(char* codecptr, int size, | |||
351 | close(fd); | 351 | close(fd); |
352 | 352 | ||
353 | /* Now load the library. */ | 353 | /* Now load the library. */ |
354 | pd = dlopen(path, RTLD_NOW); | 354 | *pd = dlopen(path, RTLD_NOW); |
355 | if (!pd) { | 355 | if (*pd == NULL) { |
356 | DEBUGF("failed to load %s\n", path); | 356 | DEBUGF("failed to load %s\n", path); |
357 | #ifdef WIN32 | 357 | #ifdef WIN32 |
358 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, | 358 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, |
@@ -361,26 +361,25 @@ void *sim_codec_load_ram(char* codecptr, int size, | |||
361 | #else | 361 | #else |
362 | DEBUGF("dlopen(%s): %s\n", path, dlerror()); | 362 | DEBUGF("dlopen(%s): %s\n", path, dlerror()); |
363 | #endif | 363 | #endif |
364 | dlclose(pd); | 364 | dlclose(*pd); |
365 | return NULL; | 365 | return NULL; |
366 | } | 366 | } |
367 | 367 | ||
368 | hdr = dlsym(pd, "__header"); | 368 | hdr = dlsym(*pd, "__header"); |
369 | if (!hdr) | 369 | if (!hdr) |
370 | hdr = dlsym(pd, "___header"); | 370 | hdr = dlsym(*pd, "___header"); |
371 | 371 | ||
372 | *pd_fd = (int)pd; | ||
373 | return hdr; /* maybe NULL if symbol not present */ | 372 | return hdr; /* maybe NULL if symbol not present */ |
374 | } | 373 | } |
375 | 374 | ||
376 | void sim_codec_close(int pd) | 375 | void sim_codec_close(void *pd) |
377 | { | 376 | { |
378 | dlclose((void *)pd); | 377 | dlclose(pd); |
379 | } | 378 | } |
380 | 379 | ||
381 | void *sim_plugin_load(char *plugin, int *fd) | 380 | void *sim_plugin_load(char *plugin, void **pd) |
382 | { | 381 | { |
383 | void *pd, *hdr; | 382 | void *hdr; |
384 | char path[256]; | 383 | char path[256]; |
385 | #ifdef WIN32 | 384 | #ifdef WIN32 |
386 | char buf[256]; | 385 | char buf[256]; |
@@ -388,10 +387,10 @@ void *sim_plugin_load(char *plugin, int *fd) | |||
388 | 387 | ||
389 | snprintf(path, sizeof path, "archos%s", plugin); | 388 | snprintf(path, sizeof path, "archos%s", plugin); |
390 | 389 | ||
391 | *fd = 0; | 390 | *pd = NULL; |
392 | 391 | ||
393 | pd = dlopen(path, RTLD_NOW); | 392 | *pd = dlopen(path, RTLD_NOW); |
394 | if (!pd) { | 393 | if (*pd == NULL) { |
395 | DEBUGF("failed to load %s\n", plugin); | 394 | DEBUGF("failed to load %s\n", plugin); |
396 | #ifdef WIN32 | 395 | #ifdef WIN32 |
397 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, | 396 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, |
@@ -400,21 +399,20 @@ void *sim_plugin_load(char *plugin, int *fd) | |||
400 | #else | 399 | #else |
401 | DEBUGF("dlopen(%s): %s\n", path, dlerror()); | 400 | DEBUGF("dlopen(%s): %s\n", path, dlerror()); |
402 | #endif | 401 | #endif |
403 | dlclose(pd); | 402 | dlclose(*pd); |
404 | return NULL; | 403 | return NULL; |
405 | } | 404 | } |
406 | 405 | ||
407 | hdr = dlsym(pd, "__header"); | 406 | hdr = dlsym(*pd, "__header"); |
408 | if (!hdr) | 407 | if (!hdr) |
409 | hdr = dlsym(pd, "___header"); | 408 | hdr = dlsym(*pd, "___header"); |
410 | 409 | ||
411 | *fd = (int)pd; /* success */ | ||
412 | return hdr; /* maybe NULL if symbol not present */ | 410 | return hdr; /* maybe NULL if symbol not present */ |
413 | } | 411 | } |
414 | 412 | ||
415 | void sim_plugin_close(int pd) | 413 | void sim_plugin_close(void *pd) |
416 | { | 414 | { |
417 | dlclose((void *)pd); | 415 | dlclose(pd); |
418 | } | 416 | } |
419 | 417 | ||
420 | #if !defined(WIN32) || defined(SDL) | 418 | #if !defined(WIN32) || defined(SDL) |