From 805e46450cfa9400e30fd124c893dda18e050f2b Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Thu, 11 Jan 2007 01:06:10 +0000 Subject: Documentation improved, some reindenting (again), variable types checked, unnecessary defines removed --- trackerlogic.h | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'trackerlogic.h') diff --git a/trackerlogic.h b/trackerlogic.h index 812cfce..178f8db 100644 --- a/trackerlogic.h +++ b/trackerlogic.h @@ -18,18 +18,12 @@ typedef ot_byte ot_hash[20]; typedef ot_dword ot_ip; typedef time_t ot_time; -#define MEMMOVE memmove -#define BZERO bzero -#define FORMAT_FIXED_STRING sprintf -#define FORMAT_FORMAT_STRING sprintf -#define BINARY_FIND binary_search +/* We maintain a list of 256 pointers to sorted list of ot_torrent structs + Sort key is, of course, its hash */ -// We maintain a list of 256 pointers to sorted list of ot_torrent structs -// Sort key is, of course, its hash - -// This list points to 9 pools of peers each grouped in five-minute-intervals -// thus achieving a timeout of 2700s or 45 minutes -// These pools are sorted by its binary content +/* This list points to 9 pools of peers each grouped in five-minute-intervals + thus achieving a timeout of 2700s or 45 minutes + These pools are sorted by its binary content */ #define OT_POOLS_COUNT 9 #define OT_POOLS_TIMEOUT 300 @@ -52,8 +46,8 @@ static const ot_byte PEER_FLAG_SEEDING = 0x80; static const ot_byte PEER_FLAG_COMPLETED = 0x40; static const ot_byte PEER_FLAG_STOPPED = 0x20; -#define OT_SETIP( peer, ip ) MEMMOVE((peer),(ip),4); -#define OT_SETPORT( peer, port ) MEMMOVE(((ot_byte*)peer)+4,(port),2); +#define OT_SETIP( peer, ip ) memmove((peer),(ip),4); +#define OT_SETPORT( peer, port ) memmove(((ot_byte*)peer)+4,(port),2); #define OT_FLAG(peer) (((ot_byte*)(peer))[6]) #define OT_PEER_COMPARE_SIZE ((size_t)6) @@ -61,8 +55,8 @@ static const ot_byte PEER_FLAG_STOPPED = 0x20; typedef struct { ot_time base; - unsigned long seed_count[ OT_POOLS_COUNT ]; - unsigned long downloaded; + size_t seed_count[ OT_POOLS_COUNT ]; + unsigned int downloaded; ot_vector peers[ OT_POOLS_COUNT ]; } ot_peerlist; @@ -71,9 +65,9 @@ typedef struct { ot_peerlist *peer_list; } ot_torrent; -// -// Exported functions -// +/* + Exported functions +*/ int init_logic( char *serverdir ); void deinit_logic( ); @@ -86,7 +80,7 @@ extern int g_check_blacklist; #endif ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ); -size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char *reply ); +size_t return_peers_for_torrent( ot_torrent *torrent, unsigned int amount, char *reply ); size_t return_scrape_for_torrent( ot_hash *hash, char *reply ); void remove_peer_from_torrent( ot_hash *hash, ot_peer *peer ); void cleanup_torrents( void ); -- cgit v1.2.3