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.

54 lines
1.2 KiB

  1. #ifndef BTPD_TORRENT_H
  2. #define BTPD_TORRENT_H
  3. #define PIECE_BLOCKLEN (1 << 14)
  4. #define RELPATH_SIZE SHAHEXSIZE
  5. enum torrent_state {
  6. T_STARTING,
  7. T_ACTIVE,
  8. T_STOPPING
  9. };
  10. struct torrent {
  11. struct tlib *tl;
  12. char relpath[RELPATH_SIZE];
  13. enum torrent_state state;
  14. struct content *cm;
  15. struct tracker *tr;
  16. struct net *net;
  17. off_t total_length;
  18. off_t piece_length;
  19. uint32_t npieces;
  20. unsigned nfiles;
  21. struct mi_file *files;
  22. size_t pieces_off;
  23. BTPDQ_ENTRY(torrent) entry;
  24. };
  25. BTPDQ_HEAD(torrent_tq, torrent);
  26. unsigned torrent_count(void);
  27. const struct torrent_tq *torrent_get_all(void);
  28. struct torrent *torrent_by_num(unsigned num);
  29. struct torrent *torrent_by_hash(const uint8_t *hash);
  30. enum ipc_err torrent_start(struct tlib *tl);
  31. void torrent_stop(struct torrent *tp);
  32. off_t torrent_piece_size(struct torrent *tp, uint32_t piece);
  33. uint32_t torrent_piece_blocks(struct torrent *tp, uint32_t piece);
  34. uint32_t torrent_block_size(struct torrent *tp, uint32_t piece,
  35. uint32_t nblocks, uint32_t block);
  36. const char *torrent_name(struct torrent *tp);
  37. void torrent_on_cm_stopped(struct torrent *tp);
  38. void torrent_on_cm_started(struct torrent *tp);
  39. void torrent_on_tr_stopped(struct torrent *tp);
  40. #endif