⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 btcontent.h

📁 linux系统下bt的客户端实现。 采用的是c++
💻 H
字号:
#ifndef BTCONTENT_H#define BTCONTENT_H#include "Btfiles.h"#include "Bitfield.h"struct BTCACHE {    uint64_t bc_off;    size_t bc_len;    unsigned char bc_f_flush:1;    unsigned char bc_f_reserved:7;    char *bc_buf;    struct BTCACHE *bc_next;    struct BTCACHE *bc_prev;    struct BTCACHE *age_next;    struct BTCACHE *age_prev;};class btContent {  private:    unsigned char *m_announce, *m_hash_table;    unsigned char m_shake_buffer[68];	unsigned char*m_sha_buffer;	char *m_announce_list[20];    size_t m_hash_table_length;    size_t m_piece_length;    size_t m_npieces;    time_t m_create_date;    uint64_t m_left_bytes;    btFiles m_btfiles;    bitfield *m_pbitmap;		BTCACHE** m_cache;	BTCACHE* m_cache_oldest, *m_cache_newest;	uint64_t m_cache_size, m_cache_used;	void empty_cache();  public:     btContent();    ~btContent();    void FlushCache() { FlushCache(m_npieces); };    void FlushCache(size_t idx);	void CacheClean(size_t need);	void Uncache(size_t idx);    void printout();	void free_announce_list();    int InitialFromMI(Bencode *);    ssize_t CacheIO(unsigned char *buf, uint64_t off, size_t len, int method);	ssize_t ReadSlice(unsigned char *buf, size_t idx, size_t off, size_t len);	ssize_t WriteSlice(unsigned char *buf, size_t idx, size_t off, size_t len);	ssize_t ReadPiece(size_t idx, unsigned char* buff);	int APieceComplete(size_t idx);	int GetHashValue(size_t idx, unsigned char* md);	int GetAPiece(size_t idx, unsigned char* buf);	size_t GetCacheSize() { return m_cache_size; }	size_t GetCacheUsed() { return m_cache_used; }	size_t GetPieceLength() { return m_piece_length; }	size_t GetPieceLength(size_t idx);	size_t GetNPieces() const { return m_npieces; }	unsigned char* GetAnnounce() { return m_announce; }	unsigned char* GetPeerId()  { return m_shake_buffer + 48; }	unsigned char* GetInfoHash() { return m_shake_buffer + 28; } 	         char** GetAnnounceList() { return m_announce_list; }	uint64_t GetTotalFilesLength() 		{ return m_btfiles.GetTotalLength(); }	uint64_t GetLeftBytes() const { return m_left_bytes; }	};extern btContent BTCONTENT;#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -