about summary refs log tree commit diff
path: root/misc/stream.h
diff options
context:
space:
mode:
authorRichard Nyberg <rnyberg@murmeldjur.se>2005-06-24 09:51:38 +0000
committerRichard Nyberg <rnyberg@murmeldjur.se>2005-06-24 09:51:38 +0000
commitdd0d462afae75ff243f8cd1528963f9ad489706d (patch)
tree2ef874a1fe5212245814d16f4c9b389524aed9d1 /misc/stream.h
downloadbtpd-dd0d462afae75ff243f8cd1528963f9ad489706d.tar.gz
btpd-dd0d462afae75ff243f8cd1528963f9ad489706d.zip
Import btpd-0.1.
git-svn-id: file:///home/rnyberg/svngit/btpd/releases/0.1@1 76a1f634-46fa-0310-9943-bd1476092a85
Diffstat (limited to 'misc/stream.h')
-rw-r--r--misc/stream.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/misc/stream.h b/misc/stream.h
new file mode 100644
index 0000000..f71e5c9
--- /dev/null
+++ b/misc/stream.h
@@ -0,0 +1,36 @@
+#ifndef BTPD_STREAM_H
+#define BTPD_STREAM_H
+
+typedef int (*F_fdcb)(const char *, int *, void *);
+
+#define def_stream(name) \
+struct name {\
+    struct metainfo *meta;\
+    F_fdcb fd_cb;\
+    void *fd_arg;\
+    unsigned index;\
+    off_t t_off;\
+    off_t f_off;\
+    int fd;\
+}
+
+def_stream(bt_stream_ro);
+
+struct bt_stream_ro *
+bts_open_ro(struct metainfo *meta, off_t off, F_fdcb fd_cb, void *fd_arg);
+int bts_read_ro(struct bt_stream_ro *bts, char *buf, size_t len);
+void bts_seek_ro(struct bt_stream_ro *bts, off_t nbytes);
+void bts_close_ro(struct bt_stream_ro *bts);
+
+def_stream(bt_stream_wo);
+
+struct bt_stream_wo *
+bts_open_wo(struct metainfo *meta, off_t off, F_fdcb fd_cb, void *fd_arg);
+int bts_write_wo(struct bt_stream_wo *bts, const char *buf, size_t len);
+int bts_close_wo(struct bt_stream_wo *bts);
+
+int bts_sha(struct bt_stream_ro *bts, off_t length, uint8_t *hash);
+int bts_hashes(struct metainfo *, F_fdcb fd_cb,
+	       void (*cb)(uint32_t, uint8_t *, void *), void *arg);
+
+#endif