X-Git-Url: https://git.sesse.net/?p=fjl;a=blobdiff_plain;f=input.h;fp=input.h;h=be60c5ac87db55f5591ddb2c0fd02fd11df9a3bf;hp=0000000000000000000000000000000000000000;hb=352c52d38c212a2aa93a9970731c9d7a2f8d4dac;hpb=b8abdf976177386c5fe85712280a669ba80a41d2 diff --git a/input.h b/input.h new file mode 100644 index 0000000..be60c5a --- /dev/null +++ b/input.h @@ -0,0 +1,19 @@ +#ifndef _INPUT_H +#define _INPUT_H 1 + +#include +#include + +// 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) */