summaryrefslogtreecommitdiff
path: root/uisimulator/common/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator/common/io.c')
-rw-r--r--uisimulator/common/io.c42
1 files changed, 20 insertions, 22 deletions
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
310void *sim_codec_load_ram(char* codecptr, int size, 310void *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
376void sim_codec_close(int pd) 375void sim_codec_close(void *pd)
377{ 376{
378 dlclose((void *)pd); 377 dlclose(pd);
379} 378}
380 379
381void *sim_plugin_load(char *plugin, int *fd) 380void *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
415void sim_plugin_close(int pd) 413void 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)