diff options
author | Max Horn | 2007-03-08 17:36:52 +0000 |
---|---|---|
committer | Max Horn | 2007-03-08 17:36:52 +0000 |
commit | d19adc0514d8a43f3a233649595c636d5c38b3d5 (patch) | |
tree | cd503b5f17faf59aef5ab928398245a7f705dd22 | |
parent | 8778f121e2330b5025755ddc57077a5b87fc3693 (diff) | |
download | scummvm-rg350-d19adc0514d8a43f3a233649595c636d5c38b3d5.tar.gz scummvm-rg350-d19adc0514d8a43f3a233649595c636d5c38b3d5.tar.bz2 scummvm-rg350-d19adc0514d8a43f3a233649595c636d5c38b3d5.zip |
common/util.cpp needs fprintf; various std I/O functions are not used by anything in our code, so there is no need to emulate them -- mark these; my previous commits likely broke compilation of the DS backend, try to reduce the brokeness a bit
svn-id: r26023
-rw-r--r-- | backends/fs/ds/ds-fs.cpp | 28 | ||||
-rw-r--r-- | common/file.cpp | 76 | ||||
-rw-r--r-- | common/util.cpp | 27 |
3 files changed, 86 insertions, 45 deletions
diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp index 883ad2d7ca..26a95976e6 100644 --- a/backends/fs/ds/ds-fs.cpp +++ b/backends/fs/ds/ds-fs.cpp @@ -27,8 +27,34 @@ #include "dsmain.h" #include "gba_nds_fat.h" + namespace DS { +struct fileHandle { + int pos; + bool used; + char* data; + int size; + + DSSaveFile* sramFile; +}; + +#define FILE DS::fileHandle + +// FIXME: The following definition for stdin etc. are duplicated in common/util.cpp. +// This should be fixed, e.g. by moving this (and the declarations of fileHandle, +// the various functions etc.) into a separate header file which includes by util.cpp, +// file.cpp and ds-fs.cpp + +#undef stderr +#undef stdout +#undef stdin + +#define stdout ((DS::fileHandle*) -1) +#define stderr ((DS::fileHandle*) -2) +#define stdin ((DS::fileHandle*) -3) + + ////////////////////////////////////////////////////////////// // DSFileSystemNode - Flash ROM file system using Zip files ////////////////////////////////////////////////////////////// @@ -434,7 +460,7 @@ FILE* std_fopen(const char* name, const char* mode) { } // MT_memoryReport(); - return (fileHandle *) result; + return (FILE *) result; } diff --git a/common/file.cpp b/common/file.cpp index 8e9d94eb45..6ac03dff12 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -38,31 +38,25 @@ #define fopen(a, b) ps2_fopen(a, b) #define fclose(a) ps2_fclose(a) - #define fflush(a) ps2_fflush(a) #define fseek(a, b, c) ps2_fseek(a, b, c) #define ftell(a) ps2_ftell(a) #define feof(a) ps2_feof(a) #define fread(a, b, c, d) ps2_fread(a, b, c, d) #define fwrite(a, b, c, d) ps2_fwrite(a, b, c, d) - #define fgetc(a) ps2_fgetc(a) - #define fgets(a, b, c) ps2_fgets(a, b, c) - #define fputc(a, b) ps2_fputc(a, b) - #define fputs(a, b) ps2_fputs(a, b) - #define fprintf ps2_fprintf - #define fsize(a) ps2_fsize(a) + + //#define fprintf ps2_fprintf // used in common/util.cpp + //#define fflush(a) ps2_fflush(a) // used in common/util.cpp + + //#define fgetc(a) ps2_fgetc(a) // not used + //#define fgets(a, b, c) ps2_fgets(a, b, c) // not used + //#define fputc(a, b) ps2_fputc(a, b) // not used + //#define fputs(a, b) ps2_fputs(a, b) // not used + + //#define fsize(a) ps2_fsize(a) // not used -- and it is not a standard function either #endif #ifdef __DS__ - struct fileHandle { - int pos; - bool used; - char* data; - int size; - - DSSaveFile* sramFile; - }; - // These functions replease the standard library functions of the same name. // As this header is included after the standard one, I have the chance to #define // all of these to my own code. @@ -72,37 +66,29 @@ // These functions need to be #undef'ed, as their original definition // in devkitarm is done with #includes (ugh!) #undef feof - #undef stderr - #undef stdout - #undef stdin #undef clearerr - #undef getc - #undef ferror + //#undef getc + //#undef ferror - #define stdout ((DS::fileHandle*) -1) - #define stderr ((DS::fileHandle*) -2) - #define stdin ((DS::fileHandle*) -3) - - #define FILE DS::fileHandle - //#define size_t int - - //#define FAT_chdir FAT_CWD + #define FILE void FILE* std_fopen(const char* name, const char* mode); void std_fclose(FILE* handle); size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle); size_t std_fwrite(const void* ptr, size_t size, size_t numItems, FILE* handle); - void std_fprintf(FILE* handle, const char* fmt, ...); bool std_feof(FILE* handle); - void std_fflush(FILE* handle); - char* std_fgets(char* str, int size, FILE* file); long int std_ftell(FILE* handle); int std_fseek(FILE* handle, long int offset, int whence); void std_clearerr(FILE* handle); - int std_getc(FILE* handle); - char* std_getcwd(char* dir, int dunno); - void std_cwd(char* dir); - int std_ferror(FILE* handle); + + //void std_fprintf(FILE* handle, const char* fmt, ...); // used in common/util.cpp + //void std_fflush(FILE* handle); // used in common/util.cpp + + //char* std_fgets(char* str, int size, FILE* file); // not used + //int std_getc(FILE* handle); // not used + //char* std_getcwd(char* dir, int dunno); // not used + //void std_cwd(char* dir); // not used + //int std_ferror(FILE* handle); // not used // Only functions used in the ScummVM source have been defined here! #define fopen(name, mode) DS::std_fopen(name, mode) @@ -110,17 +96,19 @@ #define fread(ptr, size, items, file) DS::std_fread(ptr, size, items, file) #define fwrite(ptr, size, items, file) DS::std_fwrite(ptr, size, items, file) #define feof(handle) DS::std_feof(handle) - //#define fprintf(file, fmt, ...) DS::fprintf(file, fmt, ##__VA_ARGS__) - #define fprintf(file, fmt, ...) { char str[128]; sprintf(str, fmt, ##__VA_ARGS__); DS::std_fwrite(str, strlen(str), 1, file); } - #define printf(fmt, ...) consolePrintf(fmt, ##__VA_ARGS__) - #define fflush(file) DS::std_fflush(file) - #define fgets(str, size, file) DS::std_fgets(str, size, file) #define ftell(handle) DS::std_ftell(handle) #define fseek(handle, offset, whence) DS::std_fseek(handle, offset, whence) #define clearerr(handle) DS::std_clearerr(handle) - #define getc(handle) DS::std_getc(handle) - #define getcwd(dir, dunno) DS::std_getcwd(dir, dunno) - #define ferror(handle) DS::std_ferror(handle) + + #define printf(fmt, ...) consolePrintf(fmt, ##__VA_ARGS__) + + //#define fprintf(file, fmt, ...) { char str[128]; sprintf(str, fmt, ##__VA_ARGS__); DS::std_fwrite(str, strlen(str), 1, file); } + //#define fflush(file) DS::std_fflush(file) // used in common/util.cpp + + //#define fgets(str, size, file) DS::std_fgets(str, size, file) // not used + //#define getc(handle) DS::std_getc(handle) // not used + //#define getcwd(dir, dunno) DS::std_getcwd(dir, dunno) // not used + //#define ferror(handle) DS::std_ferror(handle) // not used #endif diff --git a/common/util.cpp b/common/util.cpp index bcad8696fb..ffaf4a0dcc 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -30,6 +30,33 @@ extern bool isSmartphone(void); #endif +#ifdef __PLAYSTATION2__ + // for those replaced fopen/fread/etc functions + typedef unsigned long uint64; + typedef signed long int64; + #include "backends/platform/ps2/fileio.h" + + #define fprintf ps2_fprintf + #define fflush(a) ps2_fflush(a) +#endif + +#ifdef __DS__ + #undef stderr + #undef stdout + #undef stdin + + #define stdout ((DS::fileHandle*) -1) + #define stderr ((DS::fileHandle*) -2) + #define stdin ((DS::fileHandle*) -3) + + void std_fprintf(FILE* handle, const char* fmt, ...); + void std_fflush(FILE* handle); + + #define fprintf(file, fmt, ...) { char str[128]; sprintf(str, fmt, ##__VA_ARGS__); DS::std_fwrite(str, strlen(str), 1, file); } + #define fflush(file) DS::std_fflush(file) +#endif + + namespace Common { // |