Update of /cvsroot/gnucula/Gnucula In directory sc8-pr-cvs1:/tmp/cvs-serv9205 Modified Files: Common.cpp Common.h GnuNode.cpp GnuNode.h GnuSearch.cpp stdafx.h Removed Files: TimeMod.cpp TimeMod.h Log Message: initial changes to bring up to date with gnucdnaR2. Index: Common.cpp =================================================================== RCS file: /cvsroot/gnucula/Gnucula/Common.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Common.cpp 8 Jul 2003 07:43:49 -0000 1.9 --- Common.cpp 20 Jan 2004 21:43:04 -0000 1.10 *************** *** 2,6 **** Gnucula - A Gnutella Library Based on GnucDNA ! Copyright (C) 2000-2003 John Marshall This library is free software; you can redistribute it and/or --- 2,6 ---- Gnucula - A Gnutella Library Based on GnucDNA ! Copyright (C) 2000-2004 John Marshall This library is free software; you can redistribute it and/or *************** *** 105,114 **** } ! CharString GetFileError(CFileException* error) { if(!error) return "File Error Unknown"; ! switch( error->m_cause ) { --- 105,114 ---- } ! CharString GetFileError(CFileException* error) { if(!error) return "File Error Unknown"; ! switch(error->m_cause) { *************** *** 163,167 **** } ! PriorityPacket::PriorityPacket(byte* packet, int length, int type, int hops) { --- 163,169 ---- } ! // FIXME: is priority packet not needed?? ! // remove if not. ! #if 0 PriorityPacket::PriorityPacket(byte* packet, int length, int type, int hops) { *************** *** 183,186 **** --- 185,189 ---- } } + #endif // Return the first string before the delim char *************** *** 337,338 **** --- 340,403 ---- return URL; } + + CharString GetTimeZoneStr() + { + CharString TZStr; + #ifndef OPENGCC + int TZHours = abs(_timezone) / (60 * 60); + int TZMins = ((abs(_timezone) / 60) - (TZHours * 60)); + + TZStr.Format("%c%2.2d:%2.2d", (_timezone < 0 ? '-' : '+'), TZHours, TZMins); + #else + OpenTime Temp; + TZStr = Temp.GetTZString(); + #endif + return TZStr; + } + + #ifdef OPENGCC // test functions here... + + #else// still in gnuc. code + CTimeSpan LocalTimeZone() + { + int TZHours = _timezone / (60 * 60); + int TZMins = ((abs(_timezone) / 60) - (abs(TZHours) * 60)); + + return CTimeSpan(0, TZHours, TZMins, 0); + } + #endif + + + // New functions, introduced with G2 + + char tolowerex(char letter) + { + if(65 <= letter && letter <= 90) + return letter + 32; + + return letter; + } + + int memfind(byte* mem, int length, byte value) + { + ASSERT(length); + + for(int i = 0; i < length; i++) + if( mem[i] == value) + return i; + + return -1; + } + + uint32 HashGuid(GUID &Guid) + { + byte* pGuidRaw = (byte*) &Guid; + + // XOR every 4 bytes together ... + uint32 hash = (pGuidRaw[0] ^ pGuidRaw[4] ^ pGuidRaw[8] ^ pGuidRaw[12]) + + 256 * (pGuidRaw[1] ^ pGuidRaw[5] ^ pGuidRaw[9] ^ pGuidRaw[13]) + + 256 * 256 * (pGuidRaw[2] ^ pGuidRaw[6] ^ pGuidRaw[10] ^ pGuidRaw[14]) + + 256 * 256 * 256 * (pGuidRaw[3] ^ pGuidRaw[7] ^ pGuidRaw[11] ^ pGuidRaw[15]); + + return hash; + } Index: Common.h =================================================================== RCS file: /cvsroot/gnucula/Gnucula/Common.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Common.h 9 Jul 2003 05:50:08 -0000 1.11 --- Common.h 20 Jan 2004 21:43:04 -0000 1.12 *************** *** 2,6 **** Gnucula - A Gnutella Library Based on GnucDNA ! Copyright (C) 2000-2003 John Marshall This library is free software; you can redistribute it and/or --- 2,6 ---- Gnucula - A Gnutella Library Based on GnucDNA ! Copyright (C) 2000-2004 John Marshall This library is free software; you can redistribute it and/or *************** *** 36,43 **** #include "stdafx.h" #include "FileLock.h" - #include "TimeMod.h" // Pre-definitions class CGnuNode; --- 36,47 ---- #include "stdafx.h" #include "FileLock.h" // Pre-definitions + struct Result; + struct ResultGroup; + + // eliminated in G2 + #if 0 class CGnuNode; *************** *** 56,62 **** struct QueryComp; struct RecentQuery; - struct Result; - struct ResultGroup; - struct UpdateFile; struct FileChunk; --- 60,63 ---- *************** *** 66,70 **** struct ErrorInfo; ! // Functions --- 67,71 ---- struct ErrorInfo; ! #endif // Functions *************** *** 78,81 **** --- 79,118 ---- void GnuCreateGuid(GUID *pGuid); + // Time Functions + CharString GetTimeZoneStr(); + CharString GetTimeString(char * = "%Y-%m-%dT%H:%MZ"); + + #ifdef OPENGCC + // put extensible time functions here, eliminate CTime types from main code + //void AdjustTime(&TimeObject); + //TimeObject CurrentTime(void); <- maybe unneeded + #else + CTimeSpan LocalTimeZone(); + #endif + + // introduced with G2 + char tolowerex(char letter); + int memfind(byte* mem, int length, byte value); + uint32 HashGuid(GUID &Guid); + + // introduced with G2... used in new gnushare and gnutransfers + // and most G2 files. + #ifndef OPENGCC + #pragma pack (push, 1) + #endif + struct IPv4 + { + IP Host; + UINT Port; + + IPv4() + { + Host.S_addr = 0; + Port = 0; + }; + }; + #ifndef OPENGCC + #pragma pack (pop) + #endif // Definitions *************** *** 135,139 **** --- 172,336 ---- }; + struct RangeType + { + DWORD StartByte; + DWORD EndByte; + }; + + struct FileSource + { + uint32 SourceID; + + // Node info + IPv4 Address; + int Network; + CString HostStr; + CString Path; + int Speed; + CString Vendor; + int Distance; + int GnuRouteID; + GUID PushID; + std::vector<IPv4> DirectHubs; + + bool Firewall; + bool OpenSlots; + bool Busy; + bool Stable; + bool ActualSpeed; + + int RealBytesPerSec; + + + // File info + CString Name; + CString NameLower; + + uint32 FileIndex; + uint64 Size; + + CString Sha1Hash; + CString TigerHash; + + int MetaID; + std::map<int, CString> AttributeMap; + + std::vector<CString> GnuExtraInfo; + + std::vector<RangeType> AvailableRanges; + + // Download info + CString Handshake; + CString Error; + int RetryWait; + int Tries; + bool TigerSupport; + bool PushSent; + + enum States + { + eUntested, + eTrying, + eAlive, + eCorrupt, + eFailed + } Status; + + + FileSource() + { + Init(); + }; + + FileSource(AltLocation& nAltLoc) + { + Init(); + + Network = NETWORK_GNUTELLA; // Replace with more specific + + Name = NameLower = nAltLoc.Name; + NameLower.MakeLower(); + + Sha1Hash = nAltLoc.Sha1Hash; + FileIndex = nAltLoc.Index; + + Address.Host = StrtoIP(nAltLoc.HostPort.Host); + Address.Port = nAltLoc.HostPort.Port; + }; + + void Init() + { + SourceID = 0; + + // Node + Network = 0; + Speed = 0; + Distance = 0; + GnuRouteID = 0; + memset(&PushID, 0, 16); + + Firewall = false; + OpenSlots = false; + Busy = false; + Stable = false; + ActualSpeed = false; + + RealBytesPerSec = 0; + + // File + FileIndex = 0; + Size = 0; + MetaID = 0; + + // Download + RetryWait = 0; + Tries = 0; + TigerSupport = false; + PushSent = false; + + Status = States::eUntested; + }; + }; + + + struct ResultGroup + { + uint32 ResultID; + + CharString Name; + CharString NameLower; + uint32 Size; + uint32 AvgSpeed; + + CharString Sha1Hash; + + std::map<UINT, UINT> HostMap; + std::vector<Result> ResultList; + + // Meta avg + int AvgMetaID; + std::map<int, CharString> AvgAttributeMap; + + int State; + + ResultGroup() + { + ResultID = 0; + NextHostID = 1; + + Size = 0; + AvgSpeed = 0; + + AvgMetaID = 0; + + State = 0; + }; + }; + + + // structures eliminated in G2 change + // FIXME: remove once compilation is verified. + #if 0 struct HashedFile { *************** *** 173,178 **** UINT Index; ! DWORD Size; ! DWORD Matches; DWORD Uploads; --- 370,375 ---- UINT Index; ! DWORD Size; ! DWORD Matches; DWORD Uploads; *************** *** 232,236 **** }; ! // struct WordData { --- 429,433 ---- }; ! // struct WordData { *************** *** 243,255 **** { std::vector<WordData>* LocalKey; // Locally indexed ! std::list<int>* RemoteKey; // Remotely indexed ! WordKey() { ! LocalKey = NULL; RemoteKey = NULL; }; ! ~WordKey() { if(LocalKey) --- 440,452 ---- { std::vector<WordData>* LocalKey; // Locally indexed ! std::list<int>* RemoteKey; // Remotely indexed ! WordKey() { ! LocalKey = NULL; RemoteKey = NULL; }; ! ~WordKey() { if(LocalKey) *************** *** 302,308 **** struct RecentQuery { ! GUID Guid; int SecsOld; ! RecentQuery(); --- 499,505 ---- struct RecentQuery { ! GUID Guid; int SecsOld; ! RecentQuery(); *************** *** 314,323 **** }; - struct RangeType - { - DWORD StartByte; - DWORD EndByte; - }; - struct Result { --- 511,514 ---- *************** *** 327,331 **** std::vector<CharString> Info; ! CharString Sha1Hash; --- 518,522 ---- std::vector<CharString> Info; ! CharString Sha1Hash; *************** *** 333,337 **** DWORD Size; ! // Node info UINT HostID; --- 524,528 ---- DWORD Size; ! // Node info UINT HostID; *************** *** 409,413 **** { Result(); ! Name = NameLower = nAltLoc.Name; NameLower.MakeLower(); --- 600,604 ---- { Result(); ! Name = NameLower = nAltLoc.Name; NameLower.MakeLower(); *************** *** 420,444 **** }; - struct ResultGroup - { - UINT ResultID; - - CharString Name; - CharString NameLower; - UINT Size; - UINT AvgSpeed; - - CharString Sha1Hash; - - std::map<UINT, UINT> HostMap; - std::vector<Result> ResultList; - - // Meta avg - int AvgMetaID; - std::map<int, CharString> AvgAttributeMap; - - int State; - }; - struct FilePart { --- 611,614 ---- *************** *** 461,465 **** CharString Sha1Hash; ! int StartPos; int ChunkLength; --- 631,635 ---- CharString Sha1Hash; ! int StartPos; int ChunkLength; *************** *** 493,497 **** PriorityPacket(byte*, int, int, int); ~PriorityPacket(); ! byte* m_Packet; int m_Length; --- 663,667 ---- PriorityPacket(byte*, int, int, int); ~PriorityPacket(); ! byte* m_Packet; int m_Length; *************** *** 508,511 **** --- 678,682 ---- ErrorInfo():Time(CTime::GetCurrentTime()) { } }; + #endif #endif // COMMON_H Index: GnuNode.cpp =================================================================== RCS file: /cvsroot/gnucula/Gnucula/GnuNode.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** GnuNode.cpp 23 Aug 2003 21:30:00 -0000 1.20 --- GnuNode.cpp 20 Jan 2004 21:43:04 -0000 1.21 *************** *** 136,140 **** // Host Browsing m_BrowseID = 0; ! m_BrowseSize = 0; m_BrowseBuffer = NULL; m_BrowseBuffSize = 0; --- 136,140 ---- // Host Browsing m_BrowseID = 0; ! m_BrowseSize = 0; m_BrowseBuffer = NULL; m_BrowseBuffSize = 0; *************** *** 160,164 **** m_StatPackets[i][j] = 0; ! m_StatPos = 0; m_StatElements = 0; m_Efficiency = 0; --- 160,164 ---- m_StatPackets[i][j] = 0; ! m_StatPos = 0; m_StatElements = 0; m_Efficiency = 0; *************** *** 166,174 **** for (i = 0; i < 2; i++) { ! m_StatPings[i] = 0; ! m_StatPongs[i] = 0; ! m_StatQueries[i] = 0; m_StatQueryHits[i] = 0; ! m_StatPushes[i] = 0; } --- 166,174 ---- for (i = 0; i < 2; i++) { ! m_StatPings[i] = 0; ! m_StatPongs[i] = 0; ! m_StatQueries[i] = 0; m_StatQueryHits[i] = 0; ! m_StatPushes[i] = 0; } Index: GnuNode.h =================================================================== RCS file: /cvsroot/gnucula/Gnucula/GnuNode.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** GnuNode.h 10 Jul 2003 22:41:07 -0000 1.18 --- GnuNode.h 20 Jan 2004 21:43:04 -0000 1.19 *************** *** 85,89 **** CharString FindHeader(CharString); ! void ParseTryHeader(CcharString, bool = false); // Sending packets --- 85,89 ---- CharString FindHeader(CharString); ! void ParseTryHeader(CharString, bool = false); // Sending packets *************** *** 104,111 **** // Socket vars int m_NodeID; ! int m_Status; ! int m_SecsTrying; int m_SecsAlive; ! int m_SecsDead; int m_IntervalPing; int m_NextReSearchWait; --- 104,111 ---- // Socket vars int m_NodeID; ! int m_Status; ! int m_SecsTrying; int m_SecsAlive; ! int m_SecsDead; int m_IntervalPing; int m_NextReSearchWait; Index: GnuSearch.cpp =================================================================== RCS file: /cvsroot/gnucula/Gnucula/GnuSearch.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** GnuSearch.cpp 9 Jul 2003 05:50:08 -0000 1.9 --- GnuSearch.cpp 20 Jan 2004 21:43:04 -0000 1.10 *************** *** 79,84 **** m_PacketLength = 0; - m_BrowseNode = NULL; - // Build list of hosts we've searched for (int i = 0; i < m_pComm->m_NodeList.size(); i++) --- 79,82 ---- Index: stdafx.h =================================================================== RCS file: /cvsroot/gnucula/Gnucula/stdafx.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** stdafx.h 11 Jul 2003 02:44:56 -0000 1.16 --- stdafx.h 20 Jan 2004 21:43:04 -0000 1.17 *************** *** 90,93 **** --- 90,99 ---- #else // OPENGCC start + // some standard lib.s + //#include <string> + //#include <sstream> + #include <stddef.h> // can disable?? + using namespace std; + #include "platform/opengcc/typedefs.h" // some type workarounds #include "platform/opengcc/strings.h" --- TimeMod.cpp DELETED --- --- TimeMod.h DELETED --- |