]> git.sesse.net Git - fjl/blob - bytesource.h
Add back -O2.
[fjl] / bytesource.h
1 #ifndef _BYTESOURCE_H
2 #define _BYTESOURCE_H 1
3
4 #include <stdint.h>
5 #include <sys/types.h>
6
7 static const unsigned BYTESOURCE_CHUNK_SIZE = 4096;
8
9 // Same as input_func_t, although it expects raw bytes, ie. with markers
10 // and all.
11 typedef ssize_t (raw_input_func_t)(void*, uint8_t*, size_t);
12
13 // A data source taking in a byte stream and returning unstuffed bytes until
14 // there's a marker. When there's a marker, it artificially returns EOF until
15 // byte_source_read_marker() is called.
16 struct byte_source {
17         uint8_t* bytes;
18         unsigned bytes_available;
19
20         raw_input_func_t* input_func;
21         void* userdata;
22 };
23 void init_byte_source(struct byte_source* source, raw_input_func_t* input_func, void* userdata);
24 uint8_t byte_source_read_marker(struct byte_source* source);
25 ssize_t byte_source_input_func(void* source, uint8_t* buf, size_t len);
26
27 #endif /* !defined(_BYTESOURCE_H) */