Ignore:
Timestamp:
Jul 15, 2008, 5:16:57 PM (13 years ago)
Author:
charles
Message:

add a portability wrapper tr_snprintf() around snprintf()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bencode-test.c

    r5901 r6334  
    3131
    3232    /* good int string */
    33     snprintf( (char*)buf, sizeof( buf ), "i64e" );
     33    tr_snprintf( (char*)buf, sizeof( buf ), "i64e" );
    3434    err = tr_bencParseInt( buf, buf+4, &end, &val );
    3535    check( err == 0 );
     
    5252
    5353    /* bad number */
    54     snprintf( (char*)buf, sizeof( buf ), "i6z4e" );
     54    tr_snprintf( (char*)buf, sizeof( buf ), "i6z4e" );
    5555    err = tr_bencParseInt( buf, buf+5, &end, &val );
    5656    check( err == TR_ERROR );
     
    5959
    6060    /* negative number */
    61     snprintf( (char*)buf, sizeof( buf ), "i-3e" );
     61    tr_snprintf( (char*)buf, sizeof( buf ), "i-3e" );
    6262    err = tr_bencParseInt( buf, buf+4, &end, &val );
    6363    check( err == TR_OK );
     
    6666
    6767    /* zero */
    68     snprintf( (char*)buf, sizeof( buf ), "i0e" );
     68    tr_snprintf( (char*)buf, sizeof( buf ), "i0e" );
    6969    err = tr_bencParseInt( buf, buf+4, &end, &val );
    7070    check( err == TR_OK );
     
    7575    val = 0;
    7676    end = NULL;
    77     snprintf( (char*)buf, sizeof( buf ), "i04e" );
     77    tr_snprintf( (char*)buf, sizeof( buf ), "i04e" );
    7878    err = tr_bencParseInt( buf, buf+4, &end, &val );
    7979    check( err == TR_ERROR );
     
    9494
    9595    /* good string */
    96     snprintf( (char*)buf, sizeof( buf ), "4:boat" );
     96    tr_snprintf( (char*)buf, sizeof( buf ), "4:boat" );
    9797    err = tr_bencParseStr( buf, buf+6, &end, &str, &len );
    9898    check( err == TR_OK );
     
    113113
    114114    /* empty string */
    115     snprintf( (char*)buf, sizeof( buf ), "0:" );
     115    tr_snprintf( (char*)buf, sizeof( buf ), "0:" );
    116116    err = tr_bencParseStr( buf, buf+2, &end, &str, &len );
    117117    check( err == TR_OK );
     
    125125
    126126    /* short string */
    127     snprintf( (char*)buf, sizeof( buf ), "3:boat" );
     127    tr_snprintf( (char*)buf, sizeof( buf ), "3:boat" );
    128128    err = tr_bencParseStr( buf, buf+6, &end, &str, &len );
    129129    check( err == TR_OK );
     
    179179    char * saved;
    180180
    181     snprintf( (char*)buf, sizeof( buf ), "i64e" );
     181    tr_snprintf( (char*)buf, sizeof( buf ), "i64e" );
    182182    err = tr_bencParse( buf, buf + sizeof( buf ), &val, &end );
    183183    check( !err );
     
    187187    tr_bencFree( &val );
    188188
    189     snprintf( (char*)buf, sizeof( buf ), "li64ei32ei16ee" );
     189    tr_snprintf( (char*)buf, sizeof( buf ), "li64ei32ei16ee" );
    190190    err = tr_bencParse( buf, buf + sizeof( buf ), &val, &end );
    191191    check( !err );
     
    204204
    205205    end = NULL;
    206     snprintf( (char*)buf, sizeof( buf ), "lllee" );
     206    tr_snprintf( (char*)buf, sizeof( buf ), "lllee" );
    207207    err = tr_bencParse( buf, buf + strlen( (char*)buf ), &val , &end );
    208208    check( err );
     
    210210
    211211    end = NULL;
    212     snprintf( (char*)buf, sizeof( buf ), "le" );
     212    tr_snprintf( (char*)buf, sizeof( buf ), "le" );
    213213    err = tr_bencParse( buf, buf + sizeof( buf ), &val , &end );
    214214    check( !err );
     
    242242     * save as a sorted dict */
    243243    end = NULL;
    244     snprintf( (char*)buf, sizeof( buf ), "lld1:bi32e1:ai64eeee" );
     244    tr_snprintf( (char*)buf, sizeof( buf ), "lld1:bi32e1:ai64eeee" );
    245245    err = tr_bencParse( buf, buf + sizeof( buf ), &val, &end );
    246246    check( !err );
     
    255255    /* too many endings */
    256256    end = NULL;
    257     snprintf( (char*)buf, sizeof( buf ), "leee" );
     257    tr_snprintf( (char*)buf, sizeof( buf ), "leee" );
    258258    err = tr_bencParse( buf, buf + sizeof( buf ), &val, &end );
    259259    check( !err );
     
    266266    /* no ending */
    267267    end = NULL;
    268     snprintf( (char*)buf, sizeof( buf ), "l1:a1:b1:c" );
     268    tr_snprintf( (char*)buf, sizeof( buf ), "l1:a1:b1:c" );
    269269    err = tr_bencParse( buf, buf + strlen( (char*)buf ), &val, &end );
    270270    check( err );
     
    272272    /* incomplete string */
    273273    end = NULL;
    274     snprintf( (char*)buf, sizeof( buf ), "1:" );
     274    tr_snprintf( (char*)buf, sizeof( buf ), "1:" );
    275275    err = tr_bencParse( buf, buf + strlen( (char*)buf ), &val, &end );
    276276    check( err );
Note: See TracChangeset for help on using the changeset viewer.