Changeset 1160
- Timestamp:
- Dec 6, 2006, 8:21:00 PM (16 years ago)
- Location:
- branches/multitracker/libtransmission
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/multitracker/libtransmission/metainfo.c
r1155 r1160 302 302 } 303 303 304 tr_setTorrentAnnounce( inf, &inf->trackerAnnounceList[0] ); 305 304 306 free( address ); 305 307 free( announce ); -
branches/multitracker/libtransmission/tracker.c
r1159 r1160 66 66 }; 67 67 68 static void setAnnounce( tr_tracker_t * tc, tr_announce_list_item_t * announceItem ); 69 static int announceToScrape( char * announce, char * scrape ); 68 static void setAnnounce ( tr_tracker_t * tc, tr_announce_list_item_t * announceItem ); 70 69 static void failureAnnouncing( tr_tracker_t * tc ); 71 70 static tr_http_t * getQuery ( tr_tracker_t * tc ); … … 82 81 tc->tor = tor; 83 82 tc->id = tor->id; 84 85 setAnnounce( tc, &tor->info.trackerAnnounceList[0] );86 83 87 84 tc->started = 1; … … 103 100 static void setAnnounce( tr_tracker_t * tc, tr_announce_list_item_t * announceItem ) 104 101 { 105 tr_torrent_t * tor = tc->tor; 106 tr_info_t * inf = &tor->info; 107 108 tr_lockLock( &tor->lock ); 109 110 snprintf( inf->trackerAddress, 256, "%s", announceItem->address ); 111 inf->trackerPort = announceItem->port; 112 snprintf( inf->trackerAnnounce, MAX_PATH_LENGTH, "%s", announceItem->announce ); 113 114 inf->trackerCanScrape = announceToScrape( announceItem->announce, inf->trackerScrape ); 102 tr_lockLock( &tc->tor->lock ); 103 104 tr_setTorrentAnnounce( &tc->tor->info, announceItem); 115 105 tc->dateScrape = 0; 116 106 117 tr_lockUnlock( &tor->lock ); 118 } 119 120 static int announceToScrape( char * announce, char * scrape ) 121 { 122 char * slash, * nextSlash; 123 int pre, post; 124 125 slash = strchr( announce, '/' ); 126 while( ( nextSlash = strchr( slash + 1, '/' ) ) ) 127 { 128 slash = nextSlash; 129 } 130 slash++; 131 132 if( !strncmp( slash, "announce", 8 ) ) 133 { 134 pre = (long) slash - (long) announce; 135 post = strlen( announce ) - pre - 8; 136 memcpy( scrape, announce, pre ); 137 sprintf( &scrape[pre], "scrape" ); 138 memcpy( &scrape[pre+6], &announce[pre+8], post ); 139 scrape[pre+6+post] = 0; 140 141 return 1; 142 } 143 else 144 { 145 return 0; 146 } 107 tr_lockUnlock( &tc->tor->lock ); 147 108 } 148 109 … … 319 280 320 281 setAnnounce( tc, &inf->trackerAnnounceList[tc->announceTier] ); 321 322 282 tc->shouldChangeAnnounce = 0; 323 283 } -
branches/multitracker/libtransmission/transmission.c
r1154 r1160 34 34 static void acceptLoop( void * ); 35 35 static void acceptStop( tr_handle_t * h ); 36 static int announceToScrape( char * announce, char * scrape ); 36 37 37 38 /*********************************************************************** … … 543 544 544 545 return s; 546 } 547 548 static int announceToScrape( char * announce, char * scrape ) 549 { 550 char * slash, * nextSlash; 551 int pre, post; 552 553 slash = strchr( announce, '/' ); 554 while( ( nextSlash = strchr( slash + 1, '/' ) ) ) 555 { 556 slash = nextSlash; 557 } 558 slash++; 559 560 if( !strncmp( slash, "announce", 8 ) ) 561 { 562 pre = (long) slash - (long) announce; 563 post = strlen( announce ) - pre - 8; 564 memcpy( scrape, announce, pre ); 565 sprintf( &scrape[pre], "scrape" ); 566 memcpy( &scrape[pre+6], &announce[pre+8], post ); 567 scrape[pre+6+post] = 0; 568 569 return 1; 570 } 571 else 572 { 573 return 0; 574 } 575 } 576 577 /* Must lock torrent before use */ 578 void tr_setTorrentAnnounce( tr_info_t * inf, tr_announce_list_item_t * announceItem ) 579 { 580 snprintf( inf->trackerAddress, 256, "%s", announceItem->address ); 581 inf->trackerPort = announceItem->port; 582 snprintf( inf->trackerAnnounce, MAX_PATH_LENGTH, "%s", announceItem->announce ); 583 584 inf->trackerCanScrape = announceToScrape( announceItem->announce, inf->trackerScrape ); 545 585 } 546 586 -
branches/multitracker/libtransmission/transmission.h
r1154 r1160 260 260 261 261 /*********************************************************************** 262 * tr_setTorrentAnnounce 263 ***********************************************************************/ 264 void tr_setTorrentAnnounce( tr_info_t * inf, tr_announce_list_item_t * announceItem ); 265 266 /*********************************************************************** 262 267 * tr_torrentPeers 263 268 ***********************************************************************/
Note: See TracChangeset
for help on using the changeset viewer.