Ignore:
Timestamp:
Nov 29, 2009, 5:49:58 PM (12 years ago)
Author:
charles
Message:

(trunk libT) #2631 "Add webseed support to magnet links"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/magnet.c

    r9548 r9630  
    9494
    9595#define MAX_TRACKERS 64
     96#define MAX_WEBSEEDS 64
    9697
    9798tr_magnet_info *
     
    99100{
    100101    tr_bool got_checksum = FALSE;
    101     int announceCount = 0;
    102     char * announceURLs[MAX_TRACKERS];
     102    int trCount = 0;
     103    int wsCount = 0;
     104    char * tr[MAX_TRACKERS];
     105    char * ws[MAX_WEBSEEDS];
    103106    char * displayName = NULL;
    104107    uint8_t sha1[SHA_DIGEST_LENGTH];
     
    150153
    151154            if( ( keylen==2 ) && !memcmp( key, "tr", 2 ) )
    152                 announceURLs[announceCount++] = tr_http_unescape( val, vallen );
     155                tr[trCount++] = tr_http_unescape( val, vallen );
     156
     157            if( ( keylen==2 ) && !memcmp( key, "ws", 2 ) )
     158                ws[wsCount++] = tr_http_unescape( val, vallen );
    153159
    154160            walk = next != NULL ? next + 1 : NULL;
     
    160166        info = tr_new0( tr_magnet_info, 1 );
    161167        info->displayName = displayName;
    162         info->announceCount = announceCount;
    163         info->announceURLs = tr_memdup( announceURLs, sizeof(char*) * announceCount );
     168        info->trackerCount = trCount;
     169        info->trackers = tr_memdup( tr, sizeof(char*) * trCount );
     170        info->webseedCount = wsCount;
     171        info->webseeds = tr_memdup( ws, sizeof(char*) * wsCount );
    164172        memcpy( info->hash, sha1, sizeof(uint8_t) * SHA_DIGEST_LENGTH );
    165173    }
     
    175183        int i;
    176184
    177         for( i=0; i<info->announceCount; ++i )
    178             tr_free( info->announceURLs[i] );
     185        for( i=0; i<info->trackerCount; ++i )
     186            tr_free( info->trackers[i] );
     187        tr_free( info->trackers );
    179188
    180         tr_free( info->announceURLs );
     189        for( i=0; i<info->webseedCount; ++i )
     190            tr_free( info->webseeds[i] );
     191        tr_free( info->webseeds );
     192
    181193        tr_free( info->displayName );
    182194        tr_free( info );
Note: See TracChangeset for help on using the changeset viewer.