mirror of https://github.com/aria2/aria2
Code cleanup
parent
e1e6bb1ec5
commit
ba3b823a66
|
@ -95,53 +95,53 @@ const char VLB_COMPLETE[] = "complete";
|
|||
const char VLB_USED[] = "used";
|
||||
const char VLB_ZERO[] = "0";
|
||||
|
||||
const std::string KEY_GID = "gid";
|
||||
const std::string KEY_ERROR_CODE = "errorCode";
|
||||
const std::string KEY_STATUS = "status";
|
||||
const std::string KEY_TOTAL_LENGTH = "totalLength";
|
||||
const std::string KEY_COMPLETED_LENGTH = "completedLength";
|
||||
const std::string KEY_DOWNLOAD_SPEED = "downloadSpeed";
|
||||
const std::string KEY_UPLOAD_SPEED = "uploadSpeed";
|
||||
const std::string KEY_UPLOAD_LENGTH = "uploadLength";
|
||||
const std::string KEY_CONNECTIONS = "connections";
|
||||
const std::string KEY_BITFIELD = "bitfield";
|
||||
const std::string KEY_PIECE_LENGTH = "pieceLength";
|
||||
const std::string KEY_NUM_PIECES = "numPieces";
|
||||
const std::string KEY_FOLLOWED_BY = "followedBy";
|
||||
const std::string KEY_BELONGS_TO = "belongsTo";
|
||||
const std::string KEY_INFO_HASH = "infoHash";
|
||||
const std::string KEY_NUM_SEEDERS = "numSeeders";
|
||||
const std::string KEY_PEER_ID = "peerId";
|
||||
const std::string KEY_IP = "ip";
|
||||
const std::string KEY_PORT = "port";
|
||||
const std::string KEY_AM_CHOKING = "amChoking";
|
||||
const std::string KEY_PEER_CHOKING = "peerChoking";
|
||||
const std::string KEY_SEEDER = "seeder";
|
||||
const std::string KEY_INDEX = "index";
|
||||
const std::string KEY_PATH = "path";
|
||||
const std::string KEY_SELECTED = "selected";
|
||||
const std::string KEY_LENGTH = "length";
|
||||
const std::string KEY_URI = "uri";
|
||||
const std::string KEY_CURRENT_URI = "currentUri";
|
||||
const std::string KEY_VERSION = "version";
|
||||
const std::string KEY_ENABLED_FEATURES = "enabledFeatures";
|
||||
const std::string KEY_METHOD_NAME = "methodName";
|
||||
const std::string KEY_PARAMS = "params";
|
||||
const std::string KEY_SESSION_ID = "sessionId";
|
||||
const std::string KEY_FILES = "files";
|
||||
const std::string KEY_DIR = "dir";
|
||||
const std::string KEY_URIS = "uris";
|
||||
const std::string KEY_BITTORRENT = "bittorrent";
|
||||
const std::string KEY_INFO = "info";
|
||||
const std::string KEY_NAME = "name";
|
||||
const std::string KEY_ANNOUNCE_LIST = "announceList";
|
||||
const std::string KEY_COMMENT = "comment";
|
||||
const std::string KEY_CREATION_DATE = "creationDate";
|
||||
const std::string KEY_MODE = "mode";
|
||||
const std::string KEY_SERVERS = "servers";
|
||||
const std::string KEY_NUM_WAITING = "numWaiting";
|
||||
const std::string KEY_NUM_STOPPED = "numStopped";
|
||||
const std::string KEY_NUM_ACTIVE = "numActive";
|
||||
const char KEY_GID[] = "gid";
|
||||
const char KEY_ERROR_CODE[] = "errorCode";
|
||||
const char KEY_STATUS[] = "status";
|
||||
const char KEY_TOTAL_LENGTH[] = "totalLength";
|
||||
const char KEY_COMPLETED_LENGTH[] = "completedLength";
|
||||
const char KEY_DOWNLOAD_SPEED[] = "downloadSpeed";
|
||||
const char KEY_UPLOAD_SPEED[] = "uploadSpeed";
|
||||
const char KEY_UPLOAD_LENGTH[] = "uploadLength";
|
||||
const char KEY_CONNECTIONS[] = "connections";
|
||||
const char KEY_BITFIELD[] = "bitfield";
|
||||
const char KEY_PIECE_LENGTH[] = "pieceLength";
|
||||
const char KEY_NUM_PIECES[] = "numPieces";
|
||||
const char KEY_FOLLOWED_BY[] = "followedBy";
|
||||
const char KEY_BELONGS_TO[] = "belongsTo";
|
||||
const char KEY_INFO_HASH[] = "infoHash";
|
||||
const char KEY_NUM_SEEDERS[] = "numSeeders";
|
||||
const char KEY_PEER_ID[] = "peerId";
|
||||
const char KEY_IP[] = "ip";
|
||||
const char KEY_PORT[] = "port";
|
||||
const char KEY_AM_CHOKING[] = "amChoking";
|
||||
const char KEY_PEER_CHOKING[] = "peerChoking";
|
||||
const char KEY_SEEDER[] = "seeder";
|
||||
const char KEY_INDEX[] = "index";
|
||||
const char KEY_PATH[] = "path";
|
||||
const char KEY_SELECTED[] = "selected";
|
||||
const char KEY_LENGTH[] = "length";
|
||||
const char KEY_URI[] = "uri";
|
||||
const char KEY_CURRENT_URI[] = "currentUri";
|
||||
const char KEY_VERSION[] = "version";
|
||||
const char KEY_ENABLED_FEATURES[] = "enabledFeatures";
|
||||
const char KEY_METHOD_NAME[] = "methodName";
|
||||
const char KEY_PARAMS[] = "params";
|
||||
const char KEY_SESSION_ID[] = "sessionId";
|
||||
const char KEY_FILES[] = "files";
|
||||
const char KEY_DIR[] = "dir";
|
||||
const char KEY_URIS[] = "uris";
|
||||
const char KEY_BITTORRENT[] = "bittorrent";
|
||||
const char KEY_INFO[] = "info";
|
||||
const char KEY_NAME[] = "name";
|
||||
const char KEY_ANNOUNCE_LIST[] = "announceList";
|
||||
const char KEY_COMMENT[] = "comment";
|
||||
const char KEY_CREATION_DATE[] = "creationDate";
|
||||
const char KEY_MODE[] = "mode";
|
||||
const char KEY_SERVERS[] = "servers";
|
||||
const char KEY_NUM_WAITING[] = "numWaiting";
|
||||
const char KEY_NUM_STOPPED[] = "numStopped";
|
||||
const char KEY_NUM_ACTIVE[] = "numActive";
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -68,43 +68,26 @@ namespace aria2 {
|
|||
namespace bittorrent {
|
||||
|
||||
namespace {
|
||||
const std::string C_NAME("name");
|
||||
const char C_NAME[] = "name";
|
||||
const char C_NAME_UTF8[] = "name.utf-8";
|
||||
const char C_FILES[] = "files";
|
||||
const char C_LENGTH[] = "length";
|
||||
const char C_PATH[] = "path";
|
||||
const char C_PATH_UTF8[] = "path.utf-8";
|
||||
const char C_INFO[] = "info";
|
||||
const char C_PIECES[] = "pieces";
|
||||
const char C_PIECE_LENGTH[] = "piece length";
|
||||
const char C_PRIVATE[] = "private";
|
||||
const char C_URL_LIST[] = "url-list";
|
||||
const char C_ANNOUNCE[] = "announce";
|
||||
const char C_ANNOUNCE_LIST[] = "announce-list";
|
||||
const char C_NODES[] = "nodes";
|
||||
const char C_CREATION_DATE[] = "creation date";
|
||||
const char C_COMMENT[] = "comment";
|
||||
const char C_COMMENT_UTF8[] = "comment.utf-8";
|
||||
const char C_CREATED_BY[] = "created by";
|
||||
|
||||
const std::string C_NAME_UTF8("name.utf-8");
|
||||
|
||||
const std::string C_FILES("files");
|
||||
|
||||
const std::string C_LENGTH("length");
|
||||
|
||||
const std::string C_PATH("path");
|
||||
|
||||
const std::string C_PATH_UTF8("path.utf-8");
|
||||
|
||||
const std::string C_INFO("info");
|
||||
|
||||
const std::string C_PIECES("pieces");
|
||||
|
||||
const std::string C_PIECE_LENGTH("piece length");
|
||||
|
||||
const std::string C_PRIVATE("private");
|
||||
|
||||
const std::string C_URL_LIST("url-list");
|
||||
|
||||
const std::string C_ANNOUNCE("announce");
|
||||
|
||||
const std::string C_ANNOUNCE_LIST("announce-list");
|
||||
|
||||
const std::string C_NODES("nodes");
|
||||
|
||||
const std::string C_CREATION_DATE("creation date");
|
||||
|
||||
const std::string C_COMMENT("comment");
|
||||
|
||||
const std::string C_COMMENT_UTF8("comment.utf-8");
|
||||
|
||||
const std::string C_CREATED_BY("created by");
|
||||
|
||||
const std::string DEFAULT_PEER_ID_PREFIX("aria2-");
|
||||
const char DEFAULT_PEER_ID_PREFIX[] = "aria2-";
|
||||
} // namespace
|
||||
|
||||
const std::string MULTI("multi");
|
||||
|
@ -241,7 +224,7 @@ void extractFileEntries
|
|||
}
|
||||
const Integer* fileLengthData = downcast<Integer>(fileDict->get(C_LENGTH));
|
||||
if(!fileLengthData) {
|
||||
throw DL_ABORT_EX2(fmt(MSG_MISSING_BT_INFO, C_LENGTH.c_str()),
|
||||
throw DL_ABORT_EX2(fmt(MSG_MISSING_BT_INFO, C_LENGTH),
|
||||
error_code::BITTORRENT_PARSE_ERROR);
|
||||
}
|
||||
if(length > std::numeric_limits<int64_t>::max() - fileLengthData->i()) {
|
||||
|
@ -302,7 +285,7 @@ void extractFileEntries
|
|||
torrent->mode = BT_FILE_MODE_SINGLE;
|
||||
const Integer* lengthData = downcast<Integer>(infoDict->get(C_LENGTH));
|
||||
if(!lengthData) {
|
||||
throw DL_ABORT_EX2(fmt(MSG_MISSING_BT_INFO, C_LENGTH.c_str()),
|
||||
throw DL_ABORT_EX2(fmt(MSG_MISSING_BT_INFO, C_LENGTH),
|
||||
error_code::BITTORRENT_PARSE_ERROR);
|
||||
}
|
||||
int64_t totalLength = lengthData->i();
|
||||
|
@ -412,7 +395,7 @@ void processRootDictionary
|
|||
}
|
||||
const Dict* infoDict = downcast<Dict>(rootDict->get(C_INFO));
|
||||
if(!infoDict) {
|
||||
throw DL_ABORT_EX2(fmt(MSG_MISSING_BT_INFO, C_INFO.c_str()),
|
||||
throw DL_ABORT_EX2(fmt(MSG_MISSING_BT_INFO, C_INFO),
|
||||
error_code::BITTORRENT_PARSE_ERROR);
|
||||
}
|
||||
auto torrent = make_unique<TorrentAttribute>();
|
||||
|
@ -431,7 +414,7 @@ void processRootDictionary
|
|||
// calculate the number of pieces
|
||||
const String* piecesData = downcast<String>(infoDict->get(C_PIECES));
|
||||
if(!piecesData) {
|
||||
throw DL_ABORT_EX2(fmt(MSG_MISSING_BT_INFO, C_PIECES.c_str()),
|
||||
throw DL_ABORT_EX2(fmt(MSG_MISSING_BT_INFO, C_PIECES),
|
||||
error_code::BITTORRENT_PARSE_ERROR);
|
||||
}
|
||||
// Commented out To download 0 length torrent.
|
||||
|
@ -446,7 +429,7 @@ void processRootDictionary
|
|||
// retrieve piece length
|
||||
const Integer* pieceLengthData = downcast<Integer>(infoDict->get(C_PIECE_LENGTH));
|
||||
if(!pieceLengthData) {
|
||||
throw DL_ABORT_EX2(fmt(MSG_MISSING_BT_INFO, C_PIECE_LENGTH.c_str()),
|
||||
throw DL_ABORT_EX2(fmt(MSG_MISSING_BT_INFO, C_PIECE_LENGTH),
|
||||
error_code::BITTORRENT_PARSE_ERROR);
|
||||
}
|
||||
size_t pieceLength = pieceLengthData->i();
|
||||
|
|
Loading…
Reference in New Issue