1 /*******************************************************************************
\r
2 TPI - flexible but useless plug-in framework.
\r
3 Copyright (C) 2002-2009 Silky
\r
5 This library is free software; you can redistribute it and/or modify it under
\r
6 the terms of the GNU Lesser General Public License as published by the Free
\r
7 Software Foundation; either version 2.1 of the License, or (at your option)
\r
10 This library is distributed in the hope that it will be useful, but WITHOUT
\r
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
\r
15 You should have received a copy of the GNU Lesser General Public License along
\r
16 with this library; if not, write to the Free Software Foundation, Inc.,
\r
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
\r
19 $Id: TPIHandle.cpp,v 1.5 2009/08/28 12:41:29 sirakaba Exp $
\r
20 *******************************************************************************/
\r
22 //******************************************************************************
\r
24 //******************************************************************************
\r
26 #define wxUSE_DYNLIB_CLASS 1
\r
27 #include "../header/plugin.h"
\r
28 #include <wx/dynlib.h>
\r
29 #include "TPIHandle.h"
\r
31 //******************************************************************************
\r
32 // Class (TPIHandle)
\r
33 //******************************************************************************
\r
35 TPIHandle::~TPIHandle(void)
\r
37 this->FreeLibrary();
\r
40 bool TPIHandle::InitLibrary(const wxString & _szLibName, const wxString & _szArcName, wxULongLong _llSubOption)
\r
42 this->lib.Load(_szLibName);
\r
43 if (! this->lib.IsLoaded())
\r
48 if (_szArcName.IsEmpty())
\r
53 if (! this->lib.HasSymbol(wxT("LoadPlugin")))
\r
57 void * p = this->lib.GetSymbol(wxT("LoadPlugin"));
\r
63 return ((int (__stdcall *)(const wxString &, wxULongLong)) p)(_szArcName, _llSubOption) == TPI_ERROR_SUCCESS;
\r
66 bool TPIHandle::FreeLibrary(void)
\r
68 if (! this->lib.IsLoaded())
\r
73 if (! this->lib.HasSymbol(wxT("FreePlugin")))
\r
77 void * p = this->lib.GetSymbol(wxT("FreePlugin"));
\r
82 ((int (__stdcall *)(void *)) p)(NULL);
\r
88 int TPIHandle::GetPluginInformation(unsigned int _uInfoId, wxULongLong _llSubOption, void * _pPtr)
\r
90 if (! this->lib.HasSymbol(wxT("GetPluginInformation")))
\r
94 void * p = this->lib.GetSymbol(wxT("GetPluginInformation"));
\r
100 return ((int (__stdcall *)(unsigned int, wxULongLong, void *)) p)(_uInfoId, _llSubOption, _pPtr);
\r
103 int TPIHandle::GetFormatInformation(TPI_FORMATINFO * _fiInfo, bool _bFirst)
\r
105 if (! this->lib.HasSymbol(wxT("GetFormatInformation")) || ! _fiInfo)
\r
109 void * p = this->lib.GetSymbol(wxT("GetFormatInformation"));
\r
116 _fiInfo->fComment = false;
\r
117 _fiInfo->fEncryptKeyFile = false;
\r
118 _fiInfo->fEncryptPassword = false;
\r
119 _fiInfo->fEncryptHeader = false;
\r
120 _fiInfo->fMMOptimize = false;
\r
121 _fiInfo->fMultiVolume = false;
\r
122 _fiInfo->fSolid = false;
\r
123 _fiInfo->sCompressLevelMin = 0;
\r
124 _fiInfo->sCompressLevelMax = 0;
\r
125 _fiInfo->sRecoveryRecordMin = 0;
\r
126 _fiInfo->sRecoveryRecordMax = 0;
\r
127 _fiInfo->szTypeName = wxEmptyString;
\r
128 _fiInfo->szSuffix = wxEmptyString;
\r
129 _fiInfo->szEngineName = wxEmptyString;
\r
130 _fiInfo->szTPIName = wxEmptyString;
\r
131 _fiInfo->llSupportedCommand = 0;
\r
132 _fiInfo->llTypeId = 0;
\r
133 _fiInfo->pCustomInfo = NULL;
\r
135 return ((int (__stdcall *)(TPI_FORMATINFO *, bool)) p)(_fiInfo, _bFirst);
\r
138 int TPIHandle::CheckArchive(const wxString & _szArcName, int * _nFileCount)
\r
140 if (! this->lib.HasSymbol(wxT("CheckArchive")))
\r
144 void * p = this->lib.GetSymbol(wxT("CheckArchive"));
\r
150 return ((int (__stdcall *)(const wxString &, int *)) p)(_szArcName, _nFileCount);
\r
153 int TPIHandle::OpenArchive(const wxString & _szArcName)
\r
155 if (! this->lib.HasSymbol(wxT("OpenArchive")))
\r
159 void * p = this->lib.GetSymbol(wxT("OpenArchive"));
\r
165 return ((int (__stdcall *)(const wxString &, void * *)) p)(_szArcName, & this->archive);
\r
168 int TPIHandle::CloseArchive(void)
\r
170 if (! this->lib.HasSymbol(wxT("CloseArchive")))
\r
174 void * p = this->lib.GetSymbol(wxT("CloseArchive"));
\r
180 return ((int (__stdcall *)(void *)) p)(this->archive);
\r
183 int TPIHandle::GetFileInformation(TPI_FILEINFO * _fiInfo, bool _bFirst)
\r
185 if (! this->lib.HasSymbol(wxT("GetFileInformation")) || ! _fiInfo)
\r
189 void * p = this->lib.GetSymbol(wxT("GetFileInformation"));
\r
196 _fiInfo->dwAttribute = 0;
\r
197 _fiInfo->dwCRC32 = 0;
\r
198 _fiInfo->tmAccess = 0;
\r
199 _fiInfo->tmCreate = 0;
\r
200 _fiInfo->tmModified = 0;
\r
201 _fiInfo->uDanger = 0;
\r
202 _fiInfo->uOSType = 0;
\r
203 _fiInfo->llPackedSize = 0;
\r
204 _fiInfo->llUnpackedSize = 0;
\r
205 _fiInfo->szStoredName = wxEmptyString;
\r
206 _fiInfo->szMethod = wxEmptyString;
\r
207 _fiInfo->wCompressRatio = 0;
\r
208 _fiInfo->llFileID = 0;
\r
209 _fiInfo->pCustomInfo = NULL;
\r
211 return ((int (__stdcall *)(void *, TPI_FILEINFO *, bool)) p)(this->archive, _fiInfo, _bFirst);
\r
214 int TPIHandle::GetArchiveInformation(TPI_ARCHIVEINFO * _aiInfo)
\r
216 if (! this->lib.HasSymbol(wxT("GetArchiveInformation")) || ! _aiInfo)
\r
220 void * p = this->lib.GetSymbol(wxT("GetArchiveInformation"));
\r
227 _aiInfo->fSolid = false;
\r
228 _aiInfo->fMMOptimize = false;
\r
229 _aiInfo->fEncryptData = false;
\r
230 _aiInfo->fEncryptHeader = false;
\r
231 _aiInfo->sCompressLevel = 0;
\r
232 _aiInfo->sRecoveryRecord= 0;
\r
233 _aiInfo->tmAccess = 0;
\r
234 _aiInfo->tmCreate = 0;
\r
235 _aiInfo->tmModified = 0;
\r
236 _aiInfo->nSFXType = 0;
\r
237 _aiInfo->uOSType = 0;
\r
238 _aiInfo->llFileSize = 0;
\r
239 _aiInfo->llPackedSize = 0;
\r
240 _aiInfo->llReadSize = 0;
\r
241 _aiInfo->llUnpackedSize = 0;
\r
242 _aiInfo->llSplitSize = 0;
\r
243 _aiInfo->szComment = wxEmptyString;
\r
244 _aiInfo->wCompressRatio = 0;
\r
245 _aiInfo->pCustomInfo = NULL;
\r
247 _aiInfo->fiInfo.fComment = false;
\r
248 _aiInfo->fiInfo.fEncryptKeyFile = false;
\r
249 _aiInfo->fiInfo.fEncryptPassword = false;
\r
250 _aiInfo->fiInfo.fEncryptHeader = false;
\r
251 _aiInfo->fiInfo.fMMOptimize = false;
\r
252 _aiInfo->fiInfo.fMultiVolume = false;
\r
253 _aiInfo->fiInfo.fSolid = false;
\r
254 _aiInfo->fiInfo.sCompressLevelMin = 0;
\r
255 _aiInfo->fiInfo.sCompressLevelMax = 0;
\r
256 _aiInfo->fiInfo.sRecoveryRecordMin = 0;
\r
257 _aiInfo->fiInfo.sRecoveryRecordMax = 0;
\r
258 _aiInfo->fiInfo.szTypeName = wxEmptyString;
\r
259 _aiInfo->fiInfo.szSuffix = wxEmptyString;
\r
260 _aiInfo->fiInfo.szEngineName = wxEmptyString;
\r
261 _aiInfo->fiInfo.szTPIName = wxEmptyString;
\r
262 _aiInfo->fiInfo.llSupportedCommand = 0;
\r
263 _aiInfo->fiInfo.llTypeId = 0;
\r
264 _aiInfo->fiInfo.pCustomInfo = NULL;
\r
266 return ((int (__stdcall *)(void *, TPI_ARCHIVEINFO *)) p)(this->archive, _aiInfo);
\r
269 int TPIHandle::Command(unsigned int _uCommand, TPI_SWITCHES * _swInfo, const wxString & _szArcName, const wxArrayString & _szFiles)
\r
271 if (! this->lib.HasSymbol(wxT("Command")))
\r
275 void * p = this->lib.GetSymbol(wxT("Command"));
\r
281 return ((int (__stdcall *)(unsigned int, TPI_SWITCHES *, const wxString &, const wxArrayString &)) p)(_uCommand, _swInfo, _szArcName, _szFiles);
\r
284 int TPIHandle::SetCallbackProc(TPI_PROC _prProc)
\r
286 if (! this->lib.HasSymbol(wxT("SetCallbackProc")))
\r
290 void * p = this->lib.GetSymbol(wxT("SetCallbackProc"));
\r
296 return ((int (__stdcall *)(TPI_PROC)) p)(_prProc);
\r