Selectively replace fopen() with fopen_utf8()
[pcsx_rearmed.git] / plugins / cdrcimg / cdrcimg.c
index e04ec93..007e96b 100644 (file)
@@ -8,12 +8,21 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include <compat/fopen_utf8.h>
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include <zlib.h>
-#include <bzlib.h>
+#ifndef _WIN32
+#define CALLBACK
+#ifndef NO_DYLIB
 #include <dlfcn.h>
+#endif
+#else
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
 
 #include "cdrcimg.h"
 
@@ -45,7 +54,7 @@ static struct {
 static int current_block, current_sect_in_blk;
 
 struct CdrStat;
-extern long CDR__getStatus(struct CdrStat *stat);
+extern long CALLBACK CDR__getStatus(struct CdrStat *stat);
 
 struct CdrStat
 {
@@ -93,7 +102,7 @@ static long CDRgetTD(unsigned char track, unsigned char *buffer)
        return 0;
 }
 
-int uncompress2(void *out, unsigned long *out_size, void *in, unsigned long in_size)
+static int uncompress2_pcsx(void *out, unsigned long *out_size, void *in, unsigned long in_size)
 {
        static z_stream z;
        int ret = 0;
@@ -194,7 +203,7 @@ static long CDRreadTrack(unsigned char *time)
                ret = uncompress(cdbuffer->raw[0], &cdbuffer_size, cdbuffer->compressed, size);
                break;
        case CDRC_ZLIB2:
-               ret = uncompress2(cdbuffer->raw[0], &cdbuffer_size, cdbuffer->compressed, size);
+               ret = uncompress2_pcsx(cdbuffer->raw[0], &cdbuffer_size, cdbuffer->compressed, size);
                break;
        case CDRC_BZ:
                ret = pBZ2_bzBuffToBuffDecompress((char *)cdbuffer->raw, (unsigned int *)&cdbuffer_size,
@@ -280,6 +289,7 @@ static long CDRinit(void)
                        return -1;
                }
        }
+#if !defined(_WIN32) && !defined(NO_DYLIB)
        if (pBZ2_bzBuffToBuffDecompress == NULL) {
                void *h = dlopen("/usr/lib/libbz2.so.1", RTLD_LAZY);
                if (h == NULL)
@@ -292,6 +302,7 @@ static long CDRinit(void)
                        }
                }
        }
+#endif
        return 0;
 }
 
@@ -312,7 +323,7 @@ static long handle_eboot(void)
        int i, ret;
        FILE *f;
 
-       f = fopen(cd_fname, "rb");
+       f = fopen_utf8(cd_fname, "rb");
        if (f == NULL) {
                err("missing file: %s: ", cd_fname);
                perror(NULL);
@@ -451,7 +462,7 @@ static long CDRopen(void)
                return -1;
        }
 
-       f = fopen(table_fname, "rb");
+       f = fopen_utf8(table_fname, "rb");
        if (f == NULL) {
                err("missing file: %s: ", table_fname);
                perror(NULL);
@@ -516,7 +527,7 @@ static long CDRopen(void)
                break;
        }
 
-       cd_file = fopen(cd_fname, "rb");
+       cd_file = fopen_utf8(cd_fname, "rb");
        if (cd_file == NULL) {
                err("failed to open: %s: ", table_fname);
                perror(NULL);