142
145
(std::vector<size_t>& fastSet, const std::string& ipaddr,
143
146
size_t numPieces, const unsigned char* infoHash, size_t fastSetSize);
145
// Writes the detailed information about torrent loaded in dctx.
146
void print(std::ostream& o, const SharedHandle<DownloadContext>& dctx);
148
148
SharedHandle<TorrentAttribute> getTorrentAttrs
149
149
(const SharedHandle<DownloadContext>& dctx);
291
291
for(List::ValueType::const_iterator itr = peerData.begin(),
292
292
eoi = peerData.end(); itr != eoi; ++itr) {
293
const Dict* peerDict = asDict(*itr);
293
const Dict* peerDict = downcast<Dict>(*itr);
297
297
static const std::string IP = "ip";
298
298
static const std::string PORT = "port";
299
const String* ip = asString(peerDict->get(IP));
300
const Integer* port = asInteger(peerDict->get(PORT));
299
const String* ip = downcast<String>(peerDict->get(IP));
300
const Integer* port = downcast<Integer>(peerDict->get(PORT));
301
301
if(!ip || !port || !(0 < port->i() && port->i() < 65536)) {
324
324
int getCompactLength(int family);
326
// Writes the detailed information about torrent loaded in dctx.
327
template<typename Output>
328
void print(Output& o, const SharedHandle<DownloadContext>& dctx)
330
SharedHandle<TorrentAttribute> torrentAttrs = getTorrentAttrs(dctx);
331
o.write("*** BitTorrent File Information ***\n");
332
if(!torrentAttrs->comment.empty()) {
333
o.printf("Comment: %s\n", torrentAttrs->comment.c_str());
335
if(torrentAttrs->creationDate) {
336
o.printf("Creation Date: %s\n",
337
Time(torrentAttrs->creationDate).toHTTPDate().c_str());
339
if(!torrentAttrs->createdBy.empty()) {
340
o.printf("Created By: %s\n", torrentAttrs->createdBy.c_str());
342
o.printf("Mode: %s\n", torrentAttrs->mode.c_str());
343
o.write("Announce:\n");
344
for(std::vector<std::vector<std::string> >::const_iterator tierIter =
345
torrentAttrs->announceList.begin(),
346
eoi = torrentAttrs->announceList.end(); tierIter != eoi; ++tierIter) {
347
for(std::vector<std::string>::const_iterator i = (*tierIter).begin(),
348
eoi2 = (*tierIter).end(); i != eoi2; ++i) {
349
o.printf(" %s", (*i).c_str());
353
o.printf("Info Hash: %s\n", util::toHex(torrentAttrs->infoHash).c_str());
354
o.printf("Piece Length: %sB\n",
355
util::abbrevSize(dctx->getPieceLength()).c_str());
356
o.printf("The Number of Pieces: %lu\n",
357
static_cast<unsigned long>(dctx->getNumPieces()));
358
o.printf("Total Length: %sB (%s)\n",
359
util::abbrevSize(dctx->getTotalLength()).c_str(),
360
util::uitos(dctx->getTotalLength(), true).c_str());
361
if(!torrentAttrs->urlList.empty()) {
362
o.write("URL List:\n");
363
for(std::vector<std::string>::const_iterator i =
364
torrentAttrs->urlList.begin(),
365
eoi = torrentAttrs->urlList.end(); i != eoi; ++i) {
366
o.printf(" %s\n", (*i).c_str());
369
o.printf("Name: %s\n", torrentAttrs->name.c_str());
370
o.printf("Magnet URI: %s\n", torrent2Magnet(torrentAttrs).c_str());
372
(dctx->getFileEntries().begin(), dctx->getFileEntries().end(), o);
326
375
} // namespace bittorrent
328
377
} // namespace aria2