summaryrefslogtreecommitdiff
path: root/trackerlogic.h
diff options
context:
space:
mode:
Diffstat (limited to 'trackerlogic.h')
-rw-r--r--trackerlogic.h22
1 files changed, 7 insertions, 15 deletions
diff --git a/trackerlogic.h b/trackerlogic.h
index 1eff6df..eefc038 100644
--- a/trackerlogic.h
+++ b/trackerlogic.h
@@ -9,14 +9,7 @@
9#include <time.h> 9#include <time.h>
10#include <stdint.h> 10#include <stdint.h>
11 11
12/* Should be called BYTE, WORD, DWORD - but some OSs already have that and there's no #iftypedef */ 12typedef uint8_t ot_hash[20];
13/* They mark memory used as data instead of integer or human readable string -
14 they should be cast before used as integer/text */
15typedef uint8_t ot_byte;
16typedef uint16_t ot_word;
17typedef uint32_t ot_dword;
18
19typedef ot_byte ot_hash[20];
20typedef time_t ot_time; 13typedef time_t ot_time;
21 14
22/* Some tracker behaviour tunable */ 15/* Some tracker behaviour tunable */
@@ -46,20 +39,19 @@ typedef time_t ot_time;
46#define OT_POOLS_TIMEOUT (60*5) 39#define OT_POOLS_TIMEOUT (60*5)
47 40
48/* From opentracker.c */ 41/* From opentracker.c */
49extern time_t ot_start_time;
50extern time_t g_now; 42extern time_t g_now;
51#define NOW (g_now/OT_POOLS_TIMEOUT) 43#define NOW (g_now/OT_POOLS_TIMEOUT)
52 44
53typedef struct { 45typedef struct {
54 ot_byte data[8]; 46 uint8_t data[8];
55} ot_peer; 47} ot_peer;
56static const ot_byte PEER_FLAG_SEEDING = 0x80; 48static const uint8_t PEER_FLAG_SEEDING = 0x80;
57static const ot_byte PEER_FLAG_COMPLETED = 0x40; 49static const uint8_t PEER_FLAG_COMPLETED = 0x40;
58static const ot_byte PEER_FLAG_STOPPED = 0x20; 50static const uint8_t PEER_FLAG_STOPPED = 0x20;
59 51
60#define OT_SETIP( peer, ip ) memmove((peer),(ip),4); 52#define OT_SETIP( peer, ip ) memmove((peer),(ip),4);
61#define OT_SETPORT( peer, port ) memmove(((ot_byte*)peer)+4,(port),2); 53#define OT_SETPORT( peer, port ) memmove(((uint8_t*)peer)+4,(port),2);
62#define OT_FLAG(peer) (((ot_byte*)(peer))[6]) 54#define OT_FLAG(peer) (((uint8_t*)(peer))[6])
63 55
64#define OT_PEER_COMPARE_SIZE ((size_t)6) 56#define OT_PEER_COMPARE_SIZE ((size_t)6)
65#define OT_HASH_COMPARE_SIZE (sizeof(ot_hash)) 57#define OT_HASH_COMPARE_SIZE (sizeof(ot_hash))