From 9815e48daf1d5f2b7220a86b4566e6cac216586b Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 20 May 2008 14:01:15 +0000 Subject: [PATCH] tweak the daemon & remote console messages a little --- daemon/daemon.c | 10 +++++----- daemon/remote.c | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/daemon/daemon.c b/daemon/daemon.c index 77ae6b03c..7a97d6931 100644 --- a/daemon/daemon.c +++ b/daemon/daemon.c @@ -63,7 +63,7 @@ saveState( tr_handle * h ) } tr_bencDictAddStr( &d, "encryption", str ); - tr_ninf( MY_NAME, "saving \"%s\"\n", gl_configfile ); + tr_ninf( MY_NAME, "saving \"%s\"", gl_configfile ); tr_bencSaveFile( gl_configfile, &d ); tr_bencFree( &d ); @@ -206,14 +206,14 @@ daemon( int nochdir, int noclose ) case 0: break; case -1: - tr_nerr( MY_NAME, "Error daemonizing (fork)! %d - %s\n", errno, strerror(errno) ); + tr_nerr( MY_NAME, "Error daemonizing (fork)! %d - %s", errno, strerror(errno) ); return -1; default: _exit(0); } if( setsid() < 0 ) { - tr_nerr( MY_NAME, "Error daemonizing (setsid)! %d - %s\n", errno, strerror(errno) ); + tr_nerr( MY_NAME, "Error daemonizing (setsid)! %d - %s", errno, strerror(errno) ); return -1; } @@ -221,14 +221,14 @@ daemon( int nochdir, int noclose ) case 0: break; case -1: - tr_nerr( MY_NAME, "Error daemonizing (fork2)! %d - %s\n", errno, strerror(errno) ); + tr_nerr( MY_NAME, "Error daemonizing (fork2)! %d - %s", errno, strerror(errno) ); return -1; default: _exit(0); } if( !nochdir && 0 > chdir( "/" ) ) { - tr_nerr( MY_NAME, "Error daemonizing (chdir)! %d - %s\n", errno, strerror(errno) ); + tr_nerr( MY_NAME, "Error daemonizing (chdir)! %d - %s", errno, strerror(errno) ); return -1; } diff --git a/daemon/remote.c b/daemon/remote.c index a2941efc3..e74f3502b 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -258,12 +258,13 @@ torrentStatusToString( int i ) } static void -processResponse( const void * response, size_t len ) +processResponse( const char * host, int port, + const void * response, size_t len ) { tr_benc top; if( tr_jsonParse( response, len, &top, NULL ) ) - tr_nerr( MY_NAME, "Unable to parse response\n" ); + tr_nerr( MY_NAME, "Unable to parse response" ); else { tr_benc *args, *list; @@ -272,7 +273,7 @@ processResponse( const void * response, size_t len ) tr_bencDictFindInt( &top, "tag", &tag ); if( tr_bencDictFindStr( &top, "result", &str ) ) - printf( "Server responded: \"%s\"\n", str ); + printf( "%s:%d responded: \"%s\"\n", host, port, str ); if( ( tag == TAG_LIST ) && ( tr_bencDictFindDict( &top, "arguments", &args ) ) && @@ -328,9 +329,9 @@ processRequests( const char * host, int port, CURLcode res; curl_easy_setopt( curl, CURLOPT_POSTFIELDS, reqs[i] ); if(( res = curl_easy_perform( curl ))) - tr_nerr( MY_NAME, "%s\n", curl_easy_strerror( res ) ); + tr_nerr( MY_NAME, "(%s:%d) %s", host, port, curl_easy_strerror( res ) ); else - processResponse( EVBUFFER_DATA( buf ), EVBUFFER_LENGTH( buf ) ); + processResponse( host, port, EVBUFFER_DATA( buf ), EVBUFFER_LENGTH( buf ) ); evbuffer_drain( buf, EVBUFFER_LENGTH( buf ) ); }