X-Git-Url: https://git.sesse.net/?p=fjl;a=blobdiff_plain;f=bytesource.h;h=bb934fb0cf343aac46b7513ff84b81a2c23016da;hp=fe1725981710746ed542d99fb473c4dd2c8c5660;hb=HEAD;hpb=30860bda5fd2474a3b45b05f6b89dcf7230a75a8 diff --git a/bytesource.h b/bytesource.h index fe17259..bb934fb 100644 --- a/bytesource.h +++ b/bytesource.h @@ -4,11 +4,9 @@ #include #include -static const unsigned BYTESOURCE_CHUNK_SIZE = 4096; +#include "input.h" -// 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); +static const unsigned BYTESOURCE_CHUNK_SIZE = 4096; // A data source taking in a byte stream and returning unstuffed bytes until // there's a marker. When there's a marker, it artificially returns EOF until @@ -21,7 +19,10 @@ struct byte_source { void* userdata; }; void init_byte_source(struct byte_source* source, raw_input_func_t* input_func, void* userdata); + +// Returns 0x00 if no marker was available (ie. error). uint8_t byte_source_read_marker(struct byte_source* source); + ssize_t byte_source_input_func(void* source, uint8_t* buf, size_t len); #endif /* !defined(_BYTESOURCE_H) */