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.

stream.h 1000 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef BTPD_STREAM_H
  2. #define BTPD_STREAM_H
  3. typedef int (*F_fdcb)(const char *, int *, void *);
  4. #define def_stream(name) \
  5. struct name {\
  6. struct metainfo *meta;\
  7. F_fdcb fd_cb;\
  8. void *fd_arg;\
  9. unsigned index;\
  10. off_t t_off;\
  11. off_t f_off;\
  12. int fd;\
  13. }
  14. def_stream(bt_stream_ro);
  15. struct bt_stream_ro *
  16. bts_open_ro(struct metainfo *meta, off_t off, F_fdcb fd_cb, void *fd_arg);
  17. int bts_read_ro(struct bt_stream_ro *bts, char *buf, size_t len);
  18. void bts_seek_ro(struct bt_stream_ro *bts, off_t nbytes);
  19. void bts_close_ro(struct bt_stream_ro *bts);
  20. def_stream(bt_stream_wo);
  21. struct bt_stream_wo *
  22. bts_open_wo(struct metainfo *meta, off_t off, F_fdcb fd_cb, void *fd_arg);
  23. int bts_write_wo(struct bt_stream_wo *bts, const char *buf, size_t len);
  24. int bts_close_wo(struct bt_stream_wo *bts);
  25. int bts_sha(struct bt_stream_ro *bts, off_t length, uint8_t *hash);
  26. int bts_hashes(struct metainfo *, F_fdcb fd_cb,
  27. void (*cb)(uint32_t, uint8_t *, void *), void *arg);
  28. #endif