--- /dev/null
+/*******************************************************************************\r
+ TPI - flexible but useless plug-in framework.\r
+ Copyright (C) 2002-2009 Silky\r
+\r
+ This library is free software; you can redistribute it and/or modify it under\r
+ the terms of the GNU Lesser General Public License as published by the Free\r
+ Software Foundation; either version 2.1 of the License, or (at your option)\r
+ any later version.\r
+\r
+ This library is distributed in the hope that it will be useful, but WITHOUT\r
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or \r
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License\r
+ for more details.\r
+\r
+ You should have received a copy of the GNU Lesser General Public License along\r
+ with this library; if not, write to the Free Software Foundation, Inc.,\r
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
+\r
+ $Id: library.cpp 371 2010-10-02 03:17:45Z sirakaba $\r
+*******************************************************************************/\r
+\r
+//******************************************************************************\r
+// Includes\r
+//******************************************************************************\r
+\r
+#include "xmldoc.h"\r
+\r
+//******************************************************************************\r
+// XML処理関数\r
+//******************************************************************************\r
+\r
+bool myIsLib(wxXmlNode * n)\r
+{\r
+ return (\r
+ n->GetName() == wxT("library")\r
+ && ! myGetAttributeBool(n, wxT("disable"))\r
+#ifdef __WINDOWS__\r
+ && ! myGetAttributeBool(n, wxT("disable-win"))\r
+#else\r
+ && ! myGetAttributeBool(n, wxT("disable-lin"))\r
+#endif\r
+ );\r
+}\r
+\r
+wxXmlNode * myGetFirstLib(wxXmlDocument * xmlDoc, int nLibIndex)\r
+{\r
+ if (! xmlDoc->IsOk())\r
+ {\r
+ return NULL;\r
+ }\r
+ wxXmlNode * n = xmlDoc->GetRoot()->GetChildren();\r
+ return (n == NULL || myIsLib(n)) ? (nLibIndex <= 0 ? n : myGetNextLib(n, nLibIndex - 1)) : myGetNextLib(n, nLibIndex);\r
+}\r
+\r
+wxXmlNode * myGetNextLib(wxXmlNode * n, int nLibIndex)\r
+{\r
+ n = n->GetNext();\r
+ return (n == NULL || myIsLib(n)) ? (nLibIndex <= 0 ? n : myGetNextLib(n, nLibIndex - 1)) : myGetNextLib(n, nLibIndex);\r
+}\r
+\r
+long myGetAttributeInt(wxXmlNode * n, const wxString & szValue, long nDefaultValue)\r
+{\r
+ long l;\r
+ n->GetAttribute(szValue, wxString::Format(wxT("%d"), nDefaultValue)).ToLong(& l, 16);\r
+ return l;\r
+}\r
+\r
+bool myGetAttributeBool(wxXmlNode * n, const wxString & szValue, bool bDefaultValue)\r
+{\r
+ return myGetAttributeInt(n, szValue, bDefaultValue ? 1 : 0) != 0;\r
+}\r
+\r
+#define CheckSupportedCommand(attr, value) if (n->HasAttribute(wxT(attr)) || n->HasAttribute(wxT(attr) wxT("-alt"))) _fiInfo->eSupportedCommand |= value\r
+#define CheckSupportedSwitch(var, value) value = szCmdLine.Find(wxT(var)) != wxNOT_FOUND\r
+\r
+void MakeFormatInfo(wxXmlNode * n, const wxString & szTPIName, TPI_FORMATINFO * _fiInfo, wxULongLong_t nId)\r
+{\r
+ _fiInfo->fArchive = myGetAttributeBool(n, wxT("archive"), true);\r
+ _fiInfo->szTypeName = n->GetAttribute(wxT("typename"), wxEmptyString);\r
+ _fiInfo->szSuffix = n->GetAttribute(wxT("suffix"), wxEmptyString);\r
+ _fiInfo->szEngineName = n->GetAttribute(wxT("name"), wxEmptyString);\r
+ _fiInfo->szTPIName = szTPIName;\r
+ _fiInfo->nTypeId = nId;\r
+\r
+ // 対応コマンドを調査。\r
+ CheckSupportedCommand("create", TPI_COMMAND_CREATE);\r
+ CheckSupportedCommand("add", TPI_COMMAND_ADD);\r
+ CheckSupportedCommand("extract",TPI_COMMAND_EXTRACT);\r
+ CheckSupportedCommand("delete", TPI_COMMAND_DELETE);\r
+ CheckSupportedCommand("update", TPI_COMMAND_UPDATE);\r
+ CheckSupportedCommand("test", TPI_COMMAND_TEST);\r
+ CheckSupportedCommand("repair", TPI_COMMAND_REPAIR);\r
+ CheckSupportedCommand("move", TPI_COMMAND_MOVE);\r
+ CheckSupportedCommand("sfx", TPI_COMMAND_SFX);\r
+ CheckSupportedCommand("unsfx", TPI_COMMAND_UNSFX);\r
+\r
+ // 対応スイッチを調査。\r
+ wxString szCmdLine =\r
+ n->HasAttribute(wxT("create")) ? n->GetAttribute(wxT("create"), wxEmptyString) :\r
+ n->HasAttribute(wxT("create-alt")) ? n->GetAttribute(wxT("create-alt"), wxEmptyString) :\r
+ n->HasAttribute(wxT("extract")) ? n->GetAttribute(wxT("extract"), wxEmptyString) :\r
+ n->HasAttribute(wxT("extract-alt")) ? n->GetAttribute(wxT("extract-alt"), wxEmptyString) :\r
+ (wxString) wxEmptyString;\r
+ CheckSupportedSwitch("96", _fiInfo->fComment);\r
+ CheckSupportedSwitch("a1", _fiInfo->fSFX);\r
+ CheckSupportedSwitch("a2", _fiInfo->fSolid);\r
+ CheckSupportedSwitch("a3", _fiInfo->fMMOptimize);\r
+ CheckSupportedSwitch("a4", _fiInfo->fEncryptHeader);\r
+ CheckSupportedSwitch("a5", _fiInfo->fEncryptPassword);\r
+ CheckSupportedSwitch("a6", _fiInfo->fEncryptKeyFile);\r
+ CheckSupportedSwitch("a7", _fiInfo->fMultiVolume);\r
+ CheckSupportedSwitch("a8", _fiInfo->fCompressHeader);\r
+\r
+ _fiInfo->nCompressLevelMin = myGetAttributeInt(n, wxT("level-min"));\r
+ _fiInfo->nCompressLevelMax = myGetAttributeInt(n, wxT("level-max"));\r
+ _fiInfo->nRecoveryRecordMin = myGetAttributeInt(n, wxT("rr-min"));\r
+ _fiInfo->nRecoveryRecordMax = myGetAttributeInt(n, wxT("rr-max"));\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ TPI - flexible but useless plug-in framework.\r
+ Copyright (C) 2002-2009 Silky\r
+\r
+ This library is free software; you can redistribute it and/or modify it under\r
+ the terms of the GNU Lesser General Public License as published by the Free\r
+ Software Foundation; either version 2.1 of the License, or (at your option)\r
+ any later version.\r
+\r
+ This library is distributed in the hope that it will be useful, but WITHOUT\r
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or \r
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License\r
+ for more details.\r
+\r
+ You should have received a copy of the GNU Lesser General Public License along\r
+ with this library; if not, write to the Free Software Foundation, Inc.,\r
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
+\r
+ $Id: library.h 398 2010-10-30 11:07:43Z sirakaba $\r
+*******************************************************************************/\r
+\r
+//******************************************************************************\r
+// Includes\r
+//******************************************************************************\r
+\r
+#include "../header/plugin.h"\r
+#include <wx/xml/xml.h>\r
+#include <wx/stdpaths.h>\r
+#ifndef WXWIN_COMPATIBILITY_2_8\r
+#define GetAttribute GetPropVal\r
+#define HasAttribute HasProp\r
+#endif\r
+\r
+//******************************************************************************\r
+// XML\8f\88\97\9d\8aÖ\90\94\r
+//******************************************************************************\r
+\r
+bool myIsLib(wxXmlNode * n);\r
+wxXmlNode * myGetFirstLib(wxXmlDocument * xmlDoc, int nLibIndex = 0);\r
+wxXmlNode * myGetNextLib(wxXmlNode * n, int nLibIndex = 0);\r
+\r
+long myGetAttributeInt( wxXmlNode * n, const wxString & szValue, long nDefaultValue = 0);\r
+bool myGetAttributeBool(wxXmlNode * n, const wxString & szValue, bool bDefaultValue = false);\r
+void MakeFormatInfo(wxXmlNode * n, const wxString & szTPIName, TPI_FORMATINFO * _fiInfo, wxULongLong_t nId);\r
+\r
+wxString inline myMakeXMLName(const wxString & szFile)\r
+{\r
+ wxStandardPaths p;\r
+ return wxPathOnly(p.GetExecutablePath()) + wxT("/lib/") + szFile + wxT(".xml");\r
+}\r