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;
}
//------------------------------------------------------------------------------
int TPositionBridgeIO::Create(const wchar_t* oName)
int TPositionBridgeIO::Create(const char* oName)
{
return B_OK;
}
@@ -42,7 +42,7 @@ int TPositionBridgeIO::Delete()
return B_ERROR;
}
//------------------------------------------------------------------------------
int TPositionBridgeIO::GetName(wchar_t* oBuffer)
int TPositionBridgeIO::GetName(char* oBuffer)
{
strcpy(oBuffer, "<TPositionBridgeIO>");
return B_OK;
@@ -68,7 +68,7 @@ int TPositionBridgeIO::GetSize()
return aSize;
}
//------------------------------------------------------------------------------
int TPositionBridgeIO::Open(const wchar_t* oName)
int TPositionBridgeIO::Open(const char* oName)
{
return B_OK;
}
@@ -16,7 +16,7 @@ public:
TPositionBridgeIO();
virtual ~TPositionBridgeIO();
virtual int Open(const wchar_t* oName);
virtual int Open(const char* oName);
virtual int Close();
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 Create(const wchar_t* oName);
virtual int Create(const char* oName);
virtual int Delete();
virtual int SetEOF();
virtual int GetPosition();
virtual int GetSize();
virtual int GetName(wchar_t* oBuffer);
virtual int GetName(char* oBuffer);
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_bOwnsOutputIO = TRUE;
@@ -15,7 +15,7 @@ public:
~CAPECompress();
// 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);
// add data / compress data
@@ -9,11 +9,6 @@
#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)
{
*pErrorCode = ERROR_SUCCESS;
@@ -11,7 +11,7 @@ CAPEInfo:
/*****************************************************************************************
Construction
*****************************************************************************************/
CAPEInfo::CAPEInfo(int * pErrorCode, const wchar_t * pFilename, CAPETag * pTag)
CAPEInfo::CAPEInfo(int * pErrorCode, const char* pFilename, CAPETag * pTag)
{
*pErrorCode = ERROR_SUCCESS;
CloseFile();
@@ -77,7 +77,7 @@ class CAPEInfo
public:
// 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);
virtual ~CAPEInfo();
@@ -15,7 +15,7 @@ public:
BOOL GetIsLinkFile();
int GetStartBlock();
int GetFinishBlock();
const wchar_t * GetImageFilename();
const char* GetImageFilename();
protected:
@@ -17,11 +17,6 @@
#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);
/*****************************************************************************************
@@ -7,11 +7,6 @@
#include "IO.h"
#include IO_HEADER_FILE
#if __GNUC__ != 2
using std::min;
using std::max;
#endif
/*****************************************************************************************
CAPETagField
*****************************************************************************************/
@@ -42,6 +42,12 @@ Global includes
#include <string.h>
#include "SmartPtr.h"
#if __GNUC__ != 2
#include <algorithm>
using std::min;
using std::max;
#endif
/*****************************************************************************************
Global compiler settings (useful for porting)
*****************************************************************************************/
@@ -98,7 +98,7 @@ int CBitArray::OutputBitArray(BOOL bFinalize)
m_nCurrentBitIndex = (m_nCurrentBitIndex & 31);
// 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
@@ -72,7 +72,7 @@ int WriteSafe(CIO * pIO, void * pBuffer, int nBytes)
return nRetVal;
}
BOOL FileExists(wchar_t * pFilename)
BOOL FileExists(char* pFilename)
{
if (0 == wcscmp(pFilename, "-") || 0 == wcscmp(pFilename, "/dev/stdin"))
return TRUE;
@@ -16,6 +16,6 @@ int WriteSafe(CIO * pIO, void * pBuffer, int nBytes);
/*************************************************************************************
Checks for the existence of a file
*************************************************************************************/
BOOL FileExists(wchar_t * pFilename);
BOOL FileExists(char* pFilename);
#endif // #ifndef APE_GLOBALFUNCTIONS_H
@@ -23,7 +23,7 @@ public:
virtual ~CIO() { };
// open / close
virtual int Open(const wchar_t * pName) = 0;
virtual int Open(const char* pName) = 0;
virtual int Close() = 0;
// read / write
@@ -34,7 +34,7 @@ public:
virtual int Seek(int nDistance, unsigned int nMoveMode) = 0;
// creation / destruction
virtual int Create(const wchar_t * pName) = 0;
virtual int Create(const char* pName) = 0;
virtual int Delete() = 0;
// other functions
@@ -43,7 +43,7 @@ public:
// attributes
virtual int GetPosition() = 0;
virtual int GetSize() = 0;
virtual int GetName(wchar_t * pBuffer) = 0;
virtual int GetName(char* pBuffer) = 0;
};
#endif // #ifndef APE_IO_H
@@ -19,7 +19,7 @@
//typedef char int8;
typedef char str_ansi;
typedef unsigned char str_utf8;
typedef wchar_t str_utf16;
typedef char str_utf16;
typedef unsigned long DWORD;
typedef int BOOL;
@@ -31,8 +31,8 @@ typedef unsigned int UINT;
typedef unsigned int WPARAM;
typedef long LPARAM;
typedef const char * LPCSTR;
typedef const wchar_t * LPCTSTR; // ?? SHINTA
typedef const wchar_t * LPCWSTR; // ?? SHINTA
typedef const char* LPCTSTR; // ?? SHINTA
typedef const char* LPCWSTR; // ?? SHINTA
typedef char * LPSTR;
typedef long LRESULT;
typedef unsigned char UCHAR;
@@ -218,7 +218,7 @@ int CStdLibFileIO::GetName(char * pBuffer)
return 0;
}
int CStdLibFileIO::Create(const wchar_t * pName)
int CStdLibFileIO::Create(const char* pName)
{
Close();
@@ -29,13 +29,13 @@ public:
int SetEOF();
// creation / destruction
int Create(const wchar_t * pName);
int Create(const char* pName);
int Delete();
// attributes
int GetPosition();
int GetSize();
int GetName(wchar_t * pBuffer);
int GetName(char* pBuffer);
int GetHandle();
private:
@@ -54,11 +54,6 @@ const uint32 RANGE_WIDTH_2[64] = {19578u,16582u,12257u,7906u,4576u,2366u,1170u,
#define MODEL_ELEMENTS 64
#if __GNUC__ != 2
using std::min;
using std::max;
#endif
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
if ((pSourceName == NULL) || (wcslen(pSourceName) == 0))
@@ -42,7 +42,7 @@ CInputSource * __stdcall CreateInputSource(const wchar_t * pSourceName, WAVEFORM
}
// get the extension
const wchar_t * pExtension = &pSourceName[wcslen(pSourceName)];
const char* pExtension = &pSourceName[wcslen(pSourceName)];
while ((pExtension > pSourceName) && (*pExtension != '.'))
pExtension--;
@@ -89,7 +89,7 @@ CWAVInputSource::CWAVInputSource(CIO * pIO, WAVEFORMATEX * pwfeSource, int * pTo
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)
{
m_bIsValid = FALSE;
@@ -15,7 +15,7 @@ public:
// construction / destruction
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() { }
// get data
@@ -35,7 +35,7 @@ public:
// construction / destruction
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();
// get data
@@ -63,7 +63,7 @@ private:
Input souce creation
*************************************************************************************/
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