From: <arn...@us...> - 2006-10-08 20:01:23
|
Revision: 666 http://svn.sourceforge.net/dcplusplus/?rev=666&view=rev Author: arnetheduck Date: 2006-10-08 12:59:43 -0700 (Sun, 08 Oct 2006) Log Message: ----------- cleanup, bugfixes Modified Paths: -------------- dcplusplus/trunk/Compile.txt dcplusplus/trunk/changelog.txt dcplusplus/trunk/client/AdcCommand.cpp dcplusplus/trunk/client/AdcCommand.h dcplusplus/trunk/client/AdcHub.cpp dcplusplus/trunk/client/AdcHub.h dcplusplus/trunk/client/BitInputStream.h dcplusplus/trunk/client/BitOutputStream.h dcplusplus/trunk/client/BufferedSocket.cpp dcplusplus/trunk/client/BufferedSocket.h dcplusplus/trunk/client/CID.h dcplusplus/trunk/client/Client.cpp dcplusplus/trunk/client/Client.h dcplusplus/trunk/client/ClientManager.cpp dcplusplus/trunk/client/ClientManager.h dcplusplus/trunk/client/ConnectionManager.cpp dcplusplus/trunk/client/ConnectionManager.h dcplusplus/trunk/client/CryptoManager.cpp dcplusplus/trunk/client/CryptoManager.h dcplusplus/trunk/client/DownloadManager.cpp dcplusplus/trunk/client/DownloadManager.h dcplusplus/trunk/client/Encoder.cpp dcplusplus/trunk/client/Encoder.h dcplusplus/trunk/client/FastAlloc.h dcplusplus/trunk/client/FavoriteManager.cpp dcplusplus/trunk/client/FavoriteManager.h dcplusplus/trunk/client/FavoriteUser.h dcplusplus/trunk/client/File.cpp dcplusplus/trunk/client/File.h dcplusplus/trunk/client/FilteredFile.h dcplusplus/trunk/client/FinishedManager.h dcplusplus/trunk/client/HashManager.cpp dcplusplus/trunk/client/HashManager.h dcplusplus/trunk/client/HashValue.h dcplusplus/trunk/client/HttpConnection.cpp dcplusplus/trunk/client/HttpConnection.h dcplusplus/trunk/client/MerkleCheckOutputStream.h dcplusplus/trunk/client/MerkleTree.h dcplusplus/trunk/client/NmdcHub.cpp dcplusplus/trunk/client/NmdcHub.h dcplusplus/trunk/client/QueueItem.h dcplusplus/trunk/client/QueueManager.cpp dcplusplus/trunk/client/QueueManager.h dcplusplus/trunk/client/SFVReader.h dcplusplus/trunk/client/SSLSocket.cpp dcplusplus/trunk/client/SSLSocket.h dcplusplus/trunk/client/SearchManager.cpp dcplusplus/trunk/client/SearchManager.h dcplusplus/trunk/client/Semaphore.h dcplusplus/trunk/client/ShareManager.cpp dcplusplus/trunk/client/ShareManager.h dcplusplus/trunk/client/Socket.cpp dcplusplus/trunk/client/Socket.h dcplusplus/trunk/client/Streams.h dcplusplus/trunk/client/StringSearch.h dcplusplus/trunk/client/Text.cpp dcplusplus/trunk/client/Text.h dcplusplus/trunk/client/Thread.h dcplusplus/trunk/client/TigerHash.cpp dcplusplus/trunk/client/TigerHash.h dcplusplus/trunk/client/TimerManager.cpp dcplusplus/trunk/client/TimerManager.h dcplusplus/trunk/client/UploadManager.cpp dcplusplus/trunk/client/UploadManager.h dcplusplus/trunk/client/User.cpp dcplusplus/trunk/client/User.h dcplusplus/trunk/client/UserConnection.cpp dcplusplus/trunk/client/UserConnection.h dcplusplus/trunk/client/Util.cpp dcplusplus/trunk/client/Util.h dcplusplus/trunk/client/ZUtils.h dcplusplus/trunk/client/config.h dcplusplus/trunk/client/stdinc.cpp dcplusplus/trunk/client/stdinc.h dcplusplus/trunk/windows/AboutDlg.h dcplusplus/trunk/windows/HashProgressDlg.h dcplusplus/trunk/windows/HubFrame.cpp dcplusplus/trunk/windows/MainFrm.cpp dcplusplus/trunk/windows/MainFrm.h dcplusplus/trunk/windows/QueueFrame.h dcplusplus/trunk/windows/SpyFrame.cpp dcplusplus/trunk/windows/SpyFrame.h dcplusplus/trunk/windows/StatsFrame.cpp dcplusplus/trunk/windows/StatsFrame.h dcplusplus/trunk/windows/TransferView.h dcplusplus/trunk/windows/WinUtil.cpp Removed Paths: ------------- dcplusplus/trunk/Makefile.am dcplusplus/trunk/acinclude.m4 dcplusplus/trunk/client/Makefile.am dcplusplus/trunk/configure.ac Modified: dcplusplus/trunk/Compile.txt =================================================================== --- dcplusplus/trunk/Compile.txt 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/Compile.txt 2006-10-08 19:59:43 UTC (rev 666) @@ -2,7 +2,10 @@ How to compile in 3 easy steps: -1) Download the source and STLPort from the DC++ download site. Unpack the DC++ source. Unpack the STLport source into the stlport directory. +1) Download the source DC++ download site. Unpack the DC++ source. + Download STLPort 5.0.2 from http://sf.net/stlport and unpack it to a temporary folder. Inside you'll + find a folder named stlport which contains files such as "algorithm". Copy the contents of this folder + to the stlport folder where you unpacked DC++. Download WTL from http://sf.net/projects/wtl. Unpack it to the wtl folder. 2) You most probably have to update your Platform SDK, http://msdn.microsoft.com will tell you how. @@ -10,29 +13,24 @@ one file, you can ask someone at the dev hub to supply it for you (or look for it in the DC++ bugzilla, it's attached to one of the bugs). -3) Open the solution and press your build button. If you find your executable unreasonably large, you - probably compiled in debug mode - switch to release once you're done testing the code. +3) Open the solution in vc7.1 (2004) and press your build button. If you find your executable unreasonably large, + you probably compiled in debug mode - switch to release once you're done testing the code. -Note 1; I now use vc7.1 (2003). I don't care particularly if you use an older MS compiler (6.0, 7.0), - because these don't even come close to supporting the c++ standard. If you want to try anyway, - you're on your own. You will need a new Platform SDK if you're using VS 6.0. - The client part usually compiles fine with g++ 3.4+, There's a bug in 3.3 - (and probably older versions) that prevents a few files from being compiled. -Note 2; You'll need DBGHELP.dll from the binary distribution unless you're using WinXP, otherwise +Note; You'll need DBGHELP.dll from the binary distribution unless you're using WinXP, otherwise you'll get errors saying symbols are missing when running your compiled executable. My copy says version 5.1.2600.1106 right now. -Note 3; If you have problems, read the forum posts before posting. Somebody else has probably made your +Note; If you have problems, read the forum posts before posting. Somebody else has probably made your mistake already. The word to note in the last sentence is 'your', so let me articulate a bit more, it works on my computer, so it's yours that is not correctly set up. -Note 4; To build the HTML Help file, you will need to download and install the HTML Help Workshop +Note; To build the HTML Help file, you will need to download and install the HTML Help Workshop application. The custom build setup relies on it being installed to the default path, which is: "C:\Program Files\HTML Help Workshop\" http://msdn.microsoft.com/library/default.asp?url=/library/en-us/htmlhelp/html/hwMicrosoftHTMLHelpDownloads.asp -Note 5; You need to have python installed if you change StringDefs.h, as a small python script is automatically +Note; You need to have python installed if you change StringDefs.h, as a small python script is automatically run to generate StringDefs.cpp and Example.xml. To turn it off or change python path, go to client->Header Files->StringDefs.h->Properties->Custom build step and change the appropriate values. The help file's changelog.html is also updated via a python script (courtesy of fusbar). @@ -41,12 +39,7 @@ to generate some nice docs...just check that the paths in doxyfile are correct (graphviz)... Linux / Unix: -I've made some rudimentary autoconf/automake scripts now, so you can compile the client part into a library -without too much hassle (I don't check if it compiles very often though...). You'll need the latest versions -of automake and autoconf, and after getting the source (from SVN is easiest), do -"aclocal && automake && autoconf && configure && make" and you'll have the client part nicely compiled. -When / if I test it I do it on a Gentoo AMD64 box with the latest gcc in 64-bit mode, so I don't have a clue -if the 32-bit compile works... +Look at linuxdcpp.berlios.de for the *nix port of DC++ - they'll gladly accept any help. Submitting patches @@ -55,12 +48,17 @@ completely random, which just might be the case. Popular reasons for rejecting a patch include, but are not limited to, ugly code, abusable features, feature that I don't like that bloat the application and incompatibility with other modifications I've already done. -To increase the chances of your patch being accepted, post them in the DC++ bugzilla as diffs against the latest -code you can find (in the SVN repository on sourceforge most probably). You can find a lot of -information about diff and patch by googling for it. I like unified format (diff -u). When diffing, apply diff to -the folders of the two versions, so that the paths will be included in the diff. + +To increase the chances of your patch being accepted, do like this: +1) Check out the latest code from SVN (see http://sf.net/projects/dcplusplus for instructions) +2) Make your modification. If you make other modifications apart from the one you want to submit, do them + on a separate copy of the DC++ source code and then copy them to this folder. +3) In the source root folder (the one with this file in it) do "svn diff > my-patch.diff". +4) Post the file in the DC++ bugzilla (don't forget to hand over copyright, see below). + By submitting a patch, you agree to that I get copyright of it. This to avoid stupid situations later on where the copyright is split out over a million people, each of which could stop further distribution of DC++, and also to make it easier for us to defend the gpl against violators. If you don't like this policy, start your own distribution, if you're lucky it might become more popular than the original =). Please -state explicitly in the email that you give me copyright over the code if the submission is larger than trivial. +state explicitly in the bugzilla that you give me copyright over the code if the submission is larger than trivial. + Deleted: dcplusplus/trunk/Makefile.am =================================================================== --- dcplusplus/trunk/Makefile.am 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/Makefile.am 2006-10-08 19:59:43 UTC (rev 666) @@ -1 +0,0 @@ -SUBDIRS=client Deleted: dcplusplus/trunk/acinclude.m4 =================================================================== --- dcplusplus/trunk/acinclude.m4 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/acinclude.m4 2006-10-08 19:59:43 UTC (rev 666) @@ -1,21 +0,0 @@ - -# Check for STLPort -AC_DEFUN([AX_LIB_STLPORT], -[ - AC_MSG_CHECKING([for STLPort]) - AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE( - [ - AC_LANG_PROGRAM - ([[ -#include <string> -#ifndef _STLPORT_VERSION -#error No STLPort -#endif - ]]) - ], - [AC_DEFINE([HAVE_STLPORT], 1, [If you have STLPort installed]) AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])] - ) - AC_LANG_POP -]) \ No newline at end of file Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/changelog.txt 2006-10-08 19:59:43 UTC (rev 666) @@ -6,6 +6,12 @@ * Fixed crash on invalid remote command during upload * [ADC] Improved GFI command support * Lowest priority downloads are no longer started if there are other downloads running +* Upgraded to STLport 5.0.2 +* Updated compile instructions +* Updated unsigned types to C99 +* Removed unmaintained autoconf files +* Reworked match listing to make it slightly faster +* Fixed a few random crashes -- 0.697 2006-09-29 -- * [ADC] Fixed a few protocol issues Modified: dcplusplus/trunk/client/AdcCommand.cpp =================================================================== --- dcplusplus/trunk/client/AdcCommand.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/AdcCommand.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -22,8 +22,8 @@ #include "AdcCommand.h" #include "ClientManager.h" -AdcCommand::AdcCommand(u_int32_t aCmd, char aType /* = TYPE_CLIENT */) : cmdInt(aCmd), from(0), type(aType) { } -AdcCommand::AdcCommand(u_int32_t aCmd, const u_int32_t aTarget, char aType) : cmdInt(aCmd), from(0), to(aTarget), type(aType) { } +AdcCommand::AdcCommand(uint32_t aCmd, char aType /* = TYPE_CLIENT */) : cmdInt(aCmd), from(0), type(aType) { } +AdcCommand::AdcCommand(uint32_t aCmd, const uint32_t aTarget, char aType) : cmdInt(aCmd), from(0), to(aTarget), type(aType) { } AdcCommand::AdcCommand(Severity sev, Error err, const string& desc, char aType /* = TYPE_CLIENT */) : cmdInt(CMD_STA), from(0), type(aType) { addParam(Util::toString(sev * 100 + err)); addParam(desc); @@ -161,7 +161,7 @@ return getHeaderString(aCID) + getParamString(false); } -string AdcCommand::toString(u_int32_t sid /* = 0 */, bool nmdc /* = false */) const { +string AdcCommand::toString(uint32_t sid /* = 0 */, bool nmdc /* = false */) const { return getHeaderString(sid, nmdc) + getParamString(nmdc); } @@ -183,7 +183,7 @@ return tmp; } -string AdcCommand::getHeaderString(u_int32_t sid, bool nmdc) const { +string AdcCommand::getHeaderString(uint32_t sid, bool nmdc) const { string tmp; if(nmdc) { tmp += "$ADC"; Modified: dcplusplus/trunk/client/AdcCommand.h =================================================================== --- dcplusplus/trunk/client/AdcCommand.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/AdcCommand.h 2006-10-08 19:59:43 UTC (rev 666) @@ -32,7 +32,7 @@ class AdcCommand { public: - template<u_int32_t T> + template<uint32_t T> struct Type { enum { CMD = T }; }; @@ -82,9 +82,9 @@ static const char TYPE_UDP = 'U'; #if defined(_WIN32) || defined(__i386__) || defined(__x86_64__) || defined(__alpha) -#define C(n, a, b, c) static const u_int32_t CMD_##n = (((u_int32_t)a) | (((u_int32_t)b)<<8) | (((u_int32_t)c)<<16)); typedef Type<CMD_##n> n +#define C(n, a, b, c) static const uint32_t CMD_##n = (((uint32_t)a) | (((uint32_t)b)<<8) | (((uint32_t)c)<<16)); typedef Type<CMD_##n> n #else -#define C(n, a, b, c) static const u_int32_t CMD_##n = ((((u_int32_t)a)<<24) | (((u_int32_t)b)<<16) | (((u_int32_t)c)<<8)); typedef Type<CMD_##n> n +#define C(n, a, b, c) static const uint32_t CMD_##n = ((((uint32_t)a)<<24) | (((uint32_t)b)<<16) | (((uint32_t)c)<<8)); typedef Type<CMD_##n> n #endif // Base commands C(SUP, 'S','U','P'); @@ -107,15 +107,15 @@ C(CMD, 'C','M','D'); #undef C - static const u_int32_t HUB_SID = 0x41414141; // AAAA in base32 + static const uint32_t HUB_SID = 0x41414141; // AAAA in base32 - explicit AdcCommand(u_int32_t aCmd, char aType = TYPE_CLIENT); - explicit AdcCommand(u_int32_t aCmd, const u_int32_t aTarget, char aType); + explicit AdcCommand(uint32_t aCmd, char aType = TYPE_CLIENT); + explicit AdcCommand(uint32_t aCmd, const uint32_t aTarget, char aType); explicit AdcCommand(Severity sev, Error err, const string& desc, char aType = TYPE_CLIENT); explicit AdcCommand(const string& aLine, bool nmdc = false) throw(ParseException); void parse(const string& aLine, bool nmdc = false) throw(ParseException); - u_int32_t getCommand() const { return cmdInt; } + uint32_t getCommand() const { return cmdInt; } char getType() const { return type; } void setType(char t) { type = t; } @@ -125,7 +125,7 @@ const StringList& getParameters() const { return parameters; } string toString(const CID& aCID) const; - string toString(u_int32_t sid, bool nmdc = false) const; + string toString(uint32_t sid, bool nmdc = false) const; AdcCommand& addParam(const string& name, const string& value) { parameters.push_back(name); @@ -142,30 +142,30 @@ /** Return a named parameter where the name is a two-letter code */ bool getParam(const char* name, size_t start, string& ret) const; bool hasFlag(const char* name, size_t start) const; - static u_int16_t toCode(const char* x) { return *((u_int16_t*)x); } + static uint16_t toCode(const char* x) { return *((uint16_t*)x); } - bool operator==(u_int32_t aCmd) { return cmdInt == aCmd; } + bool operator==(uint32_t aCmd) { return cmdInt == aCmd; } static string escape(const string& str, bool old); - u_int32_t getTo() const { return to; } - AdcCommand& setTo(const u_int32_t sid) { to = sid; return *this; } - u_int32_t getFrom() const { return from; } + uint32_t getTo() const { return to; } + AdcCommand& setTo(const uint32_t sid) { to = sid; return *this; } + uint32_t getFrom() const { return from; } - static u_int32_t toSID(const string& aSID) { return *reinterpret_cast<const u_int32_t*>(aSID.data()); } - static string fromSID(const u_int32_t aSID) { return string(reinterpret_cast<const char*>(&aSID), sizeof(aSID)); } + static uint32_t toSID(const string& aSID) { return *reinterpret_cast<const uint32_t*>(aSID.data()); } + static string fromSID(const uint32_t aSID) { return string(reinterpret_cast<const char*>(&aSID), sizeof(aSID)); } private: string getHeaderString(const CID& cid) const; - string getHeaderString(u_int32_t sid, bool nmdc) const; + string getHeaderString(uint32_t sid, bool nmdc) const; string getParamString(bool nmdc) const; StringList parameters; string features; union { char cmdChar[4]; - u_int8_t cmd[4]; - u_int32_t cmdInt; + uint8_t cmd[4]; + uint32_t cmdInt; }; - u_int32_t from; - u_int32_t to; + uint32_t from; + uint32_t to; char type; }; Modified: dcplusplus/trunk/client/AdcHub.cpp =================================================================== --- dcplusplus/trunk/client/AdcHub.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/AdcHub.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -48,7 +48,7 @@ clearUsers(); } -OnlineUser& AdcHub::getUser(const u_int32_t aSID, const CID& aCID) { +OnlineUser& AdcHub::getUser(const uint32_t aSID, const CID& aCID) { OnlineUser* ou = findUser(aSID); if(ou) { return *ou; @@ -62,17 +62,17 @@ } if(aSID != AdcCommand::HUB_SID) - ClientManager::getInstance()->putOnline(*ou); + ClientManager::getInstance()->putOnline(ou); return *ou; } -OnlineUser* AdcHub::findUser(const u_int32_t aSID) const { +OnlineUser* AdcHub::findUser(const uint32_t aSID) const { Lock l(cs); SIDMap::const_iterator i = users.find(aSID); return i == users.end() ? NULL : i->second; } -void AdcHub::putUser(const u_int32_t aSID) { +void AdcHub::putUser(const uint32_t aSID) { OnlineUser* ou = 0; { Lock l(cs); @@ -84,7 +84,7 @@ } if(aSID != AdcCommand::HUB_SID) - ClientManager::getInstance()->putOffline(*ou); + ClientManager::getInstance()->putOffline(ou); fire(ClientListener::UserRemoved(), this, *ou); delete ou; @@ -99,12 +99,11 @@ for(SIDIter i = tmp.begin(); i != tmp.end(); ++i) { if(i->first != AdcCommand::HUB_SID) - ClientManager::getInstance()->putOffline(*i->second); + ClientManager::getInstance()->putOffline(i->second); delete i->second; } } - void AdcHub::handle(AdcCommand::INF, AdcCommand& c) throw() { if(c.getParameters().empty()) return; @@ -386,7 +385,7 @@ } void AdcHub::connect(const OnlineUser& user) { - u_int32_t r = Util::rand(); + uint32_t r = Util::rand(); connect(user, Util::toString(r), CryptoManager::getInstance()->TLSOk() && user.getUser()->isSet(User::TLS)); } @@ -460,7 +459,7 @@ return; if(!salt.empty()) { size_t saltBytes = salt.size() * 5 / 8; - AutoArray<u_int8_t> buf(saltBytes); + AutoArray<uint8_t> buf(saltBytes); Encoder::fromBase32(salt.c_str(), buf, saltBytes); TigerHash th; CID cid = getMyIdentity().getUser()->getCID(); @@ -568,7 +567,7 @@ string AdcHub::checkNick(const string& aNick) { string tmp = aNick; for(size_t i = 0; i < aNick.size(); ++i) { - if(static_cast<u_int8_t>(tmp[i]) <= 32) { + if(static_cast<uint8_t>(tmp[i]) <= 32) { tmp[i] = '_'; } } @@ -607,7 +606,7 @@ send(cmd.toString(sid)); } -void AdcHub::on(Second, u_int32_t aTick) throw() { +void AdcHub::on(Second, uint32_t aTick) throw() { if(getAutoReconnect() && state == STATE_PROTOCOL && (getReconnecting() || ((getLastActivity() + getReconnDelay() * 1000) < aTick)) ) { // Try to reconnect... connect(); Modified: dcplusplus/trunk/client/AdcHub.h =================================================================== --- dcplusplus/trunk/client/AdcHub.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/AdcHub.h 2006-10-08 19:59:43 UTC (rev 666) @@ -70,7 +70,7 @@ virtual ~AdcHub() throw(); /** Map session id to OnlineUser */ - typedef HASH_MAP<u_int32_t, OnlineUser*> SIDMap; + typedef HASH_MAP<uint32_t, OnlineUser*> SIDMap; typedef SIDMap::iterator SIDIter; Socket udp; @@ -80,7 +80,7 @@ string salt; - u_int32_t sid; + uint32_t sid; bool reconnect; static const string CLIENT_PROTOCOL; @@ -91,9 +91,9 @@ virtual string checkNick(const string& nick); - OnlineUser& getUser(const u_int32_t aSID, const CID& aCID); - OnlineUser* findUser(const u_int32_t sid) const; - void putUser(const u_int32_t sid); + OnlineUser& getUser(const uint32_t aSID, const CID& aCID); + OnlineUser* findUser(const uint32_t sid) const; + void putUser(const uint32_t sid); void clearUsers(); @@ -121,7 +121,7 @@ virtual void on(Line, const string& aLine) throw(); virtual void on(Failed, const string& aLine) throw(); - virtual void on(Second, u_int32_t aTick) throw(); + virtual void on(Second, uint32_t aTick) throw(); }; #endif // !defined(ADC_HUB_H) Modified: dcplusplus/trunk/client/BitInputStream.h =================================================================== --- dcplusplus/trunk/client/BitInputStream.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/BitInputStream.h 2006-10-08 19:59:43 UTC (rev 666) @@ -35,14 +35,14 @@ class BitInputStream { public: - BitInputStream(const u_int8_t* aStream, size_t aStart, size_t aEnd) : bitPos(aStart*8), endPos(aEnd*8), is(aStream) { } + BitInputStream(const uint8_t* aStream, size_t aStart, size_t aEnd) : bitPos(aStart*8), endPos(aEnd*8), is(aStream) { } ~BitInputStream() { } bool get() throw(BitStreamException) { if(bitPos > endPos) { throw BitStreamException(STRING(SEEK_BEYOND_END)); } - bool ret = (((u_int8_t)is[bitPos>>3]) >> (bitPos&0x07)) & 0x01; + bool ret = (((uint8_t)is[bitPos>>3]) >> (bitPos&0x07)) & 0x01; bitPos++; return ret; } @@ -62,7 +62,7 @@ size_t bitPos; size_t endPos; - const u_int8_t* is; + const uint8_t* is; }; #endif // !defined(BIT_INPUT_STREAM_H) Modified: dcplusplus/trunk/client/BitOutputStream.h =================================================================== --- dcplusplus/trunk/client/BitOutputStream.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/BitOutputStream.h 2006-10-08 19:59:43 UTC (rev 666) @@ -29,8 +29,8 @@ BitOutputStream(string& aStream) : is(aStream), bitPos(0), next(0) { } ~BitOutputStream() { } - void put(vector<u_int8_t>& b) { - for(vector<u_int8_t>::iterator i = b.begin(); i != b.end(); ++i) { + void put(vector<uint8_t>& b) { + for(vector<uint8_t>::iterator i = b.begin(); i != b.end(); ++i) { next |= (*i) << bitPos++; if(bitPos > 7) { @@ -54,7 +54,7 @@ BitOutputStream& operator=(const BitOutputStream&); string& is; int bitPos; - u_int8_t next; + uint8_t next; }; #endif // !defined(BIT_OUTPUT_STREAM_H) Modified: dcplusplus/trunk/client/BufferedSocket.cpp =================================================================== --- dcplusplus/trunk/client/BufferedSocket.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/BufferedSocket.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -136,7 +136,7 @@ return; fire(BufferedSocketListener::Connecting()); - u_int32_t startTime = GET_TICK(); + uint32_t startTime = GET_TICK(); if(proxy) { sock->socksConnect(aAddr, aPort, CONNECT_TIMEOUT); } else { @@ -180,7 +180,7 @@ const int BufSize = 1024; // Special to autodetect nmdc connections... string::size_type pos = 0; - AutoArray<u_int8_t> buffer (BufSize); + AutoArray<uint8_t> buffer (BufSize); size_t in; l = line; // decompress all input data and store in l. @@ -269,8 +269,8 @@ size_t sockSize = (size_t)sock->getSocketOptInt(SO_SNDBUF); size_t bufSize = max(sockSize, (size_t)64*1024); - vector<u_int8_t> readBuf(bufSize); - vector<u_int8_t> writeBuf(bufSize); + vector<uint8_t> readBuf(bufSize); + vector<uint8_t> writeBuf(bufSize); size_t readPos = 0; Modified: dcplusplus/trunk/client/BufferedSocket.h =================================================================== --- dcplusplus/trunk/client/BufferedSocket.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/BufferedSocket.h 2006-10-08 19:59:43 UTC (rev 666) @@ -51,7 +51,7 @@ virtual void on(Connecting) throw() { } virtual void on(Connected) throw() { } virtual void on(Line, const string&) throw() { } - virtual void on(Data, u_int8_t*, size_t) throw() { } + virtual void on(Data, uint8_t*, size_t) throw() { } virtual void on(BytesSent, size_t, size_t) throw() { } virtual void on(ModeChange) throw() { } virtual void on(TransmitDone) throw() { } @@ -158,9 +158,9 @@ size_t rollback; bool failed; string line; - vector<u_int8_t> inbuf; - vector<u_int8_t> writeBuf; - vector<u_int8_t> sendBuf; + vector<uint8_t> inbuf; + vector<uint8_t> writeBuf; + vector<uint8_t> sendBuf; Socket* sock; bool disconnecting; Modified: dcplusplus/trunk/client/CID.h =================================================================== --- dcplusplus/trunk/client/CID.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/CID.h 2006-10-08 19:59:43 UTC (rev 666) @@ -34,7 +34,7 @@ size_t operator()(const CID& c) const { return c.toHash(); } }; CID() { memset(cid, 0, sizeof(cid)); } - explicit CID(const u_int8_t* data) { memcpy(cid, data, sizeof(cid)); } + explicit CID(const uint8_t* data) { memcpy(cid, data, sizeof(cid)); } explicit CID(const string& base32) { Encoder::fromBase32(base32.c_str(), cid, sizeof(cid)); } bool operator==(const CID& rhs) const { return memcmp(cid, rhs.cid, sizeof(cid)) == 0; } @@ -44,20 +44,20 @@ string& toBase32(string& tmp) const { return Encoder::toBase32(cid, sizeof(cid), tmp); } size_t toHash() const { return *reinterpret_cast<const size_t*>(cid); } - const u_int8_t* data() const { return cid; } + const uint8_t* data() const { return cid; } - bool isZero() const { return find_if(cid, cid+SIZE, bind2nd(not_equal_to<u_int8_t>(), 0)) == (cid+SIZE); } + bool isZero() const { return find_if(cid, cid+SIZE, bind2nd(not_equal_to<uint8_t>(), 0)) == (cid+SIZE); } static CID generate() { - u_int8_t data[CID::SIZE]; + uint8_t data[CID::SIZE]; for(size_t i = 0; i < sizeof(data); ++i) { - data[i] = (u_int8_t)Util::rand(); + data[i] = (uint8_t)Util::rand(); } return CID(data); } private: - u_int8_t cid[SIZE]; + uint8_t cid[SIZE]; }; #endif // !defined(CID_H) Modified: dcplusplus/trunk/client/Client.cpp =================================================================== --- dcplusplus/trunk/client/Client.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/Client.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -166,5 +166,5 @@ return lip; } -void Client::on(Second, u_int32_t) throw() { +void Client::on(Second, uint32_t) throw() { } Modified: dcplusplus/trunk/client/Client.h =================================================================== --- dcplusplus/trunk/client/Client.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/Client.h 2006-10-08 19:59:43 UTC (rev 666) @@ -149,8 +149,8 @@ GETSET(Identity, hubIdentity, HubIdentity); GETSET(string, defpassword, Password); - GETSET(u_int32_t, reconnDelay, ReconnDelay); - GETSET(u_int32_t, lastActivity, LastActivity); + GETSET(uint32_t, reconnDelay, ReconnDelay); + GETSET(uint32_t, lastActivity, LastActivity); GETSET(bool, registered, Registered); GETSET(bool, autoReconnect, AutoReconnect); GETSET(bool, reconnecting, Reconnecting); @@ -183,7 +183,7 @@ virtual string checkNick(const string& nick) = 0; // TimerManagerListener - virtual void on(Second, u_int32_t aTick) throw(); + virtual void on(Second, uint32_t aTick) throw(); private: @@ -200,7 +200,7 @@ string hubUrl; string address; string ip; - u_int16_t port; + uint16_t port; char separator; bool secure; CountType countType; Modified: dcplusplus/trunk/client/ClientManager.cpp =================================================================== --- dcplusplus/trunk/client/ClientManager.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/ClientManager.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -33,7 +33,6 @@ #include "AdcHub.h" #include "NmdcHub.h" - Client* ClientManager::getClient(const string& aHubURL) { Client* c; if(Util::strnicmp("adc://", aHubURL.c_str(), 6) == 0) { @@ -67,41 +66,41 @@ delete aClient; } -size_t ClientManager::getUserCount() { +size_t ClientManager::getUserCount() const { Lock l(cs); return onlineUsers.size(); } -StringList ClientManager::getHubs(const CID& cid) { +StringList ClientManager::getHubs(const CID& cid) const { Lock l(cs); StringList lst; - OnlinePair op = onlineUsers.equal_range(cid); - for(OnlineIter i = op.first; i != op.second; ++i) { + OnlinePairC op = onlineUsers.equal_range(cid); + for(OnlineIterC i = op.first; i != op.second; ++i) { lst.push_back(i->second->getClient().getHubUrl()); } return lst; } -StringList ClientManager::getHubNames(const CID& cid) { +StringList ClientManager::getHubNames(const CID& cid) const { Lock l(cs); StringList lst; - OnlinePair op = onlineUsers.equal_range(cid); - for(OnlineIter i = op.first; i != op.second; ++i) { + OnlinePairC op = onlineUsers.equal_range(cid); + for(OnlineIterC i = op.first; i != op.second; ++i) { lst.push_back(i->second->getClient().getHubName()); } return lst; } -StringList ClientManager::getNicks(const CID& cid) { +StringList ClientManager::getNicks(const CID& cid) const { Lock l(cs); StringSet nicks; - OnlinePair op = onlineUsers.equal_range(cid); - for(OnlineIter i = op.first; i != op.second; ++i) { + OnlinePairC op = onlineUsers.equal_range(cid); + for(OnlineIterC i = op.first; i != op.second; ++i) { nicks.insert(i->second->getIdentity().getNick()); } if(nicks.empty()) { // Offline perhaps? - UserIter i = users.find(cid); + UserMap::const_iterator i = users.find(cid); if(i != users.end() && !i->second->getFirstNick().empty()) { nicks.insert(i->second->getFirstNick()); } else { @@ -111,29 +110,29 @@ return StringList(nicks.begin(), nicks.end()); } -string ClientManager::getConnection(const CID& cid) { +string ClientManager::getConnection(const CID& cid) const { Lock l(cs); - OnlineIter i = onlineUsers.find(cid); + OnlineIterC i = onlineUsers.find(cid); if(i != onlineUsers.end()) { return i->second->getIdentity().getConnection(); } return STRING(OFFLINE); } -int64_t ClientManager::getAvailable() { +int64_t ClientManager::getAvailable() const { Lock l(cs); int64_t bytes = 0; - for(OnlineIter i = onlineUsers.begin(); i != onlineUsers.end(); ++i) { + for(OnlineIterC i = onlineUsers.begin(); i != onlineUsers.end(); ++i) { bytes += i->second->getIdentity().getBytesShared(); } return bytes; } -bool ClientManager::isConnected(const string& aUrl) { +bool ClientManager::isConnected(const string& aUrl) const { Lock l(cs); - for(Client::Iter i = clients.begin(); i != clients.end(); ++i) { + for(Client::List::const_iterator i = clients.begin(); i != clients.end(); ++i) { if((*i)->getHubUrl() == aUrl) { return true; } @@ -141,7 +140,7 @@ return false; } -string ClientManager::findHub(const string& ipPort) { +string ClientManager::findHub(const string& ipPort) const { Lock l(cs); string ip; @@ -155,8 +154,8 @@ } string url; - for(Client::Iter i = clients.begin(); i != clients.end(); ++i) { - Client* c = *i; + for(Client::List::const_iterator i = clients.begin(); i != clients.end(); ++i) { + const Client* c = *i; if(c->getIp() == ip) { // If exact match is found, return it if(c->getPort() == port) @@ -188,15 +187,15 @@ UserIter ui = users.find(cid); if(ui != users.end()) { - if(ui->second->getFirstNick().empty()) // Could happen on bad queue loads etc... + if(ui->second->getFirstNick().empty()) ui->second->setFirstNick(aNick); ui->second->setFlag(User::NMDC); return ui->second; } - User::Ptr p(new User(aNick)); - - p->setCID(cid); + User::Ptr p(new User(cid)); + p->setFirstNick(aNick); + p->setFlag(User::NMDC); users.insert(make_pair(cid, p)); return p; @@ -214,19 +213,19 @@ return p; } -User::Ptr ClientManager::findUser(const CID& cid) throw() { +User::Ptr ClientManager::findUser(const CID& cid) const throw() { Lock l(cs); - UserIter ui = users.find(cid); + UserMap::const_iterator ui = users.find(cid); if(ui != users.end()) { return ui->second; } - return NULL; + return 0; } -bool ClientManager::isOp(const User::Ptr& user, const string& aHubUrl) { +bool ClientManager::isOp(const User::Ptr& user, const string& aHubUrl) const { Lock l(cs); - pair<OnlineIter, OnlineIter> p = onlineUsers.equal_range(user->getCID()); - for(OnlineIter i = p.first; i != p.second; ++i) { + OnlinePairC p = onlineUsers.equal_range(user->getCID()); + for(OnlineIterC i = p.first; i != p.second; ++i) { if(i->second->getClient().getHubUrl() == aHubUrl) { return i->second->getIdentity().isOp(); } @@ -234,39 +233,37 @@ return false; } -CID ClientManager::makeCid(const string& aNick, const string& aHubUrl) throw() { +CID ClientManager::makeCid(const string& aNick, const string& aHubUrl) const throw() { string n = Text::toLower(aNick); TigerHash th; th.update(n.c_str(), n.length()); th.update(Text::toLower(aHubUrl).c_str(), aHubUrl.length()); - // Construct hybrid CID from the first 64 bits of the tiger hash - should be + // Construct hybrid CID from the bits of the tiger hash - should be // fairly random, and hopefully low-collision return CID(th.finalize()); } -void ClientManager::putOnline(OnlineUser& ou) throw() { +void ClientManager::putOnline(OnlineUser* ou) throw() { { Lock l(cs); - dcassert(!ou.getUser()->getCID().isZero()); - onlineUsers.insert(make_pair(ou.getUser()->getCID(), &ou)); + onlineUsers.insert(make_pair(ou->getUser()->getCID(), ou)); } - if(!ou.getUser()->isOnline()) { - ou.getUser()->setFlag(User::ONLINE); - fire(ClientManagerListener::UserConnected(), ou.getUser()); + if(!ou->getUser()->isOnline()) { + ou->getUser()->setFlag(User::ONLINE); + fire(ClientManagerListener::UserConnected(), ou->getUser()); } } -void ClientManager::putOffline(OnlineUser& ou) throw() { +void ClientManager::putOffline(OnlineUser* ou) throw() { bool lastUser = false; { Lock l(cs); - OnlinePair op = onlineUsers.equal_range(ou.getUser()->getCID()); + OnlinePair op = onlineUsers.equal_range(ou->getUser()->getCID()); dcassert(op.first != op.second); for(OnlineIter i = op.first; i != op.second; ++i) { OnlineUser* ou2 = i->second; - /// @todo something nicer to compare with... - if(&ou.getClient() == &ou2->getClient()) { + if(ou == ou2) { lastUser = (distance(op.first, op.second) == 1); onlineUsers.erase(i); break; @@ -275,8 +272,8 @@ } if(lastUser) { - ou.getUser()->unsetFlag(User::ONLINE); - fire(ClientManagerListener::UserDisconnected(), ou.getUser()); + ou->getUser()->unsetFlag(User::ONLINE); + fire(ClientManagerListener::UserDisconnected(), ou->getUser()); } } @@ -362,7 +359,7 @@ } else { try { string ip, file; - u_int16_t port = 0; + uint16_t port = 0; Util::decodeUrl(aSeeker, ip, port, file); ip = Socket::resolve(ip); @@ -387,6 +384,7 @@ } void ClientManager::userCommand(const User::Ptr& p, const ::UserCommand& uc, StringMap& params, bool compatibility) { + Lock l(cs); OnlineIter i = onlineUsers.find(p->getCID()); if(i == onlineUsers.end()) return; @@ -435,7 +433,7 @@ users.insert(make_pair(getMe()->getCID(), getMe())); } -void ClientManager::on(TimerManagerListener::Minute, u_int32_t /* aTick */) throw() { +void ClientManager::on(TimerManagerListener::Minute, uint32_t /* aTick */) throw() { Lock l(cs); // Collect some garbage... Modified: dcplusplus/trunk/client/ClientManager.h =================================================================== --- dcplusplus/trunk/client/ClientManager.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/ClientManager.h 2006-10-08 19:59:43 UTC (rev 666) @@ -41,14 +41,14 @@ Client* getClient(const string& aHubURL); void putClient(Client* aClient); - size_t getUserCount(); - int64_t getAvailable(); - StringList getHubs(const CID& cid); - StringList getHubNames(const CID& cid); - StringList getNicks(const CID& cid); - string getConnection(const CID& cid); + size_t getUserCount() const; + int64_t getAvailable() const; + StringList getHubs(const CID& cid) const; + StringList getHubNames(const CID& cid) const; + StringList getNicks(const CID& cid) const; + string getConnection(const CID& cid) const; - bool isConnected(const string& aUrl); + bool isConnected(const string& aUrl) const; void search(int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken); void search(StringList& who, int aSizeMode, int64_t aSize, int aFileType, const string& aString, const string& aToken); @@ -57,24 +57,24 @@ User::Ptr getUser(const string& aNick, const string& aHubUrl) throw(); User::Ptr getUser(const CID& cid) throw(); - string findHub(const string& ipPort); + string findHub(const string& ipPort) const; - User::Ptr findUser(const string& aNick, const string& aHubUrl) throw() { return findUser(makeCid(aNick, aHubUrl)); } - User::Ptr findUser(const CID& cid) throw(); + User::Ptr findUser(const string& aNick, const string& aHubUrl) const throw() { return findUser(makeCid(aNick, aHubUrl)); } + User::Ptr findUser(const CID& cid) const throw(); User::Ptr findLegacyUser(const string& aNick) const throw(); - bool isOnline(const User::Ptr& aUser) { + bool isOnline(const User::Ptr& aUser) const { Lock l(cs); return onlineUsers.find(aUser->getCID()) != onlineUsers.end(); } - bool isOp(const User::Ptr& aUser, const string& aHubUrl); + bool isOp(const User::Ptr& aUser, const string& aHubUrl) const; /** Constructs a synthetic, hopefully unique CID */ - CID makeCid(const string& nick, const string& hubUrl) throw(); + CID makeCid(const string& nick, const string& hubUrl) const throw(); - void putOnline(OnlineUser& ou) throw(); - void putOffline(OnlineUser& ou) throw(); + void putOnline(OnlineUser* ou) throw(); + void putOffline(OnlineUser* ou) throw(); User::Ptr& getMe(); @@ -105,7 +105,9 @@ typedef HASH_MULTIMAP_X(CID, OnlineUser*, CID::Hash, equal_to<CID>, less<CID>) OnlineMap; typedef OnlineMap::iterator OnlineIter; + typedef OnlineMap::const_iterator OnlineIterC; typedef pair<OnlineIter, OnlineIter> OnlinePair; + typedef pair<OnlineIterC, OnlineIterC> OnlinePairC; Client::List clients; mutable CriticalSection cs; @@ -148,7 +150,7 @@ int aFileType, const string& aString) throw(); virtual void on(AdcSearch, Client* c, const AdcCommand& adc, const CID& from) throw(); // TimerManagerListener - virtual void on(TimerManagerListener::Minute, u_int32_t aTick) throw(); + virtual void on(TimerManagerListener::Minute, uint32_t aTick) throw(); }; #endif // !defined(CLIENT_MANAGER_H) Modified: dcplusplus/trunk/client/ConnectionManager.cpp =================================================================== --- dcplusplus/trunk/client/ConnectionManager.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/ConnectionManager.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -126,7 +126,7 @@ userConnections.erase(remove(userConnections.begin(), userConnections.end(), aConn), userConnections.end()); } -void ConnectionManager::on(TimerManagerListener::Second, u_int32_t aTick) throw() { +void ConnectionManager::on(TimerManagerListener::Second, uint32_t aTick) throw() { User::List passiveUsers; ConnectionQueueItem::List removed; User::List idlers; @@ -202,7 +202,7 @@ } } -void ConnectionManager::on(TimerManagerListener::Minute, u_int32_t aTick) throw() { +void ConnectionManager::on(TimerManagerListener::Minute, uint32_t aTick) throw() { Lock l(cs); for(UserConnection::Iter j = userConnections.begin(); j != userConnections.end(); ++j) { @@ -212,8 +212,8 @@ } } -static const u_int32_t FLOOD_TRIGGER = 20000; -static const u_int32_t FLOOD_ADD = 2000; +static const uint32_t FLOOD_TRIGGER = 20000; +static const uint32_t FLOOD_ADD = 2000; ConnectionManager::Server::Server(bool secure_, short aPort, const string& ip /* = "0.0.0.0" */) : port(0), secure(secure_), die(false) { sock.create(); @@ -223,7 +223,7 @@ start(); } -static const u_int32_t POLL_TIMEOUT = 250; +static const uint32_t POLL_TIMEOUT = 250; int ConnectionManager::Server::run() throw() { try { @@ -243,7 +243,7 @@ * It's always the other fellow that starts sending if he made the connection. */ void ConnectionManager::accept(const Socket& sock, bool secure) throw() { - u_int32_t now = GET_TICK(); + uint32_t now = GET_TICK(); if(now > floodCounter) { floodCounter = now + FLOOD_ADD; Modified: dcplusplus/trunk/client/ConnectionManager.h =================================================================== --- dcplusplus/trunk/client/ConnectionManager.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/ConnectionManager.h 2006-10-08 19:59:43 UTC (rev 666) @@ -54,7 +54,7 @@ const User::Ptr& getUser() const { return user; } GETSET(State, state, State); - GETSET(u_int32_t, lastAttempt, LastAttempt); + GETSET(uint32_t, lastAttempt, LastAttempt); GETSET(bool, download, Download); private: ConnectionQueueItem(const ConnectionQueueItem&); @@ -152,7 +152,7 @@ ExpectedMap expectedConnections; - u_int32_t floodCounter; + uint32_t floodCounter; Server* server; Server* secureServer; @@ -189,8 +189,8 @@ virtual void on(AdcCommand::STA, UserConnection*, const AdcCommand&) throw(); // TimerManagerListener - virtual void on(TimerManagerListener::Second, u_int32_t aTick) throw(); - virtual void on(TimerManagerListener::Minute, u_int32_t aTick) throw(); + virtual void on(TimerManagerListener::Second, uint32_t aTick) throw(); + virtual void on(TimerManagerListener::Minute, uint32_t aTick) throw(); }; Modified: dcplusplus/trunk/client/CryptoManager.cpp =================================================================== --- dcplusplus/trunk/client/CryptoManager.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/CryptoManager.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -216,7 +216,7 @@ } -void CryptoManager::decodeBZ2(const u_int8_t* is, size_t sz, string& os) throw (CryptoException) { +void CryptoManager::decodeBZ2(const uint8_t* is, size_t sz, string& os) throw (CryptoException) { bz_stream bs = { 0 }; if(BZ2_bzDecompressInit(&bs, 0, 0) != BZ_OK) @@ -229,7 +229,7 @@ bs.avail_in = sz; bs.avail_out = bufsize; - bs.next_in = (char*)(const_cast<u_int8_t*>(is)); + bs.next_in = (char*)(const_cast<uint8_t*>(is)); bs.next_out = buf; int err; @@ -257,8 +257,8 @@ } } -string CryptoManager::keySubst(const u_int8_t* aKey, size_t len, size_t n) { - AutoArray<u_int8_t> temp(len + n * 10); +string CryptoManager::keySubst(const uint8_t* aKey, size_t len, size_t n) { + AutoArray<uint8_t> temp(len + n * 10); size_t j=0; @@ -279,32 +279,32 @@ temp[j++] = aKey[i]; } } - return string((char*)(u_int8_t*)temp, j); + return string((char*)(uint8_t*)temp, j); } string CryptoManager::makeKey(const string& aLock) { if(aLock.size() < 3) return Util::emptyString; - AutoArray<u_int8_t> temp(aLock.length()); - u_int8_t v1; + AutoArray<uint8_t> temp(aLock.length()); + uint8_t v1; size_t extra=0; - v1 = (u_int8_t)(aLock[0]^5); - v1 = (u_int8_t)(((v1 >> 4) | (v1 << 4)) & 0xff); + v1 = (uint8_t)(aLock[0]^5); + v1 = (uint8_t)(((v1 >> 4) | (v1 << 4)) & 0xff); temp[0] = v1; string::size_type i; for(i = 1; i<aLock.length(); i++) { - v1 = (u_int8_t)(aLock[i]^aLock[i-1]); - v1 = (u_int8_t)(((v1 >> 4) | (v1 << 4))&0xff); + v1 = (uint8_t)(aLock[i]^aLock[i-1]); + v1 = (uint8_t)(((v1 >> 4) | (v1 << 4))&0xff); temp[i] = v1; if(isExtra(temp[i])) extra++; } - temp[0] = (u_int8_t)(temp[0] ^ temp[aLock.length()-1]); + temp[0] = (uint8_t)(temp[0] ^ temp[aLock.length()-1]); if(isExtra(temp[0])) { extra++; Modified: dcplusplus/trunk/client/CryptoManager.h =================================================================== --- dcplusplus/trunk/client/CryptoManager.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/CryptoManager.h 2006-10-08 19:59:43 UTC (rev 666) @@ -44,7 +44,7 @@ const string& getPk() { return pk; } bool isExtended(const string& aLock) { return strncmp(aLock.c_str(), "EXTENDEDPROTOCOL", 16) == 0; } - void decodeBZ2(const u_int8_t* is, size_t sz, string& os) throw(CryptoException); + void decodeBZ2(const uint8_t* is, size_t sz, string& os) throw(CryptoException); SSLSocket* getClientSocket(bool allowUntrusted) throw(SocketException); SSLSocket* getServerSocket(bool allowUntrusted) throw(SocketException); @@ -71,8 +71,8 @@ const string lock; const string pk; - string keySubst(const u_int8_t* aKey, size_t len, size_t n); - bool isExtra(u_int8_t b) { + string keySubst(const uint8_t* aKey, size_t len, size_t n); + bool isExtra(uint8_t b) { return (b == 0 || b==5 || b==124 || b==96 || b==126 || b==36); } }; Modified: dcplusplus/trunk/client/DownloadManager.cpp =================================================================== --- dcplusplus/trunk/client/DownloadManager.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/DownloadManager.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -110,7 +110,7 @@ } } -void DownloadManager::on(TimerManagerListener::Second, u_int32_t aTick) throw() { +void DownloadManager::on(TimerManagerListener::Second, uint32_t aTick) throw() { typedef vector<pair<string, User::Ptr> > TargetList; TargetList dropTargets; @@ -130,15 +130,15 @@ // Automatically remove or disconnect slow sources - if((u_int32_t)(aTick / 1000) % SETTING(AUTODROP_INTERVAL) == 0) { + if((uint32_t)(aTick / 1000) % SETTING(AUTODROP_INTERVAL) == 0) { for(Download::Iter i = downloads.begin(); i != downloads.end(); ++i) { - u_int32_t timeElapsed = GET_TICK() - (*i)->getStart(); - u_int32_t timeInactive = GET_TICK() - (*i)->getUserConnection().getLastActivity(); - u_int64_t bytesDownloaded = (*i)->getTotal(); - bool timeElapsedOk = timeElapsed >= (u_int32_t)SETTING(AUTODROP_ELAPSED) * 1000; - bool timeInactiveOk = timeInactive <= (u_int32_t)SETTING(AUTODROP_INACTIVITY) * 1000; + uint32_t timeElapsed = GET_TICK() - (*i)->getStart(); + uint32_t timeInactive = GET_TICK() - (*i)->getUserConnection().getLastActivity(); + uint64_t bytesDownloaded = (*i)->getTotal(); + bool timeElapsedOk = timeElapsed >= (uint32_t)SETTING(AUTODROP_ELAPSED) * 1000; + bool timeInactiveOk = timeInactive <= (uint32_t)SETTING(AUTODROP_INACTIVITY) * 1000; bool speedTooLow = timeElapsedOk && timeInactiveOk && bytesDownloaded > 0 ? - bytesDownloaded / timeElapsed * 1000 < (u_int32_t)SETTING(AUTODROP_SPEED) : false; + bytesDownloaded / timeElapsed * 1000 < (uint32_t)SETTING(AUTODROP_SPEED) : false; bool onlineSourcesOk = (*i)->isSet(Download::FLAG_USER_LIST) ? true : QueueManager::getInstance()->countOnlineSources((*i)->getTarget()) >= SETTING(AUTODROP_MINSOURCES); bool filesizeOk = !((*i)->isSet(Download::FLAG_USER_LIST)) && (*i)->getSize() >= ((int64_t)SETTING(AUTODROP_FILESIZE)) * 1024; @@ -211,7 +211,7 @@ virtual size_t write(const void* xbuf, size_t len) throw(Exception) { size_t pos = 0; - u_int8_t* b = (u_int8_t*)xbuf; + uint8_t* b = (uint8_t*)xbuf; while(pos < len) { size_t left = len - pos; if(bufPos == 0 && left >= TigerTree::HASH_SIZE) { @@ -236,7 +236,7 @@ } private: TigerTree& tree; - u_int8_t buf[TigerTree::HASH_SIZE]; + uint8_t buf[TigerTree::HASH_SIZE]; size_t bufPos; }; @@ -372,7 +372,7 @@ DummyOutputStream dummy; - vector<u_int8_t> buf((size_t)min((int64_t)1024*1024, tt.getBlockSize())); + vector<uint8_t> buf((size_t)min((int64_t)1024*1024, tt.getBlockSize())); do { int64_t blockPos = startPos - tt.getBlockSize(); @@ -457,7 +457,7 @@ template<bool managed> class RollbackOutputStream : public OutputStream { public: - RollbackOutputStream(File* f, OutputStream* aStream, size_t bytes) : s(aStream), pos(0), bufSize(bytes), buf(new u_int8_t[bytes]) { + RollbackOutputStream(File* f, OutputStream* aStream, size_t bytes) : s(aStream), pos(0), bufSize(bytes), buf(new uint8_t[bytes]) { size_t n = bytes; f->read(buf, n); f->movePos(-((int64_t)bytes)); @@ -472,7 +472,7 @@ if(buf != NULL) { size_t n = min(len, bufSize - pos); - u_int8_t* wb = (u_int8_t*)b; + uint8_t* wb = (uint8_t*)b; if(memcmp(buf + pos, wb, n) != 0) { throw RollbackException(STRING(ROLLBACK_INCONSISTENCY)); } @@ -489,7 +489,7 @@ OutputStream* s; size_t pos; size_t bufSize; - u_int8_t* buf; + uint8_t* buf; }; @@ -587,7 +587,7 @@ return true; } -void DownloadManager::on(UserConnectionListener::Data, UserConnection* aSource, const u_int8_t* aData, size_t aLen) throw() { +void DownloadManager::on(UserConnectionListener::Data, UserConnection* aSource, const uint8_t* aData, size_t aLen) throw() { Download* d = aSource->getDownload(); dcassert(d != NULL); @@ -648,7 +648,7 @@ } else { // Hm, if the real crc == 0, we'll get a file reread extra, but what the heck... - u_int32_t crc = 0; + uint32_t crc = 0; // First, finish writing the file (flushing the buffers and closing the file...) try { @@ -702,20 +702,20 @@ checkDownloads(aSource); } -u_int32_t DownloadManager::calcCrc32(const string& file) throw(FileException) { +uint32_t DownloadManager::calcCrc32(const string& file) throw(FileException) { File ff(file, File::READ, File::OPEN); CalcInputStream<CRC32Filter, false> f(&ff); const size_t BUF_SIZE = 1024*1024; - AutoArray<u_int8_t> b(BUF_SIZE); + AutoArray<uint8_t> b(BUF_SIZE); size_t n = BUF_SIZE; - while(f.read((u_int8_t*)b, n) > 0) + while(f.read((uint8_t*)b, n) > 0) ; // Keep on looping... return f.getFilter().getValue(); } -bool DownloadManager::checkSfv(UserConnection* aSource, Download* d, u_int32_t crc) { +bool DownloadManager::checkSfv(UserConnection* aSource, Download* d, uint32_t crc) { SFVReader sfv(d->getTarget()); if(sfv.hasCRC()) { bool crcMatch = (crc == sfv.getCRC()); Modified: dcplusplus/trunk/client/DownloadManager.h =================================================================== --- dcplusplus/trunk/client/DownloadManager.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/DownloadManager.h 2006-10-08 19:59:43 UTC (rev 666) @@ -199,7 +199,7 @@ Download::List downloads; UserConnection::List idlers; - bool checkRollback(Download* aDownload, const u_int8_t* aBuf, int aLen) throw(FileException); + bool checkRollback(Download* aDownload, const uint8_t* aBuf, int aLen) throw(FileException); void removeConnection(UserConnection::Ptr aConn); void removeDownload(Download* aDown); void fileNotAvailable(UserConnection* aSource); @@ -207,8 +207,8 @@ void moveFile(const string& source, const string&target); void logDownload(UserConnection* aSource, Download* d); - u_int32_t calcCrc32(const string& file) throw(FileException); - bool checkSfv(UserConnection* aSource, Download* d, u_int32_t crc); + uint32_t calcCrc32(const string& file) throw(FileException); + bool checkSfv(UserConnection* aSource, Download* d, uint32_t crc); int64_t getResumePos(const string& file, const TigerTree& tt, int64_t startPos); void failDownload(UserConnection* aSource, const string& reason); @@ -222,7 +222,7 @@ void handleEndData(UserConnection* aSource); // UserConnectionListener - virtual void on(Data, UserConnection*, const u_int8_t*, size_t) throw(); + virtual void on(Data, UserConnection*, const uint8_t*, size_t) throw(); virtual void on(Error, UserConnection*, const string&) throw(); virtual void on(Failed, UserConnection*, const string&) throw(); virtual void on(Sending, UserConnection*, int64_t) throw(); @@ -235,7 +235,7 @@ bool prepareFile(UserConnection* aSource, int64_t newSize, bool z); // TimerManagerListener - virtual void on(TimerManagerListener::Second, u_int32_t aTick) throw(); + virtual void on(TimerManagerListener::Second, uint32_t aTick) throw(); }; #endif // !defined(DOWNLOAD_MANAGER_H) Modified: dcplusplus/trunk/client/Encoder.cpp =================================================================== --- dcplusplus/trunk/client/Encoder.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/Encoder.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -42,16 +42,16 @@ const char Encoder::base32Alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; -string& Encoder::toBase32(const u_int8_t* src, size_t len, string& dst) { +string& Encoder::toBase32(const uint8_t* src, size_t len, string& dst) { // Code snagged from the bitzi bitcollider size_t i, index; - u_int8_t word; + uint8_t word; dst.reserve(((len * 8) / 5) + 1); for(i = 0, index = 0; i < len;) { /* Is the current word going to span a byte boundary? */ if (index > 3) { - word = (u_int8_t)(src[i] & (0xFF >> index)); + word = (uint8_t)(src[i] & (0xFF >> index)); index = (index + 5) % 8; word <<= index; if ((i + 1) < len) @@ -59,7 +59,7 @@ i++; } else { - word = (u_int8_t)(src[i] >> (8 - (index + 5))) & 0x1F; + word = (uint8_t)(src[i] >> (8 - (index + 5))) & 0x1F; index = (index + 5) % 8; if (index == 0) i++; @@ -71,7 +71,7 @@ return dst; } -void Encoder::fromBase32(const char* src, u_int8_t* dst, size_t len) { +void Encoder::fromBase32(const char* src, uint8_t* dst, size_t len) { size_t i, index, offset; memset(dst, 0, len); Modified: dcplusplus/trunk/client/Encoder.h =================================================================== --- dcplusplus/trunk/client/Encoder.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/Encoder.h 2006-10-08 19:59:43 UTC (rev 666) @@ -26,12 +26,12 @@ class Encoder { public: - static string& toBase32(const u_int8_t* src, size_t len, string& tgt); - static string toBase32(const u_int8_t* src, size_t len) { + static string& toBase32(const uint8_t* src, size_t len, string& tgt); + static string toBase32(const uint8_t* src, size_t len) { string tmp; return toBase32(src, len, tmp); } - static void fromBase32(const char* src, u_int8_t* dst, size_t len); + static void fromBase32(const char* src, uint8_t* dst, size_t len); private: static const int8_t base32Table[]; static const char base32Alphabet[]; Modified: dcplusplus/trunk/client/FastAlloc.h =================================================================== --- dcplusplus/trunk/client/FastAlloc.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/FastAlloc.h 2006-10-08 19:59:43 UTC (rev 666) @@ -56,7 +56,7 @@ if (s != sizeof(T)) { ::operator delete(m); } else if(m != NULL) { - deallocate((u_int8_t*)m); + deallocate((uint8_t*)m); } } private: @@ -83,8 +83,8 @@ dcassert(sizeof(T) >= sizeof(void*)); // We want to grow by approximately 128kb at a time... size_t items = ((128*1024 + sizeof(T) - 1)/sizeof(T)); - freeList = new u_int8_t[sizeof(T)*items]; - u_int8_t* tmp = (u_int8_t*)freeList; + freeList = new uint8_t[sizeof(T)*items]; + uint8_t* tmp = (uint8_t*)freeList; for(size_t i = 0; i < items - 1; i++) { *(void**)tmp = tmp + sizeof(T); tmp += sizeof(T); Modified: dcplusplus/trunk/client/FavoriteManager.cpp =================================================================== --- dcplusplus/trunk/client/FavoriteManager.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/FavoriteManager.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -237,7 +237,7 @@ if(listType == TYPE_BZIP2) { try { - CryptoManager::getInstance()->decodeBZ2((u_int8_t*)downloadBuf.data(), downloadBuf.size(), bzlist); + CryptoManager::getInstance()->decodeBZ2((uint8_t*)downloadBuf.data(), downloadBuf.size(), bzlist); } catch(const CryptoException&) { bzlist.clear(); } @@ -439,10 +439,10 @@ e->setPassword(aXml.getChildAttrib("Password")); e->setServer(aXml.getChildAttrib("Server")); e->setUserDescription(aXml.getChildAttrib("UserDescription")); - e->setBottom((u_int16_t)aXml.getIntChildAttrib("Bottom") ); - e->setTop((u_int16_t)aXml.getIntChildAttrib("Top")); - e->setRight((u_int16_t)aXml.getIntChildAttrib("Right")); - e->setLeft((u_int16_t)aXml.getIntChildAttrib("Left")); + e->setBottom((uint16_t)aXml.getIntChildAttrib("Bottom") ); + e->setTop((uint16_t)aXml.getIntChildAttrib("Top")); + e->setRight((uint16_t)aXml.getIntChildAttrib("Right")); + e->setLeft((uint16_t)aXml.getIntChildAttrib("Left")); favoriteHubs.push_back(e); } aXml.stepOut(); @@ -470,7 +470,7 @@ if(aXml.getBoolChildAttrib("GrantSlot")) i->second.setFlag(FavoriteUser::FLAG_GRANTSLOT); - i->second.setLastSeen((u_int32_t)aXml.getIntChildAttrib("LastSeen")); + i->second.setLastSeen((uint32_t)aXml.getIntChildAttrib("LastSeen")); i->second.setDescription(aXml.getChildAttrib("UserDescription")); } @@ -639,7 +639,7 @@ } // HttpConnectionListener -void FavoriteManager::on(Data, HttpConnection*, const u_int8_t* buf, size_t len) throw() { +void FavoriteManager::on(Data, HttpConnection*, const uint8_t* buf, size_t len) throw() { downloadBuf.append((const char*)buf, len); } Modified: dcplusplus/trunk/client/FavoriteManager.h =================================================================== --- dcplusplus/trunk/client/FavoriteManager.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/FavoriteManager.h 2006-10-08 19:59:43 UTC (rev 666) @@ -98,10 +98,10 @@ GETSET(string, password, Password); GETSET(bool, connect, Connect); - GETSET(u_int16_t, bottom, Bottom); - GETSET(u_int16_t, top, Top); - GETSET(u_int16_t, left, Left); - GETSET(u_int16_t, right, Right); + GETSET(uint16_t, bottom, Bottom); + GETSET(uint16_t, top, Top); + GETSET(uint16_t, left, Left); + GETSET(uint16_t, right, Right); private: @@ -259,7 +259,7 @@ virtual void on(UserDisconnected, const User::Ptr& user) throw(); // HttpConnectionListener - virtual void on(Data, HttpConnection*, const u_int8_t*, size_t) throw(); + virtual void on(Data, HttpConnection*, const uint8_t*, size_t) throw(); virtual void on(Failed, HttpConnection*, const string&) throw(); virtual void on(Complete, HttpConnection*, const string&) throw(); virtual void on(Redirected, HttpConnection*, const string&) throw(); Modified: dcplusplus/trunk/client/FavoriteUser.h =================================================================== --- dcplusplus/trunk/client/FavoriteUser.h 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/FavoriteUser.h 2006-10-08 19:59:43 UTC (rev 666) @@ -42,7 +42,7 @@ GETSET(User::Ptr, user, User); GETSET(string, nick, Nick); GETSET(string, url, Url); - GETSET(u_int32_t, lastSeen, LastSeen); + GETSET(uint32_t, lastSeen, LastSeen); GETSET(string, description, Description); }; Modified: dcplusplus/trunk/client/File.cpp =================================================================== --- dcplusplus/trunk/client/File.cpp 2006-10-07 21:51:27 UTC (rev 665) +++ dcplusplus/trunk/client/File.cpp 2006-10-08 19:59:43 UTC (rev 666) @@ -47,21 +47,21 @@ } } -u_int32_t File::getLastModified() throw() { +uint32_t File::getLastModified() throw() { FILETIME f = {0}; ::GetFileTime(h, NULL, NULL, &f); return convertTime(&f); } -u_int32_t File::convertTime(FILETIME* f) { +uint32_t File::convertTime(FILETIME* f) { SYSTEMTIME s = { 1970, 1, 0, 1, 0, 0, 0, 0 }; FILETIME f2 = {0}; if(::SystemTimeToFileTime(&s, &f2)) { - u_int64_t* a = (u_int64_t*)f; - u_int64_t* b = (u_int64_t*)&f2; + uint... [truncated message content] |