summaryrefslogtreecommitdiff
path: root/plugins/ao
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-08-11 21:25:00 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-08-11 21:25:00 +0200
commiteb46e2ca1048b5d7938a48690cd1340c6f213f9e (patch)
treeefed6b093f06ca22cf1a0bb1be7d67377dbb5fe1 /plugins/ao
parent36b14449d71b14e29358560894d6ed94d7adedc1 (diff)
fixed psf aux library loading code
Diffstat (limited to 'plugins/ao')
-rw-r--r--plugins/ao/eng_psf/eng_psf.c27
-rw-r--r--plugins/ao/main.c2
2 files changed, 21 insertions, 8 deletions
diff --git a/plugins/ao/eng_psf/eng_psf.c b/plugins/ao/eng_psf/eng_psf.c
index 4cc284e1..8101557b 100644
--- a/plugins/ao/eng_psf/eng_psf.c
+++ b/plugins/ao/eng_psf/eng_psf.c
@@ -44,6 +44,9 @@
#define DEBUG_LOADER (0)
+#define trace(...) { fprintf(stderr, __VA_ARGS__); }
+//#define trace(fmt,...)
+
int psf_refresh = -1; // hack
typedef struct {
@@ -137,9 +140,7 @@ void *psf_start(const char *path, uint8 *buffer, uint32 length)
strcpy (libpath, s->c->lib);
}
- #if DEBUG_LOADER
- printf("Loading library: %s\n", c->lib);
- #endif
+ trace ("Loading library: %s\n", s->c->lib);
if (ao_get_lib(libpath, &lib_raw_file, &tmp_length) != AO_SUCCESS)
{
psf_stop (s);
@@ -226,12 +227,24 @@ void *psf_start(const char *path, uint8 *buffer, uint32 length)
if (s->c->libaux[i][0] != 0)
{
uint64 tmp_length;
+ char libpath[PATH_MAX];
+ const char *e = path + strlen(path);
+ while (e > path && *e != '/') {
+ e--;
+ }
+ if (*e == '/') {
+ e++;
+ memcpy (libpath, path, e-path);
+ libpath[e-path] = 0;
+ strcat (libpath, s->c->lib);
+ }
+ else {
+ strcpy (libpath, s->c->lib);
+ }
- #if DEBUG_LOADER
- printf("Loading aux library: %s\n", c->libaux[i]);
- #endif
+ trace ("Loading aux library: %s\n", s->c->libaux[i]);
- if (ao_get_lib(s->c->libaux[i], &lib_raw_file, &tmp_length) != AO_SUCCESS)
+ if (ao_get_lib(libpath, &lib_raw_file, &tmp_length) != AO_SUCCESS)
{
psf_stop (s);
return NULL;
diff --git a/plugins/ao/main.c b/plugins/ao/main.c
index 073347d8..2d2c45aa 100644
--- a/plugins/ao/main.c
+++ b/plugins/ao/main.c
@@ -68,7 +68,7 @@ int ao_get_lib(char *filename, uint8 **buffer, uint64 *length)
auxfile = fopen(filename, "rb");
if (!auxfile)
{
- printf("Unable to find auxiliary file %s\n", filename);
+ fprintf(stderr, "Unable to find auxiliary file %s\n", filename);
return AO_FAIL;
}