summaryrefslogtreecommitdiff
path: root/trackerlogic.h
diff options
context:
space:
mode:
authorerdgeist <>2006-12-14 02:44:50 +0000
committererdgeist <>2006-12-14 02:44:50 +0000
commit688a4edd9e489de26a9b53ea79f513e6461c7533 (patch)
tree25cb8c040bf69fbb350a602950528f5f15addd61 /trackerlogic.h
parentc0f667defe1efd74b98e283aad635eed5092475e (diff)
Now actually seems to work for the most parts
Added scraping Added graceful disconnect
Diffstat (limited to 'trackerlogic.h')
-rw-r--r--trackerlogic.h48
1 files changed, 21 insertions, 27 deletions
diff --git a/trackerlogic.h b/trackerlogic.h
index 3243eb7..44bd744 100644
--- a/trackerlogic.h
+++ b/trackerlogic.h
@@ -32,40 +32,31 @@ typedef time_t ot_time;
32#define OT_POOLS_TIMEOUT 300 32#define OT_POOLS_TIMEOUT 300
33#define NOW (time(NULL)/OT_POOLS_TIMEOUT) 33#define NOW (time(NULL)/OT_POOLS_TIMEOUT)
34 34
35typedef struct ot_vector { 35typedef struct {
36 void *data; 36 void *data;
37 size_t size; 37 size_t size;
38 size_t space; 38 size_t space;
39} *ot_vector; 39} ot_vector;
40 40
41typedef struct ot_peer { 41typedef struct {
42 ot_ip ip; 42 ot_ip ip;
43 ot_dword port_flags; 43 ot_dword port_flags;
44} *ot_peer; 44} ot_peer;
45static const ot_byte PEER_FLAG_SEEDING = 0x80; 45static const ot_byte PEER_FLAG_SEEDING = 0x80;
46static const ot_byte PEER_FLAG_COMPLETED = 0x40;
47static const ot_byte PEER_FLAG_STOPPED = 0x20;
46 48
47typedef struct ot_peerlist { 49typedef struct {
48 ot_time base; 50 ot_time base;
49 unsigned long seed_count[ OT_POOLS_COUNT ]; 51 unsigned long seed_count[ OT_POOLS_COUNT ];
50 struct ot_vector peers[ OT_POOLS_COUNT ]; 52 unsigned long downloaded;
51} *ot_peerlist; 53 ot_vector peers[ OT_POOLS_COUNT ];
54} ot_peerlist;
52 55
53typedef struct ot_torrent { 56typedef struct {
54 ot_hash hash; 57 ot_hash hash;
55 ot_peerlist peer_list; 58 ot_peerlist *peer_list;
56} *ot_torrent; 59} ot_torrent;
57
58void *map_file( char *file_name, size_t map_size );
59void unmap_file( char *file_name, void *map, size_t mapped_size, unsigned long real_size );
60
61// This behaves quite like bsearch but allows to find
62// the insertion point for inserts after unsuccessful searches
63// in this case exactmatch is 0 on exit
64//
65void *binary_search( const void *key, const void *base,
66 const unsigned long member_count, const unsigned long member_size,
67 int (*compar) (const void *, const void *),
68 int *exactmatch );
69 60
70// 61//
71// Exported functions 62// Exported functions
@@ -74,7 +65,10 @@ void *binary_search( const void *key, const void *base,
74int init_logic( char *chdir_directory ); 65int init_logic( char *chdir_directory );
75void deinit_logic( ); 66void deinit_logic( );
76 67
77ot_torrent add_peer_to_torrent( ot_hash *hash, ot_peer peer ); 68ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer );
78size_t return_peers_for_torrent( ot_torrent torrent, unsigned long amount, char *reply ); 69size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char *reply );
70size_t return_scrape_for_torrent( ot_hash *hash, char *reply );
71void remove_peer_from_torrent( ot_hash *hash, ot_peer *peer );
72void cleanup_torrents( void );
79 73
80#endif 74#endif