A clone of btpd with my configuration changes.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.5 KiB

  1. #ifndef BTPD_TORRENT_H
  2. #define BTPD_TORRENT_H
  3. #define PIECE_BLOCKLEN (1 << 14)
  4. struct piece {
  5. struct torrent *tp;
  6. uint32_t index;
  7. unsigned nblocks;
  8. unsigned ngot;
  9. unsigned nbusy;
  10. uint8_t *have_field;
  11. uint8_t *down_field;
  12. BTPDQ_ENTRY(piece) entry;
  13. };
  14. BTPDQ_HEAD(piece_tq, piece);
  15. struct torrent {
  16. const char *relpath;
  17. struct metainfo meta;
  18. BTPDQ_ENTRY(torrent) entry;
  19. void *imem;
  20. size_t isiz;
  21. uint8_t *piece_field;
  22. uint8_t *block_field;
  23. uint8_t *busy_field;
  24. uint32_t npcs_busy;
  25. uint32_t have_npieces;
  26. unsigned *piece_count;
  27. uint64_t uploaded, downloaded;
  28. unsigned long choke_time;
  29. unsigned long opt_time;
  30. unsigned long tracker_time;
  31. short ndown;
  32. struct peer *optimistic;
  33. unsigned npeers;
  34. struct peer_tq peers;
  35. int endgame;
  36. struct piece_tq getlst;
  37. };
  38. BTPDQ_HEAD(torrent_tq, torrent);
  39. off_t torrent_bytes_left(struct torrent *tp);
  40. char *torrent_get_bytes(struct torrent *tp, off_t start, size_t len);
  41. void torrent_put_bytes(struct torrent *tp, const char *buf,
  42. off_t start, size_t len);
  43. int torrent_load(const char *metafile);
  44. void torrent_unload(struct torrent *tp);
  45. int torrent_has_peer(struct torrent *tp, const uint8_t *id);
  46. struct torrent *torrent_get_by_hash(const uint8_t *hash);
  47. off_t torrent_piece_size(struct torrent *tp, uint32_t index);
  48. uint32_t torrent_block_size(struct piece *pc, uint32_t index);
  49. int torrent_has_all(struct torrent *tp);
  50. #endif