From: sirakaba Date: Mon, 15 Nov 2010 14:04:22 +0000 (+0000) Subject: 7zArcでのxmlによる設定を可能にしたのに伴い、xml関連の操作をcommon/library/xmldoc.cppへ移動して共通化。 X-Git-Tag: 0.01beta9~9 X-Git-Url: http://git.osdn.net/view?p=tpi%2Flychee.git;a=commitdiff_plain;h=206102dc622523624cbc4dd6be44f978b64bb097 7zArcでのxmlによる設定を可能にしたのに伴い、xml関連の操作をcommon/library/xmldoc.cppへ移動して共通化。 git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/tpi/tpi@435 9df91469-1e22-0410-86e7-ea8537beb833 --- diff --git a/bin/lib/7zArc.xml b/bin/lib/7zArc.xml new file mode 100644 index 0000000..7e18453 --- /dev/null +++ b/bin/lib/7zArc.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/files.html b/doc/files.html index 1420998..d15f642 100644 --- a/doc/files.html +++ b/doc/files.html @@ -37,6 +37,7 @@
7zArc.dll
7zArcの本体です。
7zArc.so
7zArcの本体です。
+
7zArc.xml
7zArcの設定ファイルです。
calLibrary.dll
calLibraryの本体です。
calLibrary.xml
calLibraryの設定ファイルです。
cuiWrapper.dll
cuiWrapperの本体です。
diff --git a/doc/history.html b/doc/history.html index ce07043..72af33e 100644 --- a/doc/history.html +++ b/doc/history.html @@ -35,6 +35,7 @@
  • 書庫を複製する機能を追加。
  • ツリービューとリストビューでコンテキストメニューを表示する機能を追加。
  • 単ファイル格納形式の処理において、書庫ファイル名から格納ファイル名を生成する機能を追加。
  • +
  • 改行文字やタブ文字を名前に含むファイルを含む書庫を開こうとした場合に警告する機能を追加。
  • ファイルを開く動作でアプリケーションが起動している間も、Lycheeのウインドウを操作できるよう変更。
  • 書庫閲覧時のメモリ使用量を削減。
  • 書庫のアイコンを変更。
  • @@ -51,6 +52,7 @@
    7zArc
      +
    • 対応するファイルの種類を指定する7zArc.xmlを追加。
    • SquashFS,CramFS,PPMdへの対応を追加。
    • ファイルの属性と作成/参照時刻の復元を行う機能を追加。
    diff --git a/doc/readme.html b/doc/readme.html index 9fdd148..47bc4dc 100644 --- a/doc/readme.html +++ b/doc/readme.html @@ -44,6 +44,7 @@

    7zArc

    7z,zip,NSIS,MSIなど、7-zipで対応している諸形式の処理に対応するTPIです。

    動作には7z.dllか7z.soが必要です。

    +

    動作の設定については7zArc.xmlを参照してください。また、このファイルに記述することで7zArcで対応する形式を変更することができます。cuiWrapper.xmlには簡単な書式の説明を行っていますので、そちらも参考にしてください。

    calLibrary

    統合アーカイバライブラリに対応するTPIです。統合アーカイバ仕様に従う一般的なライブラリに対応しています。

    diff --git a/src/common/library/Makefile b/src/common/library/Makefile index 1808fa0..5a3a84f 100644 --- a/src/common/library/Makefile +++ b/src/common/library/Makefile @@ -1,6 +1,6 @@ # Makefile. # $Id: Makefile 125 2009-11-19 14:17:38Z sirakaba $ -OBJS = library.o +OBJS = library.o xmldoc.o DIR_OBJ = ../../tmp include ../Makefile.default diff --git a/src/plugin/7zArc/7zArc.cpp b/src/plugin/7zArc/7zArc.cpp index 170b644..447eea7 100644 --- a/src/plugin/7zArc/7zArc.cpp +++ b/src/plugin/7zArc/7zArc.cpp @@ -27,23 +27,29 @@ #include "../../common/header/plugin.h" #include "../../common/header/plugin-extra.h" #include "../../common/library/library.h" +#include "../../common/library/xmldoc.h" #include #include "7zArc.h" #ifdef __LINUX__ #define LIB_NAME wxT("7z.so") #else -#define LIB_NAME g_hLib.CanonicalizeName(wxT("7z")) +#define LIB_NAME g_LibInfo.hLib.CanonicalizeName(wxT("7z")) #endif //****************************************************************************** // Global varients //****************************************************************************** -wxDynamicLibrary g_hLib; -void * g_fpProc; +struct g_LibInfo +{ + wxDynamicLibrary hLib; + int nLibIndex; + wxXmlNode node; + void * fpProc; +} g_LibInfo; + TPI_PROC g_prProc; -wxULongLong_t g_nEngineId; #ifdef __LINUX__ extern int global_use_utf16_conversion; @@ -133,151 +139,6 @@ int GetFileInformation2(void * _hArchive, TPI_FILEINFO * _fiInfo, wxULongLong_t return TPI_ERROR_SUCCESS; } -int __stdcall GetFormatInformation2(TPI_FORMATINFO * _fiInfo, wxULongLong_t & nIndex) -{ - // Initialization. - _fiInfo->fArchive = true; - _fiInfo->fComment = false; - _fiInfo->fEncryptKeyFile = false; - _fiInfo->fEncryptPassword = false; - _fiInfo->fEncryptHeader = false; - _fiInfo->fCompressHeader = false; - _fiInfo->fMMOptimize = false; - _fiInfo->fMultiVolume = false; - _fiInfo->fSFX = false; - _fiInfo->fSolid = false; - _fiInfo->nCompressLevelMin = 0; - _fiInfo->nCompressLevelMax = 0; - _fiInfo->nRecoveryRecordMin = 0; - _fiInfo->nRecoveryRecordMax = 0; - _fiInfo->szTypeName.Empty(); - _fiInfo->szSuffix.Empty(); - _fiInfo->szEngineName = LIB_NAME; - _fiInfo->szTPIName = wxT("7zArc"); - _fiInfo->eSupportedCommand = TPI_COMMAND_EXTRACT | TPI_COMMAND_TEST; - _fiInfo->nTypeId = nIndex; - _fiInfo->pCustomInfo = NULL; - wxULongLong_t nBase = nIndex++; - if (nBase >= sizeof(guidList) / sizeof(GUID)) - { - return TPI_ERROR_S_ENDOFDATA; - } - else if (guidList[nBase] == CLSID_CFormatZip) - { - _fiInfo->szTypeName = wxT("7-zip"); - _fiInfo->szSuffix = wxT("zip"); - _fiInfo->eSupportedCommand |= TPI_COMMAND_CREATE;// | TPI_COMMAND_ADD; - _fiInfo->fSFX = true; - _fiInfo->fMultiVolume = true; - _fiInfo->fEncryptPassword = true; - _fiInfo->nCompressLevelMin = 0; - _fiInfo->nCompressLevelMax = 9; - } - else if (guidList[nBase] == CLSID_CFormatBZip2) - { - _fiInfo->szTypeName = wxT("BZip2"); - _fiInfo->szSuffix = wxT("bz2"); - _fiInfo->eSupportedCommand |= TPI_COMMAND_CREATE; - _fiInfo->fArchive = false; - _fiInfo->nCompressLevelMin = 1; - _fiInfo->nCompressLevelMax = 9; - } -// else if (guidList[nBase] == CLSID_CFormatRar) { _fiInfo->szTypeName = wxT("Rar"); _fiInfo->szSuffix = wxT("rar"); } -#ifdef __LINUX__ - else if (guidList[nBase] == CLSID_CFormatArj) { _fiInfo->szTypeName = wxT("Arj"); _fiInfo->szSuffix = wxT("arj"); _fiInfo->fEncryptPassword = true; _fiInfo->fSFX = true; } -#endif - else if (guidList[nBase] == CLSID_CFormatZ) { _fiInfo->szTypeName = wxT("Z"); _fiInfo->szSuffix = wxT("Z"); _fiInfo->fArchive = false; } -#ifdef __LINUX__ - else if (guidList[nBase] == CLSID_CFormatLzh) { _fiInfo->szTypeName = wxT("Lzh"); _fiInfo->szSuffix = wxT("lzh;lha;lzs"); _fiInfo->fSFX = true; } -#endif - else if (guidList[nBase] == CLSID_CFormat7z) - { - _fiInfo->szTypeName = wxT("7z"); - _fiInfo->szSuffix = wxT("7z"); - _fiInfo->eSupportedCommand |= TPI_COMMAND_CREATE;// | TPI_COMMAND_ADD; - _fiInfo->fSFX = true; - _fiInfo->fMultiVolume = true; - _fiInfo->fSolid = true; - _fiInfo->fEncryptPassword = true; - _fiInfo->fEncryptHeader = true; - _fiInfo->fCompressHeader = true; - _fiInfo->nCompressLevelMin = 0; - _fiInfo->nCompressLevelMax = 9; - } -#ifdef __LINUX__ - else if (guidList[nBase] == CLSID_CFormatCab) { _fiInfo->szTypeName = wxT("Cab"); _fiInfo->szSuffix = wxT("cab"); _fiInfo->fMultiVolume = true; _fiInfo->fSFX = true; } -#endif - else if (guidList[nBase] == CLSID_CFormatNsis) { _fiInfo->szTypeName = wxT("NSIS"); _fiInfo->szSuffix = wxT("exe"); _fiInfo->fSFX = true; } - else if (guidList[nBase] == CLSID_CFormatLzma) { _fiInfo->szTypeName = wxT("LZMA"); _fiInfo->szSuffix = wxT("lzma"); _fiInfo->fArchive = false; } - else if (guidList[nBase] == CLSID_CFormatLzma86){_fiInfo->szTypeName = wxT("LZMA86"); _fiInfo->szSuffix = wxT("lzma"); _fiInfo->fArchive = false; } - else if (guidList[nBase] == CLSID_CFormatXz) - { - _fiInfo->szTypeName = wxT("XZ"); - _fiInfo->szSuffix = wxT("xz"); - _fiInfo->eSupportedCommand |= TPI_COMMAND_CREATE; - _fiInfo->fArchive = false; - _fiInfo->nCompressLevelMin = 0; - _fiInfo->nCompressLevelMax = 9; - } - else if (guidList[nBase] == CLSID_CFormatPpmd) { _fiInfo->szTypeName = wxT("PPMd"); _fiInfo->szSuffix = wxT("pmd"); } - else if (guidList[nBase] == CLSID_CFormatSquash){_fiInfo->szTypeName = wxT("SquashFS");_fiInfo->szSuffix = wxT("squashfs"); } - else if (guidList[nBase] == CLSID_CFormatCram) { _fiInfo->szTypeName = wxT("CramFS"); _fiInfo->szSuffix = wxT("cramfs"); } - else if (guidList[nBase] == CLSID_CFormatApm) { _fiInfo->szTypeName = wxT("Apm"); } - else if (guidList[nBase] == CLSID_CFormatMslz) { _fiInfo->szTypeName = wxT("MSLZ"); _fiInfo->szSuffix = wxT("xx_"); _fiInfo->fArchive = false; } - else if (guidList[nBase] == CLSID_CFormatFlv) { _fiInfo->szTypeName = wxT("Flv"); _fiInfo->szSuffix = wxT("flv"); } -// else if (guidList[nBase] == CLSID_CFormatSwf) { _fiInfo->szTypeName = wxT("Swf"); _fiInfo->szSuffix = wxT("swf"); } - else if (guidList[nBase] == CLSID_CFormatSwfc) { _fiInfo->szTypeName = wxT("Swfc"); _fiInfo->szSuffix = wxT("swf"); } - else if (guidList[nBase] == CLSID_CFormatNtfs) { _fiInfo->szTypeName = wxT("NTFS"); _fiInfo->szSuffix = wxT("ntfs;img");} - else if (guidList[nBase] == CLSID_CFormatFat) { _fiInfo->szTypeName = wxT("FAT"); _fiInfo->szSuffix = wxT("fat;img"); } - else if (guidList[nBase] == CLSID_CFormatMbr) { _fiInfo->szTypeName = wxT("Mbr"); _fiInfo->szSuffix = wxT("mbr"); } - else if (guidList[nBase] == CLSID_CFormatVhd) { _fiInfo->szTypeName = wxT("Vhd"); _fiInfo->szSuffix = wxT("vhd"); } -// else if (guidList[nBase] == CLSID_CFormatPe) { _fiInfo->szTypeName = wxT("PE"); _fiInfo->szSuffix = wxT("exe"); _fiInfo->fArchive = false; } -// else if (guidList[nBase] == CLSID_CFormatElf) { _fiInfo->szTypeName = wxT("ELF"); _fiInfo->fArchive = false; } - else if (guidList[nBase] == CLSID_CFormatMachO){ _fiInfo->szTypeName = wxT("Mach-O"); } - else if (guidList[nBase] == CLSID_CFormatUdf) { _fiInfo->szTypeName = wxT("Udf"); _fiInfo->szSuffix = wxT("iso;img"); } - else if (guidList[nBase] == CLSID_CFormatXar) { _fiInfo->szTypeName = wxT("Xar"); _fiInfo->szSuffix = wxT("xar"); } - else if (guidList[nBase] == CLSID_CFormatMub) { _fiInfo->szTypeName = wxT("Mub"); } - else if (guidList[nBase] == CLSID_CFormatHfs) { _fiInfo->szTypeName = wxT("HFS"); _fiInfo->szSuffix = wxT("hfs"); } - else if (guidList[nBase] == CLSID_CFormatDmg) { _fiInfo->szTypeName = wxT("DMG"); _fiInfo->szSuffix = wxT("dmg"); } - else if (guidList[nBase] == CLSID_CFormatCom) { _fiInfo->szTypeName = wxT("Compound");_fiInfo->szSuffix = wxT("msi;msp"); _fiInfo->fSFX = true; } - else if (guidList[nBase] == CLSID_CFormatWim) - { - _fiInfo->szTypeName = wxT("WIM"); - _fiInfo->szSuffix = wxT("wim;swm"); - _fiInfo->eSupportedCommand |= TPI_COMMAND_CREATE;// | TPI_COMMAND_ADD; - } - else if (guidList[nBase] == CLSID_CFormatIso) { _fiInfo->szTypeName = wxT("ISO"); _fiInfo->szSuffix = wxT("iso;img"); } - else if (guidList[nBase] == CLSID_CFormatBkf) { _fiInfo->szTypeName = wxT("Bkf"); _fiInfo->szSuffix = wxT("bkf"); } - else if (guidList[nBase] == CLSID_CFormatChm) { _fiInfo->szTypeName = wxT("Chm"); _fiInfo->szSuffix = wxT("chm;chi;chq;chw;hxs;hxi;hxr;hxq;hxw;lit"); } - else if (guidList[nBase] == CLSID_CFormatSplit){ _fiInfo->szTypeName = wxT("Split"); _fiInfo->szSuffix = wxT("001"); } -#ifdef __LINUX__ - else if (guidList[nBase] == CLSID_CFormatRpm) { _fiInfo->szTypeName = wxT("RPM"); _fiInfo->szSuffix = wxT("rpm"); _fiInfo->fArchive = false; } - else if (guidList[nBase] == CLSID_CFormatDeb) { _fiInfo->szTypeName = wxT("Deb"); _fiInfo->szSuffix = wxT("deb"); } - else if (guidList[nBase] == CLSID_CFormatCpio) { _fiInfo->szTypeName = wxT("Cpio"); _fiInfo->szSuffix = wxT("cpio");} - else if (guidList[nBase] == CLSID_CFormatTar) - { - _fiInfo->szTypeName = wxT("TAR"); - _fiInfo->szSuffix = wxT("tar"); - _fiInfo->fSFX = true; - _fiInfo->eSupportedCommand |= TPI_COMMAND_CREATE;// | TPI_COMMAND_ADD; - } -#endif - else if (guidList[nBase] == CLSID_CFormatGZip) - { - _fiInfo->szTypeName = wxT("GZip"); - _fiInfo->szSuffix = wxT("gz"); - _fiInfo->eSupportedCommand |= TPI_COMMAND_CREATE; - _fiInfo->fArchive = false; - _fiInfo->nCompressLevelMin = 1; - _fiInfo->nCompressLevelMax = 9; - } - else - { - return GetFormatInformation2(_fiInfo, nIndex); - } - return TPI_ERROR_SUCCESS; -} - //****************************************************************************** // Callback Wrapper //****************************************************************************** @@ -786,12 +647,26 @@ int __stdcall GetPluginInformation int __stdcall GetFormatInformation(TPI_FORMATINFO * _fiInfo, bool _bFirst) { - static wxULongLong_t s_nTypeId; + static wxULongLong_t s_nFileId; + static wxXmlDocument xmlDoc(myMakeXMLName(wxT("7zArc"))); + static wxXmlNode * xmlLibrary; if (_bFirst) { - s_nTypeId = 0; + // xml解析開始。 + s_nFileId = 0; + xmlLibrary = myGetFirstLib(& xmlDoc); } - return GetFormatInformation2(_fiInfo, s_nTypeId); + else + { + xmlLibrary = myGetNextLib(xmlLibrary); + } + if (xmlLibrary == NULL) + { + // データの終端に達した場合。 + return TPI_ERROR_S_ENDOFDATA; + } + MakeFormatInfo(xmlLibrary, wxT("7zArc"), _fiInfo, s_nFileId++); + return TPI_ERROR_SUCCESS; } int __stdcall LoadPlugin @@ -804,26 +679,37 @@ int __stdcall LoadPlugin #ifdef __LINUX__ global_use_utf16_conversion = 1; #endif - g_hLib.Load(LIB_NAME); - if (! g_hLib.IsLoaded()) + g_LibInfo.hLib.Load(LIB_NAME); + if (! g_LibInfo.hLib.IsLoaded()) { - g_hLib.Unload(); + g_LibInfo.hLib.Unload(); return TPI_ERROR_U_LOAD_LIBRARY; } - if (! g_hLib.HasSymbol(wxT("CreateObject"))) + if (! g_LibInfo.hLib.HasSymbol(wxT("CreateObject"))) { return TPI_ERROR_U_USE_LIBRARY; } - g_fpProc = g_hLib.GetSymbol(wxT("CreateObject")); - if (! g_fpProc) + g_LibInfo.fpProc = g_LibInfo.hLib.GetSymbol(wxT("CreateObject")); + if (! g_LibInfo.fpProc) { return TPI_ERROR_U_USE_LIBRARY; } + // 対象が存在しないならば指示されたライブラリをロード。 if (! ::wxFileExists(_szArcName)) { - g_nEngineId = _nTypeId; + // xml解析開始。 + wxXmlDocument xmlDoc(myMakeXMLName(wxT("7zArc"))); + wxXmlNode * xmlLibrary = myGetFirstLib(& xmlDoc, _nTypeId); + if (xmlLibrary == NULL) + { + // xml文法エラー。 + return TPI_ERROR_UNDEFINED; + } + g_LibInfo.node = * xmlLibrary; + g_LibInfo.nLibIndex = _nTypeId; + return TPI_ERROR_SUCCESS; } return TPI_ERROR_SUCCESS; @@ -834,7 +720,7 @@ int __stdcall FreePlugin void * // _pReserved ) { - g_hLib.Unload(); + g_LibInfo.hLib.Unload(); return TPI_ERROR_SUCCESS; } @@ -852,15 +738,23 @@ int __stdcall OpenArchive return TPI_ERROR_IO_ARC_OPEN; } - // 書庫形式を認識。 + // xml解析開始。 IInArchive * hArc; - for (wxULongLong_t i = 0; i < sizeof(guidList) / sizeof(GUID); ) + wxXmlDocument xmlDoc(myMakeXMLName(wxT("7zArc"))); + wxXmlNode * xmlLibrary = myGetFirstLib(& xmlDoc); + + // 対応するライブラリを調査。 + // 無限ループに陥らないよう上限を設定。 + for (g_LibInfo.nLibIndex = 0; g_LibInfo.nLibIndex < 300 && xmlLibrary != NULL; g_LibInfo.nLibIndex++) { - if (((unsigned int (__stdcall *)(const GUID *, const GUID *, void * *)) g_fpProc)(& guidList[i], & IID_IInArchive, (void **) & hArc) != S_OK) + // ライブラリをロード。 + const GUID guid = {0x23170F69, 0x40C1, 0x278A, {0x10, 0x00, 0x00, 0x01, 0x10, myGetAttributeInt(xmlLibrary, wxT("name")), 0x00, 0x00}}; + if (((unsigned int (__stdcall *)(const GUID *, const GUID *, void * *)) g_LibInfo.fpProc)(& guid, & IID_IInArchive, (void **) & hArc) != S_OK) { - i++; + xmlLibrary = myGetNextLib(xmlLibrary); continue; } + g_LibInfo.node = * xmlLibrary; // 書庫を開く。 CInFileStream * fileSpec = new CInFileStream; @@ -871,11 +765,10 @@ int __stdcall OpenArchive } // 形式の情報を取得。 - g_nEngineId = i; TPI_FORMATINFO fiInfo; - GetFormatInformation2(& fiInfo, i); + MakeFormatInfo(xmlLibrary, wxT("7zArc"), & fiInfo, g_LibInfo.nLibIndex); - // 書庫として開く。 + // 書庫に対応しているかチェック。 CArchiveOpenCallback * openCallbackSpec = new CArchiveOpenCallback; CMyComPtr openCallback(openCallbackSpec); // SFXを完全に検出するには全体をロードする必要がある。 @@ -897,7 +790,9 @@ int __stdcall OpenArchive * _hArchive = hArc; return TPI_ERROR_SUCCESS; } + xmlLibrary = myGetNextLib(xmlLibrary); } + return TPI_ERROR_IO_ARC_OPEN; } @@ -949,8 +844,7 @@ int __stdcall GetArchiveInformation { _aiInfo->szComment = WC2String(prop.bstrVal); } - wxULongLong_t n = g_nEngineId; - GetFormatInformation2(& _aiInfo->fiInfo, n); + MakeFormatInfo(& g_LibInfo.node, wxT("7zArc"), & _aiInfo->fiInfo, g_LibInfo.nLibIndex); return TPI_ERROR_SUCCESS; } @@ -1036,15 +930,15 @@ int __stdcall Command // エンジンを読み込み。 IOutArchive * hArc; - if (((unsigned int (__stdcall *)(const GUID *, const GUID *, void **)) g_fpProc)(& guidList[g_nEngineId], & IID_IOutArchive, (void **) & hArc) != S_OK) + const GUID guid = {0x23170F69, 0x40C1, 0x278A, {0x10, 0x00, 0x00, 0x01, 0x10, myGetAttributeInt(& g_LibInfo.node, wxT("name")), 0x00, 0x00}}; + if (((unsigned int (__stdcall *)(const GUID *, const GUID *, void **)) g_LibInfo.fpProc)(& guid, & IID_IOutArchive, (void **) & hArc) != S_OK) { return TPI_ERROR_ARC_UNSUPPORTED; } // 形式情報を取得。 TPI_FORMATINFO fiInfo; - wxULongLong_t nIndex = g_nEngineId; - GetFormatInformation2(& fiInfo, nIndex); + MakeFormatInfo(& g_LibInfo.node, wxT("7zArc"), & fiInfo, g_LibInfo.nLibIndex); // パラメータを設定。 ISetProperties * setProp; diff --git a/src/plugin/7zArc/7zArc.h b/src/plugin/7zArc/7zArc.h index debec21..8d6a629 100644 --- a/src/plugin/7zArc/7zArc.h +++ b/src/plugin/7zArc/7zArc.h @@ -39,110 +39,3 @@ #include "../../IPassword.h" #include "../../MyVersion.h" - -//****************************************************************************** -// Defines -//****************************************************************************** - -DEFINE_GUID(CLSID_CFormatZip, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x01, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatBZip2, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x02, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatRar, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x03, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatArj, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x04, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatZ, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x05, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatLzh, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x06, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormat7z, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatCab, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x08, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatNsis, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x09, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatLzma, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x0A, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatLzma86,0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x0B, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatXz, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x0C, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatPpmd, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x0D, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatSquash,0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xD2, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatCram, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xD3, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatApm, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xD4, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatMslz, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xD5, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatFlv, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xD6, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatSwf, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xD7, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatSwfc, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xD8, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatNtfs, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xD9, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatFat, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xDA, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatMbr, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xDB, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatVhd, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xDC, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatPe, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xDD, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatElf, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xDE, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatMachO, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xDF, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatUdf, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE0, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatXar, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE1, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatMub, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE2, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatHfs, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE3, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatDmg, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE4, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatCom, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE5, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatWim, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE6, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatIso, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE7, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatBkf, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE8, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatChm, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE9, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatSplit, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xEA, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatRpm, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xEB, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatDeb, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xEC, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatCpio, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xED, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatTar, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xEE, 0x00, 0x00); -DEFINE_GUID(CLSID_CFormatGZip, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xEF, 0x00, 0x00); - -const GUID guidList[] = { - CLSID_CFormatZip, - CLSID_CFormatBZip2, -// CLSID_CFormatRar, -#ifdef __LINUX__ - CLSID_CFormatArj, -#endif - CLSID_CFormatZ, -#ifdef __LINUX__ - CLSID_CFormatLzh, -#endif - CLSID_CFormat7z, -#ifdef __LINUX__ - CLSID_CFormatCab, -#endif - CLSID_CFormatNsis, - CLSID_CFormatLzma, - CLSID_CFormatLzma86, - CLSID_CFormatXz, - CLSID_CFormatPpmd, - CLSID_CFormatSquash, - CLSID_CFormatCram, - CLSID_CFormatApm, - CLSID_CFormatMslz, - CLSID_CFormatFlv, -// CLSID_CFormatSwf, - CLSID_CFormatSwfc, - CLSID_CFormatNtfs, - CLSID_CFormatFat, - CLSID_CFormatMbr, - CLSID_CFormatVhd, -// CLSID_CFormatPe, -// CLSID_CFormatElf, - CLSID_CFormatMachO, - CLSID_CFormatUdf, - CLSID_CFormatXar, - CLSID_CFormatMub, - CLSID_CFormatHfs, - CLSID_CFormatDmg, - CLSID_CFormatCom, - CLSID_CFormatWim, - CLSID_CFormatIso, - CLSID_CFormatBkf, - CLSID_CFormatChm, - CLSID_CFormatSplit, -#ifdef __LINUX__ - CLSID_CFormatRpm, - CLSID_CFormatDeb, - CLSID_CFormatCpio, - CLSID_CFormatTar, -#endif - CLSID_CFormatGZip -}; - -//****************************************************************************** -// Structures -//****************************************************************************** - diff --git a/src/plugin/7zArc/7zArc.vcproj b/src/plugin/7zArc/7zArc.vcproj index 1a74a60..606a360 100644 --- a/src/plugin/7zArc/7zArc.vcproj +++ b/src/plugin/7zArc/7zArc.vcproj @@ -61,7 +61,7 @@ /> + + diff --git a/src/plugin/Makefile.default b/src/plugin/Makefile.default index b9b2e33..4cd178b 100644 --- a/src/plugin/Makefile.default +++ b/src/plugin/Makefile.default @@ -8,10 +8,12 @@ LDFLAGS = -s -shared -Wl,-Bsymbolic # Define i/o files. DIR_OBJ = ../../tmp/$(PLUGIN_NAME) -ifdef NOUSE_LIBRARY - OBJS = $(PLUGIN_NAME).o -else - OBJS = $(PLUGIN_NAME).o ../library.o +OBJS = $(PLUGIN_NAME).o +ifndef NOUSE_LIBRARY + OBJS += ../library.o +endif +ifndef NOUSE_XML + OBJS += ../xmldoc.o endif IN_DEF = ../../common/header/plugin.def diff --git a/src/plugin/cuiWrapper/cuiWrapper.cpp b/src/plugin/cuiWrapper/cuiWrapper.cpp index 18c67d4..5288704 100644 --- a/src/plugin/cuiWrapper/cuiWrapper.cpp +++ b/src/plugin/cuiWrapper/cuiWrapper.cpp @@ -26,9 +26,8 @@ #include "../../common/header/plugin.h" #include "../../common/header/plugin-extra.h" #include "../../common/library/library.h" +#include "../../common/library/xmldoc.h" #include -#include -#include #include #include "cuiWrapper.h" @@ -196,66 +195,49 @@ int __stdcall GetPluginInformation int __stdcall GetFormatInformation(TPI_FORMATINFO * _fiInfo, bool _bFirst) { static wxULongLong_t s_nFileId; - wxStandardPaths p; - wxXmlDocument config(wxPathOnly(p.GetExecutablePath()) + wxT("/lib/cuiWrapper.xml")); - // 一気に先頭のライブラリの情報を取得。 - wxXmlNode * xmlLibrary = config.GetRoot()->GetChildren(); - + static wxXmlDocument xmlDoc(myMakeXMLName(wxT("cuiWrapper"))); + static wxXmlNode * xmlLibrary; if (_bFirst) { // xml解析開始。 s_nFileId = 0; + xmlLibrary = myGetFirstLib(& xmlDoc); } else { - for (wxULongLong_t i = 0; i < s_nFileId && xmlLibrary != NULL; i++) - { - xmlLibrary = xmlLibrary->GetNext(); - } + xmlLibrary = myGetNextLib(xmlLibrary); } - - if (xmlLibrary == NULL || xmlLibrary->GetName() != wxT("library")) + if (xmlLibrary == NULL) { // データの終端に達した場合。 return TPI_ERROR_S_ENDOFDATA; } - MakeFormatInfo(wxT("cuiWrapper"), _fiInfo, xmlLibrary, s_nFileId++); + MakeFormatInfo(xmlLibrary, wxT("cuiWrapper"), _fiInfo, s_nFileId++); wxString szExeFile = xmlLibrary->GetAttribute(wxT("name"), wxEmptyString); if (myExecute(szExeFile, NULL, wxEmptyString, szExeFile.Find(wxT('.')) != wxNOT_FOUND && szExeFile.AfterLast(wxT('.')) == wxT("exe")) != TPI_ERROR_SUCCESS) { _fiInfo->eSupportedCommand = 0; } - return TPI_ERROR_SUCCESS; } int __stdcall LoadPlugin ( const wxString & _szArcName, - wxULongLong_t _llTypeId + wxULongLong_t _nTypeId ) { // xml解析開始。 - wxStandardPaths p; - wxXmlDocument config(wxPathOnly(p.GetExecutablePath()) + wxT("/lib/cuiWrapper.xml")); - if (! config.IsOk()) - { - return TPI_ERROR_UNDEFINED; - } - // 一気に先頭のライブラリの情報を取得。 - wxXmlNode * xmlLibrary = config.GetRoot()->GetChildren(); + wxXmlDocument xmlDoc(myMakeXMLName(wxT("cuiWrapper"))); + wxXmlNode * xmlLibrary; // 対象が存在するならば対応するライブラリを調査、 // 対象が存在しないならば指示されたライブラリをロード。 if (! ::wxFileExists(_szArcName)) { - // 適当な位置まで移動。 - for (g_LibInfo.nLibIndex = 0; g_LibInfo.nLibIndex < _llTypeId && xmlLibrary != NULL; g_LibInfo.nLibIndex++) - { - xmlLibrary = xmlLibrary->GetNext(); - } - if (xmlLibrary == NULL || xmlLibrary->GetName() != wxT("library")) + xmlLibrary = myGetFirstLib(& xmlDoc, _nTypeId); + if (xmlLibrary == NULL) { // xml文法エラー。 return TPI_ERROR_UNDEFINED; @@ -263,40 +245,36 @@ int __stdcall LoadPlugin g_LibInfo.szExeFile = xmlLibrary->GetAttribute(wxT("name"), wxEmptyString); g_LibInfo.szExeFileAlt = xmlLibrary->GetAttribute(wxT("name-alt"), wxEmptyString); g_LibInfo.node = * xmlLibrary; - + g_LibInfo.nLibIndex = _nTypeId; return TPI_ERROR_SUCCESS; } // 無限ループに陥らないよう上限を設定。 - for (g_LibInfo.nLibIndex = 0; g_LibInfo.nLibIndex < 300 && xmlLibrary != NULL && xmlLibrary->GetName() == wxT("library"); g_LibInfo.nLibIndex++) + xmlLibrary = myGetFirstLib(& xmlDoc); + for (g_LibInfo.nLibIndex = 0; g_LibInfo.nLibIndex < 300 && xmlLibrary != NULL; g_LibInfo.nLibIndex++) { - // ライブラリをロード。 - g_LibInfo.szExeFile = xmlLibrary->GetAttribute(wxT("name"), wxEmptyString); - g_LibInfo.szExeFileAlt = xmlLibrary->GetAttribute(wxT("name-alt"), wxEmptyString); - g_LibInfo.node = * xmlLibrary; - // 書庫に対応しているかチェック。 wxFileName fnArchive(_szArcName); - wxArrayString asExt = ::wxStringTokenize(g_LibInfo.node.GetAttribute(wxT("suffix"), wxEmptyString), wxT(";")); - if (! g_LibInfo.node.HasAttribute(wxT("list"))) + wxArrayString asExt = ::wxStringTokenize(xmlLibrary->GetAttribute(wxT("suffix"), wxEmptyString), wxT(";")); + if (xmlLibrary->HasAttribute(wxT("list"))) { - xmlLibrary = xmlLibrary->GetNext(); - continue; - } - - for (size_t i = 0; i < asExt.GetCount(); i++) - { - // .tar.XXXなど二重判定への対応。 -// if (asExt[i].IsSameAs(fnArchive.GetExt(), false)) - if (fnArchive.GetFullName().EndsWith(wxT('.') + asExt[i])) + for (size_t i = 0; i < asExt.GetCount(); i++) { - return TPI_ERROR_SUCCESS; + // .tar.XXXなど二重判定への対応。 +// if (asExt[i].IsSameAs(fnArchive.GetExt(), false)) + if (fnArchive.GetFullName().EndsWith(wxT('.') + asExt[i])) + { + // ライブラリをロード。 + g_LibInfo.szExeFile = xmlLibrary->GetAttribute(wxT("name"), wxEmptyString); + g_LibInfo.szExeFileAlt = xmlLibrary->GetAttribute(wxT("name-alt"), wxEmptyString); + g_LibInfo.node = * xmlLibrary; + g_LibInfo.nLibIndex = _nTypeId; + return TPI_ERROR_SUCCESS; + } } } - - xmlLibrary = xmlLibrary->GetNext(); + xmlLibrary = myGetNextLib(xmlLibrary); } - return TPI_ERROR_U_LOAD_LIBRARY; } @@ -426,7 +404,7 @@ int __stdcall GetArchiveInformation ) { // 形式に関する情報を取得。 - MakeFormatInfo(wxT("cuiWrapper"), & _aiInfo->fiInfo, & g_LibInfo.node, 0); + MakeFormatInfo(& g_LibInfo.node, wxT("cuiWrapper"), & _aiInfo->fiInfo, 0); return TPI_ERROR_SUCCESS; } diff --git a/src/plugin/rarArc/Makefile b/src/plugin/rarArc/Makefile index df8d582..af627c4 100644 --- a/src/plugin/rarArc/Makefile +++ b/src/plugin/rarArc/Makefile @@ -1,4 +1,5 @@ # Makefile. # $Id$ PLUGIN_NAME = rarArc +NOUSE_XML = 1 include ../Makefile.default diff --git a/src/tpi.sln b/src/tpi.sln index 98d6174..910564e 100644 --- a/src/tpi.sln +++ b/src/tpi.sln @@ -17,6 +17,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "library", "library", "{85B5 ProjectSection(SolutionItems) = preProject common\library\library.cpp = common\library\library.cpp common\library\library.h = common\library\library.h + common\library\xmldoc.cpp = common\library\xmldoc.cpp + common\library\xmldoc.h = common\library\xmldoc.h EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lychee", "lychee\lychee.vcproj", "{50F13951-5698-4418-8353-BFDFC5A6BC13}"