C++ (Qt)#ifndef TESTAPP_H#define TESTAPP_H #include <QDialog> class testApp : public QDialog{ Q_OBJECTpublic: testApp(QWidget *parent=0);private slots: void generate();}; #endif // TESTAPP_H
C++ (Qt)#include <QtGui>#include "testapp.h" testApp::testApp(QWidget *parent):QDialog(parent){ QPushButton *openbtn=new QPushButton("OpenFile"); QPushButton *genbtn=new QPushButton("Generate"); QVBoxLayout *layout=new QVBoxLayout; layout->addWidget(openbtn); layout->addWidget(genbtn); setLayout(layout); connect(openbtn,SIGNAL(clicked()),this,SLOT(generate()));}void testApp::generate(){ QString announce="http://donald.org.ua/tracker/announce.php"; QString createdby="BitTorrent/6120"; int pieceslength= 256*1024; QString torrentcontent; QString fileName = QFileDialog::getOpenFileName(this,tr("Select Image"), QApplication::applicationDirPath(), tr("All Files (*.*)")); if(fileName.isEmpty()) return; QFile file(fileName); QFileInfo fi(file); if (!file.open(QIODevice::ReadOnly)) return; QByteArray pieces = file.readAll(); QByteArray tmp; QCryptographicHash *hash=new QCryptographicHash(QCryptographicHash::Sha1); for (int i = 0; i < pieces.size(); i += 20){ hash->reset(); hash->addData(pieces.mid(i, 20)); tmp.append(hash->result()); } //hash->addData(pieces); torrentcontent = QString("d8:announce%1:%2") .arg(announce.length()).arg(announce); torrentcontent.append(QString("10:created by%1:%2") .arg(createdby.length()).arg(createdby)); torrentcontent.append(QString("13:creation datei%1") .arg(QDateTime::currentDateTime().currentDateTime().toTime_t())); torrentcontent.append(QString("e8:encoding5:UTF-84:infod6:lengthi%1e4:name%2:%3") .arg(file.size()).arg(fi.fileName().length()).arg(fi.fileName())); torrentcontent.append(QString("12:piece lengthi%1e6:pieces%2:") .arg(pieceslength).arg(hash->result().length())); QFile data("output.torrent"); if (data.open(QFile::WriteOnly)) { QTextStream out(&data); out << torrentcontent << tmp; } data.close();}
C++ (Qt) int pieceslength= 64*1024; QByteArray pieces = QString(file.readAll()).toAscii(); QByteArray tmp; QCryptographicHash *hash=new QCryptographicHash(QCryptographicHash::Sha1); for (int i = 0; i < pieces.size(); i += pieceslength){ hash->reset(); hash->addData(pieces.mid(i, pieceslength)); tmp.append(hash->result()); } qDebug() << tmp;
bjam gcc link=static boost=source
BOOST_ROOT = d:\Qt4_tutorial\addin\boost_1_34_0OS = NTBuilding Boost.Regex with the optional Unicode/ICU support disabled.Please refer to the Boost.Regex documentation for more information(don't panic: this is a strictly optional feature).error: Unable to find file or target namederror: '/boost/system//boost_system'error: referred from project aterror: '.'
D:\Qt4_tutorial\addin\libtorrent-rasterbar-0.14.4>bjam gcc link=static boost=sourceBOOST_ROOT = d:\Qt4_tutorial\addin\boost_1_39_0OS = NTWARNING: No python installation configured and autoconfiguration failed. See http://www.boost.org/libs/python/doc/building.html for configuration instructions or pass --without-python to suppress this message and silently skip all Boost.Python targets...patience......patience......found 2161 targets......updating 75 targets...gcc.compile.c++ bin\gcc-mingw-3.4.5\debug\boost-source\link-static\threading-multi\src\kademlia\dht_tracker.oIn file included from d:/Qt4_tutorial/addin/boost_1_39_0/boost/date_time/microsec_time_clock.hpp:23, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/date_time/posix_time/posix_time_types.hpp:11, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/detail/select_reactor.hpp:25, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/impl/io_service.ipp:27, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/io_service.hpp:550, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/basic_io_object.hpp:20, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/basic_socket_acceptor.hpp:20, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/ip/tcp.hpp:20, from include/libtorrent/socket.hpp:60, from include/libtorrent/kademlia/node_entry.hpp:37, from include/libtorrent/kademlia/routing_table.hpp:50, from include/libtorrent/kademlia/node.hpp:40, from src\kademlia\dht_tracker.cpp:45:d:/Qt4_tutorial/addin/boost_1_39_0/boost/date_time/filetime_functions.hpp: In function `uint64_t boost::date_time::winapi::file_time_to_microseconds(const FileTimeT&)':d:/Qt4_tutorial/addin/boost_1_39_0/boost/date_time/filetime_functions.hpp:101: warning: left shift count >= width of typeinclude/libtorrent/bencode.hpp: In function `void libtorrent::detail::bdecode_recursive(InIt&, InIt, libtorrent::entry&, bool&, int) [with InIt = const char*]':include/libtorrent/bencode.hpp:392: instantiated from `libtorrent::entry libtorrent::bdecode(InIt, InIt) [with InIt = const char*]'src\kademlia\dht_tracker.cpp:447: instantiated from hereinclude/libtorrent/bencode.hpp:250: error: `_strtoi64' was not declared in thisscopeinclude/libtorrent/bencode.hpp:250: warning: unused variable '_strtoi64' "g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -mthreads -Wno-missing-braces -fno-strict-aliasing -DBOOST_ALL_NO_LIB -DBOOST_FILESYSTEM_STATIC_LINK=1-DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_SYSTEM_STATIC_LINK=1 -DBOOST_THREAD_USE_LIB -DBOOST_THREAD_USE_LIB=1 -DTORRENT_DEBUG -DTORRENT_DISABLE_GEO_IP-DTORRENT_USE_OPENSSL -DUNICODE -DWIN32 -DWIN32_LEAN_AND_MEAN -D_FILE_OFFSET_BITS=64 -D_UNICODE -D_WIN32 -D_WIN32_WINNT=0x0500 -D__USE_W32_SOCKETS -I"d:\Qt4_tutorial\addin\boost_1_39_0" -I"\usr\sfw\include" -I"d:\Qt4_tutorial\addin\boost_1_39_0" -I"include" -I"include\libtorrent" -I"zlib" -c -o "bin\gcc-mingw-3.4.5\debug\boost-source\link-static\threading-multi\src\kademlia\dht_tracker.o" "src\kademlia\dht_tracker.cpp"...failed gcc.compile.c++ bin\gcc-mingw-3.4.5\debug\boost-source\link-static\threading-multi\src\kademlia\dht_tracker.o...gcc.compile.c++ bin\gcc-mingw-3.4.5\debug\boost-source\link-static\threading-multi\src\kademlia\find_data.oIn file included from d:/Qt4_tutorial/addin/boost_1_39_0/boost/date_time/microsec_time_clock.hpp:23, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/date_time/posix_time/posix_time_types.hpp:11, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/detail/select_reactor.hpp:25, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/impl/io_service.ipp:27, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/io_service.hpp:550, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/basic_io_object.hpp:20, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/basic_socket_acceptor.hpp:20, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/ip/tcp.hpp:20, from include/libtorrent/socket.hpp:60, from include/libtorrent/kademlia/node_entry.hpp:37, from include/libtorrent/kademlia/routing_table.hpp:50, from include/libtorrent/kademlia/traversal_algorithm.hpp:40, from include/libtorrent/kademlia/find_data.hpp:38, from src\kademlia\find_data.cpp:35:d:/Qt4_tutorial/addin/boost_1_39_0/boost/date_time/filetime_functions.hpp: In function `uint64_t boost::date_time::winapi::file_time_to_microseconds(const FileTimeT&)':d:/Qt4_tutorial/addin/boost_1_39_0/boost/date_time/filetime_functions.hpp:101: warning: left shift count >= width of type...interruptedgcc.compile.c++ bin\gcc-mingw-3.4.5\debug\boost-source\link-static\threading-multi\src\kademlia\node.oIn file included from src\kademlia\node.cpp:42:include/libtorrent/hasher.hpp:46:25: openssl/sha.h: No such file or directoryIn file included from src\kademlia\node.cpp:42:include/libtorrent/hasher.hpp:116: error: `SHA_CTX' does not name a typeinclude/libtorrent/hasher.hpp: In constructor `libtorrent::hasher::hasher()':include/libtorrent/hasher.hpp:90: error: `m_context' was not declared in this scopeinclude/libtorrent/hasher.hpp:90: error: `SHA1_Init' was not declared in this scopeinclude/libtorrent/hasher.hpp:90: warning: unused variable 'm_context'include/libtorrent/hasher.hpp:90: warning: unused variable 'SHA1_Init'include/libtorrent/hasher.hpp: In constructor `libtorrent::hasher::hasher(constchar*, int)':include/libtorrent/hasher.hpp:93: error: `m_context' was not declared in this scopeinclude/libtorrent/hasher.hpp:93: error: `SHA1_Init' was not declared in this scopeinclude/libtorrent/hasher.hpp:96: error: `SHA1_Update' was not declared in thisscopeinclude/libtorrent/hasher.hpp:93: warning: unused variable 'SHA1_Init'include/libtorrent/hasher.hpp:96: warning: unused variable 'SHA1_Update'include/libtorrent/hasher.hpp: In member function `void libtorrent::hasher::update(const char*, int)':include/libtorrent/hasher.hpp:102: error: `m_context' was not declared in this scopeinclude/libtorrent/hasher.hpp:102: error: `SHA1_Update' was not declared in this scopeinclude/libtorrent/hasher.hpp:102: warning: unused variable 'm_context'include/libtorrent/hasher.hpp:102: warning: unused variable 'SHA1_Update'include/libtorrent/hasher.hpp: In member function `libtorrent::sha1_hash libtorrent::hasher::final()':include/libtorrent/hasher.hpp:108: error: `m_context' was not declared in this scopeinclude/libtorrent/hasher.hpp:108: error: `SHA1_Final' was not declared in thisscopeinclude/libtorrent/hasher.hpp:108: warning: unused variable 'm_context'include/libtorrent/hasher.hpp:108: warning: unused variable 'SHA1_Final'include/libtorrent/hasher.hpp: In member function `void libtorrent::hasher::reset()':include/libtorrent/hasher.hpp:112: error: `m_context' was not declared in this scopeinclude/libtorrent/hasher.hpp:112: error: `SHA1_Init' was not declared in this scopeinclude/libtorrent/hasher.hpp:112: warning: unused variable 'm_context'include/libtorrent/hasher.hpp:112: warning: unused variable 'SHA1_Init'In file included from d:/Qt4_tutorial/addin/boost_1_39_0/boost/date_time/microsec_time_clock.hpp:23, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/date_time/posix_time/posix_time_types.hpp:11, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/detail/select_reactor.hpp:25, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/impl/io_service.ipp:27, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/io_service.hpp:550, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/basic_io_object.hpp:20, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/basic_socket_acceptor.hpp:20, from d:/Qt4_tutorial/addin/boost_1_39_0/boost/asio/ip/tcp.hpp:20, from include/libtorrent/socket.hpp:60, from include/libtorrent/kademlia/rpc_manager.hpp:45, from src\kademlia\node.cpp:45:d:/Qt4_tutorial/addin/boost_1_39_0/boost/date_time/filetime_functions.hpp: In function `uint64_t boost::date_time::winapi::file_time_to_microseconds(const FileTimeT&)':d:/Qt4_tutorial/addin/boost_1_39_0/boost/date_time/filetime_functions.hpp:101: warning: left shift count >= width of type
C++ (Qt)#define _strtoi64(a,b,c) strtoll(a,b,c)
C++ (Qt)#define PROTECTION_LEVEL_UNRESTRICTED 10
TEMPLATE = appTARGET = consoleDEPENDPATH += .INCLUDEPATH += . \ ../../addin/libtorrent-rasterbar-0.14.4/include \ # путь к инклудам libtorrent ../../addin/boost_1_39_0 # наш бустCONFIG += staticlib \ static \ consoleSOURCES += main.cpp# ну и либы от буста filesystem, thread, system, сам libtorrent, и если испольовали SSH то линкуем и виндосовские библиотеки.win32:LIBS += -llibboost_system-mgw34-mt-1_39 -llibtorrent -llibboost_filesystem-mgw34 -llibboost_thread-mgw34-mt-1_39 -lws2_32 -lwsock32 -ladvapi32 -lwinmm -lssl32 -leay32 -lssleay32 -luser32 -lshell32 -lgdi32 -lcrypto -lssl