summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorMichael Lauer <mickey@vanille-media.de>2005-08-12 13:59:08 +0000
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>2005-08-12 13:59:08 +0000
commitfbfb5b4608244162d40320f09352b2694a1c2cfe (patch)
treee0e547a4d213422824980387977af6354271385a /packages
parent439e1fb9756d4eb27aaf6731862da01696005656 (diff)
parent44499f7e725f61854f7fce09aa8364317293b62b (diff)
merge of 41ccdaa6ccec1fc3dd5467a321a4920945f4a673
and f79035e45efd4ec295a4f073b25a42193a9cda7b
Diffstat (limited to 'packages')
-rw-r--r--packages/ctorrent/ctorrent_1.3.4.bb11
-rw-r--r--packages/ctorrent/files/align.patch189
-rw-r--r--packages/ctorrent/files/configure.patch29
-rw-r--r--packages/ctorrent/files/crash.patch24
-rw-r--r--packages/ctorrent/files/extended_ctorrent.diff2169
-rw-r--r--packages/ctorrent/files/fmt.patch42
-rw-r--r--packages/ctorrent/files/nogetwd.patch34
-rw-r--r--packages/ctorrent/files/passkey.patch16
-rw-r--r--packages/ctorrent/files/stall.patch27
-rw-r--r--packages/ctorrent/files/tracker.patch175
-rw-r--r--packages/efl/e_20050810.bb2
-rw-r--r--packages/gimp/gimp_2.3.3.bb2
-rw-r--r--packages/initscripts/initscripts-1.0/akita/keymap-2.6.map213
-rw-r--r--packages/initscripts/initscripts-1.0/spitz/keymap-2.6.map213
-rw-r--r--packages/ixp425-eth/ixp425-eth_1.1.bb4
-rw-r--r--packages/ixp4xx/ixp4xx-csr_1.4.bb4
-rw-r--r--packages/linux/linux-openzaurus-2.6.13-rc5-mm1/defconfig-spitz403
-rw-r--r--packages/linux/linux-openzaurus_2.6.13-rc5-mm1.bb15
-rw-r--r--packages/linux/nslu2-kernel.inc4
-rw-r--r--packages/linux/nslu2-kernel/2.6/nslu2-io_rpbutton.patch139
-rw-r--r--packages/linux/nslu2-kernel_2.6.12.2.bb3
-rw-r--r--packages/pcre/pcre_4.4.bb4
-rw-r--r--packages/ppp/ppp-2.4.3/plugins-fix-CC.patch7
-rw-r--r--packages/ppp/ppp_2.4.3.bb2
-rw-r--r--packages/sysvinit/sysvinit/openslug/inittab4
-rw-r--r--packages/sysvinit/sysvinit_2.86.bb2
-rw-r--r--packages/uicmoc/uicmoc3-native_3.3.2.bb5
27 files changed, 3020 insertions, 722 deletions
diff --git a/packages/ctorrent/ctorrent_1.3.4.bb b/packages/ctorrent/ctorrent_1.3.4.bb
index 087823cdb4..d2b02e8748 100644
--- a/packages/ctorrent/ctorrent_1.3.4.bb
+++ b/packages/ctorrent/ctorrent_1.3.4.bb
@@ -1,11 +1,4 @@
include ctorrent.inc
-PR = "r4"
+PR = "r5"
-SRC_URI += "file://configure.patch;patch=1 \
- file://align.patch;patch=1 \
- file://nogetwd.patch;patch=1 \
- file://crash.patch;patch=1 \
- file://fmt.patch;patch=1 \
- file://stall.patch;patch=1 \
- file://tracker.patch;patch=1 \
- file://passkey.patch;patch=1"
+SRC_URI += "file://extended_ctorrent.diff;patch=1"
diff --git a/packages/ctorrent/files/align.patch b/packages/ctorrent/files/align.patch
deleted file mode 100644
index 71dd7058cb..0000000000
--- a/packages/ctorrent/files/align.patch
+++ /dev/null
@@ -1,189 +0,0 @@
-diff -ur ctorrent-1.3.4/btstream.cpp new/btstream.cpp
---- ctorrent-1.3.4/btstream.cpp 2004-09-09 00:10:51.000000000 +0100
-+++ new/btstream.cpp 2005-01-25 01:25:31.000000000 +0000
-@@ -1,5 +1,6 @@
- #include <arpa/inet.h>
- #include "btstream.h"
-+#include "peer.h"
- #include "msgencode.h"
- #include "btconfig.h"
-
-@@ -11,7 +12,7 @@
- ssize_t btStream::Send_State(unsigned char state)
- {
- char msg[H_BASE_LEN + 4];
-- *(size_t*)msg = htonl(H_BASE_LEN);
-+ set_nl(msg, H_BASE_LEN);
- msg[4] = (char)state;
- return out_buffer.PutFlush(sock,msg,H_BASE_LEN + 4);
- }
-@@ -19,12 +20,9 @@
- ssize_t btStream::Send_Have(size_t idx)
- {
- char msg[H_HAVE_LEN + 4];
-- size_t *p = (size_t*)msg;
--
-- *p = htonl(H_HAVE_LEN);
-+ set_nl(msg, H_HAVE_LEN);
- msg[4] = (char)M_HAVE;
-- p = (size_t*)(msg + 5);
-- *p = htonl(idx);
-+ set_nl(msg + 5, idx);
-
- return out_buffer.PutFlush(sock,msg,H_HAVE_LEN + 4);
- }
-@@ -43,14 +41,12 @@
- ssize_t btStream::Send_Cancel(size_t idx,size_t off,size_t len)
- {
- char msg[H_CANCEL_LEN + 4];
-- size_t *p = (size_t*)msg;
-
-- *p = htonl(H_CANCEL_LEN);
-+ set_nl(msg, H_CANCEL_LEN);
- msg[4] = M_CANCEL;
-- p = (size_t*)(msg + 5);
-- *p = htonl(idx); p++;
-- *p = htonl(off); p++;
-- *p = htonl(len);
-+ set_nl(msg + 5, idx);
-+ set_nl(msg + 9, off);
-+ set_nl(msg + 13, len);
- return out_buffer.Put(sock,msg,H_CANCEL_LEN + 4);
- }
-
-@@ -72,14 +68,12 @@
- ssize_t btStream::Send_Request(size_t idx, size_t off,size_t len)
- {
- char msg[H_REQUEST_LEN + 4];
-- size_t *p = (size_t*) msg;
-
-- *p = htonl(H_REQUEST_LEN);
-+ set_nl(msg, H_REQUEST_LEN);
- msg[4] = (char)M_REQUEST;
-- p = (size_t*)(msg + 5);
-- *p = htonl(idx); p++;
-- *p = htonl(off); p++;
-- *p = htonl(len);
-+ set_nl(msg + 5, idx);
-+ set_nl(msg + 9, off);
-+ set_nl(msg + 13, len);
- return out_buffer.Put(sock,msg,H_REQUEST_LEN + 4);
- }
-
-@@ -94,7 +88,7 @@
- // if message arrived.
- size_t r;
- if( 4 <= in_buffer.Count() ){
-- r = ntohl(*(size_t*)in_buffer.BasePointer());
-+ r = get_nl(in_buffer.BasePointer());
- if( (cfg_max_slice_size + H_PIECE_LEN + 4) < r) return -1; //message too long
- if( (r + 4) <= in_buffer.Count() ) return 1;
- }
-diff -ur ctorrent-1.3.4/peer.cpp new/peer.cpp
---- ctorrent-1.3.4/peer.cpp 2004-09-09 00:10:51.000000000 +0100
-+++ new/peer.cpp 2005-01-25 01:23:51.000000000 +0000
-@@ -3,11 +3,32 @@
- #include <stdlib.h>
- #include <string.h>
-
-+#include "btstream.h"
- #include "./btcontent.h"
- #include "./msgencode.h"
- #include "./peerlist.h"
- #include "./btconfig.h"
-
-+size_t get_nl(char *sfrom)
-+{
-+ unsigned char *from = (unsigned char *)sfrom;
-+ size_t t;
-+ t = (*from++) << 24;
-+ t |= (*from++) << 16;
-+ t |= (*from++) << 8;
-+ t |= *from;
-+ return t;
-+}
-+
-+void set_nl(char *sto, size_t from)
-+{
-+ unsigned char *to = (unsigned char *)sto;
-+ *to++ = (from >> 24) & 0xff;
-+ *to++ = (from >> 16) & 0xff;
-+ *to++ = (from >> 8) & 0xff;
-+ *to = from & 0xff;
-+}
-+
- btBasic Self;
-
- void btBasic::SetIp(struct sockaddr_in addr)
-@@ -152,7 +173,8 @@
-
- char *msgbuf = stream.in_buffer.BasePointer();
-
-- r = ntohl(*(size_t*) msgbuf);
-+ r = get_nl(msgbuf);
-+
-
- if( 0 == r ){
- time(&m_last_timestamp);
-@@ -193,7 +215,7 @@
- case M_HAVE:
- if(H_HAVE_LEN != r){return -1;}
-
-- idx = ntohl(*(size_t*) (msgbuf + 5));
-+ idx = get_nl(msgbuf + 5);
-
- if( idx >= BTCONTENT.GetNPieces() || bitfield.IsSet(idx)) return -1;
-
-@@ -208,12 +230,12 @@
- case M_REQUEST:
- if(H_REQUEST_LEN != r || !m_state.remote_interested){ return -1; }
-
-- idx = ntohl(*(size_t*)(msgbuf + 5));
-+ idx = get_nl(msgbuf + 5);
-
- if( !BTCONTENT.pBF->IsSet(idx) ) return -1;
-
-- off = ntohl(*(size_t*)(msgbuf + 9));
-- len = ntohl(*(size_t*)(msgbuf + 13));
-+ off = get_nl(msgbuf + 9);
-+ len = get_nl(msgbuf + 13);
-
- if( !reponse_q.IsValidRequest(idx, off, len) ) return -1;
-
-@@ -235,9 +257,9 @@
- case M_CANCEL:
- if(r != H_CANCEL_LEN || !m_state.remote_interested) return -1;
-
-- idx = ntohl(*(size_t*)(msgbuf + 5));
-- off = ntohl(*(size_t*)(msgbuf + 9));
-- len = ntohl(*(size_t*)(msgbuf + 13));
-+ idx = get_nl(msgbuf + 5);
-+ off = get_nl(msgbuf + 9);
-+ len = get_nl(msgbuf + 13);
- if( reponse_q.Remove(idx,off,len) < 0 ){
- m_err_count++;
- return 0;
-@@ -312,8 +334,8 @@
- size_t idx,off,len;
- char *msgbuf = stream.in_buffer.BasePointer();
-
-- idx = ntohl(*(size_t*) (msgbuf + 5));
-- off = ntohl(*(size_t*) (msgbuf + 9));
-+ idx = get_nl(msgbuf + 5);
-+ off = get_nl(msgbuf + 9);
- len = mlen - 9;
-
- if( request_q.Remove(idx,off,len) < 0 ){
-diff -ur ctorrent-1.3.4/peer.h new/peer.h
---- ctorrent-1.3.4/peer.h 2004-09-09 00:10:51.000000000 +0100
-+++ new/peer.h 2005-01-25 01:23:01.000000000 +0000
-@@ -34,6 +34,9 @@
- unsigned char reserved:4; /* unused */
- }BTSTATUS;
-
-+size_t get_nl(char *from);
-+void set_nl(char *to, size_t from);
-+
- class btBasic
- {
- private:
diff --git a/packages/ctorrent/files/configure.patch b/packages/ctorrent/files/configure.patch
deleted file mode 100644
index 95fe5cc2be..0000000000
--- a/packages/ctorrent/files/configure.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-diff -ur ctorrent/configure ctorrent.new/configure
---- ctorrent/configure 2004-09-09 00:10:51.000000000 +0100
-+++ ctorrent.new/configure 2005-01-23 18:29:34.000000000 +0000
-@@ -3216,13 +3216,13 @@
-
- else
-
--echo "$as_me:$LINENO: checking for SHA1_Init in -lcrypt" >&5
--echo $ECHO_N "checking for SHA1_Init in -lcrypt... $ECHO_C" >&6
-+echo "$as_me:$LINENO: checking for SHA1_Init in -lcrypto" >&5
-+echo $ECHO_N "checking for SHA1_Init in -lcrypto... $ECHO_C" >&6
- if test "${ac_cv_lib_crypt_SHA1_Init+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
- else
- ac_check_lib_save_LIBS=$LIBS
--LIBS="-lcrypt $LIBS"
-+LIBS="-lcrypto $LIBS"
- cat >conftest.$ac_ext <<_ACEOF
- #line $LINENO "configure"
- /* confdefs.h. */
-@@ -3275,7 +3275,7 @@
- #define HAVE_LIBCRYPT 1
- _ACEOF
-
-- LIBS="-lcrypt $LIBS"
-+ LIBS="-lcrypto $LIBS"
-
- else
-
diff --git a/packages/ctorrent/files/crash.patch b/packages/ctorrent/files/crash.patch
deleted file mode 100644
index 70ef72e6cd..0000000000
--- a/packages/ctorrent/files/crash.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff -ur ctorrent/btcontent.cpp ctorrent.new/btcontent.cpp
---- ctorrent/btcontent.cpp 2004-09-09 00:10:51.000000000 +0100
-+++ ctorrent.new/btcontent.cpp 2005-02-03 01:32:24.000000000 +0000
-@@ -226,6 +226,7 @@
- if( m_btfiles.BuildFromMI(b, flen, saveas) < 0) ERR_RETURN();
-
- delete []b;
-+ b = (char *)0;
- PrintOut();
-
- if( arg_flg_exam_only ) return 0;
-diff -ur ctorrent/iplist.cpp ctorrent.new/iplist.cpp
---- ctorrent/iplist.cpp 2004-09-09 00:10:51.000000000 +0100
-+++ ctorrent.new/iplist.cpp 2005-02-08 13:02:45.000000000 +0000
-@@ -8,8 +8,8 @@
- IPLIST *node = ipl_head;
- for(; ipl_head;){
- node = ipl_head;
-- delete ipl_head;
- ipl_head = node->next;
-+ delete node;
- }
- count = 0;
- }
diff --git a/packages/ctorrent/files/extended_ctorrent.diff b/packages/ctorrent/files/extended_ctorrent.diff
new file mode 100644
index 0000000000..d35c434d07
--- /dev/null
+++ b/packages/ctorrent/files/extended_ctorrent.diff
@@ -0,0 +1,2169 @@
+Only in ctorrent-1.3.4: README-DNH.TXT
+diff -u ctorrent-1.3.4.orig/btconfig.cpp ctorrent-1.3.4/btconfig.cpp
+--- ctorrent-1.3.4.orig/btconfig.cpp 2004-09-09 01:10:51.000000000 +0200
++++ ctorrent-1.3.4/btconfig.cpp 2005-08-11 23:45:29.424694440 +0200
+@@ -1,6 +1,7 @@
+ #include <sys/types.h>
+
+-size_t cfg_req_slice_size = 32768;
++//size_t cfg_req_slice_size = 32768;
++size_t cfg_req_slice_size = 16384;
+
+ size_t cfg_cache_size = 16;
+
+@@ -11,7 +12,8 @@
+ int cfg_max_listen_port = 2706;
+ int cfg_min_listen_port = 2106;
+
+-int cfg_max_bandwidth = -1;
++int cfg_max_bandwidth_down = -1;
++int cfg_max_bandwidth_up = -1;
+
+ time_t cfg_seed_hours = 72;
+
+@@ -25,6 +27,8 @@
+ unsigned char arg_flg_check_only = 0;
+ unsigned char arg_flg_exam_only = 0;
+ unsigned char arg_flg_make_torrent = 0;
++unsigned char arg_file_to_download = 0;
++unsigned char arg_verbose = 0;
+
+ size_t arg_piece_length = 262144;
+ char *arg_announce = (char*) 0;
+diff -u ctorrent-1.3.4.orig/btconfig.h ctorrent-1.3.4/btconfig.h
+--- ctorrent-1.3.4.orig/btconfig.h 2004-09-09 01:10:51.000000000 +0200
++++ ctorrent-1.3.4/btconfig.h 2005-08-11 23:45:29.425694288 +0200
+@@ -22,6 +22,8 @@
+ extern time_t cfg_seed_hours;
+
+ extern int cfg_max_bandwidth;
++extern int cfg_max_bandwidth_down;
++extern int cfg_max_bandwidth_up;
+
+ // arguments global value
+ extern char *arg_metainfo_file;
+@@ -33,6 +35,8 @@
+ extern unsigned char arg_flg_check_only;
+ extern unsigned char arg_flg_exam_only;
+ extern unsigned char arg_flg_make_torrent;
++extern unsigned char arg_file_to_download;
++extern unsigned char arg_verbose;
+
+ extern size_t arg_piece_length;
+ extern char *arg_announce;
+diff -u ctorrent-1.3.4.orig/btcontent.cpp ctorrent-1.3.4/btcontent.cpp
+--- ctorrent-1.3.4.orig/btcontent.cpp 2004-09-09 01:10:51.000000000 +0200
++++ ctorrent-1.3.4/btcontent.cpp 2005-08-11 23:45:29.425694288 +0200
+@@ -23,6 +23,7 @@
+ #include "bencode.h"
+ #include "peer.h"
+ #include "httpencode.h"
++#include "tracker.h"
+
+ #define meta_str(keylist,pstr,pint) decode_query(b,flen,(keylist),(pstr),(pint),QUERY_STR)
+ #define meta_int(keylist,pint) decode_query(b,flen,(keylist),(const char**) 0,(pint),QUERY_INT)
+@@ -53,6 +54,7 @@
+ m_announce = global_piece_buffer = (char*) 0;
+ m_hash_table = (unsigned char *) 0;
+ pBF = (BitField*) 0;
++ pBFilter = (BitField*) 0;
+ m_create_date = m_seed_timestamp = (time_t) 0;
+ time(&m_start_timestamp);
+ m_cache = (BTCACHE*) 0;
+@@ -226,6 +228,7 @@
+ if( m_btfiles.BuildFromMI(b, flen, saveas) < 0) ERR_RETURN();
+
+ delete []b;
++ b = (char *)0;
+ PrintOut();
+
+ if( arg_flg_exam_only ) return 0;
+@@ -242,6 +245,17 @@
+ if( !pBF ) ERR_RETURN();
+ #endif
+
++ //create the file filter
++ pBFilter = new BitField(m_npieces);
++#ifndef WINDOWS
++ if( !pBFilter ) ERR_RETURN();
++#endif
++ if(arg_file_to_download>0){
++ m_btfiles.SetFilter(arg_file_to_download,pBFilter,m_piece_length);
++ }
++
++
++
+ m_left_bytes = m_btfiles.GetTotalLength() / m_piece_length;
+ if( m_btfiles.GetTotalLength() % m_piece_length ) m_left_bytes++;
+ if( m_left_bytes != m_npieces ) ERR_RETURN();
+@@ -309,7 +323,8 @@
+
+ ssize_t btContent::ReadSlice(char *buf,size_t idx,size_t off,size_t len)
+ {
+- u_int64_t offset = idx * m_piece_length + off;
++ //changed
++ u_int64_t offset = (u_int64_t)idx * (u_int64_t)m_piece_length + (u_int64_t)off;
+
+ if( !m_cache_size ) return m_btfiles.IO(buf, offset, len, 0);
+ else{
+@@ -405,7 +420,11 @@
+
+ ssize_t btContent::WriteSlice(char *buf,size_t idx,size_t off,size_t len)
+ {
+- u_int64_t offset = (u_int64_t)(idx * m_piece_length + off);
++ //u_int64_t offset = (u_int64_t)(idx * m_piece_length + off);
++ //changed
++ u_int64_t offset = (u_int64_t)idx * (u_int64_t)m_piece_length + (u_int64_t)off;
++
++ // printf("\nOffset-write: %lu - Piece:%lu\n",offset,(unsigned long)idx);
+
+ if( !m_cache_size ) return m_btfiles.IO(buf, offset, len, 1);
+ else{
+@@ -514,9 +533,9 @@
+ if( !percent ) percent = 1;
+
+ for( ; idx < m_npieces; idx++){
+- if( GetHashValue(idx, md) == 0 && memcmp(md, m_hash_table + idx * 20, 20) == 0){
+- m_left_bytes -= GetPieceLength(idx);
+- pBF->Set(idx);
++ if( GetHashValue(idx, md) == 0 && memcmp(md, m_hash_table + idx * 20, 20) == 0){
++ m_left_bytes -= GetPieceLength(idx);
++ pBF->Set(idx);
+ }
+ if(idx % percent == 0){
+ printf("\rCheck exist: %d/%d",idx,pBF->NBits());
+@@ -575,7 +594,6 @@
+ fprintf(stderr,"warn,piece %d hash check failed.\n",idx);
+ return 0;
+ }
+-
+ pBF->Set(idx);
+ m_left_bytes -= GetPieceLength(idx);
+ return 1;
+@@ -592,6 +610,7 @@
+ {
+ if( pBF->IsFull() ){
+ if( !m_seed_timestamp ){
++ Tracker.Reset(15);
+ Self.ResetDLTimer();
+ Self.ResetULTimer();
+ ReleaseHashTable();
+@@ -605,3 +624,13 @@
+ }
+ return 0;
+ }
++
++
++size_t btContent::getFilePieces(unsigned char nfile){
++ return m_btfiles.getFilePieces(nfile);
++}
++
++
++void btContent::SetFilter(){
++ m_btfiles.SetFilter(arg_file_to_download,pBFilter,m_piece_length);
++}
+diff -u ctorrent-1.3.4.orig/btcontent.h ctorrent-1.3.4/btcontent.h
+--- ctorrent-1.3.4.orig/btcontent.h 2004-09-09 01:10:51.000000000 +0200
++++ ctorrent-1.3.4/btcontent.h 2005-08-11 23:45:29.426694136 +0200
+@@ -60,6 +60,7 @@
+
+ public:
+ BitField *pBF;
++ BitField *pBFilter;
+ char *global_piece_buffer;
+
+ btContent();
+@@ -93,6 +94,11 @@
+
+ int PrintOut();
+ int SeedTimeout(const time_t *pnow);
++
++
++ void SetFilter();
++ size_t getFilePieces(unsigned char nfile);
++
+ };
+
+ extern btContent BTCONTENT;
+diff -u ctorrent-1.3.4.orig/btfiles.cpp ctorrent-1.3.4/btfiles.cpp
+--- ctorrent-1.3.4.orig/btfiles.cpp 2004-09-09 01:10:51.000000000 +0200
++++ ctorrent-1.3.4/btfiles.cpp 2005-08-11 23:45:29.426694136 +0200
+@@ -105,6 +105,7 @@
+ pos = (size_t) (off - (n - pbf->bf_length));
+
+ for(; len ;){
++
+ if( !pbf->bf_flag_opened ){
+ if( _btf_open(pbf) < 0 ) return -1;
+ }
+@@ -119,6 +120,7 @@
+ if( 1 != fread(buf,nio,1,pbf->bf_fp) ) return -1;
+ }else{
+ if( 1 != fwrite(buf,nio,1,pbf->bf_fp) ) return -1;
++ fflush(pbf->bf_fp);
+ }
+
+ len -= nio;
+@@ -169,7 +171,7 @@
+ DIR *dp;
+ BTFILE *pbf;
+
+- if( !getwd(full_cur) ) return -1;
++ if( !getcwd(full_cur,MAXPATHLEN) ) return -1;
+
+ if( cur_path ){
+ strcpy(fn, full_cur);
+@@ -293,7 +295,7 @@
+ m_btfhead = pbf;
+ }else if( S_IFDIR & sb.st_mode ){
+ char wd[MAXPATHLEN];
+- if( !getwd(wd) ) return -1;
++ if( !getcwd(wd,MAXPATHLEN) ) return -1;
+ m_directory = new char[strlen(pathname) + 1];
+ #ifndef WINDOWS
+ if( !m_directory ) return -1;
+@@ -488,3 +490,54 @@
+ }
+ return 1;
+ }
++
++
++void btFiles::SetFilter(int nfile, BitField *pFilter, size_t pieceLength)
++{
++ //set the filter
++
++ BTFILE *p = m_btfhead;
++ size_t id = 1;
++ u_int64_t sizeBuffer=0;
++ size_t index;
++
++
++ pFilter->SetAll();
++ for( ; p ; p = p->bf_next ){
++ if(id++ == nfile){
++ size_t start,stop;
++ start = sizeBuffer/pieceLength;
++ stop = (sizeBuffer+p->bf_length)/pieceLength;
++ printf ("\rDownloading file: <%d> %s \nPieces: %d - %d (%d)\n",nfile,p->bf_filename,start,stop,stop-start+1);
++ p->bf_npieces = stop-start+1;
++ for(index=sizeBuffer/pieceLength;index<=(sizeBuffer+p->bf_length)/pieceLength;index++){
++ pFilter->UnSet(index);
++ }
++ }
++ sizeBuffer+=(u_int64_t) p->bf_length;
++ }
++ if(nfile>=id){
++ printf("\nEnd of files list. Resuming normal behaviour\n");
++ pFilter->Invert();
++ arg_file_to_download = 0;
++ }
++}
++
++size_t btFiles::getFilePieces(unsigned char nfile)
++{
++ //returns the pieces of the file already gotten
++
++ BTFILE *p = m_btfhead;
++ size_t id = 1;
++
++ for( ; p ; p = p->bf_next ){
++ if(id++ == nfile){
++ return p->bf_npieces;
++ }
++ }
++return 0;
++}
++
++
++
++
+diff -u ctorrent-1.3.4.orig/btfiles.h ctorrent-1.3.4/btfiles.h
+--- ctorrent-1.3.4.orig/btfiles.h 2004-09-09 01:10:51.000000000 +0200
++++ ctorrent-1.3.4/btfiles.h 2005-08-11 23:45:29.427693984 +0200
+@@ -3,6 +3,10 @@
+
+ #include <sys/types.h>
+ #include <stdio.h>
++
++#include "bitfield.h"
++extern unsigned char arg_file_to_download;
++
+ #include "./def.h"
+
+ typedef struct _btfile{
+@@ -14,6 +18,8 @@
+
+ size_t bf_completed; // already downloaded length
+
++ size_t bf_npieces; //number of pieces
++
+ unsigned char bf_flag_opened:1;
+ unsigned char bf_flag_need:1;
+ unsigned char bf_reserved:6;
+@@ -53,6 +59,10 @@
+ u_int64_t GetTotalLength() const { return m_total_files_length; }
+ ssize_t IO(char *buf, u_int64_t off, size_t len, const int iotype);
+ size_t FillMetaInfo(FILE* fp);
++
++ void SetFilter(int nfile, BitField *pFilter,size_t pieceLength);
++ size_t getFilePieces(unsigned char nfile);
++
+ #ifndef WINDOWS
+ void PrintOut();
+ #endif
+diff -u ctorrent-1.3.4.orig/btrequest.cpp ctorrent-1.3.4/btrequest.cpp
+--- ctorrent-1.3.4.orig/btrequest.cpp 2004-09-09 01:10:51.000000000 +0200
++++ ctorrent-1.3.4/btrequest.cpp 2005-08-11 23:45:29.427693984 +0200
+@@ -44,6 +44,58 @@
+ rq.rq_head = (PSLICE) 0;
+ }
+
++int RequestQueue::CopyShuffle(RequestQueue &rq)
++{
++ PSLICE ps;
++
++ if( rq_head ) _empty_slice_list(&rq_head);
++
++ if( rq.IsEmpty() ) return 0;
++ for (ps = rq.GetHead(); ps; ps = ps->next) {
++ if (random()&01) {
++ if (Add(ps->index, ps->offset, ps->length) < 0) return -1;
++ }
++ else if (Insert(ps->index, ps->offset, ps->length) < 0) return -1;
++ }
++ return 0;
++}
++
++size_t RequestQueue::Qsize()
++{
++ size_t cnt = 0;
++ PSLICE n = rq_head;
++ PSLICE u = (PSLICE) 0;
++
++ for( ; n ; u = n,n = u->next) cnt++; // move to end
++ return cnt;
++}
++
++int RequestQueue::Insert(size_t idx,size_t off,size_t len)
++{
++ size_t cnt = 0;
++ PSLICE n = rq_head;
++ PSLICE u = (PSLICE) 0;
++
++ for( ; n ; u = n,n = u->next) cnt++; // move to end (count)
++
++ if( cnt >= cfg_req_queue_length ) return -1; // already full
++
++ n = new SLICE;
++
++#ifndef WINDOWS
++ if( !n ) return -1;
++#endif
++
++ n->next = rq_head;
++ n->index = idx;
++ n->offset = off;
++ n->length = len;
++
++ rq_head = n;
++
++ return 0;
++}
++
+ int RequestQueue::Add(size_t idx,size_t off,size_t len)
+ {
+ size_t cnt = 0;
+@@ -231,3 +283,33 @@
+ }
+ return 0;
+ }
++
++int PendingQueue::Delete(size_t idx)
++{
++ int i = 0;
++ for ( ; i < PENDING_QUEUE_SIZE && pq_count; i++){
++ if( (PSLICE) 0 != pending_array[i] && idx == pending_array[i]->index){
++ delete pending_array[i];
++ pending_array[i] = (PSLICE) 0;
++ }
++ }
++ return 0;
++}
++
++int PendingQueue::DeleteSlice(size_t idx, size_t off, size_t len)
++{
++ int i = 0;
++ RequestQueue rq;
++ for ( ; i < PENDING_QUEUE_SIZE && pq_count; i++){
++ if( (PSLICE) 0 != pending_array[i] && idx == pending_array[i]->index){
++ //check if off & len match any slice
++ //remove the slice if so
++ rq.SetHead(pending_array[i]);
++ if( rq.Remove(idx, off, len) == 0 )
++ pending_array[i] = rq.GetHead();
++ rq.Release();
++ }
++ }
++ return 0;
++}
++
+diff -u ctorrent-1.3.4.orig/btrequest.h ctorrent-1.3.4/btrequest.h
+--- ctorrent-1.3.4.orig/btrequest.h 2004-09-09 01:10:51.000000000 +0200
++++ ctorrent-1.3.4/btrequest.h 2005-08-11 23:45:29.427693984 +0200
+@@ -31,9 +31,12 @@
+ int IsValidRequest(size_t idx,size_t off,size_t len);
+
+ void operator=(RequestQueue &rq);
++ int CopyShuffle(RequestQueue &rq);
++ size_t Qsize();
+
+ int IsEmpty() const { return rq_head ? 0 : 1; }
+
++ int Insert(size_t idx,size_t off,size_t len);
+ int Add(size_t idx,size_t off,size_t len);
+ int Remove(size_t idx,size_t off,size_t len);
+
+@@ -60,6 +63,8 @@
+ int Pending(RequestQueue *prq);
+ int ReAssign(RequestQueue *prq, BitField &bf);
+ int Exist(size_t idx);
++ int Delete(size_t idx);
++ int DeleteSlice(size_t idx, size_t off, size_t len);
+ };
+
+ extern PendingQueue PENDINGQUEUE;
+diff -u ctorrent-1.3.4.orig/btstream.cpp ctorrent-1.3.4/btstream.cpp
+--- ctorrent-1.3.4.orig/btstream.cpp 2004-09-09 01:10:51.000000000 +0200
++++ ctorrent-1.3.4/btstream.cpp 2005-08-11 23:45:29.428693832 +0200
+@@ -1,5 +1,6 @@
+ #include <arpa/inet.h>
+ #include "btstream.h"
++#include "peer.h"
+ #include "msgencode.h"
+ #include "btconfig.h"
+
+@@ -11,7 +12,8 @@
+ ssize_t btStream::Send_State(unsigned char state)
+ {
+ char msg[H_BASE_LEN + 4];
+- *(size_t*)msg = htonl(H_BASE_LEN);
++
++ set_nl(msg, H_BASE_LEN);
+ msg[4] = (char)state;
+ return out_buffer.PutFlush(sock,msg,H_BASE_LEN + 4);
+ }
+@@ -19,12 +21,10 @@
+ ssize_t btStream::Send_Have(size_t idx)
+ {
+ char msg[H_HAVE_LEN + 4];
+- size_t *p = (size_t*)msg;
+
+- *p = htonl(H_HAVE_LEN);
++ set_nl(msg, H_HAVE_LEN);
+ msg[4] = (char)M_HAVE;
+- p = (size_t*)(msg + 5);
+- *p = htonl(idx);
++ set_nl(msg + 5, idx);
+
+ return out_buffer.PutFlush(sock,msg,H_HAVE_LEN + 4);
+ }
+@@ -43,14 +43,12 @@
+ ssize_t btStream::Send_Cancel(size_t idx,size_t off,size_t len)
+ {
+ char msg[H_CANCEL_LEN + 4];
+- size_t *p = (size_t*)msg;
+
+- *p = htonl(H_CANCEL_LEN);
++ set_nl(msg, H_CANCEL_LEN);
+ msg[4] = M_CANCEL;
+- p = (size_t*)(msg + 5);
+- *p = htonl(idx); p++;
+- *p = htonl(off); p++;
+- *p = htonl(len);
++ set_nl(msg + 5, idx);
++ set_nl(msg + 9, off);
++ set_nl(msg + 13, len);
+ return out_buffer.Put(sock,msg,H_CANCEL_LEN + 4);
+ }
+
+@@ -72,14 +70,12 @@
+ ssize_t btStream::Send_Request(size_t idx, size_t off,size_t len)
+ {
+ char msg[H_REQUEST_LEN + 4];
+- size_t *p = (size_t*) msg;
+
+- *p = htonl(H_REQUEST_LEN);
++ set_nl(msg, H_REQUEST_LEN);
+ msg[4] = (char)M_REQUEST;
+- p = (size_t*)(msg + 5);
+- *p = htonl(idx); p++;
+- *p = htonl(off); p++;
+- *p = htonl(len);
++ set_nl(msg + 5, idx);
++ set_nl(msg + 9, off);
++ set_nl(msg + 13, len);
+ return out_buffer.Put(sock,msg,H_REQUEST_LEN + 4);
+ }
+
+@@ -94,7 +90,7 @@
+ // if message arrived.
+ size_t r;
+ if( 4 <= in_buffer.Count() ){
+- r = ntohl(*(size_t*)in_buffer.BasePointer());
++ r = get_nl(in_buffer.BasePointer());
+ if( (cfg_max_slice_size + H_PIECE_LEN + 4) < r) return -1; //message too long
+ if( (r + 4) <= in_buffer.Count() ) return 1;
+ }
+diff -u ctorrent-1.3.4.orig/ctorrent.cpp ctorrent-1.3.4/ctorrent.cpp
+--- ctorrent-1.3.4.orig/ctorrent.cpp 2004-09-09 01:10:51.000000000 +0200
++++ ctorrent-1.3.4/ctorrent.cpp 2005-08-11 23:45:29.428693832 +0200
+@@ -87,9 +87,13 @@
+ Tracker.Initial();
+
+ signal(SIGPIPE,SIG_IGN);
+- signal(SIGINT,sigint_catch);
++ signal(SIGINT,sig_catch);
++ signal(SIGTERM,sig_catch);
+ Downloader();
+ }
++ if( cfg_cache_size ) BTCONTENT.FlushCache();
++ if( arg_bitfield_file ) BTCONTENT.pBF->WriteToFile(arg_bitfield_file);
++ WORLD.CloseAll();
+
+ exit(0);
+ }
+@@ -99,7 +103,7 @@
+ int param_check(int argc, char **argv)
+ {
+ int c, l;
+- while ( ( c = getopt(argc,argv,"b:B:cC:e:fl:M:m:P:p:s:tu:xhH")) != -1)
++ while ( ( c = getopt(argc,argv,"b:cC:D:e:fl:M:m:n:P:p:s:tu:U:vxhH")) != -1)
+ switch( c ){
+ case 'b':
+ arg_bitfield_file = new char[strlen(optarg) + 1];
+@@ -150,14 +154,23 @@
+ }
+ break;
+
++ case 'n': // Which file download
++ arg_file_to_download = atoi(optarg);
++ break;
++
++
+ case 'f': // force seed mode, skip sha1 check when startup.
+ arg_flg_force_seed_mode = 1;
+ break;
+
+- case 'B':
+- cfg_max_bandwidth = atoi(optarg);
++ case 'D':
++ cfg_max_bandwidth_down = (int)(strtod(optarg, NULL) * 1024);
+ break;
+
++ case 'U':
++ cfg_max_bandwidth_up = (int)(strtod(optarg, NULL) * 1024);
++ break;
++
+ case 'P':
+ l = strlen(optarg);
+ if (l > MAX_PF_LEN) {printf("-P arg must be 8 or less characters\n"); exit(1);}
+@@ -190,6 +203,10 @@
+ arg_flg_exam_only = 1;
+ break;
+
++ case 'v':
++ arg_verbose = 1;
++ break;
++
+ case 'h':
+ case 'H':
+ default:
+@@ -217,6 +234,7 @@
+ fprintf(stderr,"-h/-H\t\tShow this message.\n");
+ fprintf(stderr,"-x\t\tDecode metainfo(torrent) file only, don't download.\n");
+ fprintf(stderr,"-c\t\tCheck exist only. don't download.\n");
++ fprintf(stderr,"-v\t\tVerbose output (for debugging).\n");
+ fprintf(stderr,"\nDownload Options:\n");
+ fprintf(stderr,"-e int\t\tExit while seed <int> hours later. (default 72 hours)\n");
+ fprintf(stderr,"-p port\t\tListen port. (default 2706 -> 2106)\n");
+@@ -226,7 +244,9 @@
+ fprintf(stderr,"-b bf_filename\tBit field filename. (use it carefully)\n");
+ fprintf(stderr,"-M max_peers\tMax peers count.\n");
+ fprintf(stderr,"-m min_peers\tMin peers count.\n");
+- fprintf(stderr,"-B rate\t\tMax bandwidth (unit KB/s)\n");
++ fprintf(stderr,"-n file_number\tWhich file download.\n");
++ fprintf(stderr,"-D rate\t\tMax bandwidth down (unit KB/s)\n");
++ fprintf(stderr,"-U rate\t\tMax bandwidth up (unit KB/s)\n");
+ fprintf(stderr,"-P peer_id\tSet Peer ID ["PEER_PFX"]\n");
+ fprintf(stderr,"\nMake metainfo(torrent) file Options:\n");
+ fprintf(stderr,"-t\t\tWith make torrent. must specify this option.\n");
+diff -u ctorrent-1.3.4.orig/downloader.cpp ctorrent-1.3.4/downloader.cpp
+--- ctorrent-1.3.4.orig/downloader.cpp 2004-09-09 01:10:51.000000000 +0200
++++ ctorrent-1.3.4/downloader.cpp 2005-08-11 23:45:29.429693680 +0200
+@@ -29,10 +29,14 @@
+ time_t now;
+ fd_set rfd;
+ fd_set wfd;
++ int stopped = 0;
+
+- for(;;){
++ do{
+ time(&now);
+- if( BTCONTENT.SeedTimeout(&now) ) break;
++ if( !stopped && BTCONTENT.SeedTimeout(&now) ) {
++ Tracker.SetStoped();
++ stopped = 1;
++ }
+