]> git.sesse.net Git - fjl/blobdiff - input.h
Move some common input stuff around.
[fjl] / input.h
diff --git a/input.h b/input.h
new file mode 100644 (file)
index 0000000..be60c5a
--- /dev/null
+++ b/input.h
@@ -0,0 +1,19 @@
+#ifndef _INPUT_H
+#define _INPUT_H 1
+
+#include <stdint.h>
+#include <sys/types.h>
+
+// A function to read bytes from some input source. The bytes should be
+// already unstuffed (and thus without markers).
+// A return value of -1 indicates error, a return value of 0 indicates EOF.
+typedef ssize_t (input_func_t)(void*, uint8_t*, size_t);
+
+// Same as input_func_t, although it expects raw bytes, ie. with markers
+// and all.
+typedef ssize_t (raw_input_func_t)(void*, uint8_t*, size_t);
+
+void reliable_read(raw_input_func_t* input_func, void* userdata, uint8_t* buf, size_t len);
+uint16_t read_length(raw_input_func_t* input_func, void* userdata);
+
+#endif /* !defined(_INPUT_H) */