From 7542573044f32048c514ef1be8efc5402d256966 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 22 Dec 2007 03:51:12 +0000 Subject: [PATCH] brush away the last remnants of tr_torrentInit() --- cli/transmissioncli.c | 10 +++- daemon/torrents.c | 22 ++++---- libtransmission/torrent.c | 96 ---------------------------------- libtransmission/transmission.h | 79 ---------------------------- 4 files changed, 19 insertions(+), 188 deletions(-) diff --git a/cli/transmissioncli.c b/cli/transmissioncli.c index fe497b2a9..717db4604 100644 --- a/cli/transmissioncli.c +++ b/cli/transmissioncli.c @@ -108,6 +108,7 @@ int main( int argc, char ** argv ) tr_handle * h; const tr_stat * s; tr_handle_status * hstat; + tr_ctor * ctor; printf( "Transmission %s - http://transmission.m0k.org/\n\n", LONG_VERSION_STRING ); @@ -163,8 +164,13 @@ int main( int argc, char ** argv ) return ret; } - /* Open and parse torrent file */ - if( !( tor = tr_torrentInit( h, torrentPath, savePath, 0, &error ) ) ) + ctor = tr_ctorNew( h ); + tr_ctorSetMetainfoFromFile( ctor, torrentPath ); + tr_ctorSetPaused( ctor, TR_FORCE, 0 ); + tr_ctorSetDestination( ctor, TR_FORCE, savePath ); + tor = tr_torrentNew( h, ctor, &error ); + tr_ctorFree( ctor ); + if( tor == NULL ) { printf( "Failed opening torrent file `%s'\n", torrentPath ); tr_close( h ); diff --git a/daemon/torrents.c b/daemon/torrents.c index 2d68bac63..61db8fd35 100644 --- a/daemon/torrents.c +++ b/daemon/torrents.c @@ -489,6 +489,7 @@ opentor( const char * path, const char * hash, uint8_t * data, size_t size, struct tor * tor, * found; int errcode; const tr_info * inf; + tr_ctor * ctor; assert( ( NULL != path && NULL == hash && NULL == data ) || ( NULL == path && NULL != hash && NULL == data ) || @@ -512,18 +513,17 @@ opentor( const char * path, const char * hash, uint8_t * data, size_t size, if( dir == NULL ) dir = gl_dir; - if( NULL != path ) - { - tor->tor = tr_torrentInit( gl_handle, path, dir, 1, &errcode ); - } - else if( NULL != hash ) - { - tor->tor = tr_torrentInitSaved( gl_handle, hash, dir, 1, &errcode ); - } + ctor = tr_ctorNew( gl_handle ); + tr_ctorSetPaused( ctor, TR_FORCE, 1 ); + tr_ctorSetDestination( ctor, TR_FORCE, dir ); + if( path != NULL ) + tr_ctorSetMetainfoFromFile( ctor, path ); + else if( hash != NULL ) + tr_ctorSetMetainfoFromHash( ctor, hash ); else - { - tor->tor = tr_torrentInitData( gl_handle, data, size, dir, 1, &errcode ); - } + tr_ctorSetMetainfo( ctor, data, size ); + tor->tor = tr_torrentNew( gl_handle, ctor, &errcode ); + tr_ctorFree( ctor ); if( NULL == tor->tor ) { diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index d4e12db12..286035b81 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -441,102 +441,6 @@ tr_torrentNew( tr_handle * handle, **** ***/ -/** @deprecated */ -int -tr_torrentParse( const tr_handle * h, - const char * path, - const char * destination, - tr_info * setmeInfo ) -{ - int err; - tr_ctor * ctor = tr_ctorNew( h ); - tr_ctorSetMetainfoFromFile( ctor, path ); - if( destination && *destination ) - tr_ctorSetDestination( ctor, TR_FORCE, destination ); - err = tr_torrentParseFromCtor( h, ctor, setmeInfo ); - tr_ctorFree( ctor ); - return err; -} - -/** @deprecated */ -tr_torrent * -tr_torrentInit( tr_handle * h, - const char * path, - const char * destination, - int isPaused, - int * setmeError ) -{ - tr_torrent * tor; - tr_ctor * ctor = tr_ctorNew( h ); - tr_ctorSetMetainfoFromFile( ctor, path ); - if( destination && *destination ) - tr_ctorSetDestination( ctor, TR_FORCE, destination ); - tr_ctorSetPaused( ctor, TR_FORCE, isPaused ); - tor = tr_torrentNew( h, ctor, setmeError ); - tr_ctorFree( ctor ); - return tor; -} - -/** @deprecated */ -int -tr_torrentParseHash( const tr_handle * h, - const char * hashStr, - const char * destination, - tr_info * setmeInfo ) -{ - int err; - tr_ctor * ctor = tr_ctorNew( h ); - tr_ctorSetMetainfoFromHash( ctor, hashStr ); - if( destination && *destination ) - tr_ctorSetDestination( ctor, TR_FORCE, destination ); - err = tr_torrentParseFromCtor( h, ctor, setmeInfo ); - tr_ctorFree( ctor ); - return err; -} - -/** @deprecated */ -tr_torrent * -tr_torrentInitSaved( tr_handle * h, - const char * hashStr, - const char * destination, - int isPaused, - int * setmeError ) -{ - tr_torrent * tor; - tr_ctor * ctor = tr_ctorNew( h ); - tr_ctorSetMetainfoFromHash( ctor, hashStr ); - if( destination && *destination ) - tr_ctorSetDestination( ctor, TR_FORCE, destination ); - tr_ctorSetPaused( ctor, TR_FORCE, isPaused ); - tor = tr_torrentNew( h, ctor, setmeError ); - tr_ctorFree( ctor ); - return tor; -} - -/** @deprecated */ -tr_torrent * -tr_torrentInitData( tr_handle * h, - const uint8_t * metainfo, - size_t len, - const char * destination, - int isPaused, - int * setmeError ) -{ - tr_torrent * tor; - tr_ctor * ctor = tr_ctorNew( h ); - tr_ctorSetMetainfo( ctor, metainfo, len ); - if( destination && *destination ) - tr_ctorSetDestination( ctor, TR_FORCE, destination ); - tr_ctorSetPaused( ctor, TR_FORCE, isPaused ); - tor = tr_torrentNew( h, ctor, setmeError ); - tr_ctorFree( ctor ); - return tor; -} - -/*** -**** -***/ - static void saveFastResumeNow( tr_torrent * tor ) { diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index 38a8c0e15..e61622014 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -471,85 +471,6 @@ tr_torrent ** tr_loadTorrents ( tr_handle * h, int * setmeCount ); -/** -*** -**/ - -/*********************************************************************** - * Opens and parses torrent file at 'path'. If the file exists and is - * a valid torrent file, returns an handle and adds it to the list of - * torrents (but doesn't start it). Returns NULL and sets *error - * otherwise. If hash is not NULL and the torrent is already loaded - * then it's 20-byte hash will be copied in. If the TR_FLAG_SAVE flag - * is passed then a copy of the torrent file will be saved. - * - * !! DO NOT USE THIS FUNCTION IN NEW CODE !! - */ -tr_torrent * tr_torrentInit( tr_handle * handle, - const char * metainfo_filename, - const char * destination, - int isPaused, - int * setme_error ); - -/** - * Parses the specified metainfo file. - * - * Returns TR_OK if it parsed and can be added to Transmission. - * Returns TR_INVALID if it couldn't be parsed. - * Returns TR_EDUPLICATE if it parsed but can't be added. - * - * "destination" can be NULL if you don't need to know whether - * or not the torrent can be added. - * - " "setme_info" can be NULL if you don't need the information. - * If the metainfo can be parsed and setme_info is non-NULL, - * it will be filled with the metainfo's info. You'll need to - * call tr_metainfoFree( setme_info ) when done with it. - * - * !! DO NOT USE THIS FUNCTION IN NEW CODE !! - */ -int tr_torrentParse( const tr_handle * handle, - const char * metainfo_filename, - const char * destination, - tr_info * setme_info ); - -/** - * Parses the cached metainfo file that matches the given hash string. - * See tr_torrentParse() for a description of the arguments - * - * !! DO NOT USE THIS FUNCTION IN NEW CODE !! - */ -int -tr_torrentParseHash( const tr_handle * h, - const char * hashStr, - const char * destination, - tr_info * setme_info ); - - -/*********************************************************************** - * Like tr_torrentInit, except the actual torrent data is passed in - * instead of the filename. - * - * !! DO NOT USE THIS FUNCTION IN NEW CODE !! - */ -tr_torrent * tr_torrentInitData( tr_handle *, - const uint8_t * data, size_t size, - const char * destination, - int isPaused, - int * error ); - -/*********************************************************************** - * Opens and parses a torrent file as with tr_torrentInit, only taking - * the hash string of a saved torrent file instead of a filename. There - * are currently no valid flags for this function. - * - * !! DO NOT USE THIS FUNCTION IN NEW CODE !! - */ -tr_torrent * tr_torrentInitSaved( tr_handle *, - const char * hashStr, - const char * destination, - int isPaused, - int * error ); /*********************************************************************** * tr_torrentDisablePex