Changeset 4277
- Timestamp:
- Dec 22, 2007, 3:51:12 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli/transmissioncli.c
r4092 r4277 109 109 const tr_stat * s; 110 110 tr_handle_status * hstat; 111 tr_ctor * ctor; 111 112 112 113 printf( "Transmission %s - http://transmission.m0k.org/\n\n", … … 164 165 } 165 166 166 /* Open and parse torrent file */ 167 if( !( tor = tr_torrentInit( h, torrentPath, savePath, 0, &error ) ) ) 167 ctor = tr_ctorNew( h ); 168 tr_ctorSetMetainfoFromFile( ctor, torrentPath ); 169 tr_ctorSetPaused( ctor, TR_FORCE, 0 ); 170 tr_ctorSetDestination( ctor, TR_FORCE, savePath ); 171 tor = tr_torrentNew( h, ctor, &error ); 172 tr_ctorFree( ctor ); 173 if( tor == NULL ) 168 174 { 169 175 printf( "Failed opening torrent file `%s'\n", torrentPath ); -
trunk/daemon/torrents.c
r4092 r4277 490 490 int errcode; 491 491 const tr_info * inf; 492 tr_ctor * ctor; 492 493 493 494 assert( ( NULL != path && NULL == hash && NULL == data ) || … … 513 514 dir = gl_dir; 514 515 515 if( NULL != path ) 516 { 517 tor->tor = tr_torrentInit( gl_handle, path, dir, 1, &errcode ); 518 } 519 else if( NULL != hash ) 520 { 521 tor->tor = tr_torrentInitSaved( gl_handle, hash, dir, 1, &errcode ); 522 } 516 ctor = tr_ctorNew( gl_handle ); 517 tr_ctorSetPaused( ctor, TR_FORCE, 1 ); 518 tr_ctorSetDestination( ctor, TR_FORCE, dir ); 519 if( path != NULL ) 520 tr_ctorSetMetainfoFromFile( ctor, path ); 521 else if( hash != NULL ) 522 tr_ctorSetMetainfoFromHash( ctor, hash ); 523 523 else 524 {525 tor->tor = tr_torrentInitData( gl_handle, data, size, dir, 1, &errcode );526 }524 tr_ctorSetMetainfo( ctor, data, size ); 525 tor->tor = tr_torrentNew( gl_handle, ctor, &errcode ); 526 tr_ctorFree( ctor ); 527 527 528 528 if( NULL == tor->tor ) -
trunk/libtransmission/torrent.c
r4272 r4277 442 442 ***/ 443 443 444 /** @deprecated */445 int446 tr_torrentParse( const tr_handle * h,447 const char * path,448 const char * destination,449 tr_info * setmeInfo )450 {451 int err;452 tr_ctor * ctor = tr_ctorNew( h );453 tr_ctorSetMetainfoFromFile( ctor, path );454 if( destination && *destination )455 tr_ctorSetDestination( ctor, TR_FORCE, destination );456 err = tr_torrentParseFromCtor( h, ctor, setmeInfo );457 tr_ctorFree( ctor );458 return err;459 }460 461 /** @deprecated */462 tr_torrent *463 tr_torrentInit( tr_handle * h,464 const char * path,465 const char * destination,466 int isPaused,467 int * setmeError )468 {469 tr_torrent * tor;470 tr_ctor * ctor = tr_ctorNew( h );471 tr_ctorSetMetainfoFromFile( ctor, path );472 if( destination && *destination )473 tr_ctorSetDestination( ctor, TR_FORCE, destination );474 tr_ctorSetPaused( ctor, TR_FORCE, isPaused );475 tor = tr_torrentNew( h, ctor, setmeError );476 tr_ctorFree( ctor );477 return tor;478 }479 480 /** @deprecated */481 int482 tr_torrentParseHash( const tr_handle * h,483 const char * hashStr,484 const char * destination,485 tr_info * setmeInfo )486 {487 int err;488 tr_ctor * ctor = tr_ctorNew( h );489 tr_ctorSetMetainfoFromHash( ctor, hashStr );490 if( destination && *destination )491 tr_ctorSetDestination( ctor, TR_FORCE, destination );492 err = tr_torrentParseFromCtor( h, ctor, setmeInfo );493 tr_ctorFree( ctor );494 return err;495 }496 497 /** @deprecated */498 tr_torrent *499 tr_torrentInitSaved( tr_handle * h,500 const char * hashStr,501 const char * destination,502 int isPaused,503 int * setmeError )504 {505 tr_torrent * tor;506 tr_ctor * ctor = tr_ctorNew( h );507 tr_ctorSetMetainfoFromHash( ctor, hashStr );508 if( destination && *destination )509 tr_ctorSetDestination( ctor, TR_FORCE, destination );510 tr_ctorSetPaused( ctor, TR_FORCE, isPaused );511 tor = tr_torrentNew( h, ctor, setmeError );512 tr_ctorFree( ctor );513 return tor;514 }515 516 /** @deprecated */517 tr_torrent *518 tr_torrentInitData( tr_handle * h,519 const uint8_t * metainfo,520 size_t len,521 const char * destination,522 int isPaused,523 int * setmeError )524 {525 tr_torrent * tor;526 tr_ctor * ctor = tr_ctorNew( h );527 tr_ctorSetMetainfo( ctor, metainfo, len );528 if( destination && *destination )529 tr_ctorSetDestination( ctor, TR_FORCE, destination );530 tr_ctorSetPaused( ctor, TR_FORCE, isPaused );531 tor = tr_torrentNew( h, ctor, setmeError );532 tr_ctorFree( ctor );533 return tor;534 }535 536 /***537 ****538 ***/539 540 444 static void 541 445 saveFastResumeNow( tr_torrent * tor ) -
trunk/libtransmission/transmission.h
r4272 r4277 472 472 473 473 474 /**475 ***476 **/477 478 /***********************************************************************479 * Opens and parses torrent file at 'path'. If the file exists and is480 * a valid torrent file, returns an handle and adds it to the list of481 * torrents (but doesn't start it). Returns NULL and sets *error482 * otherwise. If hash is not NULL and the torrent is already loaded483 * then it's 20-byte hash will be copied in. If the TR_FLAG_SAVE flag484 * is passed then a copy of the torrent file will be saved.485 *486 * !! DO NOT USE THIS FUNCTION IN NEW CODE !!487 */488 tr_torrent * tr_torrentInit( tr_handle * handle,489 const char * metainfo_filename,490 const char * destination,491 int isPaused,492 int * setme_error );493 494 /**495 * Parses the specified metainfo file.496 *497 * Returns TR_OK if it parsed and can be added to Transmission.498 * Returns TR_INVALID if it couldn't be parsed.499 * Returns TR_EDUPLICATE if it parsed but can't be added.500 *501 * "destination" can be NULL if you don't need to know whether502 * or not the torrent can be added.503 *504 " "setme_info" can be NULL if you don't need the information.505 * If the metainfo can be parsed and setme_info is non-NULL,506 * it will be filled with the metainfo's info. You'll need to507 * call tr_metainfoFree( setme_info ) when done with it.508 *509 * !! DO NOT USE THIS FUNCTION IN NEW CODE !!510 */511 int tr_torrentParse( const tr_handle * handle,512 const char * metainfo_filename,513 const char * destination,514 tr_info * setme_info );515 516 /**517 * Parses the cached metainfo file that matches the given hash string.518 * See tr_torrentParse() for a description of the arguments519 *520 * !! DO NOT USE THIS FUNCTION IN NEW CODE !!521 */522 int523 tr_torrentParseHash( const tr_handle * h,524 const char * hashStr,525 const char * destination,526 tr_info * setme_info );527 528 529 /***********************************************************************530 * Like tr_torrentInit, except the actual torrent data is passed in531 * instead of the filename.532 *533 * !! DO NOT USE THIS FUNCTION IN NEW CODE !!534 */535 tr_torrent * tr_torrentInitData( tr_handle *,536 const uint8_t * data, size_t size,537 const char * destination,538 int isPaused,539 int * error );540 541 /***********************************************************************542 * Opens and parses a torrent file as with tr_torrentInit, only taking543 * the hash string of a saved torrent file instead of a filename. There544 * are currently no valid flags for this function.545 *546 * !! DO NOT USE THIS FUNCTION IN NEW CODE !!547 */548 tr_torrent * tr_torrentInitSaved( tr_handle *,549 const char * hashStr,550 const char * destination,551 int isPaused,552 int * error );553 474 554 475 /***********************************************************************
Note: See TracChangeset
for help on using the changeset viewer.