/* osfstream.h */
/* Reads lines serially from a file (using OS handles),
   analogous to stdio except where documented otherwise */
#ifndef OSFSTREAM_H
#define OSFSTREAM_H

#include <stddef.h>

#include "fmstream.h"

/* Read-only */
osfstream *
osfstream_open(const char *filename);

int
osfstream_close(fmstream);

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

long int
osfstream_tell(fmstream);

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

/* Returns a pointer to size bytes in the stream, starting from offset.
   Stream's internal position pointer is updated.
*/
char *
osfstream_read_bytes(fmstream, long int offset, size_t size, char *buffer);

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

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

int
osfstream_read_word32le(fmstream, int *value);

#endif
