diff -ur ctorrent-dnh3.2/bencode.cpp ctorrent-build/bencode.cpp --- ctorrent-dnh3.2/bencode.cpp 2007-08-22 13:54:56 +0400 +++ ctorrent-build/bencode.cpp 2008-01-15 23:14:42 +0300 @@ -201,6 +201,17 @@ return (EOF == fputc('e', fp)) ? 0: 1; } +size_t bencode_ullint(const unsigned long long int ullinteger, FILE *fp) +{ + char buf[MAX_ULLINT_SIZ]; + if (EOF == fputc('i', fp)) return 0; + if (MAX_ULLINT_SIZ <= snprintf(buf, MAX_ULLINT_SIZ, "%llu", (unsigned long long)ullinteger)) { + return 0; + } + if (fwrite(buf, strlen(buf), 1, fp) != 1) return 0; + return (EOF == fputc('e', fp)) ? 0 : 1; +} + size_t bencode_begin_dict(FILE *fp) { return (EOF == fputc('d',fp)) ? 0 : 1; diff -ur ctorrent-dnh3.2/bencode.h ctorrent-build/bencode.h --- ctorrent-dnh3.2/bencode.h 2007-08-22 13:54:56 +0400 +++ ctorrent-build/bencode.h 2008-01-15 23:12:52 +0300 @@ -10,6 +10,7 @@ #define KEYNAME_LISTSIZ 256 #define MAX_INT_SIZ 64 +#define MAX_ULLINT_SIZ 64 #define QUERY_STR 0 #define QUERY_INT 1 @@ -29,6 +30,7 @@ size_t bencode_buf(const char *str,size_t len,FILE *fp); size_t bencode_str(const char *str, FILE *fp); size_t bencode_int(const int integer, FILE *fp); +size_t bencode_ullint(const unsigned long long int ullinteger, FILE *fp); size_t bencode_begin_dict(FILE *fp); size_t bencode_begin_list(FILE *fp); size_t bencode_end_dict_list(FILE *fp); diff -ur ctorrent-dnh3.2/btfiles.cpp ctorrent-build/btfiles.cpp --- ctorrent-dnh3.2/btfiles.cpp 2007-08-22 13:54:56 +0400 +++ ctorrent-build/btfiles.cpp 2008-01-15 23:16:24 +0300 @@ -700,7 +700,7 @@ }else{ if( bencode_str("length", fp) != 1 ) return 0; - if( bencode_int(m_btfhead->bf_length, fp) != 1) return 0; + if (bencode_ullint(m_btfhead->bf_length, fp) != 1) return 0; if( bencode_str("name", fp) != 1 ) return 0; return bencode_str(m_btfhead->bf_filename, fp); diff -ur ctorrent-dnh3.2/btfiles.h ctorrent-build/btfiles.h --- ctorrent-dnh3.2/btfiles.h 2007-08-22 13:54:56 +0400 +++ ctorrent-build/btfiles.h 2008-01-14 16:50:45 +0300 @@ -33,7 +33,7 @@ BTFILE *m_btfhead; char *m_directory; - uint64_t m_total_files_length; + off_t m_total_files_length; size_t m_total_opened; // already opened size_t m_nfiles; BTFILE **m_file; @@ -64,7 +64,7 @@ const char *saveas); char *GetDataName() const; - uint64_t GetTotalLength() const { return m_total_files_length; } + off_t GetTotalLength() const { return m_total_files_length; } ssize_t IO(char *buf, uint64_t off, size_t len, const int iotype); size_t FillMetaInfo(FILE* fp);