2008-08-26 12:39:07 +00:00
|
|
|
#include "common.h"
|
2010-01-28 14:01:50 +00:00
|
|
|
|
2008-08-26 12:39:07 +00:00
|
|
|
#include <string>
|
2013-06-21 16:10:38 +00:00
|
|
|
#include <memory>
|
2008-08-26 12:39:07 +00:00
|
|
|
|
2010-01-28 14:01:50 +00:00
|
|
|
#include "Cookie.h"
|
2012-11-27 13:04:59 +00:00
|
|
|
#include "WrDiskCacheEntry.h"
|
2012-12-19 14:03:48 +00:00
|
|
|
#include "GroupId.h"
|
2010-01-28 14:01:50 +00:00
|
|
|
|
2008-08-26 12:39:07 +00:00
|
|
|
namespace aria2 {
|
|
|
|
|
2010-11-11 02:56:24 +00:00
|
|
|
class MessageDigest;
|
2012-12-19 14:03:48 +00:00
|
|
|
class RequestGroupMan;
|
|
|
|
class RequestGroup;
|
2012-12-22 14:37:44 +00:00
|
|
|
class Option;
|
2013-03-01 12:17:52 +00:00
|
|
|
struct DownloadResult;
|
2010-11-11 02:56:24 +00:00
|
|
|
|
2008-08-26 12:39:07 +00:00
|
|
|
void createFile(const std::string& filename, size_t length);
|
|
|
|
|
2009-05-15 05:20:11 +00:00
|
|
|
std::string readFile(const std::string& path);
|
|
|
|
|
2010-01-28 14:01:50 +00:00
|
|
|
class CookieSorter {
|
|
|
|
public:
|
2013-06-27 15:25:06 +00:00
|
|
|
bool operator()(const Cookie* lhs, const Cookie* rhs) const
|
2010-01-28 14:01:50 +00:00
|
|
|
{
|
2013-06-27 15:25:06 +00:00
|
|
|
if(lhs->getDomain() == rhs->getDomain()) {
|
|
|
|
return lhs->getName() < rhs->getName();
|
2010-01-28 14:01:50 +00:00
|
|
|
} else {
|
2013-06-27 15:25:06 +00:00
|
|
|
return lhs->getDomain() < rhs->getDomain();
|
2010-01-28 14:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-06-27 15:25:06 +00:00
|
|
|
std::unique_ptr<Cookie> createCookie
|
2010-10-09 14:22:49 +00:00
|
|
|
(const std::string& name,
|
|
|
|
const std::string& value,
|
|
|
|
const std::string& domain,
|
|
|
|
bool hostOnly,
|
|
|
|
const std::string& path,
|
|
|
|
bool secure);
|
|
|
|
|
2013-06-27 15:25:06 +00:00
|
|
|
std::unique_ptr<Cookie> createCookie
|
2010-10-09 14:22:49 +00:00
|
|
|
(const std::string& name,
|
|
|
|
const std::string& value,
|
|
|
|
time_t expiryTime,
|
|
|
|
const std::string& domain,
|
|
|
|
bool hostOnly,
|
|
|
|
const std::string& path,
|
|
|
|
bool secure);
|
|
|
|
|
2011-11-05 09:05:23 +00:00
|
|
|
std::string fromHex(const std::string& s);
|
|
|
|
|
2010-11-11 02:56:24 +00:00
|
|
|
// Returns hex digest of contents of file denoted by filename.
|
2013-07-02 16:13:13 +00:00
|
|
|
std::string fileHexDigest(MessageDigest* ctx, const std::string& filename);
|
2010-11-11 02:56:24 +00:00
|
|
|
|
2012-11-27 13:04:59 +00:00
|
|
|
WrDiskCacheEntry::DataCell* createDataCell(int64_t goff,
|
|
|
|
const char* data,
|
|
|
|
size_t offset = 0);
|
|
|
|
|
2013-06-21 16:10:38 +00:00
|
|
|
std::shared_ptr<RequestGroup> findReservedGroup
|
2013-07-05 15:59:43 +00:00
|
|
|
(RequestGroupMan* rgman, a2_gid_t gid);
|
2012-12-19 14:03:48 +00:00
|
|
|
|
2013-06-21 16:10:38 +00:00
|
|
|
std::shared_ptr<RequestGroup> getReservedGroup
|
2013-07-05 15:59:43 +00:00
|
|
|
(RequestGroupMan* rgman, size_t index);
|
2012-12-19 14:03:48 +00:00
|
|
|
|
2013-06-21 16:10:38 +00:00
|
|
|
std::shared_ptr<RequestGroup> createRequestGroup(int32_t pieceLength,
|
2012-12-22 14:37:44 +00:00
|
|
|
int64_t totalLength,
|
|
|
|
const std::string& path,
|
|
|
|
const std::string& uri,
|
2013-06-21 16:10:38 +00:00
|
|
|
const std::shared_ptr<Option>& opt);
|
2013-02-25 12:42:54 +00:00
|
|
|
|
2013-06-21 16:10:38 +00:00
|
|
|
std::shared_ptr<DownloadResult> createDownloadResult
|
2013-02-25 12:42:54 +00:00
|
|
|
(error_code::Value result, const std::string& uri);
|
|
|
|
|
2013-06-27 15:25:06 +00:00
|
|
|
namespace {
|
|
|
|
template<typename V, typename T>
|
|
|
|
bool derefFind(const V& v, const T& t)
|
|
|
|
{
|
|
|
|
for(auto i : v) {
|
|
|
|
if(*i == *t) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} // namespace
|
|
|
|
|
2008-08-26 12:39:07 +00:00
|
|
|
} // namespace aria2
|