#include <wx/dynlib.h>\r
#include "TPIHandle.h"\r
\r
+#define GetAPIAddress(name, p) \\r
+ if (! this->lib.HasSymbol(wxT(name))) \\r
+ { \\r
+ return false; \\r
+ } \\r
+ void * p = this->lib.GetSymbol(wxT(name)); \\r
+ if (! p) \\r
+ { \\r
+ return false; \\r
+ }\r
+\r
//******************************************************************************\r
// Class (TPIHandle)\r
//******************************************************************************\r
\r
+TPIHandle::TPIHandle(void)\r
+{\r
+ this->nErrorCode = TPI_ERROR_SUCCESS;\r
+}\r
+\r
TPIHandle::~TPIHandle(void)\r
{\r
this->FreeLibrary();\r
\r
bool TPIHandle::InitLibrary(const wxString & _szLibName, const wxString & _szArcName, wxULongLong _llSubOption)\r
{\r
+ this->nErrorCode = TPI_ERROR_SUCCESS;\r
this->lib.Load(_szLibName);\r
if (! this->lib.IsLoaded())\r
{\r
return true;\r
}\r
\r
- if (! this->lib.HasSymbol(wxT("LoadPlugin")))\r
- {\r
- return false;\r
- }\r
- void * p = this->lib.GetSymbol(wxT("LoadPlugin"));\r
- if (! p)\r
- {\r
- return false;\r
- }\r
-\r
- return ((int (__stdcall *)(const wxString &, wxULongLong)) p)(_szArcName, _llSubOption) == TPI_ERROR_SUCCESS;\r
+ GetAPIAddress("LoadPlugin", p);\r
+ this->nErrorCode = ((int (__stdcall *)(const wxString &, wxULongLong)) p)(_szArcName, _llSubOption);\r
+ return this->nErrorCode == TPI_ERROR_SUCCESS;\r
}\r
\r
bool TPIHandle::FreeLibrary(void)\r
{\r
+ this->nErrorCode = TPI_ERROR_SUCCESS;\r
if (! this->lib.IsLoaded())\r
{\r
return false;\r
}\r
\r
- if (! this->lib.HasSymbol(wxT("FreePlugin")))\r
- {\r
- return false;\r
- }\r
- void * p = this->lib.GetSymbol(wxT("FreePlugin"));\r
- if (! p)\r
- {\r
- return false;\r
- }\r
- ((int (__stdcall *)(void *)) p)(NULL);\r
+ GetAPIAddress("FreePlugin", p);\r
+ this->nErrorCode = ((int (__stdcall *)(void *)) p)(NULL);\r
\r
this->lib.Unload();\r
- return true;\r
+ return this->nErrorCode == TPI_ERROR_SUCCESS;\r
}\r
\r
-int TPIHandle::GetPluginInformation(unsigned int _uInfoId, wxULongLong _llSubOption, void * _pPtr)\r
+bool TPIHandle::GetPluginInformation(unsigned int _uInfoId, wxULongLong _llSubOption, void * _pPtr)\r
{\r
- if (! this->lib.HasSymbol(wxT("GetPluginInformation")))\r
- {\r
- return -1;\r
- }\r
- void * p = this->lib.GetSymbol(wxT("GetPluginInformation"));\r
- if (! p)\r
- {\r
- return -1;\r
- }\r
-\r
- return ((int (__stdcall *)(unsigned int, wxULongLong, void *)) p)(_uInfoId, _llSubOption, _pPtr);\r
+ this->nErrorCode = TPI_ERROR_SUCCESS;\r
+ GetAPIAddress("GetPluginInformation", p);\r
+ this->nErrorCode = ((int (__stdcall *)(unsigned int, wxULongLong, void *)) p)(_uInfoId, _llSubOption, _pPtr);\r
+ return this->nErrorCode == TPI_ERROR_SUCCESS;\r
}\r
\r
-int TPIHandle::CheckArchive(const wxString & _szArcName, int * _nFileCount)\r
+bool TPIHandle::GetFormatInformation(TPI_FORMATINFO * _fiInfo, bool _bFirst)\r
{\r
- if (! this->lib.HasSymbol(wxT("CheckArchive")))\r
- {\r
- return -1;\r
- }\r
- void * p = this->lib.GetSymbol(wxT("CheckArchive"));\r
- if (! p)\r
+ this->nErrorCode = TPI_ERROR_SUCCESS;\r
+ if (! _fiInfo)\r
{\r
- return -1;\r
+ return false;\r
}\r
\r
- return ((int (__stdcall *)(const wxString &, int *)) p)(_szArcName, _nFileCount);\r
+ // Initialization.\r
+ _fiInfo->fComment = false;\r
+ _fiInfo->fEncryptKeyFile = false;\r
+ _fiInfo->fEncryptPassword = false;\r
+ _fiInfo->fEncryptHeader = false;\r
+ _fiInfo->fMMOptimize = false;\r
+ _fiInfo->fMultiVolume = false;\r
+ _fiInfo->fSolid = false;\r
+ _fiInfo->sCompressLevelMin = 0;\r
+ _fiInfo->sCompressLevelMax = 0;\r
+ _fiInfo->sRecoveryRecordMin = 0;\r
+ _fiInfo->sRecoveryRecordMax = 0;\r
+ _fiInfo->szTypeName = wxEmptyString;\r
+ _fiInfo->szSuffix = wxEmptyString;\r
+ _fiInfo->szEngineName = wxEmptyString;\r
+ _fiInfo->szTPIName = wxEmptyString;\r
+ _fiInfo->llSupportedCommand = 0;\r
+ _fiInfo->llTypeId = 0;\r
+ _fiInfo->pCustomInfo = NULL;\r
+\r
+ GetAPIAddress("GetFormatInformation", p);\r
+ this->nErrorCode = ((int (__stdcall *)(TPI_FORMATINFO *, bool)) p)(_fiInfo, _bFirst);\r
+ return this->nErrorCode == TPI_ERROR_SUCCESS;\r
}\r
\r
-int TPIHandle::OpenArchive(const wxString & _szArcName)\r
+bool TPIHandle::CheckArchive(const wxString & _szArcName, int * _nFileCount)\r
{\r
- if (! this->lib.HasSymbol(wxT("OpenArchive")))\r
- {\r
- return -1;\r
- }\r
- void * p = this->lib.GetSymbol(wxT("OpenArchive"));\r
- if (! p)\r
- {\r
- return -1;\r
- }\r
-\r
- return ((int (__stdcall *)(const wxString &, void * *)) p)(_szArcName, & this->archive);\r
+ this->nErrorCode = TPI_ERROR_SUCCESS;\r
+ GetAPIAddress("CheckArchive", p);\r
+ this->nErrorCode = ((int (__stdcall *)(const wxString &, int *)) p)(_szArcName, _nFileCount);\r
+ return this->nErrorCode == TPI_ERROR_SUCCESS;\r
}\r
\r
-int TPIHandle::CloseArchive(void)\r
+bool TPIHandle::OpenArchive(const wxString & _szArcName)\r
{\r
- if (! this->lib.HasSymbol(wxT("CloseArchive")))\r
- {\r
- return -1;\r
- }\r
- void * p = this->lib.GetSymbol(wxT("CloseArchive"));\r
- if (! p)\r
- {\r
- return -1;\r
- }\r
+ this->nErrorCode = TPI_ERROR_SUCCESS;\r
+ GetAPIAddress("OpenArchive", p);\r
+ this->nErrorCode = ((int (__stdcall *)(const wxString &, void * *)) p)(_szArcName, & this->archive);\r
+ return this->nErrorCode == TPI_ERROR_SUCCESS;\r
+}\r
\r
- return ((int (__stdcall *)(void *)) p)(this->archive);\r
+bool TPIHandle::CloseArchive(void)\r
+{\r
+ this->nErrorCode = TPI_ERROR_SUCCESS;\r
+ GetAPIAddress("CloseArchive", p);\r
+ this->nErrorCode = ((int (__stdcall *)(void *)) p)(this->archive);\r
+ return this->nErrorCode == TPI_ERROR_SUCCESS;\r
}\r
\r
-int TPIHandle::GetFileInformation(TPI_FILEINFO * _fiInfo, bool _bFirst)\r
+bool TPIHandle::GetFileInformation(TPI_FILEINFO * _fiInfo, bool _bFirst)\r
{\r
- if (! this->lib.HasSymbol(wxT("GetFileInformation")) || ! _fiInfo)\r
+ this->nErrorCode = TPI_ERROR_SUCCESS;\r
+ if (! _fiInfo)\r
{\r
- return -1;\r
- }\r
- void * p = this->lib.GetSymbol(wxT("GetFileInformation"));\r
- if (! p)\r
- {\r
- return -1;\r
+ return false;\r
}\r
\r
// Initialization.\r
_fiInfo->llFileID = 0;\r
_fiInfo->pCustomInfo = NULL;\r
\r
- return ((int (__stdcall *)(void *, TPI_FILEINFO *, bool)) p)(this->archive, _fiInfo, _bFirst);\r
+ GetAPIAddress("GetFileInformation", p);\r
+ this->nErrorCode = ((int (__stdcall *)(void *, TPI_FILEINFO *, bool)) p)(this->archive, _fiInfo, _bFirst);\r
+ return this->nErrorCode == TPI_ERROR_SUCCESS;\r
}\r
\r
-int TPIHandle::GetArchiveInformation(TPI_ARCHIVEINFO * _aiInfo)\r
+bool TPIHandle::GetArchiveInformation(TPI_ARCHIVEINFO * _aiInfo)\r
{\r
- if (! this->lib.HasSymbol(wxT("GetArchiveInformation")) || ! _aiInfo)\r
+ this->nErrorCode = TPI_ERROR_SUCCESS;\r
+ if (! _aiInfo)\r
{\r
- return -1;\r
- }\r
- void * p = this->lib.GetSymbol(wxT("GetArchiveInformation"));\r
- if (! p)\r
- {\r
- return -1;\r
+ return false;\r
}\r
\r
// Initialization.\r
_aiInfo->szComment = wxEmptyString;\r
_aiInfo->wCompressRatio = 0;\r
_aiInfo->pCustomInfo = NULL;\r
-\r
- return ((int (__stdcall *)(void *, TPI_ARCHIVEINFO *)) p)(this->archive, _aiInfo);\r
+ // FORMATINFO\r
+ _aiInfo->fiInfo.fComment = false;\r
+ _aiInfo->fiInfo.fEncryptKeyFile = false;\r
+ _aiInfo->fiInfo.fEncryptPassword = false;\r
+ _aiInfo->fiInfo.fEncryptHeader = false;\r
+ _aiInfo->fiInfo.fMMOptimize = false;\r
+ _aiInfo->fiInfo.fMultiVolume = false;\r
+ _aiInfo->fiInfo.fSolid = false;\r
+ _aiInfo->fiInfo.sCompressLevelMin = 0;\r
+ _aiInfo->fiInfo.sCompressLevelMax = 0;\r
+ _aiInfo->fiInfo.sRecoveryRecordMin = 0;\r
+ _aiInfo->fiInfo.sRecoveryRecordMax = 0;\r
+ _aiInfo->fiInfo.szTypeName = wxEmptyString;\r
+ _aiInfo->fiInfo.szSuffix = wxEmptyString;\r
+ _aiInfo->fiInfo.szEngineName = wxEmptyString;\r
+ _aiInfo->fiInfo.szTPIName = wxEmptyString;\r
+ _aiInfo->fiInfo.llSupportedCommand = 0;\r
+ _aiInfo->fiInfo.llTypeId = 0;\r
+ _aiInfo->fiInfo.pCustomInfo = NULL;\r
+\r
+ GetAPIAddress("GetArchiveInformation", p);\r
+ this->nErrorCode = ((int (__stdcall *)(void *, TPI_ARCHIVEINFO *)) p)(this->archive, _aiInfo);\r
+ return this->nErrorCode == TPI_ERROR_SUCCESS;\r
}\r
\r
-int TPIHandle::Command(unsigned int _uCommand, TPI_SWITCHES * _swInfo, const wxString & _szArcName, const wxArrayString & _szFiles)\r
+bool TPIHandle::Command(unsigned int _uCommand, TPI_SWITCHES * _swInfo, const wxString & _szArcName, const wxArrayString & _szFiles)\r
{\r
- if (! this->lib.HasSymbol(wxT("Command")))\r
- {\r
- return -1;\r
- }\r
- void * p = this->lib.GetSymbol(wxT("Command"));\r
- if (! p)\r
- {\r
- return -1;\r
- }\r
-\r
- return ((int (__stdcall *)(unsigned int, TPI_SWITCHES *, const wxString &, const wxArrayString &)) p)(_uCommand, _swInfo, _szArcName, _szFiles);\r
+ this->nErrorCode = TPI_ERROR_SUCCESS;\r
+ GetAPIAddress("Command", p);\r
+ this->nErrorCode = ((int (__stdcall *)(unsigned int, TPI_SWITCHES *, const wxString &, const wxArrayString &)) p)(_uCommand, _swInfo, _szArcName, _szFiles);\r
+ return this->nErrorCode == TPI_ERROR_SUCCESS;\r
}\r
\r
-int TPIHandle::SetCallbackProc(TPI_PROC _prProc)\r
+bool TPIHandle::SetCallbackProc(TPI_PROC _prProc)\r
{\r
- if (! this->lib.HasSymbol(wxT("SetCallbackProc")))\r
- {\r
- return -1;\r
- }\r
- void * p = this->lib.GetSymbol(wxT("SetCallbackProc"));\r
- if (! p)\r
- {\r
- return -1;\r
- }\r
-\r
- return ((int (__stdcall *)(TPI_PROC)) p)(_prProc);\r
+ this->nErrorCode = TPI_ERROR_SUCCESS;\r
+ GetAPIAddress("SetCallbackProc", p);\r
+ this->nErrorCode = ((int (__stdcall *)(TPI_PROC)) p)(_prProc);\r
+ return this->nErrorCode == TPI_ERROR_SUCCESS;\r
}\r