A clone of btpd with my configuration changes.

59 lines
1.5 KiB

  1. #ifndef BTPD_TLIB_H
  2. #define BTPD_TLIB_H
  3. struct tlib {
  4. unsigned num;
  5. uint8_t hash[20];
  6. struct torrent *tp;
  7. char *name;
  8. char *dir;
  9. unsigned long long tot_up, tot_down;
  10. off_t content_size, content_have;
  11. HTBL_ENTRY(nchain);
  12. HTBL_ENTRY(hchain);
  13. };
  14. struct file_time_size {
  15. off_t size;
  16. time_t mtime;
  17. };
  18. void tlib_init(void);
  19. struct tlib *tlib_iter_first(struct htbl_iter *it);
  20. struct tlib *tlib_iter_next(struct htbl_iter *it);
  21. struct tlib *tlib_add(const uint8_t *hash, const char *mi, size_t mi_size,
  22. const char *content, char *name);
  23. struct tlib *tlib_readd(struct tlib *tl, const uint8_t *hash, const char *mi,
  24. size_t mi_size, const char *content, char *name);
  25. int tlib_del(struct tlib *tl);
  26. void tlib_kill(struct tlib *tl);
  27. void tlib_update_info(struct tlib *tl, int only_file);
  28. struct tlib *tlib_by_hash(const uint8_t *hash);
  29. struct tlib *tlib_by_num(unsigned num);
  30. unsigned tlib_count(void);
  31. int tlib_load_mi(struct tlib *tl, char **res);
  32. void tlib_read_hash(struct tlib *tl, size_t off, uint32_t piece,
  33. uint8_t *hash);
  34. struct resume_data *tlib_open_resume(struct tlib *tl, unsigned nfiles,
  35. size_t pfsize, size_t bfsize);
  36. void tlib_close_resume(struct resume_data *resume);
  37. uint8_t *resume_piece_field(struct resume_data *resd);
  38. uint8_t *resume_block_field(struct resume_data *resd);
  39. void resume_set_fts(struct resume_data *resd, int i,
  40. struct file_time_size *fts);
  41. void resume_get_fts(struct resume_data *resd, int i,
  42. struct file_time_size *fts);
  43. #endif