From e56643d7e710f8922c67956d91bb4ff611ecf257 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 14 Dec 2008 01:22:06 +0000 Subject: [PATCH] (trunk daemon) added --dump option to dump the settings to stderr and exit. --- daemon/daemon.c | 15 ++++++++++++++- libtransmission/session.c | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/daemon/daemon.c b/daemon/daemon.c index 0ea136504..58fa30a70 100644 --- a/daemon/daemon.c +++ b/daemon/daemon.c @@ -53,6 +53,7 @@ static const struct tr_option options[] = { 'a', "allowed", "Allowed IP addresses. (Default: " TR_DEFAULT_RPC_WHITELIST ")", "a", 1, "" }, { 'b', "blocklist", "Enable peer blocklists", "b", 0, NULL }, { 'B', "no-blocklist", "Disable peer blocklists", "B", 0, NULL }, + { 'd', "dump-settings", "Dump the settings and exit", "d", 0, NULL }, { 'f', "foreground", "Run in the foreground instead of daemonizing", "f", 0, NULL }, { 'g', "config-dir", "Where to look for configuration files", "g", 1, "" }, { 'p', "port", "RPC port (Default: " TR_DEFAULT_RPC_PORT_STR ")", "p", 1, "" }, @@ -180,9 +181,11 @@ main( int argc, char ** argv ) { int c; + int64_t i; const char * optarg; tr_benc settings; tr_bool foreground = FALSE; + tr_bool dumpSettings = FALSE; const char * configDir = NULL; signal( SIGINT, gotsig ); @@ -209,6 +212,8 @@ main( int argc, break; case 'B': tr_bencDictAddInt( &settings, TR_PREFS_KEY_BLOCKLIST_ENABLED, 0 ); break; + case 'd': dumpSettings = TRUE; + break; case 'f': foreground = TRUE; break; case 'g': /* handled above */ @@ -230,6 +235,14 @@ main( int argc, } } + if( dumpSettings ) + { + char * str = tr_bencSaveAsJSON( &settings, NULL ); + fprintf( stderr, "%s", str ); + tr_free( str ); + return 0; + } + #ifndef WIN32 if( !foreground ) { @@ -244,7 +257,7 @@ main( int argc, /* start the session */ mySession = tr_sessionInit( "daemon", configDir, FALSE, &settings ); - if( tr_bencDictFindInt( &settings, TR_PREFS_KEY_RPC_AUTH_REQUIRED, NULL ) ) + if( tr_bencDictFindInt( &settings, TR_PREFS_KEY_RPC_AUTH_REQUIRED, &i ) && i!=0 ) tr_ninf( MY_NAME, "requiring authentication" ); /* load the torrents */ diff --git a/libtransmission/session.c b/libtransmission/session.c index 282735330..e4e2c51ed 100644 --- a/libtransmission/session.c +++ b/libtransmission/session.c @@ -339,7 +339,7 @@ tr_sessionSaveSettings( tr_session * session, const char * configDir, tr_benc * tr_bencFree( &fileSettings ); } - tr_inf( "saved \"%s\"", filename ); + tr_inf( "Saved \"%s\"", filename ); tr_free( filename ); } -- 2.40.0