blob: aceada8fc83df1a296d5cda54e09e3595a3cd23a [file] [log] [blame]
swissChili923b5362021-05-09 20:31:43 -07001#pragma once
2
3#include <stdbool.h>
4#include <stdio.h>
5
6#define MIN(a, b) (a) > (b) ? (b) : (a)
7
8struct istream
9{
10 void *data;
11
12 // These two return -1 on error
13 int (*peek)(struct istream *s);
14 int (*get)(struct istream *s);
15
16 int (*read)(struct istream *s, char *buffer, int size);
17
18 void (*showpos)(struct istream *s, FILE *out);
19};
20
21struct istream *new_stristream(char *str, int length);
22// same as above but null terminated
23struct istream *new_stristream_nt(char *str);
24void del_stristream(struct istream *stristream);
25
26struct istream *new_fistream(char *path, bool binary);
27void del_fistream(struct istream *fistream);