Changeset 4706
- Timestamp:
- Jan 16, 2008, 4:47:57 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0x/cli/transmissioncli.c
r4411 r4706 32 32 #include <libtransmission/transmission.h> 33 33 #include <libtransmission/makemeta.h> 34 #include <libtransmission/metainfo.h> /* tr_metainfoFree */ 34 35 #include <libtransmission/utils.h> /* tr_wait */ 36 35 37 36 38 /* macro to shut up "unused parameter" warnings */ … … 75 77 static sig_atomic_t gotsig = 0; 76 78 static sig_atomic_t manualUpdate = 0; 77 static tr_torrent * tor;78 79 79 80 static char * finishCall = NULL; … … 85 86 static void sigHandler ( int signal ); 86 87 87 char * getStringRatio( float ratio ) 88 static char * 89 getStringRatio( float ratio ) 88 90 { 89 91 static char string[20]; … … 105 107 } 106 108 107 int main( int argc, char ** argv ) 109 int 110 main( int argc, char ** argv ) 108 111 { 109 112 int i, error; 110 113 tr_handle * h; 111 const tr_stat * s;112 114 tr_handle_status * hstat; 113 115 tr_ctor * ctor; 116 tr_torrent * tor = NULL; 114 117 115 118 printf( "Transmission %s - http://www.transmissionbt.com/\n", … … 170 173 tr_ctorSetPaused( ctor, TR_FORCE, 0 ); 171 174 tr_ctorSetDestination( ctor, TR_FORCE, savePath ); 175 176 if( showInfo ) 177 { 178 tr_info info; 179 180 if( !tr_torrentParse( h, ctor, &info ) ) 181 { 182 printf( "hash:\t" ); 183 for( i=0; i<SHA_DIGEST_LENGTH; ++i ) 184 printf( "%02x", info.hash[i] ); 185 printf( "\n" ); 186 187 printf( "name:\t%s\n", info.name ); 188 189 for( i=0; i<info.trackerTiers; ++i ) { 190 int j; 191 printf( "tracker tier #%d:\n", ( i+1 ) ); 192 for( j=0; j<info.trackerList[i].count; ++j ) { 193 const tr_tracker_info * tracker = &info.trackerList[i].list[j]; 194 printf( "\taddress:\t%s:%d\n", tracker->address, tracker->port ); 195 printf( "\tannounce:\t%s\n", tracker->announce ); 196 printf( "\n" ); 197 } 198 } 199 200 printf( "size:\t%"PRIu64" (%"PRIu64" * %d + %"PRIu64")\n", 201 info.totalSize, info.totalSize / info.pieceSize, 202 info.pieceSize, info.totalSize % info.pieceSize ); 203 204 if( info.comment[0] ) 205 printf( "comment:\t%s\n", info.comment ); 206 if( info.creator[0] ) 207 printf( "creator:\t%s\n", info.creator ); 208 if( info.isPrivate ) 209 printf( "private flag set\n" ); 210 211 printf( "file(s):\n" ); 212 for( i=0; i<info.fileCount; ++i ) 213 printf( "\t%s (%"PRIu64")\n", info.files[i].name, info.files[i].length ); 214 215 tr_metainfoFree( &info ); 216 } 217 218 tr_ctorFree( ctor ); 219 goto cleanup; 220 } 221 222 172 223 tor = tr_torrentNew( h, ctor, &error ); 173 224 tr_ctorFree( ctor ); … … 179 230 } 180 231 181 if( showInfo )182 {183 const tr_info * info = tr_torrentInfo( tor );184 185 s = tr_torrentStat( tor );186 187 /* Print torrent info (quite à la btshowmetainfo) */188 printf( "hash: " );189 for( i = 0; i < SHA_DIGEST_LENGTH; i++ )190 {191 printf( "%02x", info->hash[i] );192 }193 printf( "\n" );194 printf( "tracker: %s:%d\n",195 s->tracker->address, s->tracker->port );196 printf( "announce: %s\n", s->tracker->announce );197 printf( "size: %"PRIu64" (%"PRIu64" * %d + %"PRIu64")\n",198 info->totalSize, info->totalSize / info->pieceSize,199 info->pieceSize, info->totalSize % info->pieceSize );200 if( info->comment[0] )201 {202 printf( "comment: %s\n", info->comment );203 }204 if( info->creator[0] )205 {206 printf( "creator: %s\n", info->creator );207 }208 if( info->isPrivate )209 {210 printf( "private flag set\n" );211 }212 printf( "file(s):\n" );213 for( i = 0; i < info->fileCount; i++ )214 {215 printf( " %s (%"PRIu64")\n", info->files[i].name,216 info->files[i].length );217 }218 219 goto cleanup;220 }221 222 232 if( showScrape ) 223 233 { … … 255 265 char string[LINEWIDTH]; 256 266 int chars = 0; 267 const tr_stat * s; 257 268 258 269 tr_wait( 1000 );
Note: See TracChangeset
for help on using the changeset viewer.