diff --git a/utils/create.c b/utils/create.c index 244bca65e..4afba2a49 100644 --- a/utils/create.c +++ b/utils/create.c @@ -17,6 +17,7 @@ #include #include #include +#include #define MY_NAME "transmission-create" @@ -24,6 +25,7 @@ static tr_tracker_info trackers[MAX_TRACKERS]; static int trackerCount = 0; static tr_bool isPrivate = FALSE; +static tr_bool showVersion = FALSE; const char * comment = NULL; const char * outfile = NULL; const char * infile = NULL; @@ -34,6 +36,7 @@ static tr_option options[] = { 'o', "outfile", "Save the generated .torrent to this filename", "o", 1, "" }, { 'c', "comment", "Add a comment", "c", 1, "" }, { 't', "tracker", "Add a tracker's announce URL", "t", 1, "" }, + { 'V', "version", "Show version number and exit", "V", 0, NULL }, { 0, NULL, NULL, NULL, 0, NULL } }; @@ -53,6 +56,7 @@ parseCommandLine( int argc, const char ** argv ) { switch( c ) { + case 'V': showVersion = TRUE; break; case 'p': isPrivate = TRUE; break; case 'o': outfile = optarg; break; case 'c': comment = optarg; break; @@ -94,6 +98,11 @@ main( int argc, char * argv[] ) if( parseCommandLine( argc, (const char**)argv ) ) return EXIT_FAILURE; + if( showVersion ) { + fprintf( stderr, MY_NAME" "LONG_VERSION_STRING"\n" ); + return 0; + } + if( !infile ) { fprintf( stderr, "ERROR: No input file or directory specified.\n" ); diff --git a/utils/edit.c b/utils/edit.c index 0563fb228..494e00776 100644 --- a/utils/edit.c +++ b/utils/edit.c @@ -18,20 +18,23 @@ #include #include #include +#include #define MY_NAME "transmission-edit" -int fileCount = 0; -const char ** files = NULL; -const char * add = NULL; -const char * deleteme = NULL; -const char * replace[2] = { NULL, NULL }; +static int fileCount = 0; +static tr_bool showVersion = FALSE; +static const char ** files = NULL; +static const char * add = NULL; +static const char * deleteme = NULL; +static const char * replace[2] = { NULL, NULL }; static tr_option options[] = { { 'a', "add", "Add a tracker's announce URL", "a", 1, "" }, { 'd', "delete", "Delete a tracker's announce URL", "d", 1, "" }, { 'r', "replace", "Search and replace a substring in the announce URLs", "r", 1, " " }, + { 'V', "version", "Show version number and exit", "V", 0, NULL }, { 0, NULL, NULL, NULL, 0, NULL } }; @@ -60,6 +63,8 @@ parseCommandLine( int argc, const char ** argv ) if( c != TR_OPT_UNK ) return 1; replace[1] = optarg; break; + case 'V': showVersion = TRUE; + break; case TR_OPT_UNK: files[fileCount++] = optarg; break; default: return 1; } @@ -258,6 +263,12 @@ main( int argc, char * argv[] ) if( parseCommandLine( argc, (const char**)argv ) ) return EXIT_FAILURE; + if( showVersion ) + { + fprintf( stderr, MY_NAME" "LONG_VERSION_STRING"\n" ); + return 0; + } + if( fileCount < 1 ) { fprintf( stderr, "ERROR: No torrent files specified.\n" ); diff --git a/utils/show.c b/utils/show.c index ef97adc96..d7def137b 100644 --- a/utils/show.c +++ b/utils/show.c @@ -51,6 +51,7 @@ static tr_option options[] = { { 's', "scrape", "Ask the torrent's trackers how many peers are in the torrent's swarm", "s", 0, NULL }, + { 'V', "version", "Show version number and exit", "V", 0, NULL }, { 0, NULL, NULL, NULL, 0, NULL } }; @@ -61,6 +62,7 @@ getUsage( void ) } static tr_bool scrapeFlag = FALSE; +static tr_bool showVersion = FALSE; const char * filename = NULL; static int @@ -74,6 +76,7 @@ parseCommandLine( int argc, const char ** argv ) switch( c ) { case 's': scrapeFlag = TRUE; break; + case 'V': showVersion = TRUE; break; case TR_OPT_UNK: filename = optarg; break; default: return 1; } @@ -258,6 +261,12 @@ main( int argc, char * argv[] ) if( parseCommandLine( argc, (const char**)argv ) ) return EXIT_FAILURE; + if( showVersion ) + { + fprintf( stderr, MY_NAME" "LONG_VERSION_STRING"\n" ); + return 0; + } + /* make sure the user specified a filename */ if( !filename ) {