diff options
author | Max Horn | 2010-10-30 21:27:42 +0000 |
---|---|---|
committer | Max Horn | 2010-10-30 21:27:42 +0000 |
commit | 44393b2dc8ba78342dcbb7df39eca2e9e1f6e429 (patch) | |
tree | b5b2d7013d64ca317072453a7fbbc391174e2851 /sound/softsynth/mt32 | |
parent | ff34a778318355ffba2ee5700524fccba9fe5cf3 (diff) | |
download | scummvm-rg350-44393b2dc8ba78342dcbb7df39eca2e9e1f6e429.tar.gz scummvm-rg350-44393b2dc8ba78342dcbb7df39eca2e9e1f6e429.tar.bz2 scummvm-rg350-44393b2dc8ba78342dcbb7df39eca2e9e1f6e429.zip |
ALL: Add code to help stop people from accidentally using "bad" APIs
A new header file common/forbidden.h is included by scummsys.h and it
re-#defines numerous symbols like fopen(), fread(), system(), etc. with
garbage, in order to provoke compile errors in any code using them.
If a .cpp file really *must* use any of these (e.g. because it is a
backend file), then these redefinitions can be disabled by #defining
FORBIDDEN_SYMBOL_ALLOW_ALL as the first thing in the .cpp file. Whenever
this is done, an explanatory comment should be added.
Note that this system cannot catch all "bad" usages (notably the Lua
code in the sword25 engine), as it can only work if scummsys.h is
included.
svn-id: r53961
Diffstat (limited to 'sound/softsynth/mt32')
-rw-r--r-- | sound/softsynth/mt32/mt32_file.cpp | 18 | ||||
-rw-r--r-- | sound/softsynth/mt32/mt32_file.h | 2 |
2 files changed, 13 insertions, 7 deletions
diff --git a/sound/softsynth/mt32/mt32_file.cpp b/sound/softsynth/mt32/mt32_file.cpp index f4eba73d33..ce5c2874c4 100644 --- a/sound/softsynth/mt32/mt32_file.cpp +++ b/sound/softsynth/mt32/mt32_file.cpp @@ -19,6 +19,12 @@ * IN THE SOFTWARE. */ + +// FIXME: Disable symbol overrides so that we can use system headers. +// But we *really* should get rid of this usage of FILE, fopen etc. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + + #include <stdio.h> #include "mt32emu.h" @@ -37,15 +43,15 @@ namespace MT32Emu { } void ANSIFile::close() { - fclose(fp); + fclose((FILE *)fp); } size_t ANSIFile::read(void *in, size_t size) { - return fread(in, 1, size, fp); + return fread(in, 1, size, (FILE *)fp); } bool ANSIFile::readBit8u(Bit8u *in) { - int c = fgetc(fp); + int c = fgetc((FILE *)fp); if (c == EOF) return false; *in = (Bit8u)c; @@ -69,11 +75,11 @@ namespace MT32Emu { } size_t ANSIFile::write(const void *out, size_t size) { - return fwrite(out, 1, size, fp); + return fwrite(out, 1, size, (FILE *)fp); } bool ANSIFile::writeBit8u(Bit8u out) { - return fputc(out, fp) != EOF; + return fputc(out, (FILE *)fp) != EOF; } bool File::writeBit16u(Bit16u out) { @@ -103,6 +109,6 @@ namespace MT32Emu { } bool ANSIFile::isEOF() { - return feof(fp) != 0; + return feof((FILE *)fp) != 0; } } diff --git a/sound/softsynth/mt32/mt32_file.h b/sound/softsynth/mt32/mt32_file.h index 27c8ccbe46..b311ad9626 100644 --- a/sound/softsynth/mt32/mt32_file.h +++ b/sound/softsynth/mt32/mt32_file.h @@ -49,7 +49,7 @@ public: class ANSIFile: public File { private: - FILE *fp; + void *fp; public: bool open(const char *filename, OpenMode mode); void close(); |