#include <libtransmission/bencode.h>
#include <libtransmission/ipcparse.h>
+#include <libtransmission/utils.h> /* tr_free */
#include "bsdtree.h"
#include "errors.h"
}
}
-int
+static int
queuemsg( struct client * client, uint8_t * buf, size_t buflen )
{
if( NULL == buf )
return 0;
}
+static int
+queuepkmsg( struct client * client, tr_benc * pk )
+{
+ size_t buflen;
+ uint8_t * buf = ipc_serialize( pk, &buflen );
+ int ret = queuemsg( client, buf, buflen );
+ tr_free( buf );
+ return ret;
+}
+
int
msgresp( struct client * client, int64_t tag, enum ipc_msg id )
{
struct client * client = arg;
benc_val_t pk, * added;
int ii, tor;
- size_t buflen;
- uint8_t * buf;
if( !tr_bencIsList( val ) )
{
}
}
- buf = ipc_serialize( &pk, &buflen );
+ queuepkmsg( client, &pk );
tr_bencFree( &pk );
- queuemsg( client, buf, buflen );
- free( buf );
}
void
struct client * client = arg;
benc_val_t * val, pk;
int tor, start;
- size_t buflen;
- uint8_t * buf;
const char * dir;
if( !tr_bencIsDict( dict ) )
byebye( client->ev, EVBUFFER_EOF, NULL );
return;
}
- buf = ipc_serialize( &pk, &buflen );
+
+ queuepkmsg( client, &pk );
tr_bencFree( &pk );
- queuemsg( client, buf, buflen );
- free( buf );
}
else
{
infomsg( enum ipc_msg id, benc_val_t * val, int64_t tag, void * arg )
{
struct client * client = arg;
- uint8_t * buf;
- size_t buflen;
benc_val_t pk, * pkinf, * typelist, * idlist, * idval;
int all, types, ii, tor;
void * iter;
}
}
- /* generate packet data and send it */
- buf = ipc_serialize( &pk, &buflen );
+ queuepkmsg( client, &pk );
tr_bencFree( &pk );
- queuemsg( client, buf, buflen );
- free( buf );
}
int
lookmsg( enum ipc_msg id UNUSED, benc_val_t * val, int64_t tag, void * arg )
{
struct client * client = arg;
- uint8_t * buf;
- size_t buflen;
int ii;
benc_val_t * hash, pk, * pkinf;
int64_t found;
}
}
- buf = ipc_serialize( &pk, &buflen );
+ queuepkmsg( client, &pk );
tr_bencFree( &pk );
- queuemsg( client, buf, buflen );
- free( buf );
}
void
supmsg( enum ipc_msg id UNUSED, benc_val_t * val, int64_t tag, void * arg )
{
struct client * client = arg;
- uint8_t * buf;
- size_t buflen;
int ii;
benc_val_t pk, *pkval;
enum ipc_msg found;
name->val.s.s, name->val.s.i, 1 );
}
- buf = ipc_serialize( &pk, &buflen );
+ queuepkmsg( client, &pk );
tr_bencFree( &pk );
- queuemsg( client, buf, buflen );
- free( buf );
}