From 61fd825e894aff1cfb9538064966e050416b676a Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 23 Jan 2009 19:36:34 +0000 Subject: [PATCH] (trunk libT) #1723: View version with / from transmission-remote --- daemon/daemon.c | 4 +++ daemon/remote.c | 63 +++++++++++++++++++++++++++++++++++- daemon/transmission-daemon.1 | 4 +++ daemon/transmission-remote.1 | 4 +++ 4 files changed, 74 insertions(+), 1 deletion(-) diff --git a/daemon/daemon.c b/daemon/daemon.c index ded9f2532..212f92c49 100644 --- a/daemon/daemon.c +++ b/daemon/daemon.c @@ -66,6 +66,7 @@ static const struct tr_option options[] = { 'T', "no-auth", "Don't require authentication", "T", 0, NULL }, { 'u', "username", "Set username for authentication", "u", 1, "" }, { 'v', "password", "Set password for authentication", "v", 1, "" }, + { 'V', "version", "Show version number and exit", "V", 0, NULL }, { 'w', "download-dir", "Where to save downloaded data", "w", 1, "" }, { 'P', "peerport", "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "P", 1, "" }, { 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", 0, NULL }, @@ -215,6 +216,9 @@ main( int argc, break; case 'g': /* handled above */ break; + case 'V': /* version */ + fprintf(stderr, "Transmission %s\n", LONG_VERSION_STRING); + exit( 0 ); case 'p': tr_bencDictAddInt( &settings, TR_PREFS_KEY_RPC_PORT, atoi( optarg ) ); break; case 't': tr_bencDictAddInt( &settings, TR_PREFS_KEY_RPC_AUTH_REQUIRED, 1 ); diff --git a/daemon/remote.c b/daemon/remote.c index 8f95061b8..2c6ecf3a8 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -36,7 +36,7 @@ #define DEFAULT_HOST "localhost" #define DEFAULT_PORT atoi(TR_DEFAULT_RPC_PORT_STR) -enum { TAG_LIST, TAG_DETAILS, TAG_FILES, TAG_PEERS }; +enum { TAG_SESSION, TAG_LIST, TAG_DETAILS, TAG_FILES, TAG_PEERS }; static const char* getUsage( void ) @@ -79,12 +79,14 @@ static tr_option opts[] = { 902, "priority-low", "Set the files' priorities as low", "pl", 1, "" }, { 'r', "remove", "Remove the current torrent(s)", "r", 0, NULL }, { 'R', "remove-and-delete", "Remove the current torrent(s) and delete local data", NULL, 0, NULL }, + { 920, "session", "Print session information", NULL, 0, NULL }, { 's', "start", "Start the current torrent(s)", "s", 0, NULL }, { 'S', "stop", "Stop the current torrent(s)", "S", 0, NULL }, { 't', "torrent", "Set the current torrent(s)", "t", 1, "" }, { 'u', "uplimit", "Set the maximum global upload speed in KB/s", "u", 1, "" }, { 'U', "no-uplimit", "Don't limit the global upload speed", "U", 0, NULL }, { 'v', "verify", "Verify the current torrent(s)", "v", 0, NULL }, + { 'V', "version", "Show version number and exit", "V", 0, NULL }, { 'w', "download-dir", "Set the default download folder", "w", 1, "" }, { 'x', "pex", "Enable peer exchange (PEX)", "x", 0, NULL }, { 'X', "no-pex", "Disable peer exchange (PEX)", "X", 0, NULL }, @@ -435,6 +437,11 @@ readargs( int argc, addIdArg( args, id ); break; + case 'V': + fprintf(stderr, "Transmission %s\n", LONG_VERSION_STRING); + exit(0); + break; + case 'w': { char * path = absolutify( optarg ); tr_bencDictAddStr( &top, "method", "session-set" ); @@ -494,6 +501,11 @@ readargs( int argc, tr_bencDictAddStr( args, "encryption", "tolerated" ); break; + case 920: + tr_bencDictAddStr( &top, "method", "session-get" ); + tr_bencDictAddInt( &top, "tag", TAG_SESSION ); + break; + case TR_OPT_ERR: fprintf( stderr, "invalid option\n" ); showUsage( ); @@ -713,6 +725,52 @@ getTrackerDateStr( const time_t t, tr_bool isStopped ) return str; } +static void +printSession( tr_benc * top ) +{ + tr_benc *args; + if( ( tr_bencDictFindDict( top, "arguments", &args ) ) ) + { + const char * str; + int64_t i; + + printf( "VERSION\n" ); + if( tr_bencDictFindStr( args, "version", &str ) ) + printf( " Daemon version: %s\n", str ); + if( tr_bencDictFindInt( args, "rpc-version", &i ) ) + printf( " RPC version: %" PRId64 "\n", i ); + if( tr_bencDictFindInt( args, "rpc-version-minimum", &i ) ) + printf( " RPC minimum version: %" PRId64 "\n", i ); + printf( "\n" ); + + printf( "TRANSFER\n" ); + if( tr_bencDictFindStr( args, "download-dir", &str ) ) + printf( " Download directory: %s\n", str ); + if( tr_bencDictFindInt( args, "port", &i ) ) + printf( " Listenport: %" PRId64 "\n", i ); + if( tr_bencDictFindInt( args, "port-forwarding-enabled", &i ) ) + printf( " Portforwarding enabled: %s\n", ( i ? "Yes" : "No" ) ); + if( tr_bencDictFindInt( args, "pex-allowed", &i ) ) + printf( " Peer exchange allowed: %s\n", ( i ? "Yes" : "No" ) ); + if( tr_bencDictFindStr( args, "encryption", &str ) ) + printf( " Encryption: %s\n", str ); + printf( "\n" ); + + printf( "LIMITS\n" ); + if( tr_bencDictFindInt( args, "peer-limit", &i ) ) + printf( " Peer limit: %" PRId64 "\n", i ); + if( tr_bencDictFindInt( args, "speed-limit-down-enabled", &i ) ) + printf( " Downloadlimit enabled: %s\n", ( i ? "Yes" : "No" ) ); + if( tr_bencDictFindInt( args, "speed-limit-down", &i ) ) + printf( " Downloadlimit: %6" PRId64 " KB/sec\n", i ); + if( tr_bencDictFindInt( args, "speed-limit-up-enabled", &i ) ) + printf( " Uploadlimit enabled: %s\n", ( i ? "Yes" : "No" ) ); + if( tr_bencDictFindInt( args, "speed-limit-up", &i ) ) + printf( " Uploadlimit: %6" PRId64 " KB/sec\n", i ); + + } +} + static void printDetails( tr_benc * top ) { @@ -1086,6 +1144,9 @@ processResponse( const char * host, switch( tag ) { + case TAG_SESSION: + printSession( &top ); break; + case TAG_FILES: printFileList( &top ); break; diff --git a/daemon/transmission-daemon.1 b/daemon/transmission-daemon.1 index 8b57d6a72..74d302bfb 100644 --- a/daemon/transmission-daemon.1 +++ b/daemon/transmission-daemon.1 @@ -23,6 +23,7 @@ .Op Fl l Ar limit .Op Fl L Ar limit .Op Fl er | ep | et +.Op Fl V .Op Fl w Ar download-dir .Ek @@ -97,6 +98,9 @@ Used for client authentication. .It Fl v Fl -password Ar password Used for client authentication. +.It Fl V Fl -version +Show version number and exit + .It Fl w Fl -download-dir Where to store downloaded data. diff --git a/daemon/transmission-remote.1 b/daemon/transmission-remote.1 index 2926e4926..526bc520a 100644 --- a/daemon/transmission-remote.1 +++ b/daemon/transmission-remote.1 @@ -33,6 +33,7 @@ and .Op Fl t Ar all | Ar id | Ar hash .Op Fl u Ar number | Fl U .Op Fl v +.Op Fl V .Op Fl w Ar download-dir .Op Fl x | X .Op Fl z | peers @@ -162,6 +163,9 @@ Remove the global upload limit. .It Fl v Fl -verify Verify the current torrent(s) +.It Fl V Fl -version +Show version number and exit + .It Fl w Fl -download-dir Ar directory Use .Ar directory -- 2.40.0