Ignore:
Timestamp:
Jun 11, 2008, 8:09:36 PM (14 years ago)
Author:
charles
Message:

#966: allow blocklist support in the daemon. add extra info in the man page explaining how to add blocklists.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bencode.c

    r6073 r6146  
    3434#include "transmission.h"
    3535#include "bencode.h"
     36#include "json.h"
    3637#include "list.h"
    3738#include "ptrarray.h"
     
    12221223***/
    12231224
    1224 int
    1225 tr_bencSaveFile( const char * filename,  const tr_benc * b )
     1225static int
     1226saveFile( const char * filename, const char * content, size_t len )
    12261227{
    12271228    int err = TR_OK;
    1228     int len;
    1229     char * content = tr_bencSave( b, &len );
    12301229    FILE * out = NULL;
    12311230
     
    12461245    if( !err )
    12471246        tr_dbg( "tr_bencSaveFile saved \"%s\"", filename );
    1248     tr_free( content );
    12491247    if( out )
    12501248        fclose( out );
     1249    return err;
     1250}
     1251
     1252int
     1253tr_bencSaveFile( const char * filename,  const tr_benc * b )
     1254{
     1255    int len;
     1256    char * content = tr_bencSave( b, &len );
     1257    const int err = saveFile( filename, content, len );
     1258    tr_free( content );
    12511259    return err;
    12521260}
     
    12631271    return ret;
    12641272}
     1273
     1274int
     1275tr_bencSaveJSONFile( const char * filename, const tr_benc * b )
     1276{
     1277    int len;
     1278    char * content = tr_bencSaveAsJSON( b, &len );
     1279    const int err = saveFile( filename, content, len );
     1280    tr_free( content );
     1281    return err;
     1282}
     1283
     1284int
     1285tr_bencLoadJSONFile( const char * filename, tr_benc * b )
     1286{
     1287    int ret;
     1288    size_t contentLen;
     1289    uint8_t * content = tr_loadFile( filename, &contentLen );
     1290    ret = content ? tr_jsonParse( content, contentLen, b, NULL )
     1291                  : TR_ERROR_IO_OTHER;
     1292    tr_free( content );
     1293    return ret;
     1294}
Note: See TracChangeset for help on using the changeset viewer.