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::CheckArchive(const wxString & _szArcName, int * _nFileCount)
\r
105 if (! this->lib.HasSymbol(wxT("CheckArchive")))
\r
109 void * p = this->lib.GetSymbol(wxT("CheckArchive"));
\r
115 return ((int (__stdcall *)(const wxString &, int *)) p)(_szArcName, _nFileCount);
\r
118 int TPIHandle::OpenArchive(const wxString & _szArcName, void * * _hArchive)
\r
120 if (! this->lib.HasSymbol(wxT("OpenArchive")))
\r
124 void * p = this->lib.GetSymbol(wxT("OpenArchive"));
\r
130 return ((int (__stdcall *)(const wxString &, void * *)) p)(_szArcName, _hArchive);
\r
133 int TPIHandle::CloseArchive(void * _hArchive)
\r
135 if (! this->lib.HasSymbol(wxT("CloseArchive")))
\r
139 void * p = this->lib.GetSymbol(wxT("CloseArchive"));
\r
145 return ((int (__stdcall *)(void *)) p)(_hArchive);
\r
148 int TPIHandle::GetFileInformation(void * _hArchive, TPI_FILEINFO * _fiInfo, bool _bFirst)
\r
150 if (! this->lib.HasSymbol(wxT("GetFileInformation")) || ! _fiInfo)
\r
154 void * p = this->lib.GetSymbol(wxT("GetFileInformation"));
\r
161 _fiInfo->dwAttribute = 0;
\r
162 _fiInfo->dwCRC32 = 0;
\r
163 _fiInfo->tmAccess = 0;
\r
164 _fiInfo->tmCreate = 0;
\r
165 _fiInfo->tmModified = 0;
\r
166 _fiInfo->uDanger = 0;
\r
167 _fiInfo->uOSType = 0;
\r
168 _fiInfo->llPackedSize = 0;
\r
169 _fiInfo->llUnpackedSize = 0;
\r
170 _fiInfo->szStoredName = wxEmptyString;
\r
171 _fiInfo->szMethod = wxEmptyString;
\r
172 _fiInfo->wCompressRatio = 0;
\r
173 _fiInfo->llFileID = 0;
\r
174 _fiInfo->pCustomInfo = NULL;
\r
176 return ((int (__stdcall *)(void *, TPI_FILEINFO *, bool)) p)(_hArchive, _fiInfo, _bFirst);
\r
179 int TPIHandle::GetArchiveInformation(void * _hArchive, TPI_ARCHIVEINFO * _aiInfo)
\r
181 if (! this->lib.HasSymbol(wxT("GetArchiveInformation")) || ! _aiInfo)
\r
185 void * p = this->lib.GetSymbol(wxT("GetArchiveInformation"));
\r
192 _aiInfo->fSolid = false;
\r
193 _aiInfo->fMMOptimize = false;
\r
194 _aiInfo->fEncryptData = false;
\r
195 _aiInfo->fEncryptHeader = false;
\r
196 _aiInfo->sCompressLevel = 0;
\r
197 _aiInfo->sRecoveryRecord= 0;
\r
198 _aiInfo->tmAccess = 0;
\r
199 _aiInfo->tmCreate = 0;
\r
200 _aiInfo->tmModified = 0;
\r
201 _aiInfo->nSFXType = 0;
\r
202 _aiInfo->uOSType = 0;
\r
203 _aiInfo->llFileSize = 0;
\r
204 _aiInfo->llPackedSize = 0;
\r
205 _aiInfo->llReadSize = 0;
\r
206 _aiInfo->llUnpackedSize = 0;
\r
207 _aiInfo->llSplitSize = 0;
\r
208 _aiInfo->szComment = wxEmptyString;
\r
209 _aiInfo->wCompressRatio = 0;
\r
210 _aiInfo->pCustomInfo = NULL;
\r
212 return ((int (__stdcall *)(void *, TPI_ARCHIVEINFO *)) p)(_hArchive, _aiInfo);
\r
215 int TPIHandle::Command(unsigned int _uCommand, TPI_SWITCHES * _swInfo, const wxString & _szArcName, const wxArrayString & _szFiles)
\r
217 if (! this->lib.HasSymbol(wxT("Command")))
\r
221 void * p = this->lib.GetSymbol(wxT("Command"));
\r
227 return ((int (__stdcall *)(unsigned int, TPI_SWITCHES *, const wxString &, const wxArrayString &)) p)(_uCommand, _swInfo, _szArcName, _szFiles);
\r
230 int TPIHandle::SetCallbackProc(TPI_PROC _prProc)
\r
232 if (! this->lib.HasSymbol(wxT("SetCallbackProc")))
\r
236 void * p = this->lib.GetSymbol(wxT("SetCallbackProc"));
\r
242 return ((int (__stdcall *)(TPI_PROC)) p)(_prProc);
\r