Replaced gid_t with a2_gid_t cause gid_t is commonly used as group ID.

pull/1/head
Tatsuhiro Tsujikawa 2011-03-17 12:17:46 +09:00
parent 09c120da9b
commit 6e818a06dc
10 changed files with 62 additions and 62 deletions

View File

@ -45,7 +45,7 @@
namespace aria2 {
SharedHandle<DownloadContext>
BtRegistry::getDownloadContext(gid_t gid) const
BtRegistry::getDownloadContext(a2_gid_t gid) const
{
return get(gid).downloadContext_;
}
@ -54,7 +54,7 @@ SharedHandle<DownloadContext>
BtRegistry::getDownloadContext(const std::string& infoHash) const
{
SharedHandle<DownloadContext> dctx;
for(std::map<gid_t, BtObject>::const_iterator i = pool_.begin(),
for(std::map<a2_gid_t, BtObject>::const_iterator i = pool_.begin(),
eoi = pool_.end(); i != eoi; ++i) {
if(bittorrent::getTorrentAttrs((*i).second.downloadContext_)->infoHash ==
infoHash) {
@ -65,14 +65,14 @@ BtRegistry::getDownloadContext(const std::string& infoHash) const
return dctx;
}
void BtRegistry::put(gid_t gid, const BtObject& obj)
void BtRegistry::put(a2_gid_t gid, const BtObject& obj)
{
pool_[gid] = obj;
}
BtObject BtRegistry::get(gid_t gid) const
BtObject BtRegistry::get(a2_gid_t gid) const
{
std::map<gid_t, BtObject>::const_iterator i = pool_.find(gid);
std::map<a2_gid_t, BtObject>::const_iterator i = pool_.find(gid);
if(i == pool_.end()) {
return BtObject();
} else {
@ -80,7 +80,7 @@ BtObject BtRegistry::get(gid_t gid) const
}
}
bool BtRegistry::remove(gid_t gid)
bool BtRegistry::remove(a2_gid_t gid)
{
return pool_.erase(gid);
}

View File

@ -79,22 +79,22 @@ struct BtObject {
class BtRegistry {
private:
std::map<gid_t, BtObject> pool_;
std::map<a2_gid_t, BtObject> pool_;
public:
SharedHandle<DownloadContext>
getDownloadContext(gid_t gid) const;
getDownloadContext(a2_gid_t gid) const;
SharedHandle<DownloadContext>
getDownloadContext(const std::string& infoHash) const;
void put(gid_t gid, const BtObject& obj);
void put(a2_gid_t gid, const BtObject& obj);
BtObject get(gid_t gid) const;
BtObject get(a2_gid_t gid) const;
template<typename OutputIterator>
OutputIterator getAllDownloadContext(OutputIterator dest)
{
for(std::map<gid_t, BtObject>::const_iterator i = pool_.begin(),
for(std::map<a2_gid_t, BtObject>::const_iterator i = pool_.begin(),
eoi = pool_.end(); i != eoi; ++i) {
*dest++ = (*i).second.downloadContext_;
}
@ -103,7 +103,7 @@ public:
void removeAll();
bool remove(gid_t gid);
bool remove(a2_gid_t gid);
};
} // namespace aria2

View File

@ -54,7 +54,7 @@ class MetadataInfo;
struct DownloadResult
{
gid_t gid;
a2_gid_t gid;
std::vector<SharedHandle<FileEntry> > fileEntries;
@ -69,11 +69,11 @@ struct DownloadResult
// This field contains GIDs. See comment in
// RequestGroup.cc::followedByGIDs_.
std::vector<gid_t> followedBy;
std::vector<a2_gid_t> followedBy;
// This field contains GID. See comment in
// RequestGroup.cc::belongsToGID_.
gid_t belongsTo;
a2_gid_t belongsTo;
SharedHandle<Option> option;

View File

@ -120,7 +120,7 @@
namespace aria2 {
gid_t RequestGroup::gidCounter_ = 0;
a2_gid_t RequestGroup::gidCounter_ = 0;
RequestGroup::RequestGroup(const SharedHandle<Option>& option)
: gid_(newGID()),
@ -1319,7 +1319,7 @@ bool RequestGroup::p2pInvolved() const
#endif // !ENABLE_BITTORRENT
}
gid_t RequestGroup::newGID()
a2_gid_t RequestGroup::newGID()
{
if(gidCounter_ == INT64_MAX) {
gidCounter_ = 0;

View File

@ -73,7 +73,7 @@ class BtRuntime;
class PeerStorage;
#endif // ENABLE_BITTORRENT
typedef int64_t gid_t;
typedef int64_t a2_gid_t;
class RequestGroup {
public:
@ -83,9 +83,9 @@ public:
USER_REQUEST
};
private:
static gid_t gidCounter_;
static a2_gid_t gidCounter_;
gid_t gid_;
a2_gid_t gid_;
SharedHandle<Option> option_;
@ -161,13 +161,13 @@ private:
// example, downloads generated by PostDownloadHandler), this field
// has the GID of generated RequestGroups. empty list means there is
// no such RequestGroup.
std::vector<gid_t> followedByGIDs_;
std::vector<a2_gid_t> followedByGIDs_;
// If this download is a part of another download(for example,
// downloading torrent file described in Metalink file), this field
// has the GID of parent RequestGroup. 0 means this is a parent
// RequestGroup.
gid_t belongsToGID_;
a2_gid_t belongsToGID_;
SharedHandle<MetadataInfo> metadataInfo_;
@ -256,7 +256,7 @@ public:
return numConcurrentCommand_;
}
gid_t getGID() const
a2_gid_t getGID() const
{
return gid_;
}
@ -503,17 +503,17 @@ public:
}
}
const std::vector<gid_t>& followedBy() const
const std::vector<a2_gid_t>& followedBy() const
{
return followedByGIDs_;
}
void belongsTo(gid_t gid)
void belongsTo(a2_gid_t gid)
{
belongsToGID_ = gid;
}
gid_t belongsTo() const
a2_gid_t belongsTo() const
{
return belongsToGID_;
}
@ -547,7 +547,7 @@ public:
static void resetGIDCounter() { gidCounter_ = 0; }
static gid_t newGID();
static a2_gid_t newGID();
};
} // namespace aria2

View File

@ -167,7 +167,7 @@ SharedHandle<RequestGroup> RequestGroupMan::getRequestGroup(size_t index) const
namespace {
template<typename Iterator>
Iterator findByGID(Iterator first, Iterator last, gid_t gid)
Iterator findByGID(Iterator first, Iterator last, a2_gid_t gid)
{
for(; first != last; ++first) {
if((*first)->getGID() == gid) {
@ -179,7 +179,7 @@ Iterator findByGID(Iterator first, Iterator last, gid_t gid)
} // namespace
SharedHandle<RequestGroup>
RequestGroupMan::findRequestGroup(gid_t gid) const
RequestGroupMan::findRequestGroup(a2_gid_t gid) const
{
std::deque<SharedHandle<RequestGroup> >::const_iterator i =
findByGID(requestGroups_.begin(), requestGroups_.end(), gid);
@ -191,7 +191,7 @@ RequestGroupMan::findRequestGroup(gid_t gid) const
}
SharedHandle<RequestGroup>
RequestGroupMan::findReservedGroup(gid_t gid) const
RequestGroupMan::findReservedGroup(a2_gid_t gid) const
{
std::deque<SharedHandle<RequestGroup> >::const_iterator i =
findByGID(reservedGroups_.begin(), reservedGroups_.end(), gid);
@ -203,7 +203,7 @@ RequestGroupMan::findReservedGroup(gid_t gid) const
}
size_t RequestGroupMan::changeReservedGroupPosition
(gid_t gid, int pos, HOW how)
(a2_gid_t gid, int pos, HOW how)
{
std::deque<SharedHandle<RequestGroup> >::iterator i =
findByGID(reservedGroups_.begin(), reservedGroups_.end(), gid);
@ -246,7 +246,7 @@ size_t RequestGroupMan::changeReservedGroupPosition
return pos;
}
bool RequestGroupMan::removeReservedGroup(gid_t gid)
bool RequestGroupMan::removeReservedGroup(a2_gid_t gid)
{
std::deque<SharedHandle<RequestGroup> >::iterator i =
findByGID(reservedGroups_.begin(), reservedGroups_.end(), gid);
@ -735,7 +735,7 @@ TransferStat RequestGroupMan::calculateStat()
}
SharedHandle<DownloadResult>
RequestGroupMan::findDownloadResult(gid_t gid) const
RequestGroupMan::findDownloadResult(a2_gid_t gid) const
{
for(std::deque<SharedHandle<DownloadResult> >::const_iterator i =
downloadResults_.begin(), eoi = downloadResults_.end(); i != eoi; ++i) {
@ -746,7 +746,7 @@ RequestGroupMan::findDownloadResult(gid_t gid) const
return SharedHandle<DownloadResult>();
}
bool RequestGroupMan::removeDownloadResult(gid_t gid)
bool RequestGroupMan::removeDownloadResult(a2_gid_t gid)
{
for(std::deque<SharedHandle<DownloadResult> >::iterator i =
downloadResults_.begin(), eoi = downloadResults_.end(); i != eoi; ++i) {

View File

@ -132,14 +132,14 @@ public:
return requestGroups_;
}
SharedHandle<RequestGroup> findRequestGroup(gid_t gid) const;
SharedHandle<RequestGroup> findRequestGroup(a2_gid_t gid) const;
const std::deque<SharedHandle<RequestGroup> >& getReservedGroups() const
{
return reservedGroups_;
}
SharedHandle<RequestGroup> findReservedGroup(gid_t gid) const;
SharedHandle<RequestGroup> findReservedGroup(a2_gid_t gid) const;
enum HOW {
POS_SET,
@ -156,9 +156,9 @@ public:
// beyond the end of the queue, it moves the download to the
// beginning or the end of the queue respectively. Returns the
// destination position.
size_t changeReservedGroupPosition(gid_t gid, int pos, HOW how);
size_t changeReservedGroupPosition(a2_gid_t gid, int pos, HOW how);
bool removeReservedGroup(gid_t gid);
bool removeReservedGroup(a2_gid_t gid);
void showDownloadResults(std::ostream& o) const;
@ -209,14 +209,14 @@ public:
return downloadResults_;
}
SharedHandle<DownloadResult> findDownloadResult(gid_t gid) const;
SharedHandle<DownloadResult> findDownloadResult(a2_gid_t gid) const;
// Removes all download results.
void purgeDownloadResult();
// Removes download result of given gid. Returns true if download
// result was removed. Otherwise returns false.
bool removeDownloadResult(gid_t gid);
bool removeDownloadResult(a2_gid_t gid);
void addDownloadResult(const SharedHandle<DownloadResult>& downloadResult);

View File

@ -139,7 +139,7 @@ const std::string KEY_SERVERS = "servers";
} // namespace
namespace {
SharedHandle<ValueBase> createGIDResponse(gid_t gid)
SharedHandle<ValueBase> createGIDResponse(a2_gid_t gid)
{
return String::g(util::itos(gid));
}
@ -162,7 +162,7 @@ addRequestGroup(const SharedHandle<RequestGroup>& group,
namespace {
SharedHandle<RequestGroup>
findRequestGroup(const SharedHandle<RequestGroupMan>& rgman, gid_t gid)
findRequestGroup(const SharedHandle<RequestGroupMan>& rgman, a2_gid_t gid)
{
SharedHandle<RequestGroup> group = rgman->findRequestGroup(gid);
if(!group) {
@ -191,7 +191,7 @@ void getPosParam(const RpcRequest& req, size_t posParamIndex,
} // namespace
namespace {
gid_t getRequiredGidParam
a2_gid_t getRequiredGidParam
(const RpcRequest& req, size_t posParamIndex)
{
const String* gidParam = req.getStringParam(posParamIndex);
@ -365,7 +365,7 @@ namespace {
SharedHandle<ValueBase> removeDownload
(const RpcRequest& req, DownloadEngine* e, bool forceRemove)
{
gid_t gid = getRequiredGidParam(req, 0);
a2_gid_t gid = getRequiredGidParam(req, 0);
SharedHandle<RequestGroup> group =
e->getRequestGroupMan()->findRequestGroup(gid);
@ -436,7 +436,7 @@ namespace {
SharedHandle<ValueBase> pauseDownload
(const RpcRequest& req, DownloadEngine* e, bool forcePause)
{
gid_t gid = getRequiredGidParam(req, 0);
a2_gid_t gid = getRequiredGidParam(req, 0);
bool reserved = false;
SharedHandle<RequestGroup> group =
@ -508,7 +508,7 @@ SharedHandle<ValueBase> ForcePauseAllRpcMethod::process
SharedHandle<ValueBase> UnpauseRpcMethod::process
(const RpcRequest& req, DownloadEngine* e)
{
gid_t gid = getRequiredGidParam(req, 0);
a2_gid_t gid = getRequiredGidParam(req, 0);
SharedHandle<RequestGroup> group =
e->getRequestGroupMan()->findReservedGroup(gid);
if(!group || !group->isPauseRequested()) {
@ -645,7 +645,7 @@ void gatherProgressCommon
if(!group->followedBy().empty()) {
SharedHandle<List> list = List::g();
// The element is GID.
for(std::vector<gid_t>::const_iterator i = group->followedBy().begin(),
for(std::vector<a2_gid_t>::const_iterator i = group->followedBy().begin(),
eoi = group->followedBy().end(); i != eoi; ++i) {
list->append(util::itos(*i));
}
@ -804,7 +804,7 @@ void gatherStoppedDownload
if(!ds->followedBy.empty()) {
SharedHandle<List> list = List::g();
// The element is GID.
for(std::vector<gid_t>::const_iterator i = ds->followedBy.begin(),
for(std::vector<a2_gid_t>::const_iterator i = ds->followedBy.begin(),
eoi = ds->followedBy.end(); i != eoi; ++i) {
list->append(util::itos(*i));
}
@ -866,7 +866,7 @@ void gatherStoppedDownload
SharedHandle<ValueBase> GetFilesRpcMethod::process
(const RpcRequest& req, DownloadEngine* e)
{
gid_t gid = getRequiredGidParam(req, 0);
a2_gid_t gid = getRequiredGidParam(req, 0);
SharedHandle<List> files = List::g();
SharedHandle<RequestGroup> group =
findRequestGroup(e->getRequestGroupMan(), gid);
@ -891,7 +891,7 @@ SharedHandle<ValueBase> GetFilesRpcMethod::process
SharedHandle<ValueBase> GetUrisRpcMethod::process
(const RpcRequest& req, DownloadEngine* e)
{
gid_t gid = getRequiredGidParam(req, 0);
a2_gid_t gid = getRequiredGidParam(req, 0);
SharedHandle<RequestGroup> group =
findRequestGroup(e->getRequestGroupMan(), gid);
if(!group) {
@ -911,7 +911,7 @@ SharedHandle<ValueBase> GetUrisRpcMethod::process
SharedHandle<ValueBase> GetPeersRpcMethod::process
(const RpcRequest& req, DownloadEngine* e)
{
gid_t gid = getRequiredGidParam(req, 0);
a2_gid_t gid = getRequiredGidParam(req, 0);
SharedHandle<RequestGroup> group =
findRequestGroup(e->getRequestGroupMan(), gid);
@ -933,7 +933,7 @@ SharedHandle<ValueBase> GetPeersRpcMethod::process
SharedHandle<ValueBase> TellStatusRpcMethod::process
(const RpcRequest& req, DownloadEngine* e)
{
gid_t gid = getRequiredGidParam(req, 0);
a2_gid_t gid = getRequiredGidParam(req, 0);
const List* keysParam = req.getListParam(1);
std::vector<std::string> keys;
@ -1041,7 +1041,7 @@ SharedHandle<ValueBase> PurgeDownloadResultRpcMethod::process
SharedHandle<ValueBase> RemoveDownloadResultRpcMethod::process
(const RpcRequest& req, DownloadEngine* e)
{
gid_t gid = getRequiredGidParam(req, 0);
a2_gid_t gid = getRequiredGidParam(req, 0);
if(!e->getRequestGroupMan()->removeDownloadResult(gid)) {
throw DL_ABORT_EX
(fmt("Could not remove download result of GID#%s",
@ -1053,7 +1053,7 @@ SharedHandle<ValueBase> RemoveDownloadResultRpcMethod::process
SharedHandle<ValueBase> ChangeOptionRpcMethod::process
(const RpcRequest& req, DownloadEngine* e)
{
gid_t gid = getRequiredGidParam(req, 0);
a2_gid_t gid = getRequiredGidParam(req, 0);
SharedHandle<RequestGroup> group =
findRequestGroup(e->getRequestGroupMan(), gid);
@ -1160,7 +1160,7 @@ void pushRequestOption
SharedHandle<ValueBase> GetOptionRpcMethod::process
(const RpcRequest& req, DownloadEngine* e)
{
gid_t gid = getRequiredGidParam(req, 0);
a2_gid_t gid = getRequiredGidParam(req, 0);
SharedHandle<RequestGroup> group =
findRequestGroup(e->getRequestGroupMan(), gid);
@ -1192,7 +1192,7 @@ SharedHandle<ValueBase> GetGlobalOptionRpcMethod::process
SharedHandle<ValueBase> ChangePositionRpcMethod::process
(const RpcRequest& req, DownloadEngine* e)
{
gid_t gid = getRequiredGidParam(req, 0);
a2_gid_t gid = getRequiredGidParam(req, 0);
const Integer* posParam = req.getIntegerParam(1);
const String* howParam = req.getStringParam(2);
@ -1228,7 +1228,7 @@ SharedHandle<ValueBase> GetSessionInfoRpcMethod::process
SharedHandle<ValueBase> GetServersRpcMethod::process
(const RpcRequest& req, DownloadEngine* e)
{
gid_t gid = getRequiredGidParam(req, 0);
a2_gid_t gid = getRequiredGidParam(req, 0);
SharedHandle<RequestGroup> group =
e->getRequestGroupMan()->findRequestGroup(gid);
if(!group) {
@ -1267,7 +1267,7 @@ SharedHandle<ValueBase> GetServersRpcMethod::process
SharedHandle<ValueBase> ChangeUriRpcMethod::process
(const RpcRequest& req, DownloadEngine* e)
{
gid_t gid = getRequiredGidParam(req, 0);
a2_gid_t gid = getRequiredGidParam(req, 0);
const Integer* indexParam = req.getIntegerParam(1);
const List* delUrisParam = req.getListParam(2);
const List* addUrisParam = req.getListParam(3);

View File

@ -282,7 +282,7 @@ bool isUtf8(const std::string& str)
firstChar == 0x09u || firstChar == 0x0au ||firstChar == 0x0du) {
// UTF8-1 (without ctrl chars)
} else if(in(firstChar, 0xc2u, 0xdfu)) {
// UTF8-2
// UTF8-2
if(++s == eos || !isUtf8Tail(*s)) {
return false;
}
@ -1472,7 +1472,7 @@ namespace {
void executeHook
(const std::string& command,
gid_t gid,
a2_gid_t gid,
size_t numFiles,
const std::string& firstFilename)
{

View File

@ -713,7 +713,7 @@ void RpcMethodTest::testGetVersion()
void RpcMethodTest::testGatherStoppedDownload()
{
std::vector<SharedHandle<FileEntry> > fileEntries;
std::vector<gid_t> followedBy;
std::vector<a2_gid_t> followedBy;
followedBy.push_back(3);
followedBy.push_back(4);
SharedHandle<DownloadResult> d(new DownloadResult());
@ -853,7 +853,7 @@ void RpcMethodTest::testChangePosition()
CPPUNIT_ASSERT_EQUAL(0, res.code);
CPPUNIT_ASSERT_EQUAL((int64_t)1, asInteger(res.param)->i());
CPPUNIT_ASSERT_EQUAL
((gid_t)1, e_->getRequestGroupMan()->getReservedGroups()[1]->getGID());
((a2_gid_t)1, e_->getRequestGroupMan()->getReservedGroups()[1]->getGID());
}
void RpcMethodTest::testChangePosition_fail()