aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authornotaz2011-09-23 20:51:07 +0300
committernotaz2011-09-23 20:51:07 +0300
commitbb5cf0fcf7abafa7648734696320d5fa3bdb1e0a (patch)
tree3fd032d85cdfc7766f050951391e164ced8fe0a4 /plugins
parenta80ae4a0353fce94df700ec84222d3c56c3d813a (diff)
downloadpcsx_rearmed-bb5cf0fcf7abafa7648734696320d5fa3bdb1e0a.tar.gz
pcsx_rearmed-bb5cf0fcf7abafa7648734696320d5fa3bdb1e0a.tar.bz2
pcsx_rearmed-bb5cf0fcf7abafa7648734696320d5fa3bdb1e0a.zip
get rid of hard libbz2 dependency
it just keeps getting in my way when trying to run this elsewhere.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/cdrcimg/cdrcimg.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/plugins/cdrcimg/cdrcimg.c b/plugins/cdrcimg/cdrcimg.c
index 32786f2..dd1cf57 100644
--- a/plugins/cdrcimg/cdrcimg.c
+++ b/plugins/cdrcimg/cdrcimg.c
@@ -13,6 +13,7 @@
#include <stdlib.h>
#include <zlib.h>
#include <bzlib.h>
+#include <dlfcn.h>
#include "cdrcimg.h"
@@ -34,6 +35,9 @@ static unsigned int cd_sectors_per_blk;
static int cd_compression;
static FILE *cd_file;
+static int (*pBZ2_bzBuffToBuffDecompress)(char *dest, unsigned int *destLen, char *source,
+ unsigned int sourceLen, int small, int verbosity);
+
static struct {
unsigned char raw[16][CD_FRAMESIZE_RAW];
unsigned char compressed[CD_FRAMESIZE_RAW * 16 + 100];
@@ -193,7 +197,7 @@ static long CDRreadTrack(unsigned char *time)
ret = uncompress2(cdbuffer->raw[0], &cdbuffer_size, cdbuffer->compressed, size);
break;
case CDRC_BZ:
- ret = BZ2_bzBuffToBuffDecompress((char *)cdbuffer->raw, (unsigned int *)&cdbuffer_size,
+ ret = pBZ2_bzBuffToBuffDecompress((char *)cdbuffer->raw, (unsigned int *)&cdbuffer_size,
(char *)cdbuffer->compressed, size, 0, 0);
break;
default:
@@ -276,6 +280,18 @@ static long CDRinit(void)
return -1;
}
}
+ if (pBZ2_bzBuffToBuffDecompress == NULL) {
+ void *h = dlopen("/usr/lib/libbz2.so.1", RTLD_LAZY);
+ if (h == NULL)
+ h = dlopen("./lib/libbz2.so.1", RTLD_LAZY);
+ if (h != NULL) {
+ pBZ2_bzBuffToBuffDecompress = dlsym(h, "BZ2_bzBuffToBuffDecompress");
+ if (pBZ2_bzBuffToBuffDecompress == NULL) {
+ err("dlsym bz2: %s", dlerror());
+ dlclose(h);
+ }
+ }
+ }
return 0;
}
@@ -422,6 +438,10 @@ static long CDRopen(void)
snprintf(table_fname, sizeof(table_fname), "%s.table", cd_fname);
}
else if (strcasecmp(ext, ".bz") == 0) {
+ if (pBZ2_bzBuffToBuffDecompress == NULL) {
+ err("libbz2 unavailable for .bz2 handling\n");
+ return -1;
+ }
cd_compression = CDRC_BZ;
tabentry_size = sizeof(u.bztab_entry);
snprintf(table_fname, sizeof(table_fname), "%s.index", cd_fname);