Changeset 6600


Ignore:
Timestamp:
Aug 20, 2008, 6:42:45 PM (13 years ago)
Author:
charles
Message:

make tr_bencDictFindType() private.

Location:
trunk/libtransmission
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bencode.c

    r6591 r6600  
    381381}
    382382
    383 tr_benc*
     383static tr_benc*
    384384tr_bencDictFindType( tr_benc * val, const char * key, int type )
    385385{
  • trunk/libtransmission/bencode.h

    r6468 r6600  
    7777int       tr_bencDictFindDict( tr_benc * dict, const char * key, tr_benc ** setme );
    7878tr_benc * tr_bencDictFind( tr_benc * dict, const char * key );
    79 tr_benc * tr_bencDictFindType( tr_benc * dict, const char * key, int type );
    8079tr_benc * tr_bencDictFindFirst( tr_benc * dict, ... );
    8180
  • trunk/libtransmission/metainfo.c

    r6502 r6600  
    321321     * from the Metainfo file. Note that the value will be a bencoded
    322322     * dictionary, given the definition of the info key above. */
    323     if(( beInfo = tr_bencDictFindType( meta, "info", TYPE_DICT )))
     323    if( tr_bencDictFindDict( meta, "info", &beInfo ) )
    324324    {
    325325        int len;
  • trunk/libtransmission/peer-msgs.c

    r6595 r6600  
    981981parseLtepHandshake( tr_peermsgs * msgs, int len, struct evbuffer * inbuf )
    982982{
     983    int64_t i;
    983984    tr_benc val, * sub;
    984985    uint8_t * tmp = tr_new( uint8_t, len );
     
    996997
    997998    /* does the peer prefer encrypted connections? */
    998     if(( sub = tr_bencDictFindType( &val, "e", TYPE_INT )))
    999         msgs->info->encryption_preference = sub->val.i
    1000                                       ? ENCRYPTION_PREFERENCE_YES
    1001                                       : ENCRYPTION_PREFERENCE_NO;
     999    if( tr_bencDictFindInt( &val, "e", &i ) )
     1000        msgs->info->encryption_preference = i ? ENCRYPTION_PREFERENCE_YES
     1001                                              : ENCRYPTION_PREFERENCE_NO;
    10021002
    10031003    /* check supported messages for utorrent pex */
    10041004    msgs->peerSupportsPex = 0;
    1005     if(( sub = tr_bencDictFindType( &val, "m", TYPE_DICT ))) {
    1006         if(( sub = tr_bencDictFindType( sub, "ut_pex", TYPE_INT ))) {
    1007             msgs->ut_pex_id = (uint8_t) sub->val.i;
     1005    if( tr_bencDictFindDict( &val, "m", &sub ) ) {
     1006        if( tr_bencDictFindInt( sub, "ut_pex", &i ) ) {
     1007            msgs->ut_pex_id = (uint8_t) i;
    10081008            msgs->peerSupportsPex = msgs->ut_pex_id == 0 ? 0 : 1;
    10091009            dbgmsg( msgs, "msgs->ut_pex is %d", (int)msgs->ut_pex_id );
     
    10121012
    10131013    /* get peer's listening port */
    1014     if(( sub = tr_bencDictFindType( &val, "p", TYPE_INT ))) {
    1015         msgs->info->port = htons( (uint16_t)sub->val.i );
     1014    if( tr_bencDictFindInt( &val, "p", &i ) ) {
     1015        msgs->info->port = htons( (uint16_t)i );
    10161016        dbgmsg( msgs, "msgs->port is now %hu", msgs->info->port );
    10171017    }
     
    10261026    int loaded = 0;
    10271027    uint8_t * tmp = tr_new( uint8_t, msglen );
    1028     tr_benc val, *added;
     1028    tr_benc val;
    10291029    const tr_torrent * tor = msgs->torrent;
     1030    const uint8_t * added;
     1031    size_t added_len;
     1032
    10301033    tr_peerIoReadBytes( msgs->io, inbuf, tmp, msglen );
    10311034
    10321035    if( tr_torrentAllowsPex( tor )
    10331036        && (( loaded = !tr_bencLoad( tmp, msglen, &val, NULL )))
    1034         && (( added = tr_bencDictFindType( &val, "added", TYPE_STR ))))
     1037        && tr_bencDictFindRaw( &val, "added", &added, &added_len ) )
    10351038    {
    10361039        const uint8_t * added_f = NULL;
     
    10391042        size_t added_f_len = 0;
    10401043        tr_bencDictFindRaw( &val, "added.f", &added_f, &added_f_len );
    1041         pex = tr_peerMgrCompactToPex( added->val.s.s, added->val.s.i, added_f, added_f_len, &n );
     1044        pex = tr_peerMgrCompactToPex( added, added_len, added_f, added_f_len, &n );
    10421045        for( i=0; i<n; ++i )
    10431046            tr_peerMgrAddPex( msgs->session->peerMgr, tor->info.hash,
  • trunk/libtransmission/resume.c

    r6334 r6600  
    7878{
    7979    uint64_t ret = 0;
    80     tr_benc * p;
    81 
    82     if(( p = tr_bencDictFindType( dict, KEY_PEERS, TYPE_STR )))
     80    const uint8_t * str;
     81    size_t len;
     82
     83    if( tr_bencDictFindRaw( dict, KEY_PEERS, &str, &len ) )
    8384    {
    8485        int i;
    85         const char * str = p->val.s.s;
    86         const size_t len = p->val.s.i;
    8786        const int count = len / sizeof( tr_pex );
    8887        for( i=0; i<count; ++i ) {
     
    284283    if( tr_bencDictFindDict( dict, KEY_PROGRESS, &p ) )
    285284    {
     285        const uint8_t * raw;
     286        size_t rawlen;
    286287        tr_benc * m;
    287         tr_benc * b;
    288288        int n;
    289289        time_t * curMTimes = tr_torrentGetMTimes( tor, &n );
     
    317317        }
    318318
    319         if(( b = tr_bencDictFindType( p, KEY_PROGRESS_BITFIELD, TYPE_STR )))
     319        if( tr_bencDictFindRaw( p, KEY_PROGRESS_BITFIELD, &raw, &rawlen ) )
    320320        {
    321321            tr_bitfield tmp;
    322             tmp.byteCount = b->val.s.i;
     322            tmp.byteCount = rawlen;
    323323            tmp.bitCount = tmp.byteCount * 8;
    324             tmp.bits = (uint8_t*) b->val.s.s;
     324            tmp.bits = (uint8_t*) raw;
    325325            if( tr_cpBlockBitfieldSet( tor->completion, &tmp ) ) {
    326326                tr_torrentUncheck( tor );
  • trunk/libtransmission/torrent-ctor.c

    r6425 r6600  
    107107    /* if no `name' field was set, then set it from the filename */
    108108    if( ctor->isSet_metainfo ) {
    109         tr_benc * info = tr_bencDictFindType( &ctor->metainfo, "info", TYPE_DICT );
    110         if( info ) {
     109        tr_benc * info;
     110        if( tr_bencDictFindDict( &ctor->metainfo, "info", &info ) ) {
    111111            tr_benc * name = tr_bencDictFindFirst( info, "name.utf-8", "name", NULL );
    112112            if( name == NULL )
Note: See TracChangeset for help on using the changeset viewer.