ape_reader: Properly fix the build under GCC 7.

Since we cannot '#define wchar_t char' anymore, we need to properly
fix the source code to work with char instead.
This commit is contained in:
Augustin Cavalier
2018-05-23 18:59:32 -04:00
parent ca4d9e0f9f
commit 053cc0d4fe
24 changed files with 132 additions and 146 deletions
@@ -32,7 +32,7 @@ int TPositionBridgeIO::Close()
return B_OK; return B_OK;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int TPositionBridgeIO::Create(const wchar_t* oName) int TPositionBridgeIO::Create(const char* oName)
{ {
return B_OK; return B_OK;
} }
@@ -42,7 +42,7 @@ int TPositionBridgeIO::Delete()
return B_ERROR; return B_ERROR;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int TPositionBridgeIO::GetName(wchar_t* oBuffer) int TPositionBridgeIO::GetName(char* oBuffer)
{ {
strcpy(oBuffer, "<TPositionBridgeIO>"); strcpy(oBuffer, "<TPositionBridgeIO>");
return B_OK; return B_OK;
@@ -68,7 +68,7 @@ int TPositionBridgeIO::GetSize()
return aSize; return aSize;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int TPositionBridgeIO::Open(const wchar_t* oName) int TPositionBridgeIO::Open(const char* oName)
{ {
return B_OK; return B_OK;
} }
@@ -16,7 +16,7 @@ public:
TPositionBridgeIO(); TPositionBridgeIO();
virtual ~TPositionBridgeIO(); virtual ~TPositionBridgeIO();
virtual int Open(const wchar_t* oName); virtual int Open(const char* oName);
virtual int Close(); virtual int Close();
virtual int Read(void* oBuf, unsigned int oBytesToRead, unsigned int* oBytesRead); virtual int Read(void* oBuf, unsigned int oBytesToRead, unsigned int* oBytesRead);
@@ -24,14 +24,14 @@ public:
virtual int Seek(int oDistance, unsigned int oMoveMode); virtual int Seek(int oDistance, unsigned int oMoveMode);
virtual int Create(const wchar_t* oName); virtual int Create(const char* oName);
virtual int Delete(); virtual int Delete();
virtual int SetEOF(); virtual int SetEOF();
virtual int GetPosition(); virtual int GetPosition();
virtual int GetSize(); virtual int GetSize();
virtual int GetName(wchar_t* oBuffer); virtual int GetName(char* oBuffer);
status_t SetPositionIO(BPositionIO* oPositionIO); status_t SetPositionIO(BPositionIO* oPositionIO);
@@ -28,7 +28,7 @@ CAPECompress::~CAPECompress()
} }
} }
int CAPECompress::Start(const wchar_t * pOutputFilename, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel, const void * pHeaderData, int nHeaderBytes) int CAPECompress::Start(const char* pOutputFilename, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel, const void * pHeaderData, int nHeaderBytes)
{ {
m_pioOutput = new IO_CLASS_NAME; m_pioOutput = new IO_CLASS_NAME;
m_bOwnsOutputIO = TRUE; m_bOwnsOutputIO = TRUE;
@@ -15,7 +15,7 @@ public:
~CAPECompress(); ~CAPECompress();
// start encoding // start encoding
int Start(const wchar_t * pOutputFilename, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL, const void * pHeaderData = NULL, int nHeaderBytes = CREATE_WAV_HEADER_ON_DECOMPRESSION); int Start(const char* pOutputFilename, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL, const void * pHeaderData = NULL, int nHeaderBytes = CREATE_WAV_HEADER_ON_DECOMPRESSION);
int StartEx(CIO * pioOutput, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL, const void * pHeaderData = NULL, int nHeaderBytes = CREATE_WAV_HEADER_ON_DECOMPRESSION); int StartEx(CIO * pioOutput, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel = COMPRESSION_LEVEL_NORMAL, const void * pHeaderData = NULL, int nHeaderBytes = CREATE_WAV_HEADER_ON_DECOMPRESSION);
// add data / compress data // add data / compress data
@@ -9,11 +9,6 @@
#define DECODE_BLOCK_SIZE 4096 #define DECODE_BLOCK_SIZE 4096
#if __GNUC__ != 2
using std::min;
using std::max;
#endif
CAPEDecompress::CAPEDecompress(int * pErrorCode, CAPEInfo * pAPEInfo, int nStartBlock, int nFinishBlock) CAPEDecompress::CAPEDecompress(int * pErrorCode, CAPEInfo * pAPEInfo, int nStartBlock, int nFinishBlock)
{ {
*pErrorCode = ERROR_SUCCESS; *pErrorCode = ERROR_SUCCESS;
@@ -11,7 +11,7 @@ CAPEInfo:
/***************************************************************************************** /*****************************************************************************************
Construction Construction
*****************************************************************************************/ *****************************************************************************************/
CAPEInfo::CAPEInfo(int * pErrorCode, const wchar_t * pFilename, CAPETag * pTag) CAPEInfo::CAPEInfo(int * pErrorCode, const char* pFilename, CAPETag * pTag)
{ {
*pErrorCode = ERROR_SUCCESS; *pErrorCode = ERROR_SUCCESS;
CloseFile(); CloseFile();
@@ -77,7 +77,7 @@ class CAPEInfo
public: public:
// construction and destruction // construction and destruction
CAPEInfo(int * pErrorCode, const wchar_t * pFilename, CAPETag * pTag = NULL); CAPEInfo(int * pErrorCode, const char* pFilename, CAPETag * pTag = NULL);
CAPEInfo(int * pErrorCode, CIO * pIO, CAPETag * pTag = NULL); CAPEInfo(int * pErrorCode, CIO * pIO, CAPETag * pTag = NULL);
virtual ~CAPEInfo(); virtual ~CAPEInfo();
@@ -15,7 +15,7 @@ public:
BOOL GetIsLinkFile(); BOOL GetIsLinkFile();
int GetStartBlock(); int GetStartBlock();
int GetFinishBlock(); int GetFinishBlock();
const wchar_t * GetImageFilename(); const char* GetImageFilename();
protected: protected:
@@ -17,11 +17,6 @@
#define BLOCKS_PER_DECODE 9216 #define BLOCKS_PER_DECODE 9216
#if __GNUC__ != 2
using std::min;
using std::max;
#endif
int DecompressCore(const str_utf16 * pInputFilename, const str_utf16 * pOutputFilename, int nOutputMode, int nCompressionLevel, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag); int DecompressCore(const str_utf16 * pInputFilename, const str_utf16 * pOutputFilename, int nOutputMode, int nCompressionLevel, int * pPercentageDone, APE_PROGRESS_CALLBACK ProgressCallback, int * pKillFlag);
/***************************************************************************************** /*****************************************************************************************
@@ -7,11 +7,6 @@
#include "IO.h" #include "IO.h"
#include IO_HEADER_FILE #include IO_HEADER_FILE
#if __GNUC__ != 2
using std::min;
using std::max;
#endif
/***************************************************************************************** /*****************************************************************************************
CAPETagField CAPETagField
*****************************************************************************************/ *****************************************************************************************/
@@ -42,6 +42,12 @@ Global includes
#include <string.h> #include <string.h>
#include "SmartPtr.h" #include "SmartPtr.h"
#if __GNUC__ != 2
#include <algorithm>
using std::min;
using std::max;
#endif
/***************************************************************************************** /*****************************************************************************************
Global compiler settings (useful for porting) Global compiler settings (useful for porting)
*****************************************************************************************/ *****************************************************************************************/
@@ -98,7 +98,7 @@ int CBitArray::OutputBitArray(BOOL bFinalize)
m_nCurrentBitIndex = (m_nCurrentBitIndex & 31); m_nCurrentBitIndex = (m_nCurrentBitIndex & 31);
// zero the rest of the memory (may not need the +1 because of frame byte alignment) // zero the rest of the memory (may not need the +1 because of frame byte alignment)
memset(&m_pBitArray[1], 0, min(nBytesToWrite + 1, BIT_ARRAY_BYTES - 1)); memset(&m_pBitArray[1], 0, min((int)nBytesToWrite + 1, BIT_ARRAY_BYTES - 1));
} }
// return a success // return a success
@@ -72,7 +72,7 @@ int WriteSafe(CIO * pIO, void * pBuffer, int nBytes)
return nRetVal; return nRetVal;
} }
BOOL FileExists(wchar_t * pFilename) BOOL FileExists(char* pFilename)
{ {
if (0 == wcscmp(pFilename, "-") || 0 == wcscmp(pFilename, "/dev/stdin")) if (0 == wcscmp(pFilename, "-") || 0 == wcscmp(pFilename, "/dev/stdin"))
return TRUE; return TRUE;
@@ -16,6 +16,6 @@ int WriteSafe(CIO * pIO, void * pBuffer, int nBytes);
/************************************************************************************* /*************************************************************************************
Checks for the existence of a file Checks for the existence of a file
*************************************************************************************/ *************************************************************************************/
BOOL FileExists(wchar_t * pFilename); BOOL FileExists(char* pFilename);
#endif // #ifndef APE_GLOBALFUNCTIONS_H #endif // #ifndef APE_GLOBALFUNCTIONS_H
@@ -23,7 +23,7 @@ public:
virtual ~CIO() { }; virtual ~CIO() { };
// open / close // open / close
virtual int Open(const wchar_t * pName) = 0; virtual int Open(const char* pName) = 0;
virtual int Close() = 0; virtual int Close() = 0;
// read / write // read / write
@@ -34,7 +34,7 @@ public:
virtual int Seek(int nDistance, unsigned int nMoveMode) = 0; virtual int Seek(int nDistance, unsigned int nMoveMode) = 0;
// creation / destruction // creation / destruction
virtual int Create(const wchar_t * pName) = 0; virtual int Create(const char* pName) = 0;
virtual int Delete() = 0; virtual int Delete() = 0;
// other functions // other functions
@@ -43,7 +43,7 @@ public:
// attributes // attributes
virtual int GetPosition() = 0; virtual int GetPosition() = 0;
virtual int GetSize() = 0; virtual int GetSize() = 0;
virtual int GetName(wchar_t * pBuffer) = 0; virtual int GetName(char* pBuffer) = 0;
}; };
#endif // #ifndef APE_IO_H #endif // #ifndef APE_IO_H
@@ -19,7 +19,7 @@
//typedef char int8; //typedef char int8;
typedef char str_ansi; typedef char str_ansi;
typedef unsigned char str_utf8; typedef unsigned char str_utf8;
typedef wchar_t str_utf16; typedef char str_utf16;
typedef unsigned long DWORD; typedef unsigned long DWORD;
typedef int BOOL; typedef int BOOL;
@@ -31,8 +31,8 @@ typedef unsigned int UINT;
typedef unsigned int WPARAM; typedef unsigned int WPARAM;
typedef long LPARAM; typedef long LPARAM;
typedef const char * LPCSTR; typedef const char * LPCSTR;
typedef const wchar_t * LPCTSTR; // ?? SHINTA typedef const char* LPCTSTR; // ?? SHINTA
typedef const wchar_t * LPCWSTR; // ?? SHINTA typedef const char* LPCWSTR; // ?? SHINTA
typedef char * LPSTR; typedef char * LPSTR;
typedef long LRESULT; typedef long LRESULT;
typedef unsigned char UCHAR; typedef unsigned char UCHAR;
@@ -218,7 +218,7 @@ int CStdLibFileIO::GetName(char * pBuffer)
return 0; return 0;
} }
int CStdLibFileIO::Create(const wchar_t * pName) int CStdLibFileIO::Create(const char* pName)
{ {
Close(); Close();
@@ -29,13 +29,13 @@ public:
int SetEOF(); int SetEOF();
// creation / destruction // creation / destruction
int Create(const wchar_t * pName); int Create(const char* pName);
int Delete(); int Delete();
// attributes // attributes
int GetPosition(); int GetPosition();
int GetSize(); int GetSize();
int GetName(wchar_t * pBuffer); int GetName(char* pBuffer);
int GetHandle(); int GetHandle();
private: private:
@@ -54,11 +54,6 @@ const uint32 RANGE_WIDTH_2[64] = {19578u,16582u,12257u,7906u,4576u,2366u,1170u,
#define MODEL_ELEMENTS 64 #define MODEL_ELEMENTS 64
#if __GNUC__ != 2
using std::min;
using std::max;
#endif
CUnBitArray::CUnBitArray(CIO * pIO, int nVersion) CUnBitArray::CUnBitArray(CIO * pIO, int nVersion)
{ {
@@ -32,7 +32,7 @@ struct RIFF_CHUNK_HEADER
}; };
CInputSource * __stdcall CreateInputSource(const wchar_t * pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode) CInputSource * __stdcall CreateInputSource(const char* pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode)
{ {
// error check the parameters // error check the parameters
if ((pSourceName == NULL) || (wcslen(pSourceName) == 0)) if ((pSourceName == NULL) || (wcslen(pSourceName) == 0))
@@ -42,7 +42,7 @@ CInputSource * __stdcall CreateInputSource(const wchar_t * pSourceName, WAVEFORM
} }
// get the extension // get the extension
const wchar_t * pExtension = &pSourceName[wcslen(pSourceName)]; const char* pExtension = &pSourceName[wcslen(pSourceName)];
while ((pExtension > pSourceName) && (*pExtension != '.')) while ((pExtension > pSourceName) && (*pExtension != '.'))
pExtension--; pExtension--;
@@ -89,7 +89,7 @@ CWAVInputSource::CWAVInputSource(CIO * pIO, WAVEFORMATEX * pwfeSource, int * pTo
if (pErrorCode) *pErrorCode = nRetVal; if (pErrorCode) *pErrorCode = nRetVal;
} }
CWAVInputSource::CWAVInputSource(const wchar_t * pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode) CWAVInputSource::CWAVInputSource(const char* pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode)
: CInputSource(pSourceName, pwfeSource, pTotalBlocks, pHeaderBytes, pTerminatingBytes, pErrorCode) : CInputSource(pSourceName, pwfeSource, pTotalBlocks, pHeaderBytes, pTerminatingBytes, pErrorCode)
{ {
m_bIsValid = FALSE; m_bIsValid = FALSE;
@@ -15,7 +15,7 @@ public:
// construction / destruction // construction / destruction
CInputSource(CIO * pIO, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL) { } CInputSource(CIO * pIO, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL) { }
CInputSource(const wchar_t * pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL) { } CInputSource(const char* pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL) { }
virtual ~CInputSource() { } virtual ~CInputSource() { }
// get data // get data
@@ -35,7 +35,7 @@ public:
// construction / destruction // construction / destruction
CWAVInputSource(CIO * pIO, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL); CWAVInputSource(CIO * pIO, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL);
CWAVInputSource(const wchar_t * pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL); CWAVInputSource(const char* pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL);
~CWAVInputSource(); ~CWAVInputSource();
// get data // get data
@@ -63,7 +63,7 @@ private:
Input souce creation Input souce creation
*************************************************************************************/ *************************************************************************************/
extern "C" { // SHINTA: export extern "C" { // SHINTA: export
DLLEXPORT CInputSource* __stdcall CreateInputSource(const wchar_t * pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL); DLLEXPORT CInputSource* __stdcall CreateInputSource(const char* pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL);
} }
#endif // #ifndef APE_WAVINPUTSOURCE_H #endif // #ifndef APE_WAVINPUTSOURCE_H