/* mstream.h */
/* Reads lines serially from a block of memory, analogous to stdio except
   where documented otherwise */
#ifndef MSTREAM_H
#define MSTREAM_H

#include <stddef.h>

#include "fmstream.h"

mstream *
mstream_open(const char *block, size_t size);

int
mstream_close(fmstream);

/* No "whence", only SEEK_SET supported */
int
mstream_seek(fmstream, long int offset);

long int
mstream_tell(fmstream);

/* Here we deviate from stdio analogues, this nicely allocates the string
   to just the right length (with malloc) */
char *
mstream_read_line(fmstream);

/* Extracts size bytes from the stream, starting from offset
   and puts them into buffer.
   Stream's internal position pointer is updated.
*/
char *
mstream_read_bytes(fmstream, long int offset, size_t size, char *buffer);

/* Reads a "Pascal-style" string (preceded by one-byte length, no terminator) */
char *
mstream_read_pstring(fmstream);

/* le = little endian */
int
mstream_read_word16le(fmstream, fms_t16 *value);

int
mstream_read_word32le(fmstream, int *value);

#endif
