Changeset 5356
- Timestamp:
- Mar 24, 2008, 3:58:06 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/makemeta-ui.c
r5314 r5356 93 93 if( ui->builder->failed ) 94 94 { 95 const char * reason = ui->builder->abortFlag 96 ? _("Torrent creation cancelled") 97 : _("Torrent creation failed"); 98 95 char * reason = ui->builder->abortFlag 96 ? g_strdup( _( "Torrent creation cancelled" ) ) 97 : g_strdup_printf( _( "Torrent creation failed: %s" ), ui->builder->error ); 99 98 gtk_progress_bar_set_text( p, reason ); 100 99 gtk_progress_bar_set_fraction( p, 0 ); 100 g_free( reason ); 101 101 } 102 102 else -
trunk/libtransmission/makemeta.c
r5221 r5356 206 206 fp = fopen( b->files[fileIndex].filename, "rb" ); 207 207 if( !fp ) { 208 tr_err( _( "Couldn't open \"%s\": %s" ), b->files[fileIndex].filename, tr_strerror( errno ) ); 208 snprintf( b->error, sizeof( b->error ), _( "Couldn't open \"%s\": %s" ), b->files[fileIndex].filename, tr_strerror( errno ) ); 209 tr_err( "%s", b->error ); 209 210 tr_free( ret ); 210 211 b->failed = 1; … … 235 236 fp = fopen( b->files[fileIndex].filename, "rb" ); 236 237 if( !fp ) { 237 tr_err( _( "Couldn't open \"%s\": %s" ), b->files[fileIndex].filename, tr_strerror( errno ) ); 238 snprintf( b->error, sizeof( b->error ), 239 _( "Couldn't open \"%s\": %s" ), 240 b->files[fileIndex].filename, tr_strerror( errno ) ); 241 tr_err( "%s", b->error ); 238 242 tr_free( ret ); 239 243 b->failed = 1; … … 250 254 251 255 if( b->abortFlag ) { 256 snprintf( b->error, sizeof( b->error ), _( "Torrent creation cancelled" ) ); 252 257 b->failed = 1; 253 258 break; … … 367 372 } 368 373 369 static void tr_realMakeMetaInfo ( tr_metainfo_builder * builder ) 374 static void 375 tr_realMakeMetaInfo ( tr_metainfo_builder * builder ) 370 376 { 371 377 int n = 5; … … 378 384 val = tr_bencDictAdd( &top, "announce" ); 379 385 tr_bencInitStrDup( val, builder->announce ); 386 if( tr_httpParseUrl( builder->announce, -1, NULL, NULL, NULL ) ) 387 { 388 snprintf( builder->error, sizeof( builder->error ), _( "Invalid announce URL" ) ); 389 tr_err( "%s", builder->error ); 390 builder->failed = 1; 391 } 380 392 381 if( builder->comment && *builder->comment ) { 382 val = tr_bencDictAdd( &top, "comment" ); 383 tr_bencInitStrDup( val, builder->comment ); 384 } 385 386 val = tr_bencDictAdd( &top, "created by" ); 387 tr_bencInitStrDup( val, TR_NAME "/" LONG_VERSION_STRING ); 388 389 val = tr_bencDictAdd( &top, "creation date" ); 390 tr_bencInitInt( val, time(0) ); 391 392 val = tr_bencDictAdd( &top, "encoding" ); 393 tr_bencInitStrDup( val, "UTF-8" ); 394 395 val = tr_bencDictAdd( &top, "info" ); 396 tr_bencInit( val, TYPE_DICT ); 397 tr_bencDictReserve( val, 666 ); 398 makeInfoDict( val, builder ); 393 if( !builder->failed && !builder->abortFlag ) 394 { 395 if( builder->comment && *builder->comment ) { 396 val = tr_bencDictAdd( &top, "comment" ); 397 tr_bencInitStrDup( val, builder->comment ); 398 } 399 400 val = tr_bencDictAdd( &top, "created by" ); 401 tr_bencInitStrDup( val, TR_NAME "/" LONG_VERSION_STRING ); 402 403 val = tr_bencDictAdd( &top, "creation date" ); 404 tr_bencInitInt( val, time(0) ); 405 406 val = tr_bencDictAdd( &top, "encoding" ); 407 tr_bencInitStrDup( val, "UTF-8" ); 408 409 val = tr_bencDictAdd( &top, "info" ); 410 tr_bencInit( val, TYPE_DICT ); 411 tr_bencDictReserve( val, 666 ); 412 makeInfoDict( val, builder ); 413 } 399 414 400 415 /* save the file */ … … 404 419 FILE * fp = fopen( builder->outputFile, "wb+" ); 405 420 nmemb = n; 406 if( fp == NULL ) 421 if( fp == NULL ) { 422 snprintf( builder->error, sizeof( builder->error ), _( "Couldn't open \"%s\": %s" ), builder->outputFile, tr_strerror( errno ) ); 423 tr_err( "%s", builder->error ); 407 424 builder->failed = 1; 408 else if( fwrite( pch, 1, nmemb, fp ) != nmemb ) 425 } else if( fwrite( pch, 1, nmemb, fp ) != nmemb ) { 426 snprintf( builder->error, sizeof( builder->error ), _( "Couldn't save file \"%s\": %s" ), builder->outputFile, tr_strerror( errno ) ); 427 tr_err( "%s", builder->error ); 409 428 builder->failed = 1; 429 fclose( fp ); 430 } 410 431 tr_free( pch ); 411 fclose( fp );412 432 } 413 433 -
trunk/libtransmission/makemeta.h
r4404 r5356 59 59 int isDone; 60 60 int failed; /* only meaningful if isDone is set */ 61 char error[1024]; /* only meaningful if failed is set */ 61 62 62 63 /** -
trunk/libtransmission/metainfo.c
r5337 r5356 33 33 #include <unistd.h> /* unlink, stat */ 34 34 35 #include <miniupnp/miniwget.h> /* parseURL */36 37 35 #include "transmission.h" 38 36 #include "bencode.h" … … 42 40 #include "trcompat.h" /* strlcpy */ 43 41 #include "utils.h" 44 45 46 static int47 tr_httpParseUrl( const char * url_in, int len,48 char ** setme_host, int * setme_port, char ** setme_path )49 {50 char * url = tr_strndup( url_in, len );51 char * path;52 char host[4096+1];53 unsigned short port;54 int success;55 56 success = parseURL( url, host, &port, &path );57 58 if( success ) {59 *setme_host = tr_strdup( host );60 *setme_port = port;61 *setme_path = tr_strdup( path );62 }63 64 tr_free( url );65 66 return !success;67 }68 42 69 43 /*********************************************************************** -
trunk/libtransmission/utils.c
r5300 r5356 44 44 #endif 45 45 46 #include <miniupnp/miniwget.h> /* parseURL */ 47 46 48 #include "transmission.h" 47 49 #include "trcompat.h" … … 974 976 *out = '\0'; 975 977 } 978 979 /*** 980 **** 981 ***/ 982 983 int 984 tr_httpParseUrl( const char * url_in, int len, 985 char ** setme_host, 986 int * setme_port, 987 char ** setme_path ) 988 { 989 char * url = tr_strndup( url_in, len ); 990 char * path; 991 char host[4096+1]; 992 unsigned short port; 993 int success; 994 995 success = parseURL( url, host, &port, &path ); 996 997 if( success ) { 998 if( setme_host ) *setme_host = tr_strdup( host ); 999 if( setme_port ) *setme_port = port; 1000 if( setme_path ) *setme_path = tr_strdup( path ); 1001 } 1002 1003 tr_free( url ); 1004 1005 return !success; 1006 } 1007 -
trunk/libtransmission/utils.h
r5291 r5356 163 163 void tr_sha1_to_hex( char * out, const uint8_t * sha1 ); 164 164 165 166 int tr_httpParseUrl( const char * url, 167 int url_len, 168 char ** setme_host, 169 int * setme_port, 170 char ** setme_path ); 171 172 165 173 /*** 166 174 ****
Note: See TracChangeset
for help on using the changeset viewer.