diff options
author | waker <wakeroid@gmail.com> | 2011-05-07 11:22:41 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2011-05-07 11:22:41 +0200 |
commit | da5345e0386a9f6fa182545a4334b03cf8ccc33c (patch) | |
tree | 57d9a2cc78ea6eb24f00f4c179bc70890aec9c6f /plugins/ao/eng_psf | |
parent | e773e777343ce971d80c55522b293d83cddae478 (diff) |
ao: fixed reading aux psf libs from archives
Diffstat (limited to 'plugins/ao/eng_psf')
-rw-r--r-- | plugins/ao/eng_psf/eng_psf.c | 45 | ||||
-rw-r--r-- | plugins/ao/eng_psf/eng_psf2.c | 14 |
2 files changed, 20 insertions, 39 deletions
diff --git a/plugins/ao/eng_psf/eng_psf.c b/plugins/ao/eng_psf/eng_psf.c index 8b12c777..268c8968 100644 --- a/plugins/ao/eng_psf/eng_psf.c +++ b/plugins/ao/eng_psf/eng_psf.c @@ -64,6 +64,23 @@ static void spu_update (unsigned char* pSound,long lBytes,void *data) memcpy(s->spu_pOutput, pSound, lBytes); } +void +ao_getlibpath (const char *path, const char *libname, char *libpath, int size) { + const char *e = strrchr (path, ':'); + if (!e) { + e = strrchr (path, '/'); + } + if (e) { + e++; + memcpy (libpath, path, e-path); + libpath[e-path] = 0; + strcat (libpath, libname); + } + else { + strcpy (libpath, libname); + } +} + void *psf_start(const char *path, uint8 *buffer, uint32 length) { psf_synth_t *s = malloc (sizeof (psf_synth_t)); @@ -126,19 +143,7 @@ void *psf_start(const char *path, uint8 *buffer, uint32 length) { 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); - } + ao_getlibpath (path, s->c->lib, libpath, sizeof (libpath)); if (ao_get_lib(libpath, &lib_raw_file, &tmp_length) != AO_SUCCESS) { @@ -228,19 +233,7 @@ void *psf_start(const char *path, uint8 *buffer, uint32 length) { 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->libaux[i]); - } - else { - strcpy (libpath, s->c->libaux[i]); - } + ao_getlibpath (path, s->c->libaux[i], libpath, sizeof (libpath)); if (ao_get_lib(libpath, &lib_raw_file, &tmp_length) != AO_SUCCESS) { diff --git a/plugins/ao/eng_psf/eng_psf2.c b/plugins/ao/eng_psf/eng_psf2.c index de9e5148..525ad3f7 100644 --- a/plugins/ao/eng_psf/eng_psf2.c +++ b/plugins/ao/eng_psf/eng_psf2.c @@ -497,19 +497,7 @@ void *psf2_start(const char *path, uint8 *buffer, uint32 length) { 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); - } + ao_getlibpath (path, s->c->lib, libpath, sizeof (libpath)); #if DEBUG_LOADER printf("Loading library: %s\n", s->c->lib); |