Changeset 6306 for trunk/cli/cli.c


Ignore:
Timestamp:
Jul 9, 2008, 3:31:35 PM (14 years ago)
Author:
charles
Message:

code cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/cli.c

    r6302 r6306  
    5555static sig_atomic_t  manualUpdate     = 0;
    5656
    57 static const char   * torrentPath   = NULL;
    58 static const char   * downloadDir   = NULL;
     57static const char   * torrentPath  = NULL;
     58static const char   * downloadDir  = NULL;
    5959static const char   * finishCall   = NULL;
    6060static const char   * announce     = NULL;
     
    166166                  inf->pieceSize, inf->totalSize % inf->pieceSize );
    167167
    168     if( inf->comment[0] )
     168    if( inf->comment && *inf->comment )
    169169        fprintf( out, "comment:\t%s\n", inf->comment );
    170     if( inf->creator[0] )
     170    if( inf->creator && *inf->creator )
    171171        fprintf( out, "creator:\t%s\n", inf->creator );
    172172    if( inf->isPrivate )
     
    175175    fprintf( out, "file(s):\n" );
    176176    for( ff=0; ff<inf->fileCount; ++ff )
    177         fprintf( out, "\t%s (%"PRIu64")\n", inf->files[ff].name, inf->files[ff].length );
     177        fprintf( out, "\t%s (%"PRIu64")\n", inf->files[ff].name,
     178                                            inf->files[ff].length );
    178179}
    179180
     
    214215                  st->rateUpload, ratioStr );
    215216    }
    216     else if( st->status & TR_STATUS_STOPPED )
    217     {
    218         *buf = '\0';
    219     }
     217    else *buf = '\0';
    220218}
    221219
     
    297295    {
    298296        int err;
    299         tr_metainfo_builder * builder = tr_metaInfoBuilderCreate( h, sourceFile );
     297        tr_metainfo_builder * b = tr_metaInfoBuilderCreate( h, sourceFile );
    300298        tr_tracker_info ti;
    301299        ti.tier = 0;
    302300        ti.announce = (char*) announce;
    303         tr_makeMetaInfo( builder, torrentPath, &ti, 1, comment, isPrivate );
    304         while( !builder->isDone ) {
     301        tr_makeMetaInfo( b, torrentPath, &ti, 1, comment, isPrivate );
     302        while( !b->isDone ) {
    305303            tr_wait( 1000 );
    306304            printf( "." );
    307305        }
    308         err = builder->result;
    309         tr_metaInfoBuilderFree( builder );
     306        err = b->result;
     307        tr_metaInfoBuilderFree( b );
    310308        return err;
    311309    }
     
    339337                    ++leftToScrape;
    340338                    tr_webRun( h, url, NULL, scrapeDoneFunc, host );
     339                    tr_free( host );
    341340                    tr_free( url );
    342341                }
     
    394393        if( gotsig ) {
    395394            gotsig = 0;
    396 fprintf( stderr, "stopping torrent...\n" );
     395            printf( "stopping torrent...\n" );
    397396            tr_torrentStop( tor );
    398397        }
     
    401400            manualUpdate = 0;
    402401            if ( !tr_torrentCanManualUpdate( tor ) )
    403                 fprintf( stderr, "\rReceived SIGHUP, but can't send a manual update now\n" );
     402                fprintf( stderr, "\nReceived SIGHUP, but can't send a manual update now\n" );
    404403            else {
    405                 fprintf( stderr, "\rReceived SIGHUP: manual update scheduled\n" );
     404                fprintf( stderr, "\nReceived SIGHUP: manual update scheduled\n" );
    406405                tr_torrentManualUpdate( tor );
    407406            }
     
    413412
    414413        getStatusStr( st, line, sizeof( line ) );
    415         printf( "%-*s\n", LINEWIDTH, line );
     414        printf( "\r%-*s", LINEWIDTH, line );
    416415        if( st->error )
    417             printf( "%s\n", st->errorString );
     416            printf( "\n%s\n", st->errorString );
    418417    }
    419418
Note: See TracChangeset for help on using the changeset viewer.