(trunk libT) tweak the bencode comments a bit

This commit is contained in:
Charles Kerr 2009-04-21 16:52:28 +00:00
parent fb587a5b30
commit 098658e3ad
2 changed files with 22 additions and 24 deletions

View File

@ -21,6 +21,8 @@ extern "C" {
struct evbuffer; struct evbuffer;
/* these are PRIVATE IMPLEMENTATION details that should not be touched.
* it's included in the header for inlining and composition */
enum enum
{ {
TR_TYPE_INT = 1, TR_TYPE_INT = 1,
@ -30,10 +32,13 @@ enum
TR_TYPE_BOOL = 16, TR_TYPE_BOOL = 16,
TR_TYPE_REAL = 32 TR_TYPE_REAL = 32
}; };
/* these are PRIVATE IMPLEMENTATION details that should not be touched.
* it's included in the header for inlining and composition */
typedef struct tr_benc typedef struct tr_benc
{ {
char type; char type;
union union
{ {
uint8_t b; /* bool type */ uint8_t b; /* bool type */
@ -44,15 +49,15 @@ typedef struct tr_benc
struct /* string type */ struct /* string type */
{ {
size_t i; size_t i; /* the string length */
char * s; char * s; /* the string */
} s; } s;
struct /* list & dict types */ struct /* list & dict types */
{ {
size_t alloc; size_t alloc; /* nodes allocated */
size_t count; size_t count; /* nodes used */
struct tr_benc * vals; struct tr_benc * vals; /* nodes */
} l; } l;
} val; } val;
} tr_benc; } tr_benc;
@ -61,26 +66,19 @@ typedef struct tr_benc
**** ****
***/ ***/
int tr_bencParse( const void * buf, int tr_bencParse( const void * buf,
const void * bufend, const void * bufend,
tr_benc * setme_benc, tr_benc * setme_benc,
const uint8_t ** setme_end ); const uint8_t ** setme_end );
int tr_bencLoad( const void * buf, int tr_bencLoad( const void * buf,
size_t buflen, size_t buflen,
tr_benc * setme_benc, tr_benc * setme_benc,
char ** setme_end ); char ** setme_end );
int tr_bencLoadFile( const char * filename, int tr_bencLoadFile( const char * filename, tr_benc * setme );
tr_benc * );
int tr_bencLoadJSONFile( const char * filename, int tr_bencLoadJSONFile( const char * filename, tr_benc * setme );
tr_benc * );
#if 0
void tr_bencPrint( const tr_benc * );
#endif
void tr_bencFree( tr_benc * ); void tr_bencFree( tr_benc * );

View File

@ -499,7 +499,7 @@ onTrackerResponse( tr_session * session,
{ {
const int allAreSeeds = incomplete == 0; const int allAreSeeds = incomplete == 0;
if( tmp->type == TR_TYPE_STR ) /* "compact" extension */ if( tr_bencIsString( tmp ) ) /* "compact" extension */
{ {
publishNewPeersCompact6( t, allAreSeeds, tmp->val.s.s, publishNewPeersCompact6( t, allAreSeeds, tmp->val.s.s,
tmp->val.s.i ); tmp->val.s.i );