00001 // 00002 // ED2K.h 00003 // 00004 // Copyright (c) Shareaza Development Team, 2002-2005. 00005 // This file is part of SHAREAZA (www.shareaza.com) 00006 // 00007 // Shareaza is free software; you can redistribute it 00008 // and/or modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 2 of 00010 // the License, or (at your option) any later version. 00011 // 00012 // Shareaza is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with Shareaza; if not, write to the Free Software 00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 // 00021 00022 #if !defined(AFX_ED2K_H__0ED688AE_E4F5_49C6_8EC8_5C80EFA6EF6C__INCLUDED_) 00023 #define AFX_ED2K_H__0ED688AE_E4F5_49C6_8EC8_5C80EFA6EF6C__INCLUDED_ 00024 00025 #pragma once 00026 00027 #include "MD4.h" 00028 00029 00030 class CED2K 00031 { 00032 // Construction 00033 public: 00034 CED2K(); 00035 virtual ~CED2K(); 00036 00037 // Operations 00038 public: 00039 void Clear(); 00040 void Serialize(CArchive& ar); 00041 DWORD GetSerialSize() const; 00042 BOOL GetRoot(MD4* pHash) const; 00043 public: 00044 void BeginFile(QWORD nLength); 00045 void AddToFile(LPCVOID pInput, DWORD nLength); 00046 BOOL FinishFile(); 00047 public: 00048 void BeginBlockTest(); 00049 void AddToTest(LPCVOID pInput, DWORD nLength); 00050 BOOL FinishBlockTest(DWORD nBlock); 00051 public: 00052 LPCVOID GetRawPtr() const; 00053 BOOL ToBytes(BYTE** pOutput, DWORD* pnOutput); 00054 BOOL FromBytes(BYTE* pOutput, DWORD nOutput, QWORD nSize = 0); 00055 BOOL FromRoot(MD4* pHash); 00056 BOOL CheckIntegrity(); 00057 public: 00058 static CString HashToString(const MD4* pHash, BOOL bURN = FALSE); 00059 static BOOL HashFromString(LPCTSTR pszHash, MD4* pHash); 00060 static BOOL HashFromURN(LPCTSTR pszHash, MD4* pHash); 00061 00062 // Inlines 00063 public: 00064 inline BOOL IsAvailable() const { return m_pList != NULL; } 00065 inline DWORD GetBlockCount() const { return m_nList; } 00066 00067 // Attributes 00068 protected: 00069 MD4 m_pRoot; 00070 MD4* m_pList; 00071 DWORD m_nList; 00072 protected: 00073 CMD4 m_pSegment; 00074 DWORD m_nCurHash; 00075 DWORD m_nCurByte; 00076 00077 }; 00078 00079 #define ED2K_PART_SIZE 9728000 // 1024*9500 00080 00081 #endif // !defined(AFX_ED2K_H__0ED688AE_E4F5_49C6_8EC8_5C80EFA6EF6C__INCLUDED_)