2008-05-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Fixed compile error on Mac OS X 10.3.9. This error was caused by 
the
	name collision of static variable and predefined macro.
	* src/BtContext.cc
	* src/BtContext.h
	* src/CookieBoxFactory.cc
	* src/CookieBoxFactory.h
	* src/CookieParser.cc
	* src/CookieParser.h
	* src/DefaultBtContext.cc
pull/1/head
Tatsuhiro Tsujikawa 2008-05-27 14:55:20 +00:00
parent e40ae31748
commit 27102091ad
8 changed files with 67 additions and 55 deletions

View File

@ -1,3 +1,15 @@
2008-05-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed compile error on Mac OS X 10.3.9. This error was caused by the
name collision of static variable and predefined macro.
* src/BtContext.cc
* src/BtContext.h
* src/CookieBoxFactory.cc
* src/CookieBoxFactory.h
* src/CookieParser.cc
* src/CookieParser.h
* src/DefaultBtContext.cc
2008-05-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/RequestGroup.cc

View File

@ -36,30 +36,30 @@
namespace aria2 {
const std::string BtContext::NAME("name");
const std::string BtContext::C_NAME("name");
const std::string BtContext::FILES("files");
const std::string BtContext::C_FILES("files");
const std::string BtContext::LENGTH("length");
const std::string BtContext::C_LENGTH("length");
const std::string BtContext::PATH("path");
const std::string BtContext::C_PATH("path");
const std::string BtContext::INFO("info");
const std::string BtContext::C_INFO("info");
const std::string BtContext::PIECES("pieces");
const std::string BtContext::C_PIECES("pieces");
const std::string BtContext::PIECE_LENGTH("piece length");
const std::string BtContext::C_PIECE_LENGTH("piece length");
const std::string BtContext::PRIVATE("private");
const std::string BtContext::C_PRIVATE("private");
const std::string BtContext::PRIVATE_ON("1");
const std::string BtContext::C_PRIVATE_ON("1");
const std::string BtContext::URL_LIST("url-list");
const std::string BtContext::C_URL_LIST("url-list");
const std::string BtContext::ANNOUNCE("announce");
const std::string BtContext::C_ANNOUNCE("announce");
const std::string BtContext::ANNOUNCE_LIST("announce-list");
const std::string BtContext::C_ANNOUNCE_LIST("announce-list");
const std::string BtContext::NODES("nodes");
const std::string BtContext::C_NODES("nodes");
} // namespace aria2

View File

@ -80,32 +80,32 @@ public:
virtual std::deque<std::pair<std::string, uint16_t> >& getNodes() = 0;
static const std::string NAME;
static const std::string C_NAME;
static const std::string FILES;
static const std::string C_FILES;
static const std::string LENGTH;
static const std::string C_LENGTH;
static const std::string PATH;
static const std::string C_PATH;
static const std::string INFO;
static const std::string C_INFO;
static const std::string PIECES;
static const std::string C_PIECES;
static const std::string PIECE_LENGTH;
static const std::string C_PIECE_LENGTH;
static const std::string PRIVATE;
static const std::string C_PRIVATE;
// This is just a string "1". Used as a value of "private" flag.
static const std::string PRIVATE_ON;
static const std::string C_PRIVATE_ON;
static const std::string URL_LIST;
static const std::string C_URL_LIST;
static const std::string ANNOUNCE;
static const std::string C_ANNOUNCE;
static const std::string ANNOUNCE_LIST;
static const std::string C_ANNOUNCE_LIST;
static const std::string NODES;
static const std::string C_NODES;
};

View File

@ -42,7 +42,7 @@
namespace aria2 {
const std::string CookieBoxFactory::TRUE("TRUE");
const std::string CookieBoxFactory::C_TRUE("TRUE");
CookieBoxHandle CookieBoxFactory::createNewInstance()
{
@ -80,7 +80,7 @@ Cookie CookieBoxFactory::parseNsCookie(const std::string& nsCookieStr) const
}
c.domain = vs[0];
c.path = vs[2];
c.secure = vs[3] == TRUE ? true : false;
c.secure = vs[3] == C_TRUE ? true : false;
int64_t expireDate = Util::parseLLInt(vs[4]);
// TODO assuming time_t is int32_t...
if(expireDate > INT32_MAX) {

View File

@ -67,7 +67,7 @@ public:
}
private:
static const std::string TRUE;
static const std::string C_TRUE;
};
typedef SharedHandle<CookieBoxFactory> CookieBoxFactoryHandle;

View File

@ -41,23 +41,23 @@
namespace aria2 {
const std::string CookieParser::SECURE("secure");
const std::string CookieParser::C_SECURE("secure");
const std::string CookieParser::DOMAIN("domain");
const std::string CookieParser::C_DOMAIN("domain");
const std::string CookieParser::PATH("path");
const std::string CookieParser::C_PATH("path");
const std::string CookieParser::EXPIRES("expires");
const std::string CookieParser::C_EXPIRES("expires");
void CookieParser::setField(Cookie& cookie, const std::string& name, const std::string& value) const
{
if(name == SECURE) {
if(name == C_SECURE) {
cookie.secure = true;
} else if(name == DOMAIN) {
} else if(name == C_DOMAIN) {
cookie.domain = value;
} else if(name == PATH) {
} else if(name == C_PATH) {
cookie.path = value;
} else if(name == EXPIRES) {
} else if(name == C_EXPIRES) {
cookie.expires = Util::httpGMT(value);
cookie.onetime = false;
} else {

View File

@ -58,13 +58,13 @@ public:
Cookies parse(std::istream& s) const;
private:
static const std::string SECURE;
static const std::string C_SECURE;
static const std::string DOMAIN;
static const std::string C_DOMAIN;
static const std::string PATH;
static const std::string C_PATH;
static const std::string EXPIRES;
static const std::string C_EXPIRES;
};
typedef SharedHandle<CookieParser> CookieParserHandle;

View File

@ -115,13 +115,13 @@ void DefaultBtContext::extractPieceHash(const unsigned char* hashData,
void DefaultBtContext::extractFileEntries(const Dictionary* infoDic,
const std::string& defaultName,
const std::deque<std::string>& urlList) {
const Data* nameData = dynamic_cast<const Data*>(infoDic->get(BtContext::NAME));
const Data* nameData = dynamic_cast<const Data*>(infoDic->get(BtContext::C_NAME));
if(nameData) {
name = nameData->toString();
} else {
name = File(defaultName).getBasename()+".file";
}
const List* files = dynamic_cast<const List*>(infoDic->get(BtContext::FILES));
const List* files = dynamic_cast<const List*>(infoDic->get(BtContext::C_FILES));
if(files) {
uint64_t length = 0;
off_t offset = 0;
@ -135,7 +135,7 @@ void DefaultBtContext::extractFileEntries(const Dictionary* infoDic,
continue;
}
const Data* lengthData =
dynamic_cast<const Data*>(fileDic->get(BtContext::LENGTH));
dynamic_cast<const Data*>(fileDic->get(BtContext::C_LENGTH));
if(lengthData) {
length += lengthData->toLLInt();
} else {
@ -143,7 +143,7 @@ void DefaultBtContext::extractFileEntries(const Dictionary* infoDic,
(StringFormat(MSG_SOMETHING_MISSING_IN_TORRENT, "file length").str());
}
const List* pathList =
dynamic_cast<const List*>(fileDic->get(BtContext::PATH));
dynamic_cast<const List*>(fileDic->get(BtContext::C_PATH));
if(!pathList) {
throw DlAbortEx
(StringFormat(MSG_SOMETHING_MISSING_IN_TORRENT, "file path list").str());
@ -182,7 +182,7 @@ void DefaultBtContext::extractFileEntries(const Dictionary* infoDic,
// single-file mode;
fileMode = BtContext::SINGLE;
const Data* length =
dynamic_cast<const Data*>(infoDic->get(BtContext::LENGTH));
dynamic_cast<const Data*>(infoDic->get(BtContext::C_LENGTH));
if(length) {
totalLength = length->toLLInt();
} else {
@ -296,7 +296,7 @@ void DefaultBtContext::processRootDictionary(const Dictionary* rootDic, const st
{
clear();
const Dictionary* infoDic =
dynamic_cast<const Dictionary*>(rootDic->get(BtContext::INFO));
dynamic_cast<const Dictionary*>(rootDic->get(BtContext::C_INFO));
if(!infoDic) {
throw DlAbortEx
(StringFormat(MSG_SOMETHING_MISSING_IN_TORRENT, "info directory").str());
@ -311,7 +311,7 @@ void DefaultBtContext::processRootDictionary(const Dictionary* rootDic, const st
infoHashString = Util::toHex(infoHash, INFO_HASH_LENGTH);
// calculate the number of pieces
const Data* pieceHashData =
dynamic_cast<const Data*>(infoDic->get(BtContext::PIECES));
dynamic_cast<const Data*>(infoDic->get(BtContext::C_PIECES));
if(!pieceHashData) {
throw DlAbortEx
(StringFormat(MSG_SOMETHING_MISSING_IN_TORRENT, "pieces").str());
@ -325,7 +325,7 @@ void DefaultBtContext::processRootDictionary(const Dictionary* rootDic, const st
}
// retrieve piece length
const Data* pieceLengthData =
dynamic_cast<const Data*>(infoDic->get(BtContext::PIECE_LENGTH));
dynamic_cast<const Data*>(infoDic->get(BtContext::C_PIECE_LENGTH));
if(!pieceLengthData) {
throw DlAbortEx
(StringFormat(MSG_SOMETHING_MISSING_IN_TORRENT, "piece length").str());
@ -335,9 +335,9 @@ void DefaultBtContext::processRootDictionary(const Dictionary* rootDic, const st
extractPieceHash(pieceHashData->getData(), pieceHashData->getLen(),
PIECE_HASH_LENGTH);
const Data* privateFlag =
dynamic_cast<const Data*>(infoDic->get(BtContext::PRIVATE));
dynamic_cast<const Data*>(infoDic->get(BtContext::C_PRIVATE));
if(privateFlag) {
if(privateFlag->toString() == BtContext::PRIVATE_ON) {
if(privateFlag->toString() == BtContext::C_PRIVATE_ON) {
_private = true;
}
}
@ -345,7 +345,7 @@ void DefaultBtContext::processRootDictionary(const Dictionary* rootDic, const st
// This implemantation obeys HTTP-Seeding specification:
// see http://www.getright.com/seedtorrent.html
std::deque<std::string> urlList;
extractUrlList(urlList, rootDic->get(BtContext::URL_LIST));
extractUrlList(urlList, rootDic->get(BtContext::C_URL_LIST));
// retrieve file entries
extractFileEntries(infoDic, defaultName, urlList);
if((totalLength+pieceLength-1)/pieceLength != numPieces) {
@ -353,9 +353,9 @@ void DefaultBtContext::processRootDictionary(const Dictionary* rootDic, const st
}
// retrieve announce
const Data* announceData =
dynamic_cast<const Data*>(rootDic->get(BtContext::ANNOUNCE));
dynamic_cast<const Data*>(rootDic->get(BtContext::C_ANNOUNCE));
const List* announceListData =
dynamic_cast<const List*>(rootDic->get(BtContext::ANNOUNCE_LIST));
dynamic_cast<const List*>(rootDic->get(BtContext::C_ANNOUNCE_LIST));
if(announceListData) {
extractAnnounceList(announceListData);
} else if(announceData) {
@ -363,7 +363,7 @@ void DefaultBtContext::processRootDictionary(const Dictionary* rootDic, const st
}
// retrieve nodes
const List* nodes =
dynamic_cast<const List*>(rootDic->get(BtContext::NODES));
dynamic_cast<const List*>(rootDic->get(BtContext::C_NODES));
if(nodes) {
extractNodes(nodes);
}