From cb79214854f6aede515269ec81658b7c752af202 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 10 Aug 2009 20:04:08 +0000 Subject: [PATCH] (trunk) remove trailing spaces --- cli/cli.c | 4 +- daemon/remote.c | 32 +++++------ gtk/conf.c | 1 + gtk/details.c | 21 ++++---- gtk/dialogs.c | 2 +- gtk/file-list.c | 4 +- gtk/main.c | 20 +++++++ gtk/makemeta-ui.c | 2 +- gtk/torrent-cell-renderer.c | 12 ++--- gtk/tr-core.h | 2 +- gtk/tr-icon.c | 2 +- gtk/tr-prefs.c | 2 +- gtk/tr-prefs.h | 1 + gtk/tr-window.c | 20 +++---- gtk/util.c | 2 +- gtk/util.h | 2 +- libtransmission/bandwidth.h | 10 ++-- libtransmission/bencode-test.c | 68 +++++++++++------------ libtransmission/bencode.h | 4 +- libtransmission/bitfield.h | 2 +- libtransmission/clients.c | 34 ++++++------ libtransmission/clients.h | 2 +- libtransmission/completion.h | 2 +- libtransmission/fdlimit.c | 46 ++++++++-------- libtransmission/handshake.c | 18 +++---- libtransmission/list.c | 1 - libtransmission/list.h | 2 +- libtransmission/metainfo.c | 4 +- libtransmission/net.c | 98 +++++++++++++++++----------------- libtransmission/peer-io.c | 14 ++--- libtransmission/peer-mgr.c | 16 +++--- libtransmission/peer-msgs.c | 11 ++-- libtransmission/platform.c | 9 ++-- libtransmission/platform.h | 4 +- libtransmission/request-list.c | 2 +- libtransmission/resume.c | 6 +-- libtransmission/rpcimpl.c | 36 ++++++------- libtransmission/session.c | 18 +++---- libtransmission/torrent.c | 4 +- libtransmission/tracker.c | 10 ++-- libtransmission/trevent.c | 50 ++++++++--------- libtransmission/utils.c | 3 +- libtransmission/utils.h | 8 +-- libtransmission/web.c | 10 ++-- 44 files changed, 319 insertions(+), 302 deletions(-) diff --git a/cli/cli.c b/cli/cli.c index 9467492f0..87068588d 100644 --- a/cli/cli.c +++ b/cli/cli.c @@ -300,8 +300,8 @@ main( int argc, tr_torrent * tor = NULL; tr_benc settings; const char * configDir; - tr_bool haveSource; - tr_bool haveAnnounce; + tr_bool haveSource; + tr_bool haveAnnounce; printf( "Transmission %s - http://www.transmissionbt.com/\n", LONG_VERSION_STRING ); diff --git a/daemon/remote.c b/daemon/remote.c index b8126933e..16cc949f6 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -788,23 +788,23 @@ getStatusString( tr_benc * t, char * buf, size_t buflen ) case TR_STATUS_DOWNLOAD: case TR_STATUS_SEED: { - int64_t fromUs = 0; - int64_t toUs = 0; - tr_bencDictFindInt( t, "peersGettingFromUs", &fromUs ); - tr_bencDictFindInt( t, "peersSendingToUs", &toUs ); - if( fromUs && toUs ) - tr_strlcpy( buf, "Up & Down", buflen ); - else if( toUs ) - tr_strlcpy( buf, "Downloading", buflen ); - else if( fromUs ) { - int64_t leftUntilDone = 0; - tr_bencDictFindInt( t, "leftUntilDone", &leftUntilDone ); + int64_t fromUs = 0; + int64_t toUs = 0; + tr_bencDictFindInt( t, "peersGettingFromUs", &fromUs ); + tr_bencDictFindInt( t, "peersSendingToUs", &toUs ); + if( fromUs && toUs ) + tr_strlcpy( buf, "Up & Down", buflen ); + else if( toUs ) + tr_strlcpy( buf, "Downloading", buflen ); + else if( fromUs ) { + int64_t leftUntilDone = 0; + tr_bencDictFindInt( t, "leftUntilDone", &leftUntilDone ); if( leftUntilDone > 0 ) - tr_strlcpy( buf, "Uploading", buflen ); + tr_strlcpy( buf, "Uploading", buflen ); else - tr_strlcpy( buf, "Seeding", buflen ); + tr_strlcpy( buf, "Seeding", buflen ); } else { - tr_strlcpy( buf, "Idle", buflen ); + tr_strlcpy( buf, "Idle", buflen ); } break; } @@ -1429,7 +1429,7 @@ tr_curl_easy_init( struct evbuffer * writebuf ) } return curl; } - + static int processRequests( const char * host, @@ -1519,7 +1519,7 @@ main( int argc, showUsage( ); return EXIT_FAILURE; } - + for( i=0; ihonorLimitsCheck, di->honorLimitsCheckTag, baseline ); } - + /* downLimitedCheck */ if( n ) { const tr_bool baseline = tr_torrentUsesSpeedLimit( torrents[0], TR_DOWN ); @@ -255,7 +255,7 @@ refreshOptions( struct DetailsImpl * di, tr_torrent ** torrents, int n ) set_int_spin_if_different( di->downLimitSpin, di->downLimitSpinTag, baseline ); } - + /* upLimitedCheck */ if( n ) { const tr_bool baseline = tr_torrentUsesSpeedLimit( torrents[0], TR_UP ); @@ -576,7 +576,7 @@ options_page_new( struct DetailsImpl * d ) hig_workarea_add_wide_control( t, &row, h ); d->seedCustomSpin = w; d->seedCustomSpinTag = tag; - + hig_workarea_add_section_divider( t, &row ); hig_workarea_add_section_title( t, &row, _( "Peer Connections" ) ); @@ -687,7 +687,7 @@ refreshInfo( struct DetailsImpl * di, tr_torrent ** torrents, int n ) } gtk_text_buffer_set_text( di->comment_buffer, str, -1 ); - /* destination_lb */ + /* destination_lb */ if( n<=0 ) str = none; else { @@ -805,7 +805,7 @@ refreshInfo( struct DetailsImpl * di, tr_torrent ** torrents, int n ) } gtk_label_set_text( GTK_LABEL( di->have_lb ), str ); - + /* dl_lb */ if( n <= 0 ) str = none; @@ -826,7 +826,7 @@ refreshInfo( struct DetailsImpl * di, tr_torrent ** torrents, int n ) } gtk_label_set_text( GTK_LABEL( di->dl_lb ), str ); - + /* ul_lb */ if( n <= 0 ) str = none; @@ -856,7 +856,7 @@ refreshInfo( struct DetailsImpl * di, tr_torrent ** torrents, int n ) if( n<=0 ) str = none; else if ( n==1 ) - str = infos[0]->hashString; + str = infos[0]->hashString; else str = mixed; gtk_label_set_text( GTK_LABEL( di->hash_lb ), str ); @@ -1254,7 +1254,7 @@ refreshWebseedList( struct DetailsImpl * di, tr_torrent ** torrents, int n ) GHashTable * hash = di->webseed_hash; GtkListStore * store = di->webseed_store; GtkTreeModel * model = GTK_TREE_MODEL( store ); - + /* step 1: mark all webseeds as not-updated */ if( gtk_tree_model_get_iter_first( model, &iter ) ) do gtk_list_store_set( store, &iter, WEBSEED_COL_WAS_UPDATED, FALSE, -1 ); @@ -1405,11 +1405,11 @@ onPeerViewQueryTooltip( GtkWidget * widget, case 'O': s = _( "Optimistic unchoke" ); break; case 'D': s = _( "Downloading from this peer" ); break; case 'd': s = _( "We would download from this peer if they would let us" ); break; - case 'U': s = _( "Uploading to peer" ); break; + case 'U': s = _( "Uploading to peer" ); break; case 'u': s = _( "We would upload to this peer if they asked" ); break; case 'K': s = _( "Peer has unchoked us, but we're not interested" ); break; case '?': s = _( "We unchoked this peer, but they're not interested" ); break; - case 'E': s = _( "Encrypted connection" ); break; + case 'E': s = _( "Encrypted connection" ); break; case 'X': s = _( "Peer was discovered through Peer Exchange (PEX)" ); break; case 'H': s = _( "Peer was discovered through DHT" ); break; case 'I': s = _( "Peer is an incoming connection" ); break; @@ -1963,7 +1963,6 @@ torrent_inspector_set_torrents( GtkWidget * w, GSList * ids ) file_list_set_torrent( di->file_list, id ); tracker_list_set_torrent( di->tracker_list, id ); - } else { diff --git a/gtk/dialogs.c b/gtk/dialogs.c index afa776a92..dace95b6e 100644 --- a/gtk/dialogs.c +++ b/gtk/dialogs.c @@ -270,7 +270,7 @@ confirmRemove( GtkWindow * parent, counts.connected ) ); if( counts.connected && counts.incomplete ) g_string_append( secondary_text, "\n" ); - + if( counts.incomplete ) g_string_assign( secondary_text, ngettext( "One of these torrents has not finished downloading.", "Some of these torrents have not finished downloading.", diff --git a/gtk/file-list.c b/gtk/file-list.c index 7d4ee50f1..46a3c1c65 100644 --- a/gtk/file-list.c +++ b/gtk/file-list.c @@ -381,7 +381,7 @@ buildTree( GNode * node, gpointer gdata ) const gboolean isLeaf = node->children == NULL; const char * mime_type = isLeaf ? get_mime_type_from_filename( child_data->name ) : DIRECTORY_MIME_TYPE; - GdkPixbuf * icon = get_mime_type_icon( mime_type, GTK_ICON_SIZE_MENU, build->w ); + GdkPixbuf * icon = get_mime_type_icon( mime_type, GTK_ICON_SIZE_MENU, build->w ); const int priority = isLeaf ? tr_torrentGetFilePriority( build->tor, child_data->index ) : 0; const gboolean enabled = isLeaf ? tr_torrentGetFileDL( build->tor, child_data->index ) : TRUE; #if GTK_CHECK_VERSION(2,10,0) @@ -415,7 +415,7 @@ buildTree( GNode * node, gpointer gdata ) } g_object_unref( icon ); - + /* we're done with this node */ g_free( child_data->name ); g_free( child_data ); diff --git a/gtk/main.c b/gtk/main.c index ecbcddfd8..e878a0b2c 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -542,6 +542,26 @@ appsetup( TrWindow * wind, gtk_window_set_skip_taskbar_hint( cbdata->wind, cbdata->icon != NULL ); } + + if( pref_flag_get( PREF_KEY_LEGAL_DIALOG_ON_STARTUP ) ) + { + /* show the legal dialog */ + GtkWidget * w = gtk_message_dialog_new( GTK_WINDOW( wind ), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, + "%s", + _( "Notice for first-time users" ) ); + gtk_message_dialog_format_secondary_text( GTK_MESSAGE_DIALOG( w ), + "%s", + _( "Transmission should only be used for legal file transfers. " + "Please respect other peoples' property." ) ); + g_signal_connect_swapped( w, "response", G_CALLBACK( gtk_widget_destroy ), w ); + gtk_widget_show( w ); + + /* only show it once */ + pref_flag_set( PREF_KEY_LEGAL_DIALOG_ON_STARTUP, FALSE ); + } } static void diff --git a/gtk/makemeta-ui.c b/gtk/makemeta-ui.c index 00450f65e..96e8da3d4 100644 --- a/gtk/makemeta-ui.c +++ b/gtk/makemeta-ui.c @@ -432,7 +432,7 @@ make_meta_ui( GtkWindow * parent, int i; int trackerCount = 0; tr_tracker_info * trackers = g_new0( tr_tracker_info, n ); - + for( i=0; ihaveValid >= info->totalSize; char buf1[32], buf2[32], buf3[32], buf4[32]; char * str; - double seedRatio; + double seedRatio; gboolean hasSeedRatio = FALSE; if( !isDone ) @@ -361,7 +361,7 @@ get_size_minimal( TorrentCellRenderer * cell, gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h ); stat_area.width = w; stat_area.height = h; - + /** *** LAYOUT **/ @@ -423,7 +423,7 @@ get_size_full( TorrentCellRenderer * cell, gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h ); stat_area.width = w; stat_area.height = h; - + /** *** LAYOUT **/ @@ -554,7 +554,7 @@ render_minimal( TorrentCellRenderer * cell, /** *** RENDER **/ - + g_object_set( p->icon_renderer, "pixbuf", icon, "sensitive", active, NULL ); gtk_cell_renderer_render( p->icon_renderer, window, widget, &icon_area, &icon_area, &icon_area, flags ); g_object_set( text_renderer, "text", status, "scale", SMALL_SCALE, "sensitive", active, "ellipsize", PANGO_ELLIPSIZE_END, NULL ); @@ -621,7 +621,7 @@ render_full( TorrentCellRenderer * cell, gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h ); stat_area.width = w; stat_area.height = h; - + /** *** LAYOUT **/ @@ -660,7 +660,7 @@ render_full( TorrentCellRenderer * cell, /** *** RENDER **/ - + g_object_set( p->icon_renderer, "pixbuf", icon, "sensitive", active, NULL ); gtk_cell_renderer_render( p->icon_renderer, window, widget, &icon_area, &icon_area, &icon_area, flags ); g_object_set( text_renderer, "text", name, "scale", 1.0, "sensitive", active, "ellipsize", PANGO_ELLIPSIZE_END, "weight", PANGO_WEIGHT_BOLD, NULL ); diff --git a/gtk/tr-core.h b/gtk/tr-core.h index 23ee78aba..5cadef605 100644 --- a/gtk/tr-core.h +++ b/gtk/tr-core.h @@ -139,7 +139,7 @@ gboolean tr_core_add_metainfo( TrCore * core, void tr_core_add_torrent( TrCore*, TrTorrent*, gboolean doNotify ); /** Present the main window */ -gboolean tr_core_present_window( TrCore*, gboolean * setme_success, GError ** err ); +gboolean tr_core_present_window( TrCore*, gboolean * setme_success, GError ** err ); /** diff --git a/gtk/tr-icon.c b/gtk/tr-icon.c index 2b360f990..7d70f7d2f 100644 --- a/gtk/tr-icon.c +++ b/gtk/tr-icon.c @@ -83,7 +83,7 @@ refresh_tooltip_cb( gpointer data ) else tr_strlspeed( down, d, sizeof( down ) ); - /* down limit */ + /* down limit */ if( !tr_sessionGetActiveSpeedLimit( session, TR_DOWN, &limit ) ) *downLimit = '\0'; else { diff --git a/gtk/tr-prefs.c b/gtk/tr-prefs.c index dcf4d8c76..7c11bd4c0 100644 --- a/gtk/tr-prefs.c +++ b/gtk/tr-prefs.c @@ -1217,7 +1217,7 @@ bandwidthPage( GObject * core ) w = new_spin_button( TR_PREFS_KEY_ALT_SPEED_UP, core, 0, INT_MAX, 5 ); hig_workarea_add_row( t, &row, s, w, NULL ); - s = _( "_Scheduled times:" ); + s = _( "_Scheduled times:" ); h = gtk_hbox_new( FALSE, 0 ); w2 = new_time_combo( core, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN ); page->sched_widgets = g_slist_append( page->sched_widgets, w2 ); diff --git a/gtk/tr-prefs.h b/gtk/tr-prefs.h index 75e81e869..3e90baf1a 100644 --- a/gtk/tr-prefs.h +++ b/gtk/tr-prefs.h @@ -21,6 +21,7 @@ GtkWidget * tr_prefs_dialog_new( GObject * core, /* if you add a key here, you /must/ add its * default in tr_prefs_init_defaults( void ) */ +#define PREF_KEY_LEGAL_DIALOG_ON_STARTUP "show-legal-dialog-on-startup" #define PREF_KEY_OPTIONS_PROMPT "show-options-window" #define PREF_KEY_OPEN_DIALOG_FOLDER "open-dialog-dir" #define PREF_KEY_INHIBIT_HIBERNATION "inhibit-desktop-hibernation" diff --git a/gtk/tr-window.c b/gtk/tr-window.c index 4a40718db..7da49c26c 100644 --- a/gtk/tr-window.c +++ b/gtk/tr-window.c @@ -187,7 +187,7 @@ makeview( PrivateData * p, p->selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) ); - p->column = col = GTK_TREE_VIEW_COLUMN (g_object_new (GTK_TYPE_TREE_VIEW_COLUMN, + p->column = col = GTK_TREE_VIEW_COLUMN (g_object_new (GTK_TYPE_TREE_VIEW_COLUMN, "title", _("Torrent"), "resizable", TRUE, "sizing", GTK_TREE_VIEW_COLUMN_FIXED, @@ -198,7 +198,7 @@ makeview( PrivateData * p, gtk_tree_view_column_add_attribute( col, r, "torrent", MC_TORRENT_RAW ); gtk_tree_view_column_add_attribute( col, r, "piece-upload-speed", MC_SPEED_UP ); gtk_tree_view_column_add_attribute( col, r, "piece-download-speed", MC_SPEED_DOWN ); - + gtk_tree_view_append_column( GTK_TREE_VIEW( view ), col ); g_object_set( r, "xpad", GUI_PAD_SMALL, "ypad", GUI_PAD_SMALL, NULL ); @@ -356,7 +356,7 @@ alt_speed_toggled_cb( GtkToggleButton * button, gpointer vprivate ) const gboolean b = gtk_toggle_button_get_active( button ); tr_core_set_pref_bool( p->core, TR_PREFS_KEY_ALT_SPEED_ENABLED, b ); } - + /*** **** FILTER ***/ @@ -490,7 +490,7 @@ setFilter( PrivateData * p, int mode ) gtk_toggle_button_set_active( p->filter_toggles[i], i==mode ); } } - + static void filter_toggled_cb( GtkToggleButton * toggle, gpointer vprivate ) @@ -622,7 +622,7 @@ onAltSpeedToggled( tr_session * s UNUSED, tr_bool isEnabled UNUSED, tr_bool byUs #define SPEED_KEY "speed-key" static void -onSpeedToggled( GtkCheckMenuItem * check, gpointer vp ) +onSpeedToggled( GtkCheckMenuItem * check, gpointer vp ) { PrivateData * p = vp; GObject * o = G_OBJECT( check ); @@ -636,7 +636,7 @@ onSpeedToggled( GtkCheckMenuItem * check, gpointer vp ) } static void -onSpeedSet( GtkCheckMenuItem * check, gpointer vp ) +onSpeedSet( GtkCheckMenuItem * check, gpointer vp ) { const char * key; PrivateData * p = vp; @@ -700,7 +700,7 @@ createSpeedMenu( PrivateData * p, tr_direction dir ) static const double stockRatios[] = { 0.25, 0.5, 0.75, 1, 1.5, 2, 3 }; static void -onRatioToggled( GtkCheckMenuItem * check, gpointer vp ) +onRatioToggled( GtkCheckMenuItem * check, gpointer vp ) { PrivateData * p = vp; if( gtk_check_menu_item_get_active( check ) ) @@ -710,7 +710,7 @@ onRatioToggled( GtkCheckMenuItem * check, gpointer vp ) } } static void -onRatioSet( GtkCheckMenuItem * check, gpointer vp ) +onRatioSet( GtkCheckMenuItem * check, gpointer vp ) { PrivateData * p = vp; int i = GPOINTER_TO_INT( g_object_get_data( G_OBJECT( check ), RATIO_KEY ) ); @@ -971,7 +971,7 @@ tr_window_new( GtkUIManager * ui_mgr, TrCore * core ) w = gtk_image_new_from_stock( GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); w = p->ul_lb = gtk_label_new( NULL ); - gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); + gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_box_pack_end( GTK_BOX( h ), hbox, FALSE, FALSE, 0 ); hbox = p->dl_hbox = gtk_hbox_new( FALSE, GUI_PAD_SMALL ); @@ -981,7 +981,7 @@ tr_window_new( GtkUIManager * ui_mgr, TrCore * core ) w = gtk_image_new_from_stock( GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_MENU ); gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); w = p->dl_lb = gtk_label_new( NULL ); - gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); + gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); gtk_box_pack_end( GTK_BOX( h ), hbox, FALSE, FALSE, 0 ); hbox = gtk_hbox_new( FALSE, GUI_PAD_SMALL ); diff --git a/gtk/util.c b/gtk/util.c index 90bf437fb..e51223cbb 100644 --- a/gtk/util.c +++ b/gtk/util.c @@ -3,7 +3,7 @@ * * This file is licensed by the GPL version 2. Works owned by the * Transmission project are granted a special exemption to clause 2(b) - * so that the bulk of its code can remain under the MIT license. + * so that the bulk of its code can remain under the MIT license. * This exemption does not extend to derived works not owned by * the Transmission project. * diff --git a/gtk/util.h b/gtk/util.h index b7c8f1302..cb6848a30 100644 --- a/gtk/util.h +++ b/gtk/util.h @@ -3,7 +3,7 @@ * * This file is licensed by the GPL version 2. Works owned by the * Transmission project are granted a special exemption to clause 2(b) - * so that the bulk of its code can remain under the MIT license. + * so that the bulk of its code can remain under the MIT license. * This exemption does not extend to derived works not owned by * the Transmission project. * diff --git a/libtransmission/bandwidth.h b/libtransmission/bandwidth.h index d6847f2c6..9ca93462d 100644 --- a/libtransmission/bandwidth.h +++ b/libtransmission/bandwidth.h @@ -76,7 +76,7 @@ struct tr_band * tr_session also owns a tr_handshake's bandwidths, so that the handshake * I/O can be counted in the global raw totals. When the handshake is done, * the bandwidth's ownership passes to a tr_peer. - * + * * MEASURING * * When you ask a bandwidth object for its speed, it gives the speed of the @@ -85,17 +85,17 @@ struct tr_band * tr_torrent's bandwidth, and per-peer speeds by asking tr_peer's bandwidth. * * CONSTRAINING - * + * * Call tr_bandwidthAllocate() periodically. tr_bandwidth knows its current * speed and will decide how many bytes to make available over the * user-specified period to reach the user-specified desired speed. * If appropriate, it notifies its peer-ios that new bandwidth is available. - * - * tr_bandwidthAllocate() operates on the tr_bandwidth subtree, so usually + * + * tr_bandwidthAllocate() operates on the tr_bandwidth subtree, so usually * you'll only need to invoke it for the top-level tr_session bandwidth. * * The peer-ios all have a pointer to their associated tr_bandwidth object, - * and call tr_bandwidthClamp() before performing I/O to see how much + * and call tr_bandwidthClamp() before performing I/O to see how much * bandwidth they can safely use. */ typedef struct tr_bandwidth diff --git a/libtransmission/bencode-test.c b/libtransmission/bencode-test.c index 93a5eed2c..943bacd55 100644 --- a/libtransmission/bencode-test.c +++ b/libtransmission/bencode-test.c @@ -374,24 +374,24 @@ testJSON( void ) return 0; } -static int +static int testMerge( void ) -{ - tr_benc dest, src; - int64_t i; - const char * s; +{ + tr_benc dest, src; + int64_t i; + const char * s; /* initial dictionary (default values) */ - tr_bencInitDict( &dest, 10 ); - tr_bencDictAddInt( &dest, "i1", 1 ); - tr_bencDictAddInt( &dest, "i2", 2 ); + tr_bencInitDict( &dest, 10 ); + tr_bencDictAddInt( &dest, "i1", 1 ); + tr_bencDictAddInt( &dest, "i2", 2 ); tr_bencDictAddInt( &dest, "i4", -35 ); /* remains untouched */ - tr_bencDictAddStr( &dest, "s5", "abc" ); - tr_bencDictAddStr( &dest, "s6", "def" ); + tr_bencDictAddStr( &dest, "s5", "abc" ); + tr_bencDictAddStr( &dest, "s6", "def" ); tr_bencDictAddStr( &dest, "s7", "127.0.0.1" ); /* remains untouched */ /* new dictionary, will overwrite items in dest */ - tr_bencInitDict( &src, 10 ); + tr_bencInitDict( &src, 10 ); tr_bencDictAddInt( &src, "i1", 1 ); /* same value */ tr_bencDictAddInt( &src, "i2", 4 ); /* new value */ tr_bencDictAddInt( &src, "i3", 3 ); /* new key:value */ @@ -399,29 +399,29 @@ testMerge( void ) tr_bencDictAddStr( &src, "s6", "xyz" ); /* new value */ tr_bencDictAddStr( &src, "s8", "ghi" ); /* new key:value */ - tr_bencMergeDicts( &dest, /*const*/ &src ); - - check( tr_bencDictFindInt( &dest, "i1", &i )); - check( i == 1); - check( tr_bencDictFindInt( &dest, "i2", &i )); - check( i == 4); - check( tr_bencDictFindInt( &dest, "i3", &i )); - check( i == 3); - check( tr_bencDictFindInt( &dest, "i4", &i )); - check( i == -35); - check( tr_bencDictFindStr( &dest, "s5", &s )); - check( strcmp( "abc", s ) == 0 ); - check( tr_bencDictFindStr( &dest, "s6", &s )); - check( strcmp( "xyz", s ) == 0 ); - check( tr_bencDictFindStr( &dest, "s7", &s )); - check( strcmp( "127.0.0.1", s ) == 0 ); - check( tr_bencDictFindStr( &dest, "s8", &s )); - check( strcmp( "ghi", s ) == 0 ); - - tr_bencFree( &dest ); - tr_bencFree( &src ); - return 0; -} + tr_bencMergeDicts( &dest, /*const*/ &src ); + + check( tr_bencDictFindInt( &dest, "i1", &i )); + check( i == 1); + check( tr_bencDictFindInt( &dest, "i2", &i )); + check( i == 4); + check( tr_bencDictFindInt( &dest, "i3", &i )); + check( i == 3); + check( tr_bencDictFindInt( &dest, "i4", &i )); + check( i == -35); + check( tr_bencDictFindStr( &dest, "s5", &s )); + check( strcmp( "abc", s ) == 0 ); + check( tr_bencDictFindStr( &dest, "s6", &s )); + check( strcmp( "xyz", s ) == 0 ); + check( tr_bencDictFindStr( &dest, "s7", &s )); + check( strcmp( "127.0.0.1", s ) == 0 ); + check( tr_bencDictFindStr( &dest, "s8", &s )); + check( strcmp( "ghi", s ) == 0 ); + + tr_bencFree( &dest ); + tr_bencFree( &src ); + return 0; +} static int testStackSmash( int depth ) diff --git a/libtransmission/bencode.h b/libtransmission/bencode.h index 7cdd6e4d8..9eb73a35d 100644 --- a/libtransmission/bencode.h +++ b/libtransmission/bencode.h @@ -26,7 +26,7 @@ struct evbuffer; * * An object that acts like a union for * integers, strings, lists, dictionaries, booleans, and floating-point numbers. - * The structure is named tr_benc due to the historical reason that it was + * The structure is named tr_benc due to the historical reason that it was * originally tightly coupled with bencoded data. It currently supports * being parsed from, and serialized to, both bencoded notation and json notation. * @@ -45,7 +45,7 @@ enum TR_TYPE_BOOL = 16, TR_TYPE_REAL = 32 }; - + /* These are PRIVATE IMPLEMENTATION details that should not be touched. * I'll probably change them just to break your code! HA HA HA! * it's included in the header for inlining and composition */ diff --git a/libtransmission/bitfield.h b/libtransmission/bitfield.h index d4bc197a7..c2a77a469 100644 --- a/libtransmission/bitfield.h +++ b/libtransmission/bitfield.h @@ -3,7 +3,7 @@ * * This file is licensed by the GPL version 2. Works owned by the * Transmission project are granted a special exemption to clause 2(b) - * so that the bulk of its code can remain under the MIT license. + * so that the bulk of its code can remain under the MIT license. * This exemption does not extend to derived works not owned by * the Transmission project. * diff --git a/libtransmission/clients.c b/libtransmission/clients.c index 181f41efd..a0cfd69c0 100644 --- a/libtransmission/clients.c +++ b/libtransmission/clients.c @@ -3,7 +3,7 @@ * * This file is licensed by the GPL version 2. Works owned by the * Transmission project are granted a special exemption to clause 2(b) - * so that the bulk of its code can remain under the MIT license. + * so that the bulk of its code can remain under the MIT license. * This exemption does not extend to derived works not owned by * the Transmission project. * @@ -32,16 +32,16 @@ charint( char ch ) return 0; } -static int -getShadowInt( char ch, int * setme ) -{ - const char * str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-"; - const char * pch = strchr( str, ch ); - if( !pch ) - return 0; - *setme = pch - str; - return 1; -} +static int +getShadowInt( char ch, int * setme ) +{ + const char * str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-"; + const char * pch = strchr( str, ch ); + if( !pch ) + return 0; + *setme = pch - str; + return 1; +} static int strint( const void * pch, int span ) @@ -110,7 +110,7 @@ isMainlineStyle( const uint8_t * peer_id ) * One of the following styles will be used: * Mx-y-z-- * Mx-yy-z- - */ + */ return peer_id[2]=='-' && peer_id[7]=='-' && ( peer_id[4]=='-' || peer_id[5]=='-' ); @@ -181,7 +181,7 @@ tr_clientForId( char * buf, size_t buflen, const void * id_in ) tr_snprintf( buf, buflen, "Transmission %d.%02d%s", strint(id+3,1), strint(id+4,2), id[6]=='Z' || id[6]=='X' ? "+" : "" ); } - + else if( !memcmp( id+1, "UT", 2 ) ) { tr_snprintf( buf, buflen, "\xc2\xb5Torrent %d.%d.%d%s", @@ -192,7 +192,7 @@ tr_clientForId( char * buf, size_t buflen, const void * id_in ) tr_snprintf( buf, buflen, "\xc2\xb5Torrent Mac %d.%d.%d%s", strint(id+3,1), strint(id+4,1), strint(id+5,1), getMnemonicEnd(id[6]) ); } - + else if( !memcmp( id+1, "AZ", 2 ) ) { if( id[3] > '3' || ( id[3] == '3' && id[4] >= '1' ) ) /* Vuze starts at version 3.1.0.0 */ @@ -200,7 +200,7 @@ tr_clientForId( char * buf, size_t buflen, const void * id_in ) else four_digits( buf, buflen, "Azureus", id+3 ); } - + else if( !memcmp( id+1, "KT", 2 ) ) { if( id[5] == 'D' ) @@ -327,8 +327,8 @@ tr_clientForId( char * buf, size_t buflen, const void * id_in ) else if( !memcmp( id, "eX", 2 ) ) no_version( buf, buflen, "eXeem" ); else if( !memcmp( id, "-aria2-", 7 ) ) no_version( buf, buflen, "aria2" ); else if( !memcmp( id, "-FG", 3 ) ) two_major_two_minor( buf, buflen, "FlashGet", id+3 ); - - /* Everything else */ + + /* Everything else */ else if( !memcmp( id, "S3", 2 ) && id[2] == '-' && id[4] == '-' && id[6] == '-' ) { tr_snprintf( buf, buflen, "Amazon S3 %c.%c.%c", id[3], id[5], id[7] ); diff --git a/libtransmission/clients.h b/libtransmission/clients.h index 1999b25cd..2caf0e749 100644 --- a/libtransmission/clients.h +++ b/libtransmission/clients.h @@ -3,7 +3,7 @@ * * This file is licensed by the GPL version 2. Works owned by the * Transmission project are granted a special exemption to clause 2(b) - * so that the bulk of its code can remain under the MIT license. + * so that the bulk of its code can remain under the MIT license. * This exemption does not extend to derived works not owned by * the Transmission project. * diff --git a/libtransmission/completion.h b/libtransmission/completion.h index f73444084..ad7a10229 100644 --- a/libtransmission/completion.h +++ b/libtransmission/completion.h @@ -3,7 +3,7 @@ * * This file is licensed by the GPL version 2. Works owned by the * Transmission project are granted a special exemption to clause 2(b) - * so that the bulk of its code can remain under the MIT license. + * so that the bulk of its code can remain under the MIT license. * This exemption does not extend to derived works not owned by * the Transmission project. * diff --git a/libtransmission/fdlimit.c b/libtransmission/fdlimit.c index e875aad7c..1de978b50 100644 --- a/libtransmission/fdlimit.c +++ b/libtransmission/fdlimit.c @@ -181,15 +181,15 @@ preallocateFileFull( const char * filename, uint64_t length ) if( !success ) /* if nothing else works, do it the old-fashioned way */ { - uint8_t buf[ 4096 ]; - memset( buf, 0, sizeof( buf ) ); - success = TRUE; - while ( success && ( length > 0 ) ) - { - const int thisPass = MIN( length, sizeof( buf ) ); - success = write( fd, buf, thisPass ) == thisPass; - length -= thisPass; - } + uint8_t buf[ 4096 ]; + memset( buf, 0, sizeof( buf ) ); + success = TRUE; + while ( success && ( length > 0 ) ) + { + const int thisPass = MIN( length, sizeof( buf ) ); + success = write( fd, buf, thisPass ) == thisPass; + length -= thisPass; + } } close( fd ); @@ -316,7 +316,7 @@ TrOpenFile( int i, if( doWrite && !alreadyExisted && ( preallocationMode == TR_PREALLOCATE_FULL ) ) if( preallocateFileFull( filename, desiredFileSize ) ) tr_inf( _( "Preallocated file \"%s\"" ), filename ); - + /* open the file */ flags = doWrite ? ( O_RDWR | O_CREAT ) : O_RDONLY; #ifdef O_SEQUENTIAL @@ -446,7 +446,7 @@ tr_fdFileCheckout( int torrentId, } assert( winner >= 0 ); - + if( fileIsOpen( &gFd->openFiles[winner] ) ) { dbgmsg( "closing file \"%s\"", gFd->openFiles[winner].filename ); @@ -576,28 +576,28 @@ tr_fdSocketAccept( int b, if( s >= 0 ) { - /* "The ss_family field of the sockaddr_storage structure will always - * align with the family field of any protocol-specific structure." */ - if( sock.ss_family == AF_INET ) + /* "The ss_family field of the sockaddr_storage structure will always + * align with the family field of any protocol-specific structure." */ + if( sock.ss_family == AF_INET ) { struct sockaddr_in *si; union { struct sockaddr_storage dummy; struct sockaddr_in si; } s; s.dummy = sock; si = &s.si; - addr->type = TR_AF_INET; - addr->addr.addr4.s_addr = si->sin_addr.s_addr; - *port = si->sin_port; - } - else - { + addr->type = TR_AF_INET; + addr->addr.addr4.s_addr = si->sin_addr.s_addr; + *port = si->sin_port; + } + else + { struct sockaddr_in6 *si; union { struct sockaddr_storage dummy; struct sockaddr_in6 si; } s; s.dummy = sock; si = &s.si; - addr->type = TR_AF_INET6; + addr->type = TR_AF_INET6; addr->addr.addr6 = si->sin6_addr; - *port = si->sin6_port; - } + *port = si->sin6_port; + } ++gFd->socketCount; } diff --git a/libtransmission/handshake.c b/libtransmission/handshake.c index 5b1577127..5cd063f64 100644 --- a/libtransmission/handshake.c +++ b/libtransmission/handshake.c @@ -76,13 +76,13 @@ enum #define HANDSHAKE_SET_LTEP( bits ) ( (void)0 ) #endif -#ifdef ENABLE_FAST - #define HANDSHAKE_HAS_FASTEXT( bits ) ( ( ( bits )[7] & 0x04 ) ? 1 : 0 ) - #define HANDSHAKE_SET_FASTEXT( bits ) ( ( bits )[7] |= 0x04 ) -#else - #define HANDSHAKE_HAS_FASTEXT( bits ) ( 0 ) - #define HANDSHAKE_SET_FASTEXT( bits ) ( (void)0 ) -#endif +#ifdef ENABLE_FAST + #define HANDSHAKE_HAS_FASTEXT( bits ) ( ( ( bits )[7] & 0x04 ) ? 1 : 0 ) + #define HANDSHAKE_SET_FASTEXT( bits ) ( ( bits )[7] |= 0x04 ) +#else + #define HANDSHAKE_HAS_FASTEXT( bits ) ( 0 ) + #define HANDSHAKE_SET_FASTEXT( bits ) ( (void)0 ) +#endif #ifdef ENABLE_DHT #define HANDSHAKE_HAS_DHT( bits ) ( ( ( bits )[7] & 0x01 ) ? 1 : 0 ) @@ -90,7 +90,7 @@ enum #else #define HANDSHAKE_HAS_DHT( bits ) ( 0 ) #define HANDSHAKE_SET_DHT( bits ) ( (void)0 ) -#endif +#endif /* http://www.azureuswiki.com/index.php/Extension_negotiation_protocol these macros are to be used if both extended messaging and the @@ -1127,7 +1127,7 @@ tr_handshakeDone( tr_handshake * handshake, success = fireDoneFunc( handshake, isOK ); - tr_handshakeFree( handshake ); + tr_handshakeFree( handshake ); return success ? READ_LATER : READ_ERR; } diff --git a/libtransmission/list.c b/libtransmission/list.c index 83abc3a69..3000d14b5 100644 --- a/libtransmission/list.c +++ b/libtransmission/list.c @@ -185,7 +185,6 @@ __tr_list_splice( struct __tr_list * prev, prev->next = next; } - void __tr_list_remove( struct __tr_list * head ) { diff --git a/libtransmission/list.h b/libtransmission/list.h index 87b63563e..46725fcde 100644 --- a/libtransmission/list.h +++ b/libtransmission/list.h @@ -125,7 +125,7 @@ __tr_list_append( struct __tr_list * head, /** * __tr_list_remove() * - * Remove @head from the list it is in. + * Remove @head from the list it is in. */ void __tr_list_remove( struct __tr_list * head ); diff --git a/libtransmission/metainfo.c b/libtransmission/metainfo.c index ca883a36d..7e02b6653 100644 --- a/libtransmission/metainfo.c +++ b/libtransmission/metainfo.c @@ -295,13 +295,13 @@ getannounce( tr_info * inf, t->tier = validTiers; t->announce = tr_strdup( url ); t->scrape = announceToScrape( url ); - + anyAdded = TRUE; } tr_free( url ); } } - + if( anyAdded ) ++validTiers; } diff --git a/libtransmission/net.c b/libtransmission/net.c index d7d99836f..d37c4e91b 100644 --- a/libtransmission/net.c +++ b/libtransmission/net.c @@ -56,8 +56,8 @@ #define IN_MULTICAST( a ) ( ( ( a ) & 0xf0000000 ) == 0xe0000000 ) #endif -const tr_address tr_in6addr_any = { TR_AF_INET6, { IN6ADDR_ANY_INIT } }; -const tr_address tr_inaddr_any = { TR_AF_INET, { { { { INADDR_ANY, 0x00, 0x00, 0x00 } } } } }; +const tr_address tr_in6addr_any = { TR_AF_INET6, { IN6ADDR_ANY_INIT } }; +const tr_address tr_inaddr_any = { TR_AF_INET, { { { { INADDR_ANY, 0x00, 0x00, 0x00 } } } } }; #ifdef WIN32 static const char * @@ -129,57 +129,57 @@ tr_netInit( void ) } } -const char * -tr_ntop( const tr_address * src, char * dst, int size ) +const char * +tr_ntop( const tr_address * src, char * dst, int size ) { assert( tr_isAddress( src ) ); - if( src->type == TR_AF_INET ) - return inet_ntop( AF_INET, &src->addr, dst, size ); - else - return inet_ntop( AF_INET6, &src->addr, dst, size ); -} - -/* - * Non-threadsafe version of tr_ntop, which uses a static memory area for a buffer. - * This function is suitable to be called from libTransmission's networking code, - * which is single-threaded. - */ -const char * -tr_ntop_non_ts( const tr_address * src ) -{ - static char buf[INET6_ADDRSTRLEN]; - return tr_ntop( src, buf, sizeof( buf ) ); -} - -tr_address * -tr_pton( const char * src, tr_address * dst ) -{ - int retval = inet_pton( AF_INET, src, &dst->addr ); + if( src->type == TR_AF_INET ) + return inet_ntop( AF_INET, &src->addr, dst, size ); + else + return inet_ntop( AF_INET6, &src->addr, dst, size ); +} + +/* + * Non-threadsafe version of tr_ntop, which uses a static memory area for a buffer. + * This function is suitable to be called from libTransmission's networking code, + * which is single-threaded. + */ +const char * +tr_ntop_non_ts( const tr_address * src ) +{ + static char buf[INET6_ADDRSTRLEN]; + return tr_ntop( src, buf, sizeof( buf ) ); +} + +tr_address * +tr_pton( const char * src, tr_address * dst ) +{ + int retval = inet_pton( AF_INET, src, &dst->addr ); assert( dst ); - if( retval < 0 ) - return NULL; - else if( retval == 0 ) - retval = inet_pton( AF_INET6, src, &dst->addr ); + if( retval < 0 ) + return NULL; + else if( retval == 0 ) + retval = inet_pton( AF_INET6, src, &dst->addr ); else - { - dst->type = TR_AF_INET; - return dst; - } - - if( retval < 1 ) - return NULL; - dst->type = TR_AF_INET6; - return dst; + { + dst->type = TR_AF_INET; + return dst; + } + + if( retval < 1 ) + return NULL; + dst->type = TR_AF_INET6; + return dst; } -/* - * Compare two tr_address structures. - * Returns: - * <0 if a < b - * >0 if a > b - * 0 if a == b - */ +/* + * Compare two tr_address structures. + * Returns: + * <0 if a < b + * >0 if a > b + * 0 if a == b + */ int tr_compareAddresses( const tr_address * a, const tr_address * b) { @@ -188,12 +188,12 @@ tr_compareAddresses( const tr_address * a, const tr_address * b) assert( tr_isAddress( a ) ); assert( tr_isAddress( b ) ); - /* IPv6 addresses are always "greater than" IPv4 */ + /* IPv6 addresses are always "greater than" IPv4 */ if( a->type != b->type ) return a->type == TR_AF_INET ? 1 : -1; return memcmp( &a->addr, &b->addr, sizes[a->type] ); -} +} /*********************************************************************** * TCP sockets @@ -313,7 +313,7 @@ tr_netOpenTCP( tr_session * session, } addrlen = setup_sockaddr( addr, port, &sock ); - + /* set source address */ source_addr = tr_sessionGetPublicAddress( session, addr->type ); assert( source_addr ); diff --git a/libtransmission/peer-io.c b/libtransmission/peer-io.c index c97b1939f..2ae2db800 100644 --- a/libtransmission/peer-io.c +++ b/libtransmission/peer-io.c @@ -99,7 +99,7 @@ didWriteWrapper( tr_peerIo * io, size_t bytes_transferred ) if( io->didWrite ) io->didWrite( io, payload, next->isPieceData, io->userData ); - + if( tr_isPeerIo( io ) ) { bytes_transferred -= payload; @@ -454,7 +454,7 @@ io_dtor( void * vio ) tr_cryptoFree( io->crypto ); __tr_list_destroy( &io->outbuf_datatypes, trDatatypeFree ); - memset( io, ~0, sizeof( tr_peerIo ) ); + memset( io, ~0, sizeof( tr_peerIo ) ); tr_free( io ); } @@ -510,10 +510,10 @@ tr_peerIoAddrStr( const tr_address * addr, tr_port port ) { static char buf[512]; - if( addr->type == TR_AF_INET ) - tr_snprintf( buf, sizeof( buf ), "%s:%u", tr_ntop_non_ts( addr ), ntohs( port ) ); - else - tr_snprintf( buf, sizeof( buf ), "[%s]:%u", tr_ntop_non_ts( addr ), ntohs( port ) ); + if( addr->type == TR_AF_INET ) + tr_snprintf( buf, sizeof( buf ), "%s:%u", tr_ntop_non_ts( addr ), ntohs( port ) ); + else + tr_snprintf( buf, sizeof( buf ), "[%s]:%u", tr_ntop_non_ts( addr ), ntohs( port ) ); return buf; } @@ -546,7 +546,7 @@ tr_peerIoReconnect( tr_peerIo * io ) if( io->socket >= 0 ) tr_netClose( io->socket ); - io->socket = tr_netOpenTCP( io->session, &io->addr, io->port ); + io->socket = tr_netOpenTCP( io->session, &io->addr, io->port ); if( io->socket >= 0 ) { tr_netSetTOS( io->socket, io->session->peerSocketTOS ); diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index b7c056582..f6a04b47a 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -47,7 +47,7 @@ enum /* minimum interval for refilling peers' request lists */ REFILL_PERIOD_MSEC = 400, - + /* how frequently to reallocate bandwidth */ BANDWIDTH_PERIOD_MSEC = 500, @@ -1078,7 +1078,7 @@ peerCallbackFunc( void * vpeer, void * vevent, void * vt ) tr_torrentSetDirty( tor ); } - /* update the stats */ + /* update the stats */ if( e->wasPieceData ) tr_statsAddDownloaded( tor->session, e->length ); @@ -1430,7 +1430,7 @@ tr_peerMgrCompact6ToPex( const void * compact, size_t n = compactLen / 18; const uint8_t * walk = compact; tr_pex * pex = tr_new0( tr_pex, n ); - + for( i = 0; i < n; ++i ) { pex[i].addr.type = TR_AF_INET6; @@ -1439,7 +1439,7 @@ tr_peerMgrCompact6ToPex( const void * compact, if( added_f && ( n == added_f_len ) ) pex[i].flags = added_f[i]; } - + *pexCount = n; return pex; } @@ -1454,14 +1454,14 @@ tr_peerMgrArrayToPex( const void * array, /*size_t n = arrayLen / sizeof( tr_peerArrayElement );*/ const uint8_t * walk = array; tr_pex * pex = tr_new0( tr_pex, n ); - + for( i = 0 ; i < n ; i++ ) { memcpy( &pex[i].addr, walk, sizeof( tr_address ) ); memcpy( &pex[i].port, walk + sizeof( tr_address ), 2 ); pex[i].flags = 0x00; walk += sizeof( tr_address ) + 2; } - + *pexCount = n; return pex; } @@ -2508,7 +2508,7 @@ enforceSessionPeerLimit( tr_session * session, uint64_t now ) while(( tor = tr_torrentNext( session, tor ))) n += tr_ptrArraySize( &tor->torrentPeers->peers ); - /* if there are too many, prune out the worst */ + /* if there are too many, prune out the worst */ if( n > max ) { tr_peer ** peers = tr_new( tr_peer*, n ); @@ -2526,7 +2526,7 @@ enforceSessionPeerLimit( tr_session * session, uint64_t now ) torrents[n] = t; } } - + /* sort 'em */ sortPeersByLiveliness( peers, (void**)torrents, n, now ); diff --git a/libtransmission/peer-msgs.c b/libtransmission/peer-msgs.c index 0c9cd1aae..d66f30c0c 100644 --- a/libtransmission/peer-msgs.c +++ b/libtransmission/peer-msgs.c @@ -1100,7 +1100,7 @@ parseUtPex( tr_peermsgs * msgs, int msglen, struct evbuffer * inbuf ) tr_peerMgrAddPex( tor, TR_PEER_FROM_PEX, pex + i ); tr_free( pex ); } - + if( tr_bencDictFindRaw( &val, "added6", &added, &added_len ) ) { const uint8_t * added_f = NULL; @@ -1115,7 +1115,6 @@ parseUtPex( tr_peermsgs * msgs, int msglen, struct evbuffer * inbuf ) tr_peerMgrAddPex( tor, TR_PEER_FROM_PEX, pex + i ); tr_free( pex ); } - } if( loaded ) @@ -1753,7 +1752,7 @@ fillOutputBuffer( tr_peermsgs * msgs, time_t now ) } else { - dbgmsg( msgs, "sending block %u:%u->%u", req.index, req.offset, req.length ); + dbgmsg( msgs, "sending block %u:%u->%u", req.index, req.offset, req.length ); EVBUFFER_LENGTH(out) += req.length; assert( EVBUFFER_LENGTH( out ) == msglen ); tr_peerIoWriteBuf( io, out, TRUE ); @@ -2058,7 +2057,7 @@ sendPex( tr_peermsgs * msgs ) assert( ( walk - tmp ) == diffs.droppedCount * 6 ); tr_bencDictAddRaw( &val, "dropped", tmp, walk - tmp ); tr_free( tmp ); - + /* "added6" */ tmp = walk = tr_new( uint8_t, diffs6.addedCount * 18 ); for( i = 0; i < diffs6.addedCount; ++i ) @@ -2071,7 +2070,7 @@ sendPex( tr_peermsgs * msgs ) assert( ( walk - tmp ) == diffs6.addedCount * 18 ); tr_bencDictAddRaw( &val, "added6", tmp, walk - tmp ); tr_free( tmp ); - + /* "added6.f" */ tmp = walk = tr_new( uint8_t, diffs6.addedCount ); for( i = 0; i < diffs6.addedCount; ++i ) @@ -2079,7 +2078,7 @@ sendPex( tr_peermsgs * msgs ) assert( ( walk - tmp ) == diffs6.addedCount ); tr_bencDictAddRaw( &val, "added6.f", tmp, walk - tmp ); tr_free( tmp ); - + /* "dropped6" */ tmp = walk = tr_new( uint8_t, diffs6.droppedCount * 18 ); for( i = 0; i < diffs6.droppedCount; ++i ) diff --git a/libtransmission/platform.c b/libtransmission/platform.c index dc49ce9d4..d71033520 100644 --- a/libtransmission/platform.c +++ b/libtransmission/platform.c @@ -522,7 +522,6 @@ isClutchDir( const char * path ) tr_inf( _( "Searching for web interface file \"%s\"" ), tmp ); tr_free( tmp ); return ret; - } const char * @@ -554,10 +553,10 @@ tr_getClutchDir( const tr_session * session UNUSED ) CFRelease( appRef ); s = tr_buildPath( appString, "Contents", "Resources", "web", NULL ); - + if( !isClutchDir( s ) ) { tr_free( s ); - + /* Fallback to the Application Support folder */ s = tr_buildPath( tr_sessionGetConfigDir( session ), "web", NULL ); if( !isClutchDir( s ) ) { @@ -570,11 +569,11 @@ tr_getClutchDir( const tr_session * session UNUSED ) /* SHGetFolderPath explicitly requires MAX_PATH length */ char dir[MAX_PATH]; - + /* Generally, Web interface should be stored in a Web subdir of * calling executable dir. */ - if( s == NULL ) { + if( s == NULL ) { /* First, we should check personal AppData/Transmission/Web */ SHGetFolderPath( NULL, CSIDL_COMMON_APPDATA, NULL, 0, dir ); s = tr_buildPath( dir, "Transmission", "Web", NULL ); diff --git a/libtransmission/platform.h b/libtransmission/platform.h index 8b2e177a8..e39bf90b8 100644 --- a/libtransmission/platform.h +++ b/libtransmission/platform.h @@ -3,7 +3,7 @@ * * This file is licensed by the GPL version 2. Works owned by the * Transmission project are granted a special exemption to clause 2(b) - * so that the bulk of its code can remain under the MIT license. + * so that the bulk of its code can remain under the MIT license. * This exemption does not extend to derived works not owned by * the Transmission project. * @@ -32,7 +32,7 @@ /** * @addtogroup utils Utilities - * @{ + * @{ */ typedef struct tr_lock tr_lock; diff --git a/libtransmission/request-list.c b/libtransmission/request-list.c index 04fef6aad..7d987f2e1 100644 --- a/libtransmission/request-list.c +++ b/libtransmission/request-list.c @@ -69,7 +69,7 @@ reqListSortPos( const struct request_list * list, return tr_lowerBound( req, list->sort, list->len, - sizeof( struct peer_request ), + sizeof( struct peer_request ), (compareFunc)compareRequests, exactMatch ); } diff --git a/libtransmission/resume.c b/libtransmission/resume.c index e59aa43c2..7a06fe9c9 100644 --- a/libtransmission/resume.c +++ b/libtransmission/resume.c @@ -87,7 +87,7 @@ savePeers( tr_benc * dict, count = tr_peerMgrGetPeers( (tr_torrent*) tor, &pex, TR_AF_INET6 ); if( count > 0 ) tr_bencDictAddRaw( dict, KEY_PEERS6, pex, sizeof( tr_pex ) * count ); - + tr_free( pex ); } @@ -112,7 +112,7 @@ loadPeers( tr_benc * dict, tr_tordbg( tor, "Loaded %d IPv4 peers from resume file", count ); ret = TR_FR_PEERS; } - + if( tr_bencDictFindRaw( dict, KEY_PEERS6, &str, &len ) ) { int i; @@ -638,7 +638,7 @@ loadFromFile( tr_torrent * tor, if( fieldsToLoad & TR_FR_SPEEDLIMIT ) fieldsLoaded |= loadSpeedLimits( &top, tor ); - + if( fieldsToLoad & TR_FR_RATIOLIMIT ) fieldsLoaded |= loadRatioLimits( &top, tor ); diff --git a/libtransmission/rpcimpl.c b/libtransmission/rpcimpl.c index b8f6b1356..5ea9512cc 100644 --- a/libtransmission/rpcimpl.c +++ b/libtransmission/rpcimpl.c @@ -1178,9 +1178,9 @@ sessionStats( tr_session * session, { int running = 0; int total = 0; - tr_benc * d; - tr_session_stats currentStats = { 0.0f, 0, 0, 0, 0, 0 }; - tr_session_stats cumulativeStats = { 0.0f, 0, 0, 0, 0, 0 }; + tr_benc * d; + tr_session_stats currentStats = { 0.0f, 0, 0, 0, 0, 0 }; + tr_session_stats cumulativeStats = { 0.0f, 0, 0, 0, 0, 0 }; tr_torrent * tor = NULL; assert( idle_data == NULL ); @@ -1191,8 +1191,8 @@ sessionStats( tr_session * session, ++running; } - tr_sessionGetStats( session, ¤tStats ); - tr_sessionGetCumulativeStats( session, &cumulativeStats ); + tr_sessionGetStats( session, ¤tStats ); + tr_sessionGetCumulativeStats( session, &cumulativeStats ); tr_bencDictAddInt( args_out, "activeTorrentCount", running ); tr_bencDictAddInt( args_out, "downloadSpeed", (int)( tr_sessionGetPieceSpeed( session, TR_DOWN ) * 1024 ) ); @@ -1200,19 +1200,19 @@ sessionStats( tr_session * session, tr_bencDictAddInt( args_out, "torrentCount", total ); tr_bencDictAddInt( args_out, "uploadSpeed", (int)( tr_sessionGetPieceSpeed( session, TR_UP ) * 1024 ) ); - d = tr_bencDictAddDict( args_out, "cumulative-stats", 5 ); - tr_bencDictAddInt( d, "downloadedBytes", cumulativeStats.downloadedBytes ); - tr_bencDictAddInt( d, "filesAdded", cumulativeStats.filesAdded ); - tr_bencDictAddInt( d, "secondsActive", cumulativeStats.secondsActive ); - tr_bencDictAddInt( d, "sessionCount", cumulativeStats.sessionCount ); - tr_bencDictAddInt( d, "uploadedBytes", cumulativeStats.uploadedBytes ); + d = tr_bencDictAddDict( args_out, "cumulative-stats", 5 ); + tr_bencDictAddInt( d, "downloadedBytes", cumulativeStats.downloadedBytes ); + tr_bencDictAddInt( d, "filesAdded", cumulativeStats.filesAdded ); + tr_bencDictAddInt( d, "secondsActive", cumulativeStats.secondsActive ); + tr_bencDictAddInt( d, "sessionCount", cumulativeStats.sessionCount ); + tr_bencDictAddInt( d, "uploadedBytes", cumulativeStats.uploadedBytes ); - d = tr_bencDictAddDict( args_out, "current-stats", 5 ); - tr_bencDictAddInt( d, "downloadedBytes", currentStats.downloadedBytes ); - tr_bencDictAddInt( d, "filesAdded", currentStats.filesAdded ); - tr_bencDictAddInt( d, "secondsActive", currentStats.secondsActive ); - tr_bencDictAddInt( d, "sessionCount", currentStats.sessionCount ); - tr_bencDictAddInt( d, "uploadedBytes", currentStats.uploadedBytes ); + d = tr_bencDictAddDict( args_out, "current-stats", 5 ); + tr_bencDictAddInt( d, "downloadedBytes", currentStats.downloadedBytes ); + tr_bencDictAddInt( d, "filesAdded", currentStats.filesAdded ); + tr_bencDictAddInt( d, "secondsActive", currentStats.secondsActive ); + tr_bencDictAddInt( d, "sessionCount", currentStats.sessionCount ); + tr_bencDictAddInt( d, "uploadedBytes", currentStats.uploadedBytes ); return NULL; } @@ -1255,7 +1255,7 @@ sessionGet( tr_session * s, tr_bencDictAddStr ( d, "version", LONG_VERSION_STRING ); switch( tr_sessionGetEncryption( s ) ) { case TR_CLEAR_PREFERRED: str = "tolerated"; break; - case TR_ENCRYPTION_REQUIRED: str = "required"; break; + case TR_ENCRYPTION_REQUIRED: str = "required"; break; default: str = "preferred"; break; } tr_bencDictAddStr( d, TR_PREFS_KEY_ENCRYPTION, str ); diff --git a/libtransmission/session.c b/libtransmission/session.c index 2847464fe..7445a22a1 100644 --- a/libtransmission/session.c +++ b/libtransmission/session.c @@ -315,15 +315,15 @@ isAltTime( const tr_session * s ) tr_localtime_r( &now, &tm ); minutes = tm.tm_hour*60 + tm.tm_min; day = tm.tm_wday; - + if( !toNextDay ) withinTime = ( begin <= minutes ) && ( minutes < end ); else /* goes past midnight */ withinTime = ( begin <= minutes ) || ( minutes < end ); - + if( !withinTime ) return FALSE; - + if( toNextDay && (minutes < end) ) day = (day - 1) % 7; @@ -794,7 +794,7 @@ tr_sessionInitImpl( void * vdata ) found = tr_bencDictFindInt( &settings, TR_PREFS_KEY_ALT_SPEED_TIME_END, &i ); assert( found ); session->altSpeedTimeEnd = i; - + found = tr_bencDictFindInt( &settings, TR_PREFS_KEY_ALT_SPEED_TIME_DAY, &i ); assert( found ); session->altSpeedTimeDay = i; @@ -1101,7 +1101,7 @@ onAltTimer( int foo UNUSED, short bar UNUSED, void * vsession ) tr_localtime_r( &now, &tm ); currentMinute = tm.tm_hour*60 + tm.tm_min; day = tm.tm_wday; - + isBeginTime = currentMinute == session->altSpeedTimeBegin; isEndTime = currentMinute == session->altSpeedTimeEnd; if( isBeginTime || isEndTime ) @@ -1109,7 +1109,7 @@ onAltTimer( int foo UNUSED, short bar UNUSED, void * vsession ) /* if looking at the end date, look at the next day if end time is before begin time */ if( isEndTime && !isBeginTime && session->altSpeedTimeEnd < session->altSpeedTimeBegin ) day = (day - 1) % 7; - + isDay = ((1<altSpeedTimeDay) != 0; if( isDay ) @@ -1167,7 +1167,7 @@ tr_sessionIsSpeedLimited( const tr_session * s, tr_direction d ) } /*** -**** Alternative speed limits that are used during scheduled times +**** Alternative speed limits that are used during scheduled times ***/ void @@ -1188,7 +1188,7 @@ tr_sessionGetAltSpeed( const tr_session * s, tr_direction d ) assert( tr_isSession( s ) ); assert( tr_isDirection( d ) ); - return s->altSpeed[d]; + return s->altSpeed[d]; } void @@ -1301,7 +1301,7 @@ useAltSpeed( tr_session * s, tr_bool enabled, tr_bool byUser ) { s->altSpeedEnabled = enabled; s->altSpeedChangedByUser = byUser; - + tr_runInEventThread( s, altSpeedToggled, s ); } } diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index 72c0039ad..fd9dce7a5 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -991,7 +991,7 @@ tr_torrentStat( tr_torrent * tor ) s->percentRatio = 1.0; else if( s->ratio == TR_RATIO_NA ) s->percentRatio = 0.0; - else + else s->percentRatio = s->ratio / seedRatio; tr_torrentUnlock( tor ); @@ -2282,7 +2282,7 @@ setLocation( void * vdata ) const tr_file * f = &tor->info.files[i]; char * oldpath = tr_buildPath( tor->downloadDir, f->name, NULL ); char * newpath = tr_buildPath( location, f->name, NULL ); - + if( do_move ) { errno = 0; diff --git a/libtransmission/tracker.c b/libtransmission/tracker.c index 3d04acc54..6d5ffd1d2 100644 --- a/libtransmission/tracker.c +++ b/libtransmission/tracker.c @@ -253,7 +253,7 @@ publishNewPeersCompact( tr_tracker * t, const int arrayLen = peerCount * ( sizeof( tr_address ) + 2 ); tr_address addr; tr_port port; - + addr.type = TR_AF_INET; memset( &addr.addr, 0x00, sizeof( addr.addr ) ); array = tr_new( uint8_t, arrayLen ); @@ -261,10 +261,10 @@ publishNewPeersCompact( tr_tracker * t, { memcpy( &addr.addr.addr4, compactWalk, 4 ); memcpy( &port, compactWalk + 4, 2 ); - + memcpy( walk, &addr, sizeof( addr ) ); memcpy( walk + sizeof( addr ), &port, 2 ); - + walk += sizeof( tr_address ) + 2; compactWalk += 6; } @@ -285,7 +285,7 @@ publishNewPeersCompact6( tr_tracker * t, const int arrayLen = peerCount * ( sizeof( tr_address ) + 2 ); tr_address addr; tr_port port; - + addr.type = TR_AF_INET6; memset( &addr.addr, 0x00, sizeof( addr.addr ) ); array = tr_new( uint8_t, arrayLen ); @@ -294,7 +294,7 @@ publishNewPeersCompact6( tr_tracker * t, memcpy( &addr.addr.addr6, compactWalk, 16 ); memcpy( &port, compactWalk + 16, 2 ); compactWalk += 18; - + memcpy( walk, &addr, sizeof( addr ) ); memcpy( walk + sizeof( addr ), &port, 2 ); walk += sizeof( tr_address ) + 2; diff --git a/libtransmission/trevent.c b/libtransmission/trevent.c index 18fb2169a..e3fdefd93 100644 --- a/libtransmission/trevent.c +++ b/libtransmission/trevent.c @@ -23,23 +23,23 @@ #ifdef WIN32 -#include - -static int -pgpipe( int handles[2] ) +#include + +static int +pgpipe( int handles[2] ) { SOCKET s; struct sockaddr_in serv_addr; int len = sizeof( serv_addr ); - + handles[0] = handles[1] = INVALID_SOCKET; - + if ( ( s = socket( AF_INET, SOCK_STREAM, 0 ) ) == INVALID_SOCKET ) { /* ereport(LOG, (errmsg_internal("pgpipe failed to create socket: %ui", WSAGetLastError()))); */ return -1; } - + memset( &serv_addr, 0, sizeof( serv_addr ) ); serv_addr.sin_family = AF_INET; serv_addr.sin_port = htons(0); @@ -68,7 +68,7 @@ pgpipe( int handles[2] ) closesocket(s); return -1; } - + if (connect(handles[1], (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR) { /* ereport(LOG, (errmsg_internal("pgpipe failed to connect socket: %ui", WSAGetLastError()))); */ @@ -86,27 +86,27 @@ pgpipe( int handles[2] ) closesocket(s); return 0; } - -static int -piperead( int s, char *buf, int len ) -{ - int ret = recv(s, buf, len, 0); - - if (ret < 0 && WSAGetLastError() == WSAECONNRESET) - /* EOF on the pipe! (win32 socket based implementation) */ - ret = 0; - return ret; -} - -#define pipe(a) pgpipe(a) -#define pipewrite(a,b,c) send(a,(char*)b,c,0) + +static int +piperead( int s, char *buf, int len ) +{ + int ret = recv(s, buf, len, 0); + + if (ret < 0 && WSAGetLastError() == WSAECONNRESET) + /* EOF on the pipe! (win32 socket based implementation) */ + ret = 0; + return ret; +} + +#define pipe(a) pgpipe(a) +#define pipewrite(a,b,c) send(a,(char*)b,c,0) #else -#define piperead(a,b,c) read(a,b,c) -#define pipewrite(a,b,c) write(a,b,c) +#define piperead(a,b,c) read(a,b,c) +#define pipewrite(a,b,c) write(a,b,c) #endif -#include +#include #include diff --git a/libtransmission/utils.c b/libtransmission/utils.c index c4535a0f1..062d6016c 100644 --- a/libtransmission/utils.c +++ b/libtransmission/utils.c @@ -284,7 +284,6 @@ tr_deepLog( const char * file, /*** **** ***/ - int tr_msgLoggingIsActive( int level ) @@ -1248,7 +1247,7 @@ compareInt( const void * va, const void * vb ) * Given a string like "1-4" or "1-4,6,9,14-51", this allocates and returns an * array of setmeCount ints of all the values in the array. * For example, "5-8" will return [ 5, 6, 7, 8 ] and setmeCount will be 4. - * It's the caller's responsibility to call tr_free() on the returned array. + * It's the caller's responsibility to call tr_free() on the returned array. * If a fragment of the string can't be parsed, NULL is returned. */ int* diff --git a/libtransmission/utils.h b/libtransmission/utils.h index e5223434c..d9f4ca04a 100644 --- a/libtransmission/utils.h +++ b/libtransmission/utils.h @@ -3,7 +3,7 @@ * * This file is licensed by the GPL version 2. Works owned by the * Transmission project are granted a special exemption to clause 2(b) - * so that the bulk of its code can remain under the MIT license. + * so that the bulk of its code can remain under the MIT license. * This exemption does not extend to derived works not owned by * the Transmission project. * @@ -33,7 +33,7 @@ extern "C" { /** * @addtogroup utils Utilities - * @{ + * @{ */ #ifndef FALSE @@ -114,7 +114,7 @@ void tr_assertImpl( const char * file, int line, const char * test, const char * #define tr_assert( test, fmt, ... ) \ do { if( ! ( test ) ) tr_assertImpl( __FILE__, __LINE__, #test, fmt, __VA_ARGS__ ); } while( 0 ) #endif - + int tr_msgLoggingIsActive( int level ); void tr_msg( const char * file, @@ -396,7 +396,7 @@ void* tr_int2ptr( int ); this can be used to prevent a printf() call from rounding up: call with the decimal_places argument equal to the number of decimal places in the printf()'s precision: - + - printf("%.2f%%", 99.999 ) ==> "100.00%" - printf("%.2f%%", tr_truncd(99.999, 2)) ==> "99.99%" diff --git a/libtransmission/web.c b/libtransmission/web.c index 7bc7592e1..7be53514e 100644 --- a/libtransmission/web.c +++ b/libtransmission/web.c @@ -3,7 +3,7 @@ * * This file is licensed by the GPL version 2. Works owned by the * Transmission project are granted a special exemption to clause 2(b) - * so that the bulk of its code can remain under the MIT license. + * so that the bulk of its code can remain under the MIT license. * This exemption does not extend to derived works not owned by * the Transmission project. * @@ -332,7 +332,7 @@ restart_timer( tr_web * g ) static void add_tasks_from_queue( tr_web * g ) { - while( ( g->still_running < MAX_CONCURRENT_TASKS ) + while( ( g->still_running < MAX_CONCURRENT_TASKS ) && ( tr_list_size( g->easy_queue ) > 0 ) ) { CURL * easy = tr_list_pop_front( &g->easy_queue ); @@ -524,13 +524,13 @@ tr_webInit( tr_session * session ) /* call curl_global_init if we haven't done it already. * try to enable ssl for https support; but if that fails, - * try a plain vanilla init */ + * try a plain vanilla init */ if( curlInited == FALSE ) { curlInited = TRUE; if( curl_global_init( CURL_GLOBAL_SSL ) ) curl_global_init( 0 ); } - + web = tr_new0( struct tr_web, 1 ); web->multi = curl_multi_init( ); web->session = session; @@ -624,7 +624,7 @@ const char * tr_webGetResponseStr( long code ) { struct http_msg * msg = bsearch( &code, - http_msg, + http_msg, sizeof( http_msg ) / sizeof( http_msg[0] ), sizeof( http_msg[0] ), compareResponseCodes ); -- 2.40.0