mirror of https://github.com/aria2/aria2
Use const char* instead of static const std::string
parent
0144397e4b
commit
d8c44fe9e8
|
@ -187,9 +187,8 @@ void DefaultBtInteractive::addPortMessageToQueue()
|
||||||
|
|
||||||
void DefaultBtInteractive::addHandshakeExtendedMessageToQueue()
|
void DefaultBtInteractive::addHandshakeExtendedMessageToQueue()
|
||||||
{
|
{
|
||||||
static const std::string CLIENT_ARIA2("aria2/"PACKAGE_VERSION);
|
|
||||||
HandshakeExtensionMessageHandle m(new HandshakeExtensionMessage());
|
HandshakeExtensionMessageHandle m(new HandshakeExtensionMessage());
|
||||||
m->setClientVersion(CLIENT_ARIA2);
|
m->setClientVersion("aria2/" PACKAGE_VERSION);
|
||||||
m->setTCPPort(tcpPort_);
|
m->setTCPPort(tcpPort_);
|
||||||
m->setExtensions(extensionMessageRegistry_->getExtensions());
|
m->setExtensions(extensionMessageRegistry_->getExtensions());
|
||||||
SharedHandle<TorrentAttribute> attrs =
|
SharedHandle<TorrentAttribute> attrs =
|
||||||
|
|
|
@ -48,18 +48,6 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
namespace {
|
|
||||||
static const std::string DEBUG_LABEL("DEBUG");
|
|
||||||
|
|
||||||
static const std::string INFO_LABEL("INFO");
|
|
||||||
|
|
||||||
static const std::string NOTICE_LABEL("NOTICE");
|
|
||||||
|
|
||||||
static const std::string WARN_LABEL("WARN");
|
|
||||||
|
|
||||||
static const std::string ERROR_LABEL("ERROR");
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
Logger::Logger()
|
Logger::Logger()
|
||||||
: logLevel_(Logger::A2_DEBUG),
|
: logLevel_(Logger::A2_DEBUG),
|
||||||
stdoutField_(0)
|
stdoutField_(0)
|
||||||
|
@ -104,21 +92,21 @@ bool Logger::levelEnabled(LEVEL level)
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const std::string& levelToString(Logger::LEVEL level)
|
const char* levelToString(Logger::LEVEL level)
|
||||||
{
|
{
|
||||||
switch(level) {
|
switch(level) {
|
||||||
case Logger::A2_DEBUG:
|
case Logger::A2_DEBUG:
|
||||||
return DEBUG_LABEL;
|
return "DEBUG";
|
||||||
case Logger::A2_INFO:
|
case Logger::A2_INFO:
|
||||||
return INFO_LABEL;
|
return "INFO";
|
||||||
case Logger::A2_NOTICE:
|
case Logger::A2_NOTICE:
|
||||||
return NOTICE_LABEL;
|
return "NOTICE";
|
||||||
case Logger::A2_WARN:
|
case Logger::A2_WARN:
|
||||||
return WARN_LABEL;
|
return "WARN";
|
||||||
case Logger::A2_ERROR:
|
case Logger::A2_ERROR:
|
||||||
return ERROR_LABEL;
|
return "ERROR";
|
||||||
default:
|
default:
|
||||||
return A2STR::NIL;
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -138,8 +126,7 @@ void writeHeader
|
||||||
size_t dateLength =
|
size_t dateLength =
|
||||||
strftime(datestr, sizeof(datestr), "%Y-%m-%d %H:%M:%S", &tm);
|
strftime(datestr, sizeof(datestr), "%Y-%m-%d %H:%M:%S", &tm);
|
||||||
assert(dateLength <= (size_t)20);
|
assert(dateLength <= (size_t)20);
|
||||||
fp.printf("%s.%06ld %s - ", datestr, tv.tv_usec,
|
fp.printf("%s.%06ld %s - ", datestr, tv.tv_usec, levelToString(level));
|
||||||
levelToString(level).c_str());
|
|
||||||
if(sourceFile) {
|
if(sourceFile) {
|
||||||
fp.printf("[%s:%d]", sourceFile, lineNum);
|
fp.printf("[%s:%d]", sourceFile, lineNum);
|
||||||
}
|
}
|
||||||
|
|
|
@ -846,8 +846,8 @@ std::string RequestGroup::getFirstFilePath() const
|
||||||
{
|
{
|
||||||
assert(downloadContext_);
|
assert(downloadContext_);
|
||||||
if(inMemoryDownload()) {
|
if(inMemoryDownload()) {
|
||||||
static const std::string DIR_MEMORY("[MEMORY]");
|
return "[MEMORY]"+
|
||||||
return DIR_MEMORY+File(downloadContext_->getFirstFileEntry()->getPath()).getBasename();
|
File(downloadContext_->getFirstFileEntry()->getPath()).getBasename();
|
||||||
} else {
|
} else {
|
||||||
return downloadContext_->getFirstFileEntry()->getPath();
|
return downloadContext_->getFirstFileEntry()->getPath();
|
||||||
}
|
}
|
||||||
|
|
|
@ -713,11 +713,6 @@ RequestGroupMan::DownloadStat RequestGroupMan::getDownloadStat() const
|
||||||
|
|
||||||
void RequestGroupMan::showDownloadResults(OutputFile& o, bool full) const
|
void RequestGroupMan::showDownloadResults(OutputFile& o, bool full) const
|
||||||
{
|
{
|
||||||
static const std::string MARK_OK("OK");
|
|
||||||
static const std::string MARK_ERR("ERR");
|
|
||||||
static const std::string MARK_INPR("INPR");
|
|
||||||
static const std::string MARK_RM("RM");
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
int pathRowSize = 58;
|
int pathRowSize = 58;
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
|
@ -749,18 +744,18 @@ void RequestGroupMan::showDownloadResults(OutputFile& o, bool full) const
|
||||||
if((*itr)->belongsTo != 0) {
|
if((*itr)->belongsTo != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std::string status;
|
const char* status;
|
||||||
if((*itr)->result == error_code::FINISHED) {
|
if((*itr)->result == error_code::FINISHED) {
|
||||||
status = MARK_OK;
|
status = "OK";
|
||||||
++ok;
|
++ok;
|
||||||
} else if((*itr)->result == error_code::IN_PROGRESS) {
|
} else if((*itr)->result == error_code::IN_PROGRESS) {
|
||||||
status = MARK_INPR;
|
status = "INPR";
|
||||||
++inpr;
|
++inpr;
|
||||||
} else if((*itr)->result == error_code::REMOVED) {
|
} else if((*itr)->result == error_code::REMOVED) {
|
||||||
status = MARK_RM;
|
status = "RM";
|
||||||
++rm;
|
++rm;
|
||||||
} else {
|
} else {
|
||||||
status = MARK_ERR;
|
status = "ERR";
|
||||||
++err;
|
++err;
|
||||||
}
|
}
|
||||||
if(full) {
|
if(full) {
|
||||||
|
@ -791,7 +786,7 @@ void RequestGroupMan::showDownloadResults(OutputFile& o, bool full) const
|
||||||
namespace {
|
namespace {
|
||||||
void formatDownloadResultCommon
|
void formatDownloadResultCommon
|
||||||
(std::ostream& o,
|
(std::ostream& o,
|
||||||
const std::string& status,
|
const char* status,
|
||||||
const DownloadResultHandle& downloadResult)
|
const DownloadResultHandle& downloadResult)
|
||||||
{
|
{
|
||||||
o << std::setw(3) << downloadResult->gid << "|"
|
o << std::setw(3) << downloadResult->gid << "|"
|
||||||
|
@ -810,7 +805,7 @@ void formatDownloadResultCommon
|
||||||
|
|
||||||
void RequestGroupMan::formatDownloadResultFull
|
void RequestGroupMan::formatDownloadResultFull
|
||||||
(OutputFile& out,
|
(OutputFile& out,
|
||||||
const std::string& status,
|
const char* status,
|
||||||
const DownloadResultHandle& downloadResult) const
|
const DownloadResultHandle& downloadResult) const
|
||||||
{
|
{
|
||||||
BitfieldMan bt(downloadResult->pieceLength, downloadResult->totalLength);
|
BitfieldMan bt(downloadResult->pieceLength, downloadResult->totalLength);
|
||||||
|
@ -852,7 +847,7 @@ void RequestGroupMan::formatDownloadResultFull
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string RequestGroupMan::formatDownloadResult
|
std::string RequestGroupMan::formatDownloadResult
|
||||||
(const std::string& status,
|
(const char* status,
|
||||||
const DownloadResultHandle& downloadResult) const
|
const DownloadResultHandle& downloadResult) const
|
||||||
{
|
{
|
||||||
std::stringstream o;
|
std::stringstream o;
|
||||||
|
|
|
@ -94,11 +94,11 @@ private:
|
||||||
|
|
||||||
void formatDownloadResultFull
|
void formatDownloadResultFull
|
||||||
(OutputFile& out,
|
(OutputFile& out,
|
||||||
const std::string& status,
|
const char* status,
|
||||||
const DownloadResultHandle& downloadResult) const;
|
const DownloadResultHandle& downloadResult) const;
|
||||||
|
|
||||||
std::string formatDownloadResult
|
std::string formatDownloadResult
|
||||||
(const std::string& status,
|
(const char* status,
|
||||||
const DownloadResultHandle& downloadResult) const;
|
const DownloadResultHandle& downloadResult) const;
|
||||||
|
|
||||||
void configureRequestGroup
|
void configureRequestGroup
|
||||||
|
|
|
@ -146,7 +146,7 @@ void Sqlite3CookieParser::parse(std::vector<Cookie>& cookies)
|
||||||
}
|
}
|
||||||
std::vector<Cookie> tcookies;
|
std::vector<Cookie> tcookies;
|
||||||
char* sqlite3ErrMsg = 0;
|
char* sqlite3ErrMsg = 0;
|
||||||
int ret = sqlite3_exec(db_, getQuery().c_str(), cookieRowMapper,
|
int ret = sqlite3_exec(db_, getQuery(), cookieRowMapper,
|
||||||
&tcookies, &sqlite3ErrMsg);
|
&tcookies, &sqlite3ErrMsg);
|
||||||
std::string errMsg;
|
std::string errMsg;
|
||||||
if(sqlite3ErrMsg) {
|
if(sqlite3ErrMsg) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ protected:
|
||||||
// must return 6 columns in the following order: host, path,
|
// must return 6 columns in the following order: host, path,
|
||||||
// secure(1 for secure, 0 for not), expiry(utc, unix time), name,
|
// secure(1 for secure, 0 for not), expiry(utc, unix time), name,
|
||||||
// value, last access time(utc, unix time)
|
// value, last access time(utc, unix time)
|
||||||
virtual const std::string& getQuery() const = 0;
|
virtual const char* getQuery() const = 0;
|
||||||
private:
|
private:
|
||||||
sqlite3* db_;
|
sqlite3* db_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,12 +41,11 @@ Sqlite3MozCookieParser::Sqlite3MozCookieParser(const std::string& filename):
|
||||||
|
|
||||||
Sqlite3MozCookieParser::~Sqlite3MozCookieParser() {}
|
Sqlite3MozCookieParser::~Sqlite3MozCookieParser() {}
|
||||||
|
|
||||||
const std::string& Sqlite3MozCookieParser::getQuery() const
|
const char* Sqlite3MozCookieParser::getQuery() const
|
||||||
{
|
{
|
||||||
static const std::string sql =
|
return
|
||||||
"SELECT host, path, isSecure, expiry, name, value, lastAccessed"
|
"SELECT host, path, isSecure, expiry, name, value, lastAccessed"
|
||||||
" FROM moz_cookies";
|
" FROM moz_cookies";
|
||||||
return sql;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Sqlite3ChromiumCookieParser::Sqlite3ChromiumCookieParser
|
Sqlite3ChromiumCookieParser::Sqlite3ChromiumCookieParser
|
||||||
|
@ -54,12 +53,11 @@ Sqlite3ChromiumCookieParser::Sqlite3ChromiumCookieParser
|
||||||
|
|
||||||
Sqlite3ChromiumCookieParser::~Sqlite3ChromiumCookieParser() {}
|
Sqlite3ChromiumCookieParser::~Sqlite3ChromiumCookieParser() {}
|
||||||
|
|
||||||
const std::string& Sqlite3ChromiumCookieParser::getQuery() const
|
const char* Sqlite3ChromiumCookieParser::getQuery() const
|
||||||
{
|
{
|
||||||
static const std::string sql =
|
return
|
||||||
"SELECT host_key, path, secure, expires_utc, name, value, last_access_utc"
|
"SELECT host_key, path, secure, expires_utc, name, value, last_access_utc"
|
||||||
" FROM cookies";
|
" FROM cookies";
|
||||||
return sql;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
Sqlite3MozCookieParser(const std::string& filename);
|
Sqlite3MozCookieParser(const std::string& filename);
|
||||||
virtual ~Sqlite3MozCookieParser();
|
virtual ~Sqlite3MozCookieParser();
|
||||||
protected:
|
protected:
|
||||||
virtual const std::string& getQuery() const;
|
virtual const char* getQuery() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Sqlite3ChromiumCookieParser:public Sqlite3CookieParser {
|
class Sqlite3ChromiumCookieParser:public Sqlite3CookieParser {
|
||||||
|
@ -52,7 +52,7 @@ public:
|
||||||
Sqlite3ChromiumCookieParser(const std::string& filename);
|
Sqlite3ChromiumCookieParser(const std::string& filename);
|
||||||
virtual ~Sqlite3ChromiumCookieParser();
|
virtual ~Sqlite3ChromiumCookieParser();
|
||||||
protected:
|
protected:
|
||||||
virtual const std::string& getQuery() const;
|
virtual const char* getQuery() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -240,11 +240,10 @@ TrackerWatcherCommand::createRequestGroup(const std::string& uri)
|
||||||
option->get(PREF_BT_TRACKER_CONNECT_TIMEOUT));
|
option->get(PREF_BT_TRACKER_CONNECT_TIMEOUT));
|
||||||
option->put(PREF_REUSE_URI, A2_V_FALSE);
|
option->put(PREF_REUSE_URI, A2_V_FALSE);
|
||||||
option->put(PREF_SELECT_LEAST_USED_HOST, A2_V_FALSE);
|
option->put(PREF_SELECT_LEAST_USED_HOST, A2_V_FALSE);
|
||||||
static const std::string TRACKER_ANNOUNCE_FILE("[tracker.announce]");
|
|
||||||
SharedHandle<DownloadContext> dctx
|
SharedHandle<DownloadContext> dctx
|
||||||
(new DownloadContext(option->getAsInt(PREF_PIECE_LENGTH),
|
(new DownloadContext(option->getAsInt(PREF_PIECE_LENGTH),
|
||||||
0,
|
0,
|
||||||
TRACKER_ANNOUNCE_FILE));
|
"[tracker.announce]"));
|
||||||
dctx->getFileEntries().front()->setUris(uris);
|
dctx->getFileEntries().front()->setUris(uris);
|
||||||
rg->setDownloadContext(dctx);
|
rg->setDownloadContext(dctx);
|
||||||
SharedHandle<DiskWriterFactory> dwf(new ByteArrayDiskWriterFactory());
|
SharedHandle<DiskWriterFactory> dwf(new ByteArrayDiskWriterFactory());
|
||||||
|
|
Loading…
Reference in New Issue