more housekeeping: benc_val_t --> tr_benc

This commit is contained in:
Charles Kerr
2008-02-26 21:58:58 +00:00
parent 325665caa2
commit 8cc587a66f
18 changed files with 216 additions and 218 deletions

View File

@@ -39,6 +39,7 @@
#include <libtransmission/bencode.h>
#include <libtransmission/ipcparse.h>
#include <libtransmission/trcompat.h>
#include <libtransmission/version.h>
#include "bsdqueue.h"
#include "client.h"

View File

@@ -300,9 +300,9 @@ translate_08_to_09( const char* oldfile, const char* newfile )
GString * out = g_string_new( NULL );
gchar * contents = NULL;
gsize contents_len = 0;
benc_val_t top;
tr_benc top;
memset( &top, 0, sizeof(benc_val_t) );
memset( &top, 0, sizeof(tr_benc) );
if( g_file_get_contents( oldfile, &contents, &contents_len, NULL )
&& !tr_bencLoad( contents, contents_len, &top, NULL )
@@ -311,7 +311,7 @@ translate_08_to_09( const char* oldfile, const char* newfile )
unsigned int i;
g_string_append( out, "\n[general]\n" );
for ( i=0; i<G_N_ELEMENTS(pref_table); ++i ) {
const benc_val_t * val = tr_bencDictFind( &top, pref_table[i].oldkey );
const tr_benc * val = tr_bencDictFind( &top, pref_table[i].oldkey );
if( val != NULL ) {
const char * valstr = val->val.s.s;
if( !strcmp( valstr, "yes" ) ) valstr = "true";

View File

@@ -47,8 +47,6 @@ void pref_save ( char **errstr );
***
**/
struct benc_val_s;
gboolean
cf_init(const char *confdir, char **errstr);
gboolean

View File

@@ -111,7 +111,7 @@ simpleresp( struct constate * con, int64_t tag, enum ipc_msg id )
}
static void
all_default( enum ipc_msg id, benc_val_t * val UNUSED, int64_t tag, void * arg )
all_default( enum ipc_msg id, tr_benc * val UNUSED, int64_t tag, void * arg )
{
switch( id )
{
@@ -164,7 +164,7 @@ client_sendmsg( struct constate * con )
GList * ii;
uint8_t * buf;
size_t size;
benc_val_t packet, * val;
tr_benc packet, * val;
int saved;
switch( cli->msg )
@@ -491,11 +491,11 @@ serv_bind(struct constate *con) {
}
static void
smsg_add( enum ipc_msg id UNUSED, benc_val_t * val, int64_t tag, void * arg )
smsg_add( enum ipc_msg id UNUSED, tr_benc * val, int64_t tag, void * arg )
{
struct constate * con = arg;
struct constate_serv * srv = &con->u.serv;
benc_val_t * path;
tr_benc * path;
int ii;
tr_ctor * ctor;
GList * list = NULL;
@@ -529,12 +529,12 @@ smsg_add( enum ipc_msg id UNUSED, benc_val_t * val, int64_t tag, void * arg )
}
static void
smsg_addone( enum ipc_msg id UNUSED, benc_val_t * val, int64_t tag,
smsg_addone( enum ipc_msg id UNUSED, tr_benc * val, int64_t tag,
void * arg )
{
struct constate * con = arg;
struct constate_serv * srv = &con->u.serv;
benc_val_t * file, * data, * dir, * start;
tr_benc * file, * data, * dir, * start;
tr_ctor * ctor;
if( NULL == val || TYPE_DICT != val->type )
@@ -576,7 +576,7 @@ smsg_addone( enum ipc_msg id UNUSED, benc_val_t * val, int64_t tag,
}
static void
smsg_quit( enum ipc_msg id UNUSED, benc_val_t * val UNUSED, int64_t tag UNUSED,
smsg_quit( enum ipc_msg id UNUSED, tr_benc * val UNUSED, int64_t tag UNUSED,
void * arg UNUSED )
{
struct constate * con = arg;
@@ -586,7 +586,7 @@ smsg_quit( enum ipc_msg id UNUSED, benc_val_t * val UNUSED, int64_t tag UNUSED,
}
static void
smsg_noop( enum ipc_msg id UNUSED, benc_val_t * val UNUSED, int64_t tag,
smsg_noop( enum ipc_msg id UNUSED, tr_benc * val UNUSED, int64_t tag,
void * arg )
{
simpleresp( arg, tag, IPC_MSG_OK );
@@ -626,7 +626,7 @@ findtorid( TrCore * core, int id, GtkTreeIter * iter )
static int
addinfo( TrTorrent * tor, enum ipc_msg msgid, int torid, int types,
benc_val_t * val )
tr_benc * val )
{
if( IPC_MSG_INFO == msgid )
{
@@ -641,12 +641,12 @@ addinfo( TrTorrent * tor, enum ipc_msg msgid, int torid, int types,
}
static void
smsg_info( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg )
smsg_info( enum ipc_msg id, tr_benc * val, int64_t tag, void * arg )
{
struct constate * con = arg;
struct constate_serv * srv = &con->u.serv;
enum ipc_msg respid;
benc_val_t * ids, * types, * idval, packet, * pkval;
tr_benc * ids, * types, * idval, packet, * pkval;
int typeflags, ii;
TrTorrent * tor;
uint8_t * buf;
@@ -704,12 +704,12 @@ smsg_info( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg )
}
static void
smsg_infoall( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg )
smsg_infoall( enum ipc_msg id, tr_benc * val, int64_t tag, void * arg )
{
struct constate * con = arg;
struct constate_serv * srv = &con->u.serv;
enum ipc_msg respid;
benc_val_t packet, * pkval;
tr_benc packet, * pkval;
int typeflags;
GtkTreeModel * model;
GtkTreeIter iter;
@@ -793,12 +793,12 @@ findtorhash( TrCore * core, const char * hash, int * torid )
}
static void
smsg_look( enum ipc_msg id UNUSED, benc_val_t * val, int64_t tag,
smsg_look( enum ipc_msg id UNUSED, tr_benc * val, int64_t tag,
void * arg )
{
struct constate * con = arg;
struct constate_serv * srv = &con->u.serv;
benc_val_t packet, * pkval, * hash;
tr_benc packet, * pkval, * hash;
int ii, torid;
TrTorrent * tor;
const tr_info * inf;
@@ -849,11 +849,11 @@ smsg_look( enum ipc_msg id UNUSED, benc_val_t * val, int64_t tag,
}
static void
smsg_tor( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg )
smsg_tor( enum ipc_msg id, tr_benc * val, int64_t tag, void * arg )
{
struct constate * con = arg;
struct constate_serv * srv = &con->u.serv;
benc_val_t * idval;
tr_benc * idval;
TrTorrent * tor;
GtkTreeIter iter;
int ii;
@@ -896,7 +896,7 @@ smsg_tor( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg )
}
static void
smsg_torall( enum ipc_msg id, benc_val_t * val UNUSED, int64_t tag,
smsg_torall( enum ipc_msg id, tr_benc * val UNUSED, int64_t tag,
void * arg )
{
struct constate * con = arg;
@@ -941,7 +941,7 @@ smsg_torall( enum ipc_msg id, benc_val_t * val UNUSED, int64_t tag,
( TR_NAT_TRAVERSAL_UNMAPPED == (st) || TR_NAT_TRAVERSAL_UNMAPPING == (st) )
static void
smsg_pref( enum ipc_msg id, benc_val_t * val UNUSED, int64_t tag, void * arg )
smsg_pref( enum ipc_msg id, tr_benc * val UNUSED, int64_t tag, void * arg )
{
struct constate * con = arg;
struct constate_serv * srv = &con->u.serv;
@@ -999,7 +999,7 @@ smsg_pref( enum ipc_msg id, benc_val_t * val UNUSED, int64_t tag, void * arg )
}
static void
smsg_int( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg )
smsg_int( enum ipc_msg id, tr_benc * val, int64_t tag, void * arg )
{
struct constate * con = arg;
struct constate_serv * srv = &con->u.serv;
@@ -1053,7 +1053,7 @@ smsg_int( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg )
}
static void
smsg_str( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg )
smsg_str( enum ipc_msg id, tr_benc * val, int64_t tag, void * arg )
{
struct constate * con = arg;
struct constate_serv * srv = &con->u.serv;
@@ -1076,10 +1076,10 @@ smsg_str( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg )
}
static void
smsg_sup( enum ipc_msg id UNUSED, benc_val_t * val, int64_t tag, void * arg )
smsg_sup( enum ipc_msg id UNUSED, tr_benc * val, int64_t tag, void * arg )
{
struct constate * con = arg;
benc_val_t packet, * pkval, * name;
tr_benc packet, * pkval, * name;
int ii;
enum ipc_msg found;
uint8_t * buf;

View File

@@ -139,7 +139,7 @@ testStr( void )
static int
testString( const char * str, int isGood )
{
benc_val_t val;
tr_benc val;
const uint8_t * end = NULL;
char * saved;
const size_t len = strlen( str );
@@ -162,9 +162,9 @@ testString( const char * str, int isGood )
static int
testParse( void )
{
benc_val_t val;
benc_val_t * child;
benc_val_t * child2;
tr_benc val;
tr_benc * child;
tr_benc * child2;
uint8_t buf[512];
const uint8_t * end;
int err;
@@ -274,7 +274,7 @@ testStackSmash( void )
int err;
uint8_t * in;
const uint8_t * end;
benc_val_t val;
tr_benc val;
char * saved;
depth = 1000000;

View File

@@ -41,7 +41,7 @@
**/
static int
isType( const benc_val_t * val, int type )
isType( const tr_benc * val, int type )
{
return ( ( val != NULL ) && ( val->type == type ) );
}
@@ -52,12 +52,12 @@ isType( const benc_val_t * val, int type )
#define isDict(v) ( isType( ( v ), TYPE_DICT ) )
static int
isContainer( const benc_val_t * val )
isContainer( const tr_benc * val )
{
return isList(val) || isDict(val);
}
static int
isSomething( const benc_val_t * val )
isSomething( const tr_benc * val )
{
return isContainer(val) || isInt(val) || isString(val);
}
@@ -158,7 +158,7 @@ tr_bencParseStr( const uint8_t * buf,
#define LIST_SIZE 8 /* number of items to increment list/dict buffer by */
static int
makeroom( benc_val_t * val, int count )
makeroom( tr_benc * val, int count )
{
assert( TYPE_LIST == val->type || TYPE_DICT == val->type );
@@ -167,7 +167,7 @@ makeroom( benc_val_t * val, int count )
/* We need a bigger boat */
const int len = val->val.l.alloc + count +
( count % LIST_SIZE ? LIST_SIZE - ( count % LIST_SIZE ) : 0 );
void * new = realloc( val->val.l.vals, len * sizeof( benc_val_t ) );
void * new = realloc( val->val.l.vals, len * sizeof( tr_benc ) );
if( NULL == new )
return 1;
@@ -178,10 +178,10 @@ makeroom( benc_val_t * val, int count )
return 0;
}
static benc_val_t*
getNode( benc_val_t * top, tr_ptrArray * parentStack, int type )
static tr_benc*
getNode( tr_benc * top, tr_ptrArray * parentStack, int type )
{
benc_val_t * parent;
tr_benc * parent;
assert( top != NULL );
assert( parentStack != NULL );
@@ -210,7 +210,7 @@ getNode( benc_val_t * top, tr_ptrArray * parentStack, int type )
int
tr_bencParse( const void * buf_in,
const void * bufend_in,
benc_val_t * top,
tr_benc * top,
const uint8_t ** setme_end )
{
int err;
@@ -230,7 +230,7 @@ tr_bencParse( const void * buf_in,
int64_t val;
const uint8_t * end;
int err;
benc_val_t * node;
tr_benc * node;
if(( err = tr_bencParseInt( buf, bufend, &end, &val )))
return err;
@@ -247,7 +247,7 @@ tr_bencParse( const void * buf_in,
}
else if( *buf=='l' ) /* list */
{
benc_val_t * node = getNode( top, parentStack, TYPE_LIST );
tr_benc * node = getNode( top, parentStack, TYPE_LIST );
if( !node )
return TR_ERROR;
tr_bencInit( node, TYPE_LIST );
@@ -256,7 +256,7 @@ tr_bencParse( const void * buf_in,
}
else if( *buf=='d' ) /* dict */
{
benc_val_t * node = getNode( top, parentStack, TYPE_DICT );
tr_benc * node = getNode( top, parentStack, TYPE_DICT );
if( !node )
return TR_ERROR;
tr_bencInit( node, TYPE_DICT );
@@ -265,7 +265,7 @@ tr_bencParse( const void * buf_in,
}
else if( *buf=='e' ) /* end of list or dict */
{
benc_val_t * node;
tr_benc * node;
++buf;
if( tr_ptrArrayEmpty( parentStack ) )
return TR_ERROR;
@@ -284,7 +284,7 @@ tr_bencParse( const void * buf_in,
uint8_t * str;
size_t str_len;
int err;
benc_val_t * node;
tr_benc * node;
if(( err = tr_bencParseStr( buf, bufend, &end, &str, &str_len )))
return err;
@@ -317,7 +317,7 @@ tr_bencParse( const void * buf_in,
int
tr_bencLoad( const void * buf_in,
int buflen,
benc_val_t * setme_benc,
tr_benc * setme_benc,
char ** setme_end )
{
const uint8_t * buf = buf_in;
@@ -332,8 +332,8 @@ tr_bencLoad( const void * buf_in,
****
***/
benc_val_t *
tr_bencDictFind( benc_val_t * val, const char * key )
tr_benc *
tr_bencDictFind( tr_benc * val, const char * key )
{
int len, ii;
@@ -356,18 +356,18 @@ tr_bencDictFind( benc_val_t * val, const char * key )
return NULL;
}
benc_val_t*
tr_bencDictFindType( benc_val_t * val, const char * key, int type )
tr_benc*
tr_bencDictFindType( tr_benc * val, const char * key, int type )
{
benc_val_t * ret = tr_bencDictFind( val, key );
tr_benc * ret = tr_bencDictFind( val, key );
return ret && ret->type == type ? ret : NULL;
}
benc_val_t *
tr_bencDictFindFirst( benc_val_t * val, ... )
tr_benc *
tr_bencDictFindFirst( tr_benc * val, ... )
{
const char * key;
benc_val_t * ret;
tr_benc * ret;
va_list ap;
ret = NULL;
@@ -380,24 +380,24 @@ tr_bencDictFindFirst( benc_val_t * val, ... )
return ret;
}
benc_val_t*
tr_bencListGetNthChild( benc_val_t * val, int i )
tr_benc*
tr_bencListGetNthChild( tr_benc * val, int i )
{
benc_val_t * ret = NULL;
tr_benc * ret = NULL;
if( isList( val ) && ( i >= 0 ) && ( i < val->val.l.count ) )
ret = val->val.l.vals + i;
return ret;
}
int64_t
tr_bencGetInt ( const benc_val_t * val )
tr_bencGetInt ( const tr_benc * val )
{
assert( isInt( val ) );
return val->val.i;
}
char *
tr_bencStealStr( benc_val_t * val )
tr_bencStealStr( tr_benc * val )
{
assert( isString( val ) );
val->val.s.nofree = 1;
@@ -409,7 +409,7 @@ tr_bencStealStr( benc_val_t * val )
***/
void
_tr_bencInitStr( benc_val_t * val, char * str, int len, int nofree )
_tr_bencInitStr( tr_benc * val, char * str, int len, int nofree )
{
tr_bencInit( val, TYPE_STR );
val->val.s.s = str;
@@ -422,7 +422,7 @@ _tr_bencInitStr( benc_val_t * val, char * str, int len, int nofree )
}
int
tr_bencInitStrDup( benc_val_t * val, const char * str )
tr_bencInitStrDup( tr_benc * val, const char * str )
{
char * newStr = tr_strdup( str );
if( newStr == NULL )
@@ -433,14 +433,14 @@ tr_bencInitStrDup( benc_val_t * val, const char * str )
}
void
tr_bencInitInt( benc_val_t * val, int64_t num )
tr_bencInitInt( tr_benc * val, int64_t num )
{
tr_bencInit( val, TYPE_INT );
val->val.i = num;
}
int
tr_bencListReserve( benc_val_t * val, int count )
tr_bencListReserve( tr_benc * val, int count )
{
assert( isList( val ) );
@@ -448,17 +448,17 @@ tr_bencListReserve( benc_val_t * val, int count )
}
int
tr_bencDictReserve( benc_val_t * val, int count )
tr_bencDictReserve( tr_benc * val, int count )
{
assert( isDict( val ) );
return makeroom( val, count * 2 );
}
benc_val_t *
tr_bencListAdd( benc_val_t * list )
tr_benc *
tr_bencListAdd( tr_benc * list )
{
benc_val_t * item;
tr_benc * item;
assert( isList( list ) );
assert( list->val.l.count < list->val.l.alloc );
@@ -470,10 +470,10 @@ tr_bencListAdd( benc_val_t * list )
return item;
}
benc_val_t *
tr_bencDictAdd( benc_val_t * dict, const char * key )
tr_benc *
tr_bencDictAdd( tr_benc * dict, const char * key )
{
benc_val_t * keyval, * itemval;
tr_benc * keyval, * itemval;
assert( isDict( dict ) );
assert( dict->val.l.count + 2 <= dict->val.l.alloc );
@@ -507,7 +507,7 @@ compareKeyIndex( const void * va, const void * vb )
struct SaveNode
{
const benc_val_t * val;
const tr_benc * val;
int valIsVisited;
int childCount;
int childIndex;
@@ -515,7 +515,7 @@ struct SaveNode
};
static struct SaveNode*
nodeNewDict( const benc_val_t * val )
nodeNewDict( const tr_benc * val )
{
int i, j;
int nKeys;
@@ -548,7 +548,7 @@ nodeNewDict( const benc_val_t * val )
}
static struct SaveNode*
nodeNewList( const benc_val_t * val )
nodeNewList( const tr_benc * val )
{
int i, n;
struct SaveNode * node;
@@ -567,7 +567,7 @@ nodeNewList( const benc_val_t * val )
}
static struct SaveNode*
nodeNewLeaf( const benc_val_t * val )
nodeNewLeaf( const tr_benc * val )
{
struct SaveNode * node;
@@ -579,7 +579,7 @@ nodeNewLeaf( const benc_val_t * val )
}
static struct SaveNode*
nodeNew( const benc_val_t * val )
nodeNew( const tr_benc * val )
{
struct SaveNode * node;
@@ -593,7 +593,7 @@ nodeNew( const benc_val_t * val )
return node;
}
typedef void (*BencWalkFunc)( const benc_val_t * val, void * user_data );
typedef void (*BencWalkFunc)( const tr_benc * val, void * user_data );
struct WalkFuncs
{
@@ -610,7 +610,7 @@ struct WalkFuncs
* attack via maliciously-crafted bencoded data. (#667)
*/
static void
bencWalk( const benc_val_t * top,
bencWalk( const tr_benc * top,
struct WalkFuncs * walkFuncs,
void * user_data )
{
@@ -620,7 +620,7 @@ bencWalk( const benc_val_t * top,
while( !tr_ptrArrayEmpty( stack ) )
{
struct SaveNode * node = tr_ptrArrayBack( stack );
const benc_val_t * val;
const tr_benc * val;
if( !node->valIsVisited )
{
@@ -681,34 +681,34 @@ bencWalk( const benc_val_t * top,
****/
static void
saveIntFunc( const benc_val_t * val, void * evbuf )
saveIntFunc( const tr_benc * val, void * evbuf )
{
evbuffer_add_printf( evbuf, "i%"PRId64"e", tr_bencGetInt(val) );
}
static void
saveStringFunc( const benc_val_t * val, void * vevbuf )
saveStringFunc( const tr_benc * val, void * vevbuf )
{
struct evbuffer * evbuf = vevbuf;
evbuffer_add_printf( evbuf, "%i:", val->val.s.i );
evbuffer_add( evbuf, val->val.s.s, val->val.s.i );
}
static void
saveDictBeginFunc( const benc_val_t * val UNUSED, void * evbuf )
saveDictBeginFunc( const tr_benc * val UNUSED, void * evbuf )
{
evbuffer_add_printf( evbuf, "d" );
}
static void
saveListBeginFunc( const benc_val_t * val UNUSED, void * evbuf )
saveListBeginFunc( const tr_benc * val UNUSED, void * evbuf )
{
evbuffer_add_printf( evbuf, "l" );
}
static void
saveContainerEndFunc( const benc_val_t * val UNUSED, void * evbuf )
saveContainerEndFunc( const tr_benc * val UNUSED, void * evbuf )
{
evbuffer_add_printf( evbuf, "e" );
}
char*
tr_bencSave( const benc_val_t * top, int * len )
tr_bencSave( const tr_benc * top, int * len )
{
char * ret;
struct WalkFuncs walkFuncs;
@@ -733,22 +733,22 @@ tr_bencSave( const benc_val_t * top, int * len )
***/
static void
freeDummyFunc( const benc_val_t * val UNUSED, void * buf UNUSED )
freeDummyFunc( const tr_benc * val UNUSED, void * buf UNUSED )
{
}
static void
freeStringFunc( const benc_val_t * val, void * freeme )
freeStringFunc( const tr_benc * val, void * freeme )
{
if( !val->val.s.nofree )
tr_ptrArrayAppend( freeme, val->val.s.s );
}
static void
freeContainerBeginFunc( const benc_val_t * val, void * freeme )
freeContainerBeginFunc( const tr_benc * val, void * freeme )
{
tr_ptrArrayAppend( freeme, val->val.l.vals );
}
void
tr_bencFree( benc_val_t * val )
tr_bencFree( tr_benc * val )
{
if( val != NULL )
{
@@ -782,14 +782,14 @@ printLeadingSpaces( struct WalkPrint * data )
fprintf( data->out, "%*.*s", width, width, " " );
}
static void
printIntFunc( const benc_val_t * val, void * vdata )
printIntFunc( const tr_benc * val, void * vdata )
{
struct WalkPrint * data = vdata;
printLeadingSpaces( data );
fprintf( data->out, "int: %"PRId64"\n", tr_bencGetInt(val) );
}
static void
printStringFunc( const benc_val_t * val, void * vdata )
printStringFunc( const tr_benc * val, void * vdata )
{
int ii;
struct WalkPrint * data = vdata;
@@ -809,7 +809,7 @@ printStringFunc( const benc_val_t * val, void * vdata )
fprintf( data->out, "\n" );
}
static void
printListBeginFunc( const benc_val_t * val UNUSED, void * vdata )
printListBeginFunc( const tr_benc * val UNUSED, void * vdata )
{
struct WalkPrint * data = vdata;
printLeadingSpaces( data );
@@ -817,7 +817,7 @@ printListBeginFunc( const benc_val_t * val UNUSED, void * vdata )
++data->depth;
}
static void
printDictBeginFunc( const benc_val_t * val UNUSED, void * vdata )
printDictBeginFunc( const tr_benc * val UNUSED, void * vdata )
{
struct WalkPrint * data = vdata;
printLeadingSpaces( data );
@@ -825,13 +825,13 @@ printDictBeginFunc( const benc_val_t * val UNUSED, void * vdata )
++data->depth;
}
static void
printContainerEndFunc( const benc_val_t * val UNUSED, void * vdata )
printContainerEndFunc( const tr_benc * val UNUSED, void * vdata )
{
struct WalkPrint * data = vdata;
--data->depth;
}
void
tr_bencPrint( benc_val_t * val )
tr_bencPrint( const tr_benc * val )
{
struct WalkFuncs walkFuncs;
struct WalkPrint walkPrint;

View File

@@ -28,7 +28,7 @@
#include <inttypes.h> /* for int64_t */
#include <string.h> /* for memset */
typedef struct benc_val_s
typedef struct tr_benc
{
#define TYPE_INT 1
#define TYPE_STR 2
@@ -48,34 +48,36 @@ typedef struct benc_val_s
{
int alloc;
int count;
struct benc_val_s * vals;
struct tr_benc * vals;
} l;
} val;
} benc_val_t;
} tr_benc;
/* backwards compatability */
typedef tr_benc benc_val_t;
int tr_bencParse( const void * buf,
const void * bufend,
benc_val_t * setme_benc,
const uint8_t ** setme_end );
int tr_bencParse( const void * buf,
const void * bufend,
tr_benc * setme_benc,
const uint8_t ** setme_end );
int tr_bencLoad( const void * buf,
int buflen,
benc_val_t * setme_benc,
char ** setme_end );
int tr_bencLoad( const void * buf,
int buflen,
tr_benc * setme_benc,
char ** setme_end );
void tr_bencPrint( benc_val_t * val );
void tr_bencFree( benc_val_t * val );
benc_val_t * tr_bencDictFind( benc_val_t * val, const char * key );
benc_val_t * tr_bencDictFindType( benc_val_t * val, const char * key, int type );
benc_val_t * tr_bencDictFindFirst( benc_val_t * val, ... );
void tr_bencPrint( const tr_benc * );
void tr_bencFree( tr_benc * );
tr_benc * tr_bencDictFind( tr_benc * dict, const char * key );
tr_benc * tr_bencDictFindType( tr_benc * dict, const char * key, int type );
tr_benc * tr_bencDictFindFirst( tr_benc * dict, ... );
/* marks a string as 'do not free' and returns it */
char * tr_bencStealStr( benc_val_t * val );
char * tr_bencStealStr( tr_benc * val );
/* convenience functions for building benc_val_t structures */
/* convenience functions for building tr_benc structures */
static inline void tr_bencInit( benc_val_t * val, int type )
static inline void tr_bencInit( tr_benc * val, int type )
{
memset( val, 0, sizeof( *val ) );
val->type = type;
@@ -83,19 +85,19 @@ static inline void tr_bencInit( benc_val_t * val, int type )
#define tr_bencInitStr( a, b, c, d ) \
_tr_bencInitStr( (a), ( char * )(b), (c), (d) )
void _tr_bencInitStr( benc_val_t * val, char * str, int len, int nofree );
int tr_bencInitStrDup( benc_val_t * val, const char * str );
void tr_bencInitInt( benc_val_t * val, int64_t num );
int tr_bencListReserve( benc_val_t * list, int count );
void _tr_bencInitStr( tr_benc * val, char * str, int len, int nofree );
int tr_bencInitStrDup( tr_benc * val, const char * str );
void tr_bencInitInt( tr_benc * val, int64_t num );
int tr_bencListReserve( tr_benc * list, int count );
/* note that for one key-value pair, count should be 1, not 2 */
int tr_bencDictReserve( benc_val_t * dict, int count );
benc_val_t * tr_bencListAdd( benc_val_t * list );
int tr_bencDictReserve( tr_benc * dict, int count );
tr_benc * tr_bencListAdd( tr_benc * list );
/* note: key must not be freed or modified while val is in use */
benc_val_t * tr_bencDictAdd( benc_val_t * dict, const char * key );
tr_benc * tr_bencDictAdd( tr_benc * dict, const char * key );
char* tr_bencSave( const benc_val_t * val, int * len );
char* tr_bencSave( const tr_benc * val, int * len );
int64_t tr_bencGetInt ( const benc_val_t * val );
int64_t tr_bencGetInt( const tr_benc * val );
/**
@@ -118,9 +120,7 @@ int tr_bencParseStr( const uint8_t * buf,
***
**/
benc_val_t* tr_bencListGetNthChild( benc_val_t * val, int i );
tr_benc * tr_bencListGetNthChild( tr_benc * list, int n );
#endif

View File

@@ -30,6 +30,7 @@
#include <string.h>
#include "transmission.h"
#include "bencode.h"
#include "utils.h"
#include "ipcparse.h"
@@ -218,14 +219,14 @@ static struct inf gl_stat[] =
{ "upload-total", IPC_ST_UPTOTAL, RB_ENTRY_INITIALIZER() },
};
static int handlevers ( struct ipc_info *, benc_val_t * );
static int handlemsgs ( struct ipc_info *, benc_val_t *, void * );
static int gotmsg ( struct ipc_info *, benc_val_t *, benc_val_t *,
benc_val_t *, void * );
static int handlevers ( struct ipc_info *, tr_benc * );
static int handlemsgs ( struct ipc_info *, tr_benc *, void * );
static int gotmsg ( struct ipc_info *, tr_benc *, tr_benc *,
tr_benc *, void * );
static int msgcmp ( struct msg *, struct msg * );
static int infcmp ( struct inf *, struct inf * );
static struct msg * msglookup ( const char * );
static int filltracker( benc_val_t *, const tr_tracker_info * );
static int filltracker( tr_benc *, const tr_tracker_info * );
static int handlercmp ( struct msgfunc *, struct msgfunc * );
RB_GENERATE_STATIC( msgtree, msg, link, msgcmp )
@@ -320,11 +321,11 @@ ipc_freecon( struct ipc_info * info )
}
}
benc_val_t *
tr_benc *
ipc_initval( struct ipc_info * info, enum ipc_msg id, int64_t tag,
benc_val_t * pk, int type )
tr_benc * pk, int type )
{
benc_val_t * ret;
tr_benc * ret;
assert( MSGVALID( id ) );
@@ -364,7 +365,7 @@ ipc_initval( struct ipc_info * info, enum ipc_msg id, int64_t tag,
}
uint8_t *
ipc_mkval( benc_val_t * pk, size_t * setmeSize )
ipc_mkval( tr_benc * pk, size_t * setmeSize )
{
int bencSize = 0;
char * benc = tr_bencSave( pk, &bencSize );
@@ -388,7 +389,7 @@ uint8_t *
ipc_mkempty( struct ipc_info * info, size_t * len, enum ipc_msg id,
int64_t tag )
{
benc_val_t pk;
tr_benc pk;
uint8_t * ret;
if( NULL == ipc_initval( info, id, tag, &pk, TYPE_STR ) )
@@ -406,7 +407,7 @@ uint8_t *
ipc_mkint( struct ipc_info * info, size_t * len, enum ipc_msg id, int64_t tag,
int64_t num )
{
benc_val_t pk, * val;
tr_benc pk, * val;
uint8_t * ret;
val = ipc_initval( info, id, tag, &pk, TYPE_INT );
@@ -426,7 +427,7 @@ uint8_t *
ipc_mkstr( struct ipc_info * info, size_t * len, enum ipc_msg id, int64_t tag,
const char * str )
{
benc_val_t pk, * val;
tr_benc pk, * val;
uint8_t * ret;
val = ipc_initval( info, id, tag, &pk, TYPE_STR );
@@ -445,7 +446,7 @@ ipc_mkstr( struct ipc_info * info, size_t * len, enum ipc_msg id, int64_t tag,
uint8_t *
ipc_mkvers( size_t * len, const char * label )
{
benc_val_t pk, * dict;
tr_benc pk, * dict;
uint8_t * ret;
tr_bencInit( &pk, TYPE_DICT );
@@ -476,7 +477,7 @@ uint8_t *
ipc_mkgetinfo( struct ipc_info * info, size_t * len, enum ipc_msg id,
int64_t tag, int types, const int * ids )
{
benc_val_t pk, * top, * idlist, * typelist;
tr_benc pk, * top, * idlist, * typelist;
size_t ii, typecount, used;
struct inf * typearray;
uint8_t * ret;
@@ -571,9 +572,9 @@ ipc_mkgetinfo( struct ipc_info * info, size_t * len, enum ipc_msg id,
}
int
ipc_addinfo( benc_val_t * list, int tor, const tr_info * inf, int types )
ipc_addinfo( tr_benc * list, int tor, const tr_info * inf, int types )
{
benc_val_t * dict, * item, * file, * tier;
tr_benc * dict, * item, * file, * tier;
int ii, jj, kk;
/* always send torrent id */
@@ -707,10 +708,10 @@ ipc_addinfo( benc_val_t * list, int tor, const tr_info * inf, int types )
}
int
ipc_addstat( benc_val_t * list, int tor,
ipc_addstat( tr_benc * list, int tor,
const tr_stat * st, int types )
{
benc_val_t * dict, * item;
tr_benc * dict, * item;
int ii, used;
tr_errno error;
@@ -915,7 +916,7 @@ ipc_parse( struct ipc_info * info, uint8_t * buf, ssize_t total, void * arg )
{
char hex[IPC_MIN_MSG_LEN+1], * end;
ssize_t off, len;
benc_val_t benc;
tr_benc benc;
for( off = 0; off + IPC_MIN_MSG_LEN < total; off += IPC_MIN_MSG_LEN + len )
{
@@ -955,9 +956,9 @@ ipc_parse( struct ipc_info * info, uint8_t * buf, ssize_t total, void * arg )
}
static int
handlevers( struct ipc_info * info, benc_val_t * dict )
handlevers( struct ipc_info * info, tr_benc * dict )
{
benc_val_t * vers, * num;
tr_benc * vers, * num;
int64_t min, max;
if( TYPE_DICT != dict->type )
@@ -1015,9 +1016,9 @@ handlevers( struct ipc_info * info, benc_val_t * dict )
}
static int
handlemsgs( struct ipc_info * info, benc_val_t * pay, void * arg )
handlemsgs( struct ipc_info * info, tr_benc * pay, void * arg )
{
benc_val_t * name, * val, * tag;
tr_benc * name, * val, * tag;
int ii;
assert( HASVERS( info ) );
@@ -1062,8 +1063,8 @@ handlemsgs( struct ipc_info * info, benc_val_t * pay, void * arg )
}
static int
gotmsg( struct ipc_info * info, benc_val_t * name, benc_val_t * val,
benc_val_t * tagval, void * arg )
gotmsg( struct ipc_info * info, tr_benc * name, tr_benc * val,
tr_benc * tagval, void * arg )
{
struct msgfunc key, * handler;
struct msg * msg;
@@ -1152,12 +1153,12 @@ ipc_havetags( struct ipc_info * info )
}
int
ipc_infotypes( enum ipc_msg id, benc_val_t * list )
ipc_infotypes( enum ipc_msg id, tr_benc * list )
{
static struct inftree infotree = RB_INITIALIZER( &tree );
static struct inftree stattree = RB_INITIALIZER( &tree );
struct inftree * tree;
benc_val_t * name;
tr_benc * name;
struct inf * array, * inf, key;
size_t len, ii;
int ret, jj;
@@ -1286,7 +1287,7 @@ msglookup( const char * name )
}
static int
filltracker( benc_val_t * val, const tr_tracker_info * tk )
filltracker( tr_benc * val, const tr_tracker_info * tk )
{
tr_bencInit( val, TYPE_DICT );
if( tr_bencDictReserve( val, ( NULL == tk->scrape ? 3 : 4 ) ) )

View File

@@ -28,11 +28,6 @@
#include <inttypes.h>
#include <unistd.h> /* for ssize_t */
/* yay for typedefs, we can't forward declare benc_val_t or tr_info
like with structs */
#include "bencode.h"
#include "transmission.h"
#define IPC_MIN_MSG_LEN ( 8 )
#define IPC_MAX_MSG_LEN ( 0x7fffffff - IPC_MIN_MSG_LEN )
@@ -125,6 +120,9 @@ enum ipc_msg
struct ipc_funcs;
struct ipc_info;
struct strlist;
struct tr_info;
struct tr_benc;
struct tr_stat;
struct ipc_info
{
@@ -138,7 +136,7 @@ struct ipc_info
#define TORRENT_ID_VALID( id ) ( 0 < (id) && INT_MAX > (id) )
typedef void ( *trd_msgfunc )( enum ipc_msg, benc_val_t *, int64_t, void * );
typedef void ( *trd_msgfunc )( enum ipc_msg, struct tr_benc *, int64_t, void * );
/* any of these functions that can fail may set errno for any of the
errors set by malloc() or calloc() */
@@ -153,9 +151,9 @@ void ipc_freecon ( struct ipc_info * );
/* message creation */
/* sets errno to EPERM if requested message not supported by protocol vers */
benc_val_t * ipc_initval ( struct ipc_info *, enum ipc_msg, int64_t,
benc_val_t *, int );
uint8_t * ipc_mkval ( benc_val_t *, size_t * );
struct tr_benc * ipc_initval ( struct ipc_info *, enum ipc_msg, int64_t,
struct tr_benc *, int );
uint8_t * ipc_mkval ( struct tr_benc *, size_t * );
uint8_t * ipc_mkempty ( struct ipc_info *, size_t *, enum ipc_msg,
int64_t );
uint8_t * ipc_mkint ( struct ipc_info *, size_t *, enum ipc_msg, int64_t,
@@ -165,8 +163,8 @@ uint8_t * ipc_mkstr ( struct ipc_info *, size_t *, enum ipc_msg, int64_t,
uint8_t * ipc_mkvers ( size_t *, const char * );
uint8_t * ipc_mkgetinfo( struct ipc_info *, size_t *, enum ipc_msg, int64_t,
int, const int * );
int ipc_addinfo ( benc_val_t *, int, const tr_info *, int );
int ipc_addstat ( benc_val_t *, int, const tr_stat *, int );
int ipc_addinfo ( struct tr_benc *, int, const struct tr_info *, int );
int ipc_addstat ( struct tr_benc *, int, const struct tr_stat *, int );
/* sets errno to EINVAL on parse error or
EPERM for unsupported protocol version */
@@ -177,7 +175,7 @@ int ipc_havemsg ( struct ipc_info *, enum ipc_msg );
enum ipc_msg ipc_msgid ( struct ipc_info *, const char * );
int ipc_ishandled( struct ipc_info *, enum ipc_msg );
int ipc_havetags ( struct ipc_info * );
int ipc_infotypes( enum ipc_msg, benc_val_t * );
int ipc_infotypes( enum ipc_msg, struct tr_benc * );
const char * ipc_infoname ( enum ipc_msg, int );
#endif /* TR_DAEMON_IPC_H */

View File

@@ -258,10 +258,10 @@ getHashInfo ( tr_metainfo_builder * b )
static void
getFileInfo( const char * topFile,
const tr_metainfo_builder_file * file,
benc_val_t * uninitialized_length,
benc_val_t * uninitialized_path )
tr_benc * uninitialized_length,
tr_benc * uninitialized_path )
{
benc_val_t *sub;
tr_benc *sub;
const char *pch, *prev;
const size_t topLen = strlen(topFile) + 1; /* +1 for '/' */
int n;
@@ -296,7 +296,7 @@ getFileInfo( const char * topFile,
}
static void
makeFilesList( benc_val_t * list,
makeFilesList( tr_benc * list,
const tr_metainfo_builder * builder )
{
uint32_t i = 0;
@@ -305,8 +305,8 @@ makeFilesList( benc_val_t * list,
for( i=0; i<builder->fileCount; ++i )
{
benc_val_t * dict = tr_bencListAdd( list );
benc_val_t *length, *pathVal;
tr_benc * dict = tr_bencListAdd( list );
tr_benc *length, *pathVal;
tr_bencInit( dict, TYPE_DICT );
tr_bencDictReserve( dict, 2 );
@@ -317,11 +317,11 @@ makeFilesList( benc_val_t * list,
}
static void
makeInfoDict ( benc_val_t * dict,
makeInfoDict ( tr_benc * dict,
tr_metainfo_builder * builder )
{
uint8_t * pch;
benc_val_t * val;
tr_benc * val;
char base[MAX_PATH_LENGTH];
tr_bencDictReserve( dict, 5 );
@@ -356,7 +356,7 @@ makeInfoDict ( benc_val_t * dict,
static void tr_realMakeMetaInfo ( tr_metainfo_builder * builder )
{
int n = 5;
benc_val_t top, *val;
tr_benc top, *val;
tr_bencInit ( &top, TYPE_DICT );
if ( builder->comment && *builder->comment ) ++n;

View File

@@ -69,10 +69,10 @@ tr_httpParseUrl( const char * url_in, int len,
/***********************************************************************
* Local prototypes
**********************************************************************/
static int getannounce( tr_info * inf, benc_val_t * meta );
static int getannounce( tr_info * inf, tr_benc * meta );
static char * announceToScrape( const char * announce );
static int parseFiles( tr_info * inf, benc_val_t * name,
benc_val_t * files, benc_val_t * length );
static int parseFiles( tr_info * inf, tr_benc * name,
tr_benc * files, tr_benc * length );
/***
****
@@ -169,11 +169,11 @@ savedname( char * name, size_t len, const char * hash, const char * tag )
int
tr_metainfoParse( tr_info * inf, const benc_val_t * meta_in, const char * tag )
tr_metainfoParse( tr_info * inf, const tr_benc * meta_in, const char * tag )
{
int i;
benc_val_t * beInfo, * val, * val2;
benc_val_t * meta = (benc_val_t *) meta_in;
tr_benc * beInfo, * val, * val2;
tr_benc * meta = (tr_benc *) meta_in;
char buf[4096];
/* info_hash: urlencoded 20-byte SHA1 hash of the value of the info key
@@ -325,10 +325,10 @@ void tr_metainfoFree( tr_info * inf )
memset( inf, '\0', sizeof(tr_info) );
}
static int getfile( char ** setme,
const char * prefix, benc_val_t * name )
static int
getfile( char ** setme, const char * prefix, tr_benc * name )
{
benc_val_t * dir;
tr_benc * dir;
const char ** list;
int ii, jj;
char buf[4096];
@@ -386,9 +386,9 @@ static int getfile( char ** setme,
return TR_OK;
}
static int getannounce( tr_info * inf, benc_val_t * meta )
static int getannounce( tr_info * inf, tr_benc * meta )
{
benc_val_t * val, * subval, * urlval;
tr_benc * val, * subval, * urlval;
char * address, * announce;
int ii, jj, port, random, subcount;
tr_tracker_info * sublist;
@@ -626,10 +626,10 @@ tr_metainfoSave( const char * hash, const char * tag,
}
static int
parseFiles( tr_info * inf, benc_val_t * name,
benc_val_t * files, benc_val_t * length )
parseFiles( tr_info * inf, tr_benc * name,
tr_benc * files, tr_benc * length )
{
benc_val_t * item, * path;
tr_benc * item, * path;
int ii;
if( NULL == name || TYPE_STR != name->type )

View File

@@ -27,9 +27,9 @@
#include "transmission.h"
struct benc_val_t;
struct tr_benc;
int tr_metainfoParse( tr_info *, const struct benc_val_s *, const char * tag );
int tr_metainfoParse( tr_info *, const struct tr_benc *, const char * tag );
void tr_metainfoFree( tr_info * inf );
void tr_metainfoRemoveSaved( const char * hashString, const char * tag );

View File

@@ -767,7 +767,7 @@ tr_peerMsgsCancel( tr_peermsgs * msgs,
static void
sendLtepHandshake( tr_peermsgs * msgs )
{
benc_val_t val, *m;
tr_benc val, *m;
char * buf;
int len;
int pex;
@@ -826,7 +826,7 @@ sendLtepHandshake( tr_peermsgs * msgs )
static void
parseLtepHandshake( tr_peermsgs * msgs, int len, struct evbuffer * inbuf )
{
benc_val_t val, * sub;
tr_benc val, * sub;
uint8_t * tmp = tr_new( uint8_t, len );
tr_peerIoReadBytes( msgs->io, inbuf, tmp, len );
@@ -875,7 +875,7 @@ parseUtPex( tr_peermsgs * msgs, int msglen, struct evbuffer * inbuf )
{
int gotval = 0;
uint8_t * tmp = tr_new( uint8_t, msglen );
benc_val_t val, *sub;
tr_benc val, *sub;
tr_peerIoReadBytes( msgs->io, inbuf, tmp, msglen );
if( tr_torrentAllowsPex( msgs->torrent )
@@ -1734,7 +1734,7 @@ sendPex( tr_peermsgs * msgs )
tr_pex * newPex = NULL;
const int newCount = tr_peerMgrGetPeers( msgs->handle->peerMgr, msgs->torrent->info.hash, &newPex );
PexDiffs diffs;
benc_val_t val, *added, *dropped, *flags;
tr_benc val, *added, *dropped, *flags;
uint8_t *tmp, *walk;
char * benc;
int bencLen;

View File

@@ -33,11 +33,11 @@ parseCumulativeStats( tr_session_stats * setme,
const uint8_t * content,
size_t len )
{
benc_val_t top;
tr_benc top;
if( !tr_bencLoad( content, len, &top, NULL ) )
{
const benc_val_t * val;
const tr_benc * val;
if(( val = tr_bencDictFindType( &top, "uploaded-bytes", TYPE_INT )))
setme->uploadedBytes = (uint64_t) tr_bencGetInt( val );
@@ -87,7 +87,7 @@ saveCumulativeStats( const tr_session_stats * stats )
char * str;
char filename[MAX_PATH_LENGTH];
int len;
benc_val_t top;
tr_benc top;
tr_bencInit( &top, TYPE_DICT );
tr_bencDictReserve( &top, 5 );

View File

@@ -7,7 +7,7 @@
* This exemption does not extend to derived works not owned by
* the Transmission project.
*
* $Id:$
* $Id$
*/
#include <libgen.h> /* basename */
@@ -38,7 +38,7 @@ struct tr_ctor
unsigned int isSet_metainfo : 1;
unsigned int isSet_delete : 1;
benc_val_t metainfo;
tr_benc metainfo;
char * sourceFile;
struct optional_args optionalArgs[2];
@@ -104,9 +104,9 @@ tr_ctorSetMetainfoFromFile( tr_ctor * ctor,
/* if no `name' field was set, then set it from the filename */
if( ctor->isSet_metainfo ) {
benc_val_t * info = tr_bencDictFindType( &ctor->metainfo, "info", TYPE_DICT );
tr_benc * info = tr_bencDictFindType( &ctor->metainfo, "info", TYPE_DICT );
if( info != NULL ) {
benc_val_t * name = tr_bencDictFindFirst( info, "name.utf-8", "name", NULL );
tr_benc * name = tr_bencDictFindFirst( info, "name.utf-8", "name", NULL );
if( name == NULL )
name = tr_bencDictAdd( info, "name" );
if( name->type!=TYPE_STR || !name->val.s.s || !*name->val.s.s ) {
@@ -265,8 +265,8 @@ tr_ctorGetDestination( const tr_ctor * ctor,
}
int
tr_ctorGetMetainfo( const tr_ctor * ctor,
const struct benc_val_s ** setme )
tr_ctorGetMetainfo( const tr_ctor * ctor,
const tr_benc ** setme )
{
int err = 0;

View File

@@ -376,7 +376,7 @@ torrentRealInit( tr_handle * h,
/* maybe save our own copy of the metainfo */
if( tr_ctorGetSave( ctor ) ) {
const benc_val_t * val;
const tr_benc * val;
if( !tr_ctorGetMetainfo( ctor, &val ) ) {
int len;
uint8_t * text = (uint8_t*) tr_bencSave( val, &len );
@@ -412,7 +412,7 @@ tr_torrentParse( const tr_handle * handle,
int err = 0;
int doFree;
tr_info tmp;
const benc_val_t * metainfo;
const tr_benc * metainfo;
if( setmeInfo == NULL )
setmeInfo = &tmp;

View File

@@ -281,7 +281,7 @@ onStoppedResponse( struct evhttp_request * req UNUSED, void * handle )
}
static int
parseBencResponse( struct evhttp_request * req, benc_val_t * setme )
parseBencResponse( struct evhttp_request * req, tr_benc * setme )
{
const unsigned char * body = EVBUFFER_DATA( req->input_buffer );
const int bodylen = EVBUFFER_LENGTH( req->input_buffer );
@@ -362,7 +362,7 @@ updateAddresses( tr_tracker * t, const struct evhttp_request * req, int * tryAga
/* Convert to compact form */
static uint8_t *
parseOldPeers( benc_val_t * bePeers, int * setmePeerCount )
parseOldPeers( tr_benc * bePeers, int * setmePeerCount )
{
int i;
uint8_t *compact, *walk;
@@ -376,8 +376,8 @@ parseOldPeers( benc_val_t * bePeers, int * setmePeerCount )
{
struct in_addr addr;
tr_port_t port;
benc_val_t * val;
benc_val_t * peer = &bePeers->val.l.vals[i];
tr_benc * val;
tr_benc * peer = &bePeers->val.l.vals[i];
val = tr_bencDictFind( peer, "ip" );
if( !val || val->type!=TYPE_STR || tr_netResolve(val->val.s.s, &addr) )
@@ -428,14 +428,14 @@ onTrackerResponse( struct evhttp_request * req, void * vhash )
if( req && ( req->response_code == HTTP_OK ) )
{
benc_val_t benc;
tr_benc benc;
const int bencLoaded = !parseBencResponse( req, &benc );
publishErrorClear( t );
if( bencLoaded && benc.type==TYPE_DICT )
{
benc_val_t * tmp;
tr_benc * tmp;
if(( tmp = tr_bencDictFind( &benc, "failure reason" ))) {
dbgmsg( t, "got failure message [%s]", tmp->val.s.s );
@@ -594,7 +594,7 @@ onScrapeResponse( struct evhttp_request * req, void * vhash )
if( req && ( req->response_code == HTTP_OK ) )
{
benc_val_t benc, *files;
tr_benc benc, *files;
const int bencLoaded = !parseBencResponse( req, &benc );
if( bencLoaded
@@ -606,8 +606,8 @@ onScrapeResponse( struct evhttp_request * req, void * vhash )
{
const uint8_t* hash =
(const uint8_t*) files->val.l.vals[i].val.s.s;
benc_val_t *tmp, *flags;
benc_val_t *tordict = &files->val.l.vals[i+1];
tr_benc *tmp, *flags;
tr_benc *tordict = &files->val.l.vals[i+1];
if( memcmp( t->hash, hash, SHA_DIGEST_LENGTH ) )
continue;

View File

@@ -355,7 +355,7 @@ typedef enum
tr_ctorMode;
typedef struct tr_ctor tr_ctor;
struct benc_val_s;
struct tr_benc;
tr_ctor* tr_ctorNew ( const tr_handle * handle);
@@ -402,7 +402,7 @@ int tr_ctorGetDestination ( const tr_ctor * ctor,
const char ** setmeDestination );
int tr_ctorGetMetainfo ( const tr_ctor * ctor,
const struct benc_val_s ** setme );
const struct tr_benc ** setme );
int tr_ctorGetSave ( const tr_ctor * ctor );