blob: aceada8fc83df1a296d5cda54e09e3595a3cd23a [file] [log] [blame]
#pragma once
#include <stdbool.h>
#include <stdio.h>
#define MIN(a, b) (a) > (b) ? (b) : (a)
struct istream
{
void *data;
// These two return -1 on error
int (*peek)(struct istream *s);
int (*get)(struct istream *s);
int (*read)(struct istream *s, char *buffer, int size);
void (*showpos)(struct istream *s, FILE *out);
};
struct istream *new_stristream(char *str, int length);
// same as above but null terminated
struct istream *new_stristream_nt(char *str);
void del_stristream(struct istream *stristream);
struct istream *new_fistream(char *path, bool binary);
void del_fistream(struct istream *fistream);