Changeset 5810


Ignore:
Timestamp:
May 11, 2008, 10:42:53 PM (13 years ago)
Author:
charles
Message:

add json-to-benc parser

Location:
trunk/libtransmission
Files:
6 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/Makefile.am

    r5788 r5810  
    55
    66libtransmission_a_SOURCES = \
     7    ConvertUTF.c \
     8    JSON_checker.c \
    79    bencode.c \
    810    blocklist.c \
     
    1618    inout.c \
    1719    ipcparse.c \
     20    json.c \
    1821    list.c \
    1922    makemeta.c \
     
    4245
    4346noinst_HEADERS = \
     47    ConvertUTF.h \
     48    JSON_checker.h \
    4449    bencode.h \
    4550    blocklist.h \
     
    8691    bencode-test \
    8792    clients-test \
     93    json-test \
    8894    test-fastset \
    8995    test-peer-id
     
    110116clients_test_SOURCES = clients-test.c
    111117clients_test_LDADD = $(APPS_LDADD)
     118json_test_SOURCES = json-test.c
     119json_test_LDADD = $(APPS_LDADD)
    112120test_fastset_SOURCES = test-fastset.c
    113121test_fastset_LDADD = $(APPS_LDADD)
  • trunk/libtransmission/bencode.c

    r5772 r5810  
    592592
    593593    assert( tr_bencIsDict( dict ) );
     594    if( dict->val.l.count + 2 > dict->val.l.alloc )
     595        makeroom( dict, 2 );
    594596    assert( dict->val.l.count + 2 <= dict->val.l.alloc );
    595597
    596598    keyval = dict->val.l.vals + dict->val.l.count++;
    597     tr_bencInitStr( keyval, (char*)key, -1, 1 );
     599    tr_bencInitStrDup( keyval, key );
    598600
    599601    itemval = dict->val.l.vals + dict->val.l.count++;
  • trunk/libtransmission/bencode.h

    r5772 r5810  
    5757typedef tr_benc benc_val_t;
    5858
     59int tr_jsonParse( const void      * buf,
     60                  const void      * bufend,
     61                  tr_benc         * setme_benc,
     62                  const uint8_t  ** setme_end );
     63
    5964int tr_bencParse( const void      * buf,
    6065                  const void      * bufend,
     
    103108tr_benc    * tr_bencListAddList( tr_benc  * list, int reserveCount );
    104109tr_benc    * tr_bencListAddDict( tr_benc  * list, int reserveCount );
    105 /* note: key must not be freed or modified while val is in use */
    106110tr_benc    * tr_bencDictAdd( tr_benc * dict, const char * key );
    107111tr_benc    * tr_bencDictAddDouble( tr_benc * dict, const char * key, double d );
Note: See TracChangeset for help on using the changeset viewer.