Changeset 8889
- Timestamp:
- Aug 10, 2009, 8:04:08 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 44 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli/cli.c
r8875 r8889 301 301 tr_benc settings; 302 302 const char * configDir; 303 tr_bool haveSource; 304 tr_bool haveAnnounce; 303 tr_bool haveSource; 304 tr_bool haveAnnounce; 305 305 306 306 printf( "Transmission %s - http://www.transmissionbt.com/\n", -
trunk/daemon/remote.c
r8875 r8889 789 789 case TR_STATUS_DOWNLOAD: 790 790 case TR_STATUS_SEED: { 791 int64_t fromUs = 0; 792 int64_t toUs = 0; 793 tr_bencDictFindInt( t, "peersGettingFromUs", &fromUs ); 794 tr_bencDictFindInt( t, "peersSendingToUs", &toUs ); 795 if( fromUs && toUs ) 796 tr_strlcpy( buf, "Up & Down", buflen ); 797 else if( toUs ) 798 tr_strlcpy( buf, "Downloading", buflen ); 799 else if( fromUs ) { 800 int64_t leftUntilDone = 0; 801 tr_bencDictFindInt( t, "leftUntilDone", &leftUntilDone ); 791 int64_t fromUs = 0; 792 int64_t toUs = 0; 793 tr_bencDictFindInt( t, "peersGettingFromUs", &fromUs ); 794 tr_bencDictFindInt( t, "peersSendingToUs", &toUs ); 795 if( fromUs && toUs ) 796 tr_strlcpy( buf, "Up & Down", buflen ); 797 else if( toUs ) 798 tr_strlcpy( buf, "Downloading", buflen ); 799 else if( fromUs ) { 800 int64_t leftUntilDone = 0; 801 tr_bencDictFindInt( t, "leftUntilDone", &leftUntilDone ); 802 802 if( leftUntilDone > 0 ) 803 tr_strlcpy( buf, "Uploading", buflen ); 803 tr_strlcpy( buf, "Uploading", buflen ); 804 804 else 805 tr_strlcpy( buf, "Seeding", buflen ); 805 tr_strlcpy( buf, "Seeding", buflen ); 806 806 } else { 807 tr_strlcpy( buf, "Idle", buflen ); 807 tr_strlcpy( buf, "Idle", buflen ); 808 808 } 809 809 break; … … 1430 1430 return curl; 1431 1431 } 1432 1432 1433 1433 1434 1434 static int … … 1520 1520 return EXIT_FAILURE; 1521 1521 } 1522 1522 1523 1523 1524 1524 for( i=0; i<reqCount; ++i ) -
trunk/gtk/conf.c
r8847 r8889 167 167 #endif 168 168 169 tr_bencDictAddBool( d, PREF_KEY_LEGAL_DIALOG_ON_STARTUP, TRUE ); 169 170 tr_bencDictAddBool( d, PREF_KEY_INHIBIT_HIBERNATION, FALSE ); 170 171 tr_bencDictAddBool( d, PREF_KEY_BLOCKLIST_UPDATES_ENABLED, TRUE ); -
trunk/gtk/details.c
r8868 r8889 232 232 di->honorLimitsCheckTag, baseline ); 233 233 } 234 234 235 235 /* downLimitedCheck */ 236 236 if( n ) { … … 256 256 di->downLimitSpinTag, baseline ); 257 257 } 258 258 259 259 /* upLimitedCheck */ 260 260 if( n ) { … … 577 577 d->seedCustomSpin = w; 578 578 d->seedCustomSpinTag = tag; 579 579 580 580 hig_workarea_add_section_divider( t, &row ); 581 581 hig_workarea_add_section_title( t, &row, _( "Peer Connections" ) ); … … 688 688 gtk_text_buffer_set_text( di->comment_buffer, str, -1 ); 689 689 690 /* destination_lb */ 690 /* destination_lb */ 691 691 if( n<=0 ) 692 692 str = none; … … 806 806 gtk_label_set_text( GTK_LABEL( di->have_lb ), str ); 807 807 808 808 809 809 /* dl_lb */ 810 810 if( n <= 0 ) … … 827 827 gtk_label_set_text( GTK_LABEL( di->dl_lb ), str ); 828 828 829 829 830 830 /* ul_lb */ 831 831 if( n <= 0 ) … … 857 857 str = none; 858 858 else if ( n==1 ) 859 str = infos[0]->hashString; 859 str = infos[0]->hashString; 860 860 else 861 861 str = mixed; … … 1255 1255 GtkListStore * store = di->webseed_store; 1256 1256 GtkTreeModel * model = GTK_TREE_MODEL( store ); 1257 1257 1258 1258 /* step 1: mark all webseeds as not-updated */ 1259 1259 if( gtk_tree_model_get_iter_first( model, &iter ) ) do … … 1406 1406 case 'D': s = _( "Downloading from this peer" ); break; 1407 1407 case 'd': s = _( "We would download from this peer if they would let us" ); break; 1408 case 'U': s = _( "Uploading to peer" ); break; 1408 case 'U': s = _( "Uploading to peer" ); break; 1409 1409 case 'u': s = _( "We would upload to this peer if they asked" ); break; 1410 1410 case 'K': s = _( "Peer has unchoked us, but we're not interested" ); break; 1411 1411 case '?': s = _( "We unchoked this peer, but they're not interested" ); break; 1412 case 'E': s = _( "Encrypted connection" ); break; 1412 case 'E': s = _( "Encrypted connection" ); break; 1413 1413 case 'X': s = _( "Peer was discovered through Peer Exchange (PEX)" ); break; 1414 1414 case 'H': s = _( "Peer was discovered through DHT" ); break; … … 1964 1964 file_list_set_torrent( di->file_list, id ); 1965 1965 tracker_list_set_torrent( di->tracker_list, id ); 1966 1967 1966 } 1968 1967 else -
trunk/gtk/dialogs.c
r8656 r8889 271 271 if( counts.connected && counts.incomplete ) 272 272 g_string_append( secondary_text, "\n" ); 273 273 274 274 if( counts.incomplete ) 275 275 g_string_assign( secondary_text, ngettext( "One of these torrents has not finished downloading.", -
trunk/gtk/file-list.c
r8808 r8889 382 382 383 383 const char * mime_type = isLeaf ? get_mime_type_from_filename( child_data->name ) : DIRECTORY_MIME_TYPE; 384 GdkPixbuf * icon = get_mime_type_icon( mime_type, GTK_ICON_SIZE_MENU, build->w ); 384 GdkPixbuf * icon = get_mime_type_icon( mime_type, GTK_ICON_SIZE_MENU, build->w ); 385 385 const int priority = isLeaf ? tr_torrentGetFilePriority( build->tor, child_data->index ) : 0; 386 386 const gboolean enabled = isLeaf ? tr_torrentGetFileDL( build->tor, child_data->index ) : TRUE; … … 416 416 417 417 g_object_unref( icon ); 418 418 419 419 /* we're done with this node */ 420 420 g_free( child_data->name ); -
trunk/gtk/main.c
r8871 r8889 543 543 cbdata->icon != NULL ); 544 544 } 545 546 if( pref_flag_get( PREF_KEY_LEGAL_DIALOG_ON_STARTUP ) ) 547 { 548 /* show the legal dialog */ 549 GtkWidget * w = gtk_message_dialog_new( GTK_WINDOW( wind ), 550 GTK_DIALOG_DESTROY_WITH_PARENT, 551 GTK_MESSAGE_INFO, 552 GTK_BUTTONS_OK, 553 "%s", 554 _( "Notice for first-time users" ) ); 555 gtk_message_dialog_format_secondary_text( GTK_MESSAGE_DIALOG( w ), 556 "%s", 557 _( "Transmission should only be used for legal file transfers. " 558 "Please respect other peoples' property." ) ); 559 g_signal_connect_swapped( w, "response", G_CALLBACK( gtk_widget_destroy ), w ); 560 gtk_widget_show( w ); 561 562 /* only show it once */ 563 pref_flag_set( PREF_KEY_LEGAL_DIALOG_ON_STARTUP, FALSE ); 564 } 545 565 } 546 566 -
trunk/gtk/makemeta-ui.c
r8757 r8889 433 433 int trackerCount = 0; 434 434 tr_tracker_info * trackers = g_new0( tr_tracker_info, n ); 435 435 436 436 for( i=0; i<n; ++i ) 437 437 { -
trunk/gtk/torrent-cell-renderer.c
r8882 r8889 53 53 char buf1[32], buf2[32], buf3[32], buf4[32]; 54 54 char * str; 55 double seedRatio; 55 double seedRatio; 56 56 gboolean hasSeedRatio = FALSE; 57 57 … … 362 362 stat_area.width = w; 363 363 stat_area.height = h; 364 364 365 365 /** 366 366 *** LAYOUT … … 424 424 stat_area.width = w; 425 425 stat_area.height = h; 426 426 427 427 /** 428 428 *** LAYOUT … … 555 555 *** RENDER 556 556 **/ 557 557 558 558 g_object_set( p->icon_renderer, "pixbuf", icon, "sensitive", active, NULL ); 559 559 gtk_cell_renderer_render( p->icon_renderer, window, widget, &icon_area, &icon_area, &icon_area, flags ); … … 622 622 stat_area.width = w; 623 623 stat_area.height = h; 624 624 625 625 /** 626 626 *** LAYOUT … … 661 661 *** RENDER 662 662 **/ 663 663 664 664 g_object_set( p->icon_renderer, "pixbuf", icon, "sensitive", active, NULL ); 665 665 gtk_cell_renderer_render( p->icon_renderer, window, widget, &icon_area, &icon_area, &icon_area, flags ); -
trunk/gtk/tr-core.h
r8882 r8889 140 140 141 141 /** Present the main window */ 142 gboolean tr_core_present_window( TrCore*, gboolean * setme_success, GError ** err ); 142 gboolean tr_core_present_window( TrCore*, gboolean * setme_success, GError ** err ); 143 143 144 144 -
trunk/gtk/tr-icon.c
r8763 r8889 84 84 tr_strlspeed( down, d, sizeof( down ) ); 85 85 86 /* down limit */ 86 /* down limit */ 87 87 if( !tr_sessionGetActiveSpeedLimit( session, TR_DOWN, &limit ) ) 88 88 *downLimit = '\0'; -
trunk/gtk/tr-prefs.c
r8763 r8889 1218 1218 hig_workarea_add_row( t, &row, s, w, NULL ); 1219 1219 1220 s = _( "_Scheduled times:" ); 1220 s = _( "_Scheduled times:" ); 1221 1221 h = gtk_hbox_new( FALSE, 0 ); 1222 1222 w2 = new_time_combo( core, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN ); -
trunk/gtk/tr-prefs.h
r8673 r8889 22 22 * default in tr_prefs_init_defaults( void ) */ 23 23 24 #define PREF_KEY_LEGAL_DIALOG_ON_STARTUP "show-legal-dialog-on-startup" 24 25 #define PREF_KEY_OPTIONS_PROMPT "show-options-window" 25 26 #define PREF_KEY_OPEN_DIALOG_FOLDER "open-dialog-dir" -
trunk/gtk/tr-window.c
r8882 r8889 188 188 p->selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) ); 189 189 190 p->column = col = GTK_TREE_VIEW_COLUMN (g_object_new (GTK_TYPE_TREE_VIEW_COLUMN, 190 p->column = col = GTK_TREE_VIEW_COLUMN (g_object_new (GTK_TYPE_TREE_VIEW_COLUMN, 191 191 "title", _("Torrent"), 192 192 "resizable", TRUE, … … 199 199 gtk_tree_view_column_add_attribute( col, r, "piece-upload-speed", MC_SPEED_UP ); 200 200 gtk_tree_view_column_add_attribute( col, r, "piece-download-speed", MC_SPEED_DOWN ); 201 201 202 202 gtk_tree_view_append_column( GTK_TREE_VIEW( view ), col ); 203 203 g_object_set( r, "xpad", GUI_PAD_SMALL, "ypad", GUI_PAD_SMALL, NULL ); … … 357 357 tr_core_set_pref_bool( p->core, TR_PREFS_KEY_ALT_SPEED_ENABLED, b ); 358 358 } 359 359 360 360 /*** 361 361 **** FILTER … … 491 491 } 492 492 } 493 493 494 494 495 495 static void … … 623 623 624 624 static void 625 onSpeedToggled( GtkCheckMenuItem * check, gpointer vp ) 625 onSpeedToggled( GtkCheckMenuItem * check, gpointer vp ) 626 626 { 627 627 PrivateData * p = vp; … … 637 637 638 638 static void 639 onSpeedSet( GtkCheckMenuItem * check, gpointer vp ) 639 onSpeedSet( GtkCheckMenuItem * check, gpointer vp ) 640 640 { 641 641 const char * key; … … 701 701 702 702 static void 703 onRatioToggled( GtkCheckMenuItem * check, gpointer vp ) 703 onRatioToggled( GtkCheckMenuItem * check, gpointer vp ) 704 704 { 705 705 PrivateData * p = vp; … … 711 711 } 712 712 static void 713 onRatioSet( GtkCheckMenuItem * check, gpointer vp ) 713 onRatioSet( GtkCheckMenuItem * check, gpointer vp ) 714 714 { 715 715 PrivateData * p = vp; … … 972 972 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); 973 973 w = p->ul_lb = gtk_label_new( NULL ); 974 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); 974 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); 975 975 gtk_box_pack_end( GTK_BOX( h ), hbox, FALSE, FALSE, 0 ); 976 976 … … 982 982 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); 983 983 w = p->dl_lb = gtk_label_new( NULL ); 984 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); 984 gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 ); 985 985 gtk_box_pack_end( GTK_BOX( h ), hbox, FALSE, FALSE, 0 ); 986 986 -
trunk/gtk/util.c
r8871 r8889 4 4 * This file is licensed by the GPL version 2. Works owned by the 5 5 * Transmission project are granted a special exemption to clause 2(b) 6 * so that the bulk of its code can remain under the MIT license. 6 * so that the bulk of its code can remain under the MIT license. 7 7 * This exemption does not extend to derived works not owned by 8 8 * the Transmission project. -
trunk/gtk/util.h
r8847 r8889 4 4 * This file is licensed by the GPL version 2. Works owned by the 5 5 * Transmission project are granted a special exemption to clause 2(b) 6 * so that the bulk of its code can remain under the MIT license. 6 * so that the bulk of its code can remain under the MIT license. 7 7 * This exemption does not extend to derived works not owned by 8 8 * the Transmission project. -
trunk/libtransmission/bandwidth.h
r8709 r8889 77 77 * I/O can be counted in the global raw totals. When the handshake is done, 78 78 * the bandwidth's ownership passes to a tr_peer. 79 * 79 * 80 80 * MEASURING 81 81 * … … 86 86 * 87 87 * CONSTRAINING 88 * 88 * 89 89 * Call tr_bandwidthAllocate() periodically. tr_bandwidth knows its current 90 90 * speed and will decide how many bytes to make available over the 91 91 * user-specified period to reach the user-specified desired speed. 92 92 * If appropriate, it notifies its peer-ios that new bandwidth is available. 93 * 94 * tr_bandwidthAllocate() operates on the tr_bandwidth subtree, so usually 93 * 94 * tr_bandwidthAllocate() operates on the tr_bandwidth subtree, so usually 95 95 * you'll only need to invoke it for the top-level tr_session bandwidth. 96 96 * 97 97 * The peer-ios all have a pointer to their associated tr_bandwidth object, 98 * and call tr_bandwidthClamp() before performing I/O to see how much 98 * and call tr_bandwidthClamp() before performing I/O to see how much 99 99 * bandwidth they can safely use. 100 100 */ -
trunk/libtransmission/bencode-test.c
r8685 r8889 375 375 } 376 376 377 static int 377 static int 378 378 testMerge( void ) 379 { 380 tr_benc dest, src; 381 int64_t i; 382 const char * s; 379 { 380 tr_benc dest, src; 381 int64_t i; 382 const char * s; 383 383 384 384 /* initial dictionary (default values) */ 385 tr_bencInitDict( &dest, 10 ); 386 tr_bencDictAddInt( &dest, "i1", 1 ); 387 tr_bencDictAddInt( &dest, "i2", 2 ); 385 tr_bencInitDict( &dest, 10 ); 386 tr_bencDictAddInt( &dest, "i1", 1 ); 387 tr_bencDictAddInt( &dest, "i2", 2 ); 388 388 tr_bencDictAddInt( &dest, "i4", -35 ); /* remains untouched */ 389 tr_bencDictAddStr( &dest, "s5", "abc" ); 390 tr_bencDictAddStr( &dest, "s6", "def" ); 389 tr_bencDictAddStr( &dest, "s5", "abc" ); 390 tr_bencDictAddStr( &dest, "s6", "def" ); 391 391 tr_bencDictAddStr( &dest, "s7", "127.0.0.1" ); /* remains untouched */ 392 392 393 393 /* new dictionary, will overwrite items in dest */ 394 tr_bencInitDict( &src, 10 ); 394 tr_bencInitDict( &src, 10 ); 395 395 tr_bencDictAddInt( &src, "i1", 1 ); /* same value */ 396 396 tr_bencDictAddInt( &src, "i2", 4 ); /* new value */ … … 400 400 tr_bencDictAddStr( &src, "s8", "ghi" ); /* new key:value */ 401 401 402 tr_bencMergeDicts( &dest, /*const*/ &src ); 403 404 check( tr_bencDictFindInt( &dest, "i1", &i )); 405 check( i == 1); 406 check( tr_bencDictFindInt( &dest, "i2", &i )); 407 check( i == 4); 408 check( tr_bencDictFindInt( &dest, "i3", &i )); 409 check( i == 3); 410 check( tr_bencDictFindInt( &dest, "i4", &i )); 411 check( i == -35); 412 check( tr_bencDictFindStr( &dest, "s5", &s )); 413 check( strcmp( "abc", s ) == 0 ); 414 check( tr_bencDictFindStr( &dest, "s6", &s )); 415 check( strcmp( "xyz", s ) == 0 ); 416 check( tr_bencDictFindStr( &dest, "s7", &s )); 417 check( strcmp( "127.0.0.1", s ) == 0 ); 418 check( tr_bencDictFindStr( &dest, "s8", &s )); 419 check( strcmp( "ghi", s ) == 0 ); 420 421 tr_bencFree( &dest ); 422 tr_bencFree( &src ); 423 return 0; 424 } 402 tr_bencMergeDicts( &dest, /*const*/ &src ); 403 404 check( tr_bencDictFindInt( &dest, "i1", &i )); 405 check( i == 1); 406 check( tr_bencDictFindInt( &dest, "i2", &i )); 407 check( i == 4); 408 check( tr_bencDictFindInt( &dest, "i3", &i )); 409 check( i == 3); 410 check( tr_bencDictFindInt( &dest, "i4", &i )); 411 check( i == -35); 412 check( tr_bencDictFindStr( &dest, "s5", &s )); 413 check( strcmp( "abc", s ) == 0 ); 414 check( tr_bencDictFindStr( &dest, "s6", &s )); 415 check( strcmp( "xyz", s ) == 0 ); 416 check( tr_bencDictFindStr( &dest, "s7", &s )); 417 check( strcmp( "127.0.0.1", s ) == 0 ); 418 check( tr_bencDictFindStr( &dest, "s8", &s )); 419 check( strcmp( "ghi", s ) == 0 ); 420 421 tr_bencFree( &dest ); 422 tr_bencFree( &src ); 423 return 0; 424 } 425 425 426 426 static int -
trunk/libtransmission/bencode.h
r8592 r8889 27 27 * An object that acts like a union for 28 28 * integers, strings, lists, dictionaries, booleans, and floating-point numbers. 29 * The structure is named tr_benc due to the historical reason that it was 29 * The structure is named tr_benc due to the historical reason that it was 30 30 * originally tightly coupled with bencoded data. It currently supports 31 31 * being parsed from, and serialized to, both bencoded notation and json notation. … … 46 46 TR_TYPE_REAL = 32 47 47 }; 48 48 49 49 /* These are PRIVATE IMPLEMENTATION details that should not be touched. 50 50 * I'll probably change them just to break your code! HA HA HA! -
trunk/libtransmission/bitfield.h
r8695 r8889 4 4 * This file is licensed by the GPL version 2. Works owned by the 5 5 * Transmission project are granted a special exemption to clause 2(b) 6 * so that the bulk of its code can remain under the MIT license. 6 * so that the bulk of its code can remain under the MIT license. 7 7 * This exemption does not extend to derived works not owned by 8 8 * the Transmission project. -
trunk/libtransmission/clients.c
r8599 r8889 4 4 * This file is licensed by the GPL version 2. Works owned by the 5 5 * Transmission project are granted a special exemption to clause 2(b) 6 * so that the bulk of its code can remain under the MIT license. 6 * so that the bulk of its code can remain under the MIT license. 7 7 * This exemption does not extend to derived works not owned by 8 8 * the Transmission project. … … 33 33 } 34 34 35 static int 36 getShadowInt( char ch, int * setme ) 37 { 38 const char * str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-"; 39 const char * pch = strchr( str, ch ); 40 if( !pch ) 41 return 0; 42 *setme = pch - str; 43 return 1; 44 } 35 static int 36 getShadowInt( char ch, int * setme ) 37 { 38 const char * str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-"; 39 const char * pch = strchr( str, ch ); 40 if( !pch ) 41 return 0; 42 *setme = pch - str; 43 return 1; 44 } 45 45 46 46 static int … … 111 111 * Mx-y-z-- 112 112 * Mx-yy-z- 113 */ 113 */ 114 114 return peer_id[2]=='-' 115 115 && peer_id[7]=='-' … … 182 182 id[6]=='Z' || id[6]=='X' ? "+" : "" ); 183 183 } 184 184 185 185 else if( !memcmp( id+1, "UT", 2 ) ) 186 186 { … … 193 193 strint(id+3,1), strint(id+4,1), strint(id+5,1), getMnemonicEnd(id[6]) ); 194 194 } 195 195 196 196 else if( !memcmp( id+1, "AZ", 2 ) ) 197 197 { … … 201 201 four_digits( buf, buflen, "Azureus", id+3 ); 202 202 } 203 203 204 204 else if( !memcmp( id+1, "KT", 2 ) ) 205 205 { … … 328 328 else if( !memcmp( id, "-aria2-", 7 ) ) no_version( buf, buflen, "aria2" ); 329 329 else if( !memcmp( id, "-FG", 3 ) ) two_major_two_minor( buf, buflen, "FlashGet", id+3 ); 330 331 /* Everything else */ 330 331 /* Everything else */ 332 332 else if( !memcmp( id, "S3", 2 ) && id[2] == '-' && id[4] == '-' && id[6] == '-' ) 333 333 { -
trunk/libtransmission/clients.h
r8561 r8889 4 4 * This file is licensed by the GPL version 2. Works owned by the 5 5 * Transmission project are granted a special exemption to clause 2(b) 6 * so that the bulk of its code can remain under the MIT license. 6 * so that the bulk of its code can remain under the MIT license. 7 7 * This exemption does not extend to derived works not owned by 8 8 * the Transmission project. -
trunk/libtransmission/completion.h
r8695 r8889 4 4 * This file is licensed by the GPL version 2. Works owned by the 5 5 * Transmission project are granted a special exemption to clause 2(b) 6 * so that the bulk of its code can remain under the MIT license. 6 * so that the bulk of its code can remain under the MIT license. 7 7 * This exemption does not extend to derived works not owned by 8 8 * the Transmission project. -
trunk/libtransmission/fdlimit.c
r8823 r8889 182 182 if( !success ) /* if nothing else works, do it the old-fashioned way */ 183 183 { 184 uint8_t buf[ 4096 ]; 185 memset( buf, 0, sizeof( buf ) ); 186 success = TRUE; 187 while ( success && ( length > 0 ) ) 188 { 189 const int thisPass = MIN( length, sizeof( buf ) ); 190 success = write( fd, buf, thisPass ) == thisPass; 191 length -= thisPass; 192 } 184 uint8_t buf[ 4096 ]; 185 memset( buf, 0, sizeof( buf ) ); 186 success = TRUE; 187 while ( success && ( length > 0 ) ) 188 { 189 const int thisPass = MIN( length, sizeof( buf ) ); 190 success = write( fd, buf, thisPass ) == thisPass; 191 length -= thisPass; 192 } 193 193 } 194 194 … … 317 317 if( preallocateFileFull( filename, desiredFileSize ) ) 318 318 tr_inf( _( "Preallocated file \"%s\"" ), filename ); 319 319 320 320 /* open the file */ 321 321 flags = doWrite ? ( O_RDWR | O_CREAT ) : O_RDONLY; … … 447 447 448 448 assert( winner >= 0 ); 449 449 450 450 if( fileIsOpen( &gFd->openFiles[winner] ) ) 451 451 { … … 577 577 if( s >= 0 ) 578 578 { 579 /* "The ss_family field of the sockaddr_storage structure will always 580 * align with the family field of any protocol-specific structure." */ 581 if( sock.ss_family == AF_INET ) 579 /* "The ss_family field of the sockaddr_storage structure will always 580 * align with the family field of any protocol-specific structure." */ 581 if( sock.ss_family == AF_INET ) 582 582 { 583 583 struct sockaddr_in *si; … … 585 585 s.dummy = sock; 586 586 si = &s.si; 587 addr->type = TR_AF_INET; 588 addr->addr.addr4.s_addr = si->sin_addr.s_addr; 589 *port = si->sin_port; 590 } 591 else 592 { 587 addr->type = TR_AF_INET; 588 addr->addr.addr4.s_addr = si->sin_addr.s_addr; 589 *port = si->sin_port; 590 } 591 else 592 { 593 593 struct sockaddr_in6 *si; 594 594 union { struct sockaddr_storage dummy; struct sockaddr_in6 si; } s; 595 595 s.dummy = sock; 596 596 si = &s.si; 597 addr->type = TR_AF_INET6; 597 addr->type = TR_AF_INET6; 598 598 addr->addr.addr6 = si->sin6_addr; 599 *port = si->sin6_port; 600 } 599 *port = si->sin6_port; 600 } 601 601 ++gFd->socketCount; 602 602 } -
trunk/libtransmission/handshake.c
r8767 r8889 77 77 #endif 78 78 79 #ifdef ENABLE_FAST 80 #define HANDSHAKE_HAS_FASTEXT( bits ) ( ( ( bits )[7] & 0x04 ) ? 1 : 0 ) 81 #define HANDSHAKE_SET_FASTEXT( bits ) ( ( bits )[7] |= 0x04 ) 82 #else 83 #define HANDSHAKE_HAS_FASTEXT( bits ) ( 0 ) 84 #define HANDSHAKE_SET_FASTEXT( bits ) ( (void)0 ) 85 #endif 79 #ifdef ENABLE_FAST 80 #define HANDSHAKE_HAS_FASTEXT( bits ) ( ( ( bits )[7] & 0x04 ) ? 1 : 0 ) 81 #define HANDSHAKE_SET_FASTEXT( bits ) ( ( bits )[7] |= 0x04 ) 82 #else 83 #define HANDSHAKE_HAS_FASTEXT( bits ) ( 0 ) 84 #define HANDSHAKE_SET_FASTEXT( bits ) ( (void)0 ) 85 #endif 86 86 87 87 #ifdef ENABLE_DHT … … 91 91 #define HANDSHAKE_HAS_DHT( bits ) ( 0 ) 92 92 #define HANDSHAKE_SET_DHT( bits ) ( (void)0 ) 93 #endif 93 #endif 94 94 95 95 /* http://www.azureuswiki.com/index.php/Extension_negotiation_protocol … … 1128 1128 success = fireDoneFunc( handshake, isOK ); 1129 1129 1130 tr_handshakeFree( handshake ); 1130 tr_handshakeFree( handshake ); 1131 1131 1132 1132 return success ? READ_LATER : READ_ERR; -
trunk/libtransmission/list.c
r8762 r8889 186 186 } 187 187 188 189 188 void 190 189 __tr_list_remove( struct __tr_list * head ) -
trunk/libtransmission/list.h
r8762 r8889 126 126 * __tr_list_remove() 127 127 * 128 * Remove @head from the list it is in. 128 * Remove @head from the list it is in. 129 129 */ 130 130 void -
trunk/libtransmission/metainfo.c
r8871 r8889 296 296 t->announce = tr_strdup( url ); 297 297 t->scrape = announceToScrape( url ); 298 298 299 299 anyAdded = TRUE; 300 300 } … … 302 302 } 303 303 } 304 304 305 305 if( anyAdded ) 306 306 ++validTiers; -
trunk/libtransmission/net.c
r8791 r8889 57 57 #endif 58 58 59 const tr_address tr_in6addr_any = { TR_AF_INET6, { IN6ADDR_ANY_INIT } }; 60 const tr_address tr_inaddr_any = { TR_AF_INET, { { { { INADDR_ANY, 0x00, 0x00, 0x00 } } } } }; 59 const tr_address tr_in6addr_any = { TR_AF_INET6, { IN6ADDR_ANY_INIT } }; 60 const tr_address tr_inaddr_any = { TR_AF_INET, { { { { INADDR_ANY, 0x00, 0x00, 0x00 } } } } }; 61 61 62 62 #ifdef WIN32 … … 130 130 } 131 131 132 const char * 133 tr_ntop( const tr_address * src, char * dst, int size ) 132 const char * 133 tr_ntop( const tr_address * src, char * dst, int size ) 134 134 { 135 135 assert( tr_isAddress( src ) ); 136 136 137 if( src->type == TR_AF_INET ) 138 return inet_ntop( AF_INET, &src->addr, dst, size ); 139 else 140 return inet_ntop( AF_INET6, &src->addr, dst, size ); 141 } 142 143 /* 144 * Non-threadsafe version of tr_ntop, which uses a static memory area for a buffer. 145 * This function is suitable to be called from libTransmission's networking code, 146 * which is single-threaded. 147 */ 148 const char * 149 tr_ntop_non_ts( const tr_address * src ) 150 { 151 static char buf[INET6_ADDRSTRLEN]; 152 return tr_ntop( src, buf, sizeof( buf ) ); 153 } 154 155 tr_address * 156 tr_pton( const char * src, tr_address * dst ) 157 { 158 int retval = inet_pton( AF_INET, src, &dst->addr ); 137 if( src->type == TR_AF_INET ) 138 return inet_ntop( AF_INET, &src->addr, dst, size ); 139 else 140 return inet_ntop( AF_INET6, &src->addr, dst, size ); 141 } 142 143 /* 144 * Non-threadsafe version of tr_ntop, which uses a static memory area for a buffer. 145 * This function is suitable to be called from libTransmission's networking code, 146 * which is single-threaded. 147 */ 148 const char * 149 tr_ntop_non_ts( const tr_address * src ) 150 { 151 static char buf[INET6_ADDRSTRLEN]; 152 return tr_ntop( src, buf, sizeof( buf ) ); 153 } 154 155 tr_address * 156 tr_pton( const char * src, tr_address * dst ) 157 { 158 int retval = inet_pton( AF_INET, src, &dst->addr ); 159 159 assert( dst ); 160 if( retval < 0 ) 161 return NULL; 162 else if( retval == 0 ) 163 retval = inet_pton( AF_INET6, src, &dst->addr ); 160 if( retval < 0 ) 161 return NULL; 162 else if( retval == 0 ) 163 retval = inet_pton( AF_INET6, src, &dst->addr ); 164 164 else 165 { 166 dst->type = TR_AF_INET; 167 return dst; 168 } 169 170 if( retval < 1 ) 171 return NULL; 172 dst->type = TR_AF_INET6; 173 return dst; 174 } 175 176 /* 177 * Compare two tr_address structures. 178 * Returns: 179 * <0 if a < b 180 * >0 if a > b 181 * 0 if a == b 182 */ 165 { 166 dst->type = TR_AF_INET; 167 return dst; 168 } 169 170 if( retval < 1 ) 171 return NULL; 172 dst->type = TR_AF_INET6; 173 return dst; 174 } 175 176 /* 177 * Compare two tr_address structures. 178 * Returns: 179 * <0 if a < b 180 * >0 if a > b 181 * 0 if a == b 182 */ 183 183 int 184 184 tr_compareAddresses( const tr_address * a, const tr_address * b) … … 189 189 assert( tr_isAddress( b ) ); 190 190 191 /* IPv6 addresses are always "greater than" IPv4 */ 191 /* IPv6 addresses are always "greater than" IPv4 */ 192 192 if( a->type != b->type ) 193 193 return a->type == TR_AF_INET ? 1 : -1; 194 194 195 195 return memcmp( &a->addr, &b->addr, sizes[a->type] ); 196 } 196 } 197 197 198 198 /*********************************************************************** … … 314 314 315 315 addrlen = setup_sockaddr( addr, port, &sock ); 316 316 317 317 /* set source address */ 318 318 source_addr = tr_sessionGetPublicAddress( session, addr->type ); -
trunk/libtransmission/peer-io.c
r8831 r8889 100 100 if( io->didWrite ) 101 101 io->didWrite( io, payload, next->isPieceData, io->userData ); 102 102 103 103 if( tr_isPeerIo( io ) ) 104 104 { … … 455 455 __tr_list_destroy( &io->outbuf_datatypes, trDatatypeFree ); 456 456 457 memset( io, ~0, sizeof( tr_peerIo ) ); 457 memset( io, ~0, sizeof( tr_peerIo ) ); 458 458 tr_free( io ); 459 459 } … … 511 511 static char buf[512]; 512 512 513 if( addr->type == TR_AF_INET ) 514 tr_snprintf( buf, sizeof( buf ), "%s:%u", tr_ntop_non_ts( addr ), ntohs( port ) ); 515 else 516 tr_snprintf( buf, sizeof( buf ), "[%s]:%u", tr_ntop_non_ts( addr ), ntohs( port ) ); 513 if( addr->type == TR_AF_INET ) 514 tr_snprintf( buf, sizeof( buf ), "%s:%u", tr_ntop_non_ts( addr ), ntohs( port ) ); 515 else 516 tr_snprintf( buf, sizeof( buf ), "[%s]:%u", tr_ntop_non_ts( addr ), ntohs( port ) ); 517 517 return buf; 518 518 } … … 547 547 tr_netClose( io->socket ); 548 548 549 io->socket = tr_netOpenTCP( io->session, &io->addr, io->port ); 549 io->socket = tr_netOpenTCP( io->session, &io->addr, io->port ); 550 550 if( io->socket >= 0 ) 551 551 { -
trunk/libtransmission/peer-mgr.c
r8879 r8889 48 48 /* minimum interval for refilling peers' request lists */ 49 49 REFILL_PERIOD_MSEC = 400, 50 50 51 51 /* how frequently to reallocate bandwidth */ 52 52 BANDWIDTH_PERIOD_MSEC = 500, … … 1079 1079 } 1080 1080 1081 /* update the stats */ 1081 /* update the stats */ 1082 1082 if( e->wasPieceData ) 1083 1083 tr_statsAddDownloaded( tor->session, e->length ); … … 1431 1431 const uint8_t * walk = compact; 1432 1432 tr_pex * pex = tr_new0( tr_pex, n ); 1433 1433 1434 1434 for( i = 0; i < n; ++i ) 1435 1435 { … … 1440 1440 pex[i].flags = added_f[i]; 1441 1441 } 1442 1442 1443 1443 *pexCount = n; 1444 1444 return pex; … … 1455 1455 const uint8_t * walk = array; 1456 1456 tr_pex * pex = tr_new0( tr_pex, n ); 1457 1457 1458 1458 for( i = 0 ; i < n ; i++ ) { 1459 1459 memcpy( &pex[i].addr, walk, sizeof( tr_address ) ); … … 1462 1462 walk += sizeof( tr_address ) + 2; 1463 1463 } 1464 1464 1465 1465 *pexCount = n; 1466 1466 return pex; … … 2509 2509 n += tr_ptrArraySize( &tor->torrentPeers->peers ); 2510 2510 2511 /* if there are too many, prune out the worst */ 2511 /* if there are too many, prune out the worst */ 2512 2512 if( n > max ) 2513 2513 { … … 2527 2527 } 2528 2528 } 2529 2529 2530 2530 /* sort 'em */ 2531 2531 sortPeersByLiveliness( peers, (void**)torrents, n, now ); -
trunk/libtransmission/peer-msgs.c
r8767 r8889 1101 1101 tr_free( pex ); 1102 1102 } 1103 1103 1104 1104 if( tr_bencDictFindRaw( &val, "added6", &added, &added_len ) ) 1105 1105 { … … 1116 1116 tr_free( pex ); 1117 1117 } 1118 1119 1118 } 1120 1119 … … 1754 1753 else 1755 1754 { 1756 dbgmsg( msgs, "sending block %u:%u->%u", req.index, req.offset, req.length ); 1755 dbgmsg( msgs, "sending block %u:%u->%u", req.index, req.offset, req.length ); 1757 1756 EVBUFFER_LENGTH(out) += req.length; 1758 1757 assert( EVBUFFER_LENGTH( out ) == msglen ); … … 2059 2058 tr_bencDictAddRaw( &val, "dropped", tmp, walk - tmp ); 2060 2059 tr_free( tmp ); 2061 2060 2062 2061 /* "added6" */ 2063 2062 tmp = walk = tr_new( uint8_t, diffs6.addedCount * 18 ); … … 2072 2071 tr_bencDictAddRaw( &val, "added6", tmp, walk - tmp ); 2073 2072 tr_free( tmp ); 2074 2073 2075 2074 /* "added6.f" */ 2076 2075 tmp = walk = tr_new( uint8_t, diffs6.addedCount ); … … 2080 2079 tr_bencDictAddRaw( &val, "added6.f", tmp, walk - tmp ); 2081 2080 tr_free( tmp ); 2082 2081 2083 2082 /* "dropped6" */ 2084 2083 tmp = walk = tr_new( uint8_t, diffs6.droppedCount * 18 ); -
trunk/libtransmission/platform.c
r8792 r8889 523 523 tr_free( tmp ); 524 524 return ret; 525 526 525 } 527 526 … … 555 554 556 555 s = tr_buildPath( appString, "Contents", "Resources", "web", NULL ); 557 556 558 557 if( !isClutchDir( s ) ) { 559 558 tr_free( s ); 560 559 561 560 /* Fallback to the Application Support folder */ 562 561 s = tr_buildPath( tr_sessionGetConfigDir( session ), "web", NULL ); … … 571 570 /* SHGetFolderPath explicitly requires MAX_PATH length */ 572 571 char dir[MAX_PATH]; 573 572 574 573 /* Generally, Web interface should be stored in a Web subdir of 575 574 * calling executable dir. */ 576 575 577 if( s == NULL ) { 576 if( s == NULL ) { 578 577 /* First, we should check personal AppData/Transmission/Web */ 579 578 SHGetFolderPath( NULL, CSIDL_COMMON_APPDATA, NULL, 0, dir ); -
trunk/libtransmission/platform.h
r8561 r8889 4 4 * This file is licensed by the GPL version 2. Works owned by the 5 5 * Transmission project are granted a special exemption to clause 2(b) 6 * so that the bulk of its code can remain under the MIT license. 6 * so that the bulk of its code can remain under the MIT license. 7 7 * This exemption does not extend to derived works not owned by 8 8 * the Transmission project. … … 33 33 /** 34 34 * @addtogroup utils Utilities 35 * @{ 35 * @{ 36 36 */ 37 37 -
trunk/libtransmission/request-list.c
r7622 r8889 70 70 list->sort, 71 71 list->len, 72 sizeof( struct peer_request ), 72 sizeof( struct peer_request ), 73 73 (compareFunc)compareRequests, 74 74 exactMatch ); -
trunk/libtransmission/resume.c
r8878 r8889 88 88 if( count > 0 ) 89 89 tr_bencDictAddRaw( dict, KEY_PEERS6, pex, sizeof( tr_pex ) * count ); 90 90 91 91 tr_free( pex ); 92 92 } … … 113 113 ret = TR_FR_PEERS; 114 114 } 115 115 116 116 if( tr_bencDictFindRaw( dict, KEY_PEERS6, &str, &len ) ) 117 117 { … … 639 639 if( fieldsToLoad & TR_FR_SPEEDLIMIT ) 640 640 fieldsLoaded |= loadSpeedLimits( &top, tor ); 641 641 642 642 if( fieldsToLoad & TR_FR_RATIOLIMIT ) 643 643 fieldsLoaded |= loadRatioLimits( &top, tor ); -
trunk/libtransmission/rpcimpl.c
r8871 r8889 1179 1179 int running = 0; 1180 1180 int total = 0; 1181 tr_benc * d; 1182 tr_session_stats currentStats = { 0.0f, 0, 0, 0, 0, 0 }; 1183 tr_session_stats cumulativeStats = { 0.0f, 0, 0, 0, 0, 0 }; 1181 tr_benc * d; 1182 tr_session_stats currentStats = { 0.0f, 0, 0, 0, 0, 0 }; 1183 tr_session_stats cumulativeStats = { 0.0f, 0, 0, 0, 0, 0 }; 1184 1184 tr_torrent * tor = NULL; 1185 1185 … … 1192 1192 } 1193 1193 1194 tr_sessionGetStats( session, ¤tStats ); 1195 tr_sessionGetCumulativeStats( session, &cumulativeStats ); 1194 tr_sessionGetStats( session, ¤tStats ); 1195 tr_sessionGetCumulativeStats( session, &cumulativeStats ); 1196 1196 1197 1197 tr_bencDictAddInt( args_out, "activeTorrentCount", running ); … … 1201 1201 tr_bencDictAddInt( args_out, "uploadSpeed", (int)( tr_sessionGetPieceSpeed( session, TR_UP ) * 1024 ) ); 1202 1202 1203 d = tr_bencDictAddDict( args_out, "cumulative-stats", 5 ); 1204 tr_bencDictAddInt( d, "downloadedBytes", cumulativeStats.downloadedBytes ); 1205 tr_bencDictAddInt( d, "filesAdded", cumulativeStats.filesAdded ); 1206 tr_bencDictAddInt( d, "secondsActive", cumulativeStats.secondsActive ); 1207 tr_bencDictAddInt( d, "sessionCount", cumulativeStats.sessionCount ); 1208 tr_bencDictAddInt( d, "uploadedBytes", cumulativeStats.uploadedBytes ); 1209 1210 d = tr_bencDictAddDict( args_out, "current-stats", 5 ); 1211 tr_bencDictAddInt( d, "downloadedBytes", currentStats.downloadedBytes ); 1212 tr_bencDictAddInt( d, "filesAdded", currentStats.filesAdded ); 1213 tr_bencDictAddInt( d, "secondsActive", currentStats.secondsActive ); 1214 tr_bencDictAddInt( d, "sessionCount", currentStats.sessionCount ); 1215 tr_bencDictAddInt( d, "uploadedBytes", currentStats.uploadedBytes ); 1203 d = tr_bencDictAddDict( args_out, "cumulative-stats", 5 ); 1204 tr_bencDictAddInt( d, "downloadedBytes", cumulativeStats.downloadedBytes ); 1205 tr_bencDictAddInt( d, "filesAdded", cumulativeStats.filesAdded ); 1206 tr_bencDictAddInt( d, "secondsActive", cumulativeStats.secondsActive ); 1207 tr_bencDictAddInt( d, "sessionCount", cumulativeStats.sessionCount ); 1208 tr_bencDictAddInt( d, "uploadedBytes", cumulativeStats.uploadedBytes ); 1209 1210 d = tr_bencDictAddDict( args_out, "current-stats", 5 ); 1211 tr_bencDictAddInt( d, "downloadedBytes", currentStats.downloadedBytes ); 1212 tr_bencDictAddInt( d, "filesAdded", currentStats.filesAdded ); 1213 tr_bencDictAddInt( d, "secondsActive", currentStats.secondsActive ); 1214 tr_bencDictAddInt( d, "sessionCount", currentStats.sessionCount ); 1215 tr_bencDictAddInt( d, "uploadedBytes", currentStats.uploadedBytes ); 1216 1216 1217 1217 return NULL; … … 1256 1256 switch( tr_sessionGetEncryption( s ) ) { 1257 1257 case TR_CLEAR_PREFERRED: str = "tolerated"; break; 1258 case TR_ENCRYPTION_REQUIRED: str = "required"; break; 1258 case TR_ENCRYPTION_REQUIRED: str = "required"; break; 1259 1259 default: str = "preferred"; break; 1260 1260 } -
trunk/libtransmission/session.c
r8888 r8889 316 316 minutes = tm.tm_hour*60 + tm.tm_min; 317 317 day = tm.tm_wday; 318 318 319 319 if( !toNextDay ) 320 320 withinTime = ( begin <= minutes ) && ( minutes < end ); 321 321 else /* goes past midnight */ 322 322 withinTime = ( begin <= minutes ) || ( minutes < end ); 323 323 324 324 if( !withinTime ) 325 325 return FALSE; 326 326 327 327 if( toNextDay && (minutes < end) ) 328 328 day = (day - 1) % 7; … … 795 795 assert( found ); 796 796 session->altSpeedTimeEnd = i; 797 797 798 798 found = tr_bencDictFindInt( &settings, TR_PREFS_KEY_ALT_SPEED_TIME_DAY, &i ); 799 799 assert( found ); … … 1102 1102 currentMinute = tm.tm_hour*60 + tm.tm_min; 1103 1103 day = tm.tm_wday; 1104 1104 1105 1105 isBeginTime = currentMinute == session->altSpeedTimeBegin; 1106 1106 isEndTime = currentMinute == session->altSpeedTimeEnd; … … 1110 1110 if( isEndTime && !isBeginTime && session->altSpeedTimeEnd < session->altSpeedTimeBegin ) 1111 1111 day = (day - 1) % 7; 1112 1112 1113 1113 isDay = ((1<<day) & session->altSpeedTimeDay) != 0; 1114 1114 … … 1168 1168 1169 1169 /*** 1170 **** Alternative speed limits that are used during scheduled times 1170 **** Alternative speed limits that are used during scheduled times 1171 1171 ***/ 1172 1172 … … 1189 1189 assert( tr_isDirection( d ) ); 1190 1190 1191 return s->altSpeed[d]; 1191 return s->altSpeed[d]; 1192 1192 } 1193 1193 … … 1302 1302 s->altSpeedEnabled = enabled; 1303 1303 s->altSpeedChangedByUser = byUser; 1304 1304 1305 1305 tr_runInEventThread( s, altSpeedToggled, s ); 1306 1306 } -
trunk/libtransmission/torrent.c
r8878 r8889 992 992 else if( s->ratio == TR_RATIO_NA ) 993 993 s->percentRatio = 0.0; 994 else 994 else 995 995 s->percentRatio = s->ratio / seedRatio; 996 996 … … 2283 2283 char * oldpath = tr_buildPath( tor->downloadDir, f->name, NULL ); 2284 2284 char * newpath = tr_buildPath( location, f->name, NULL ); 2285 2285 2286 2286 if( do_move ) 2287 2287 { -
trunk/libtransmission/tracker.c
r8878 r8889 254 254 tr_address addr; 255 255 tr_port port; 256 256 257 257 addr.type = TR_AF_INET; 258 258 memset( &addr.addr, 0x00, sizeof( addr.addr ) ); … … 262 262 memcpy( &addr.addr.addr4, compactWalk, 4 ); 263 263 memcpy( &port, compactWalk + 4, 2 ); 264 264 265 265 memcpy( walk, &addr, sizeof( addr ) ); 266 266 memcpy( walk + sizeof( addr ), &port, 2 ); 267 267 268 268 walk += sizeof( tr_address ) + 2; 269 269 compactWalk += 6; … … 286 286 tr_address addr; 287 287 tr_port port; 288 288 289 289 addr.type = TR_AF_INET6; 290 290 memset( &addr.addr, 0x00, sizeof( addr.addr ) ); … … 295 295 memcpy( &port, compactWalk + 16, 2 ); 296 296 compactWalk += 18; 297 297 298 298 memcpy( walk, &addr, sizeof( addr ) ); 299 299 memcpy( walk + sizeof( addr ), &port, 2 ); -
trunk/libtransmission/trevent.c
r8681 r8889 24 24 #ifdef WIN32 25 25 26 #include <WinSock2.h> 27 28 static int 29 pgpipe( int handles[2] ) 26 #include <WinSock2.h> 27 28 static int 29 pgpipe( int handles[2] ) 30 30 { 31 31 SOCKET s; 32 32 struct sockaddr_in serv_addr; 33 33 int len = sizeof( serv_addr ); 34 34 35 35 handles[0] = handles[1] = INVALID_SOCKET; 36 36 37 37 if ( ( s = socket( AF_INET, SOCK_STREAM, 0 ) ) == INVALID_SOCKET ) 38 38 { … … 40 40 return -1; 41 41 } 42 42 43 43 memset( &serv_addr, 0, sizeof( serv_addr ) ); 44 44 serv_addr.sin_family = AF_INET; … … 69 69 return -1; 70 70 } 71 71 72 72 if (connect(handles[1], (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR) 73 73 { … … 87 87 return 0; 88 88 } 89 90 static int 91 piperead( int s, char *buf, int len ) 92 { 93 int ret = recv(s, buf, len, 0); 94 95 if (ret < 0 && WSAGetLastError() == WSAECONNRESET) 96 /* EOF on the pipe! (win32 socket based implementation) */ 97 ret = 0; 98 return ret; 99 } 100 101 #define pipe(a) pgpipe(a) 102 #define pipewrite(a,b,c) send(a,(char*)b,c,0) 89 90 static int 91 piperead( int s, char *buf, int len ) 92 { 93 int ret = recv(s, buf, len, 0); 94 95 if (ret < 0 && WSAGetLastError() == WSAECONNRESET) 96 /* EOF on the pipe! (win32 socket based implementation) */ 97 ret = 0; 98 return ret; 99 } 100 101 #define pipe(a) pgpipe(a) 102 #define pipewrite(a,b,c) send(a,(char*)b,c,0) 103 103 104 104 #else 105 #define piperead(a,b,c) read(a,b,c) 106 #define pipewrite(a,b,c) write(a,b,c) 105 #define piperead(a,b,c) read(a,b,c) 106 #define pipewrite(a,b,c) write(a,b,c) 107 107 #endif 108 108 109 #include <unistd.h> 109 #include <unistd.h> 110 110 111 111 #include <event.h> -
trunk/libtransmission/utils.c
r8808 r8889 285 285 **** 286 286 ***/ 287 288 287 289 288 int … … 1249 1248 * array of setmeCount ints of all the values in the array. 1250 1249 * For example, "5-8" will return [ 5, 6, 7, 8 ] and setmeCount will be 4. 1251 * It's the caller's responsibility to call tr_free() on the returned array. 1250 * It's the caller's responsibility to call tr_free() on the returned array. 1252 1251 * If a fragment of the string can't be parsed, NULL is returned. 1253 1252 */ -
trunk/libtransmission/utils.h
r8825 r8889 4 4 * This file is licensed by the GPL version 2. Works owned by the 5 5 * Transmission project are granted a special exemption to clause 2(b) 6 * so that the bulk of its code can remain under the MIT license. 6 * so that the bulk of its code can remain under the MIT license. 7 7 * This exemption does not extend to derived works not owned by 8 8 * the Transmission project. … … 34 34 /** 35 35 * @addtogroup utils Utilities 36 * @{ 36 * @{ 37 37 */ 38 38 … … 115 115 do { if( ! ( test ) ) tr_assertImpl( __FILE__, __LINE__, #test, fmt, __VA_ARGS__ ); } while( 0 ) 116 116 #endif 117 117 118 118 int tr_msgLoggingIsActive( int level ); 119 119 … … 397 397 call with the decimal_places argument equal to the number of 398 398 decimal places in the printf()'s precision: 399 399 400 400 - printf("%.2f%%", 99.999 ) ==> "100.00%" 401 401 -
trunk/libtransmission/web.c
r8767 r8889 4 4 * This file is licensed by the GPL version 2. Works owned by the 5 5 * Transmission project are granted a special exemption to clause 2(b) 6 * so that the bulk of its code can remain under the MIT license. 6 * so that the bulk of its code can remain under the MIT license. 7 7 * This exemption does not extend to derived works not owned by 8 8 * the Transmission project. … … 333 333 add_tasks_from_queue( tr_web * g ) 334 334 { 335 while( ( g->still_running < MAX_CONCURRENT_TASKS ) 335 while( ( g->still_running < MAX_CONCURRENT_TASKS ) 336 336 && ( tr_list_size( g->easy_queue ) > 0 ) ) 337 337 { … … 525 525 /* call curl_global_init if we haven't done it already. 526 526 * try to enable ssl for https support; but if that fails, 527 * try a plain vanilla init */ 527 * try a plain vanilla init */ 528 528 if( curlInited == FALSE ) { 529 529 curlInited = TRUE; … … 531 531 curl_global_init( 0 ); 532 532 } 533 533 534 534 web = tr_new0( struct tr_web, 1 ); 535 535 web->multi = curl_multi_init( ); … … 625 625 { 626 626 struct http_msg * msg = bsearch( &code, 627 http_msg, 627 http_msg, 628 628 sizeof( http_msg ) / sizeof( http_msg[0] ), 629 629 sizeof( http_msg[0] ),
Note: See TracChangeset
for help on using the changeset viewer.