2013-01-29 21:45:44 -07:00
|
|
|
#ifndef _STREAM_H
|
|
|
|
#define _STREAM_H
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2013-07-23 16:30:38 -06:00
|
|
|
enum endianness {
|
|
|
|
ENDIAN_BIG,
|
|
|
|
ENDIAN_LITTLE
|
|
|
|
};
|
|
|
|
|
2013-01-29 21:45:44 -07:00
|
|
|
struct stream {
|
2013-01-29 21:53:17 -07:00
|
|
|
char const *buf;
|
|
|
|
size_t len;
|
2013-07-23 16:30:38 -06:00
|
|
|
enum endianness endian;
|
2013-01-29 21:45:44 -07:00
|
|
|
};
|
|
|
|
|
2013-07-23 16:30:38 -06:00
|
|
|
void sinit(struct stream *s, char const *buf, size_t len, enum endianness endian);
|
2013-01-29 21:45:44 -07:00
|
|
|
bool sskip(struct stream *s, size_t count);
|
|
|
|
bool sread(struct stream *s, void *buf, size_t count);
|
|
|
|
uint8_t read_uint8(struct stream *s);
|
|
|
|
uint16_t read_uint16be(struct stream *s);
|
|
|
|
uint16_t read_uint16le(struct stream *s);
|
2013-07-23 16:30:38 -06:00
|
|
|
uint16_t read_uint16(struct stream *s);
|
2013-01-29 21:45:44 -07:00
|
|
|
uint32_t read_uint32be(struct stream *s);
|
|
|
|
uint32_t read_uint32le(struct stream *s);
|
2013-07-23 16:30:38 -06:00
|
|
|
uint32_t read_uint32(struct stream *s);
|
2013-01-29 21:45:44 -07:00
|
|
|
|
|
|
|
#endif
|