From 516d19a047dcd10b525e67eac6cd2f98e6ca05a1 Mon Sep 17 00:00:00 2001 From: upstream svn Date: Fri, 18 Apr 2008 09:15:14 +0200 Subject: [PATCH] Upstream tarball 20080418 --- CVSDATE | 2 +- SVNDATE | 2 +- docs/Changelog | 1 + po/hu.po | 4 ++-- src/EncryptedDatagramSocket.cpp | 2 +- src/SafeFile.cpp | 13 ++++++++---- src/SearchList.cpp | 2 +- src/kademlia/kademlia/Indexed.cpp | 2 +- src/kademlia/kademlia/SearchManager.cpp | 5 +++-- src/kademlia/kademlia/SearchManager.h | 14 +------------ src/kademlia/utils/UInt128.h | 35 ++++++++++++++++++--------------- src/libs/common/FileFunctions.cpp | 2 +- src/webserver/litoral/Makefile.am | 1 - src/webserver/litoral/Makefile.in | 1 - 14 files changed, 41 insertions(+), 45 deletions(-) diff --git a/CVSDATE b/CVSDATE index 26f2d3e6..73da3023 100644 --- a/CVSDATE +++ b/CVSDATE @@ -1 +1 @@ -Thu Apr 17 07:01:43 CEST 2008 +Fri Apr 18 07:01:45 CEST 2008 diff --git a/SVNDATE b/SVNDATE index 26f2d3e6..73da3023 100644 --- a/SVNDATE +++ b/SVNDATE @@ -1 +1 @@ -Thu Apr 17 07:01:43 CEST 2008 +Fri Apr 18 07:01:45 CEST 2008 diff --git a/docs/Changelog b/docs/Changelog index 62e91189..8a3e97fb 100644 --- a/docs/Changelog +++ b/docs/Changelog @@ -41,6 +41,7 @@ Version 2.2.1 - ??? * Added amulegui desktop icon (with Vollstrecker). * Patch for fixing aMule spec file in Fedora and Mandriva. * Test for perl File::Copy in configure. + * Fix for building with _FORTIFY_SOURCE. Gnucco: * Workaround for string serialization bug. diff --git a/po/hu.po b/po/hu.po index 44676746..803dbd95 100644 --- a/po/hu.po +++ b/po/hu.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: aMule\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2008-04-16 03:31+0200\n" -"PO-Revision-Date: 2008-03-31 21:56+0100\n" +"PO-Revision-Date: 2008-04-18 02:18+0100\n" "Last-Translator: Dévai Tamás \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -511,7 +511,7 @@ msgstr[0] "%u Kad kapcsolat beolvasva" #, c-format msgid "Wrote %d Kad contact" msgid_plural "Wrote %d Kad contacts" -msgstr[0] "" +msgstr[0] "%d Kad kapcsolat kiírva" #: src/ListenSocket.cpp:68 msgid "Error: Could not listen to TCP port." diff --git a/src/EncryptedDatagramSocket.cpp b/src/EncryptedDatagramSocket.cpp index ee1d86e0..671245f4 100644 --- a/src/EncryptedDatagramSocket.cpp +++ b/src/EncryptedDatagramSocket.cpp @@ -159,7 +159,7 @@ int CEncryptedDatagramSocket::DecryptReceivedClient(uint8* pbyBufIn, int nBufLen if (bKad){ if (Kademlia::CKademlia::GetPrefs()) { uint8 achKeyData[18]; - memcpy(achKeyData, Kademlia::CKademlia::GetPrefs()->GetKadID().GetData(), 16); + Kademlia::CKademlia::GetPrefs()->GetKadID().ToByteArray((uint8_t *)&achKeyData); memcpy(achKeyData + 16, pbyBufIn + 1, 2); // random key part sent from remote client md5.Calculate(achKeyData, sizeof(achKeyData)); } diff --git a/src/SafeFile.cpp b/src/SafeFile.cpp index 43e15f79..f3521c65 100644 --- a/src/SafeFile.cpp +++ b/src/SafeFile.cpp @@ -158,13 +158,15 @@ uint64 CFileDataIO::ReadUInt64() const } +// UInt128 values are stored a little weird way... +// Four little-endian 32-bit numbers, stored in +// big-endian order CUInt128 CFileDataIO::ReadUInt128() const { CUInt128 value; - uint32* data = (uint32*)value.GetDataPtr(); - for (int i = 0; i < (128/32); i++) { + for (int i = 0; i < 4; i++) { // Four 32bits chunks - data[i] = ReadUInt32(); + value.Set32BitChunk(i, ReadUInt32()); } return value; @@ -281,9 +283,12 @@ void CFileDataIO::WriteUInt64(uint64 value) } +// UInt128 values are stored a little weird way... +// Four little-endian 32-bit numbers, stored in +// big-endian order void CFileDataIO::WriteUInt128(const Kademlia::CUInt128& value) { - for (int i = 0; i < (128/32); i++) { + for (int i = 0; i < 4; i++) { // Four 32bits chunks WriteUInt32(value.Get32BitChunk(i)); } diff --git a/src/SearchList.cpp b/src/SearchList.cpp index 8dbb58b2..182aec86 100644 --- a/src/SearchList.cpp +++ b/src/SearchList.cpp @@ -303,7 +303,7 @@ wxString CSearchList::StartNewSearch(uint32* searchID, SearchType type, const CS // searchstring will get tokenized there // The tab must be created with the Kad search ID, so seardhID is updated. Kademlia::CSearch* search = Kademlia::CSearchManager::PrepareFindKeywords( - params.searchString, data->GetLength(), data->GetRawBuffer()); + params.searchString, data->GetLength(), data->GetRawBuffer(), *searchID); *searchID = search->GetSearchID(); } catch (const wxString& what) { diff --git a/src/kademlia/kademlia/Indexed.cpp b/src/kademlia/kademlia/Indexed.cpp index 024b812b..6cdab35d 100644 --- a/src/kademlia/kademlia/Indexed.cpp +++ b/src/kademlia/kademlia/Indexed.cpp @@ -888,7 +888,7 @@ void CIndexed::SendValidKeywordResult(const CUInt128& keyID, const SSearchTerm* DebugSend(Kad2SearchRes, ip, port); CKademlia::GetUDPListener()->SendPacket(packetdata, KADEMLIA2_SEARCH_RES, ip, port); } else { - DebugSend(KadSearcRes, ip, port); + DebugSend(KadSearchRes, ip, port); CKademlia::GetUDPListener()->SendPacket(packetdata, KADEMLIA_SEARCH_RES, ip, port); } packetdata.Reset(); diff --git a/src/kademlia/kademlia/SearchManager.cpp b/src/kademlia/kademlia/SearchManager.cpp index de9a1faf..11c283a9 100644 --- a/src/kademlia/kademlia/SearchManager.cpp +++ b/src/kademlia/kademlia/SearchManager.cpp @@ -111,7 +111,7 @@ bool CSearchManager::StartSearch(CSearch* search) return true; } -CSearch* CSearchManager::PrepareFindKeywords(const wxString& keyword, uint32_t searchTermsDataSize, const uint8_t *searchTermsData) +CSearch* CSearchManager::PrepareFindKeywords(const wxString& keyword, uint32_t searchTermsDataSize, const uint8_t *searchTermsData, uint32_t searchid) { // Create a keyword search object. CSearch *s = new CSearch; @@ -140,7 +140,8 @@ CSearch* CSearchManager::PrepareFindKeywords(const wxString& keyword, uint32_t s s->SetSearchTermData(searchTermsDataSize, searchTermsData); // Inc our searchID - s->SetSearchID(++m_nextID); + // If called from external client use predefined search id + s->SetSearchID((searchid & 0xffffff00) == 0xffffff00 ? searchid : ++m_nextID); // Insert search into map m_searches[s->GetTarget()] = s; // Start search diff --git a/src/kademlia/kademlia/SearchManager.h b/src/kademlia/kademlia/SearchManager.h index a77de02f..7f0cca82 100644 --- a/src/kademlia/kademlia/SearchManager.h +++ b/src/kademlia/kademlia/SearchManager.h @@ -52,20 +52,9 @@ namespace Kademlia { class CSearch; class CRoutingZone; -// If type is unknown it will be an empty string -// If there are any properties about the file to report, there will follow LPCSTR key/value pairs. -//typedef void (CALLBACK *SEARCH_KEYWORD_CALLBACK)(uint32 searchID, CUInt128 fileID, wxString name, uint32 size, wxString type, uint16 numProperties, ...); -//typedef void (CALLBACK *SEARCH_ID_CALLBACK)(uint32 searchID, CUInt128 contactID, uint8 type, uint32 ip, uint16 tcp, uint16 udp, uint32 serverip, uint16 port); - typedef std::list WordList; typedef std::map SearchMap; -// #define SEARCH_IMAGE "-image" -// #define SEARCH_AUDIO "-audio" -// #define SEARCH_VIDEO "-video" -// #define SEARCH_DOC "-doc" -// #define SEARCH_PRO "-pro" - class CSearchManager { friend class CRoutingZone; @@ -82,8 +71,7 @@ public: static CSearch* PrepareLookup(uint32_t type, bool start, const CUInt128& id); // Will return unique search id, returns zero if already searching for this keyword. - // static CSearch* PrepareFindKeywords(const wxString& keyword, CMemFile* ed2k_packet, uint32 searchid); - static CSearch* PrepareFindKeywords(const wxString& keyword, uint32_t searchTermsDataSize, const uint8_t *searchTermsData); + static CSearch* PrepareFindKeywords(const wxString& keyword, uint32_t searchTermsDataSize, const uint8_t *searchTermsData, uint32_t searchid); static bool StartSearch(CSearch* search); diff --git a/src/kademlia/utils/UInt128.h b/src/kademlia/utils/UInt128.h index bb5aac57..132d7a6c 100644 --- a/src/kademlia/utils/UInt128.h +++ b/src/kademlia/utils/UInt128.h @@ -48,20 +48,21 @@ namespace Kademlia { class CUInt128 { + friend bool operator==(uint32_t, const CUInt128&); public: CUInt128(const CUInt128& value) throw() { SetValue(value); } - explicit CUInt128(bool fill) throw() + explicit CUInt128(bool fill = false) throw() { m_data[0] = m_data[1] = m_data[2] = m_data[3] = (fill ? (uint32_t)-1 : 0); } - explicit CUInt128(uint32_t value = 0) throw() + explicit CUInt128(uint32_t value) throw() { - SetValue((uint32_t)value); + SetValue(value); } explicit CUInt128(const uint8_t *valueBE) throw() @@ -75,16 +76,6 @@ public: */ CUInt128(const CUInt128& value, uint32_t numBits) throw(); - const uint8_t* GetData() const throw() - { - return (const uint8_t*)m_data; - } - - uint8_t* GetDataPtr() throw() - { - return (uint8_t*)m_data; - } - /** Bit at level 0 being most significant. */ unsigned GetBitNumber(unsigned bit) const throw() { @@ -94,7 +85,7 @@ public: int CompareTo(const CUInt128& other) const throw(); int CompareTo(uint32_t value) const throw(); - wxString ToHexString(void) const; + wxString ToHexString() const; wxString ToBinaryString(bool trim = false) const; void ToByteArray(uint8_t *b) const throw(); @@ -105,6 +96,13 @@ public: return m_data[val]; } + void Set32BitChunk(unsigned chunk, uint32_t value) throw() + { + wxASSERT(chunk < 4); + + m_data[chunk] = value; + } + CUInt128& SetValue(const CUInt128& value) throw() { m_data[0] = value.m_data[0]; @@ -123,9 +121,9 @@ public: CUInt128& SetValueBE(const uint8_t *valueBE) throw(); - CUInt128& SetValueRandom(void); -// CUInt128& SetValueGUID(void); + CUInt128& SetValueRandom(); + /** Bit at level 0 being most significant. */ CUInt128& SetBitNumber(unsigned bit, unsigned value) throw() { wxASSERT(bit <= 127); @@ -205,6 +203,11 @@ private: uint32_t m_data[4]; }; +inline bool operator==(uint32_t x, const CUInt128& y) +{ + return y.operator==(x); +} + } // End namespace #endif diff --git a/src/libs/common/FileFunctions.cpp b/src/libs/common/FileFunctions.cpp index 7591008a..e3ca12b7 100644 --- a/src/libs/common/FileFunctions.cpp +++ b/src/libs/common/FileFunctions.cpp @@ -287,7 +287,7 @@ FSCheckResult DoCheckFileSystem(const CPath& path) wxString fullName = JoinPaths(path.GetRaw(), wxT(":")); // Try to open the file, without overwriting existing files. - int fd = open(fullName.fn_str(), O_WRONLY | O_CREAT | O_EXCL); + int fd = open(fullName.fn_str(), O_WRONLY | O_CREAT | O_EXCL, 0600); if (fd != -1) { // Success, the file-system cant be FAT32 close(fd); diff --git a/src/webserver/litoral/Makefile.am b/src/webserver/litoral/Makefile.am index a52a61b3..638ad400 100644 --- a/src/webserver/litoral/Makefile.am +++ b/src/webserver/litoral/Makefile.am @@ -51,7 +51,6 @@ dist_webserver_DATA = \ stats_0.png \ stats_1.png \ stats.php \ - stats_tree_old.php \ stats_tree.php \ style.css \ tab_bottom_left.png \ diff --git a/src/webserver/litoral/Makefile.in b/src/webserver/litoral/Makefile.in index 2bec9bca..8167f6f8 100644 --- a/src/webserver/litoral/Makefile.in +++ b/src/webserver/litoral/Makefile.in @@ -353,7 +353,6 @@ dist_webserver_DATA = \ stats_0.png \ stats_1.png \ stats.php \ - stats_tree_old.php \ stats_tree.php \ style.css \ tab_bottom_left.png \ -- 2.11.4.GIT