Move ipc parsing code into libt.

This commit is contained in:
Josh Elsasser 2007-05-24 03:44:40 +00:00
parent 2e1773a974
commit 8d61b3e49e
4 changed files with 63 additions and 3 deletions

View File

@ -30,11 +30,71 @@
#include "bsdtree.h"
#include "ipc.h"
#include "misc.h"
#include "transmission.h"
#include "bencode.h"
/* begin copy-paste from daemon/misc.h */
#define ARRAYLEN( ary ) ( sizeof( ary ) / sizeof( (ary)[0] ) )
#ifndef MIN
#define MIN( aa, bb ) ( (aa) < (bb) ? (aa) : (bb) )
#endif
#ifndef MAX
#define MAX( aa, bb ) ( (aa) > (bb) ? (aa) : (bb) )
#endif
#undef NULL
#define NULL ( ( void * )0 )
#define TORRENT_ID_VALID( id ) ( 0 < (id) && INT_MAX > (id) )
#define SAFEFREE( ptr ) \
do \
{ \
int saved = errno; \
free( ptr ); \
errno = saved; \
} \
while( 0 )
#define SAFEFREESTRLIST( ptr ) \
do \
{ \
int saved = errno; \
FREESTRLIST( ptr ); \
errno = saved; \
} \
while( 0 )
#define SAFEBENCFREE( val ) \
do \
{ \
int saved = errno; \
tr_bencFree( val ); \
errno = saved; \
} \
while( 0 )
#define INTCMP_FUNC( name, type, id ) \
int \
name( struct type * _icf_first, struct type * _icf_second ) \
{ \
if( _icf_first->id < _icf_second->id ) \
{ \
return -1; \
} \
else if( _icf_first->id > _icf_second->id ) \
{ \
return 1; \
} \
else \
{ \
return 0; \
} \
}
/* end copy-paste from daemon/misc.h */
/* IPC protocol version */
#define PROTO_VERS_MIN ( 1 )
#define PROTO_VERS_MAX ( 2 )

View File

@ -3,7 +3,7 @@
include ../mk/config.mk
include ../mk/common.mk
COMSRCS = errors.c ipc.c misc.c
COMSRCS = errors.c misc.c
SRVSRCS = daemon.c server.c torrents.c
CLISRCS = client.c remote.c
PXYSRCS = proxy.c

View File

@ -6,7 +6,7 @@ include ../mk/common.mk
SRCS = transmission.c bencode.c net.c tracker.c peer.c inout.c \
metainfo.c sha1.c utils.c fdlimit.c clients.c completion.c \
platform.c ratecontrol.c choking.c natpmp.c upnp.c http.c xml.c \
shared.c torrent.c strlcpy.c strlcat.c
shared.c torrent.c strlcpy.c strlcat.c ipc.c
OBJS = $(SRCS:%.c=%.o)