trash/nice-os

Clone repo: git clone https://git.topcheto.eu/trash/nice-os.git
All branches, All tags, View raw

File contents

#ifndef STREAMS_H
#define STREAMS_H

#define EOF -1
#define ERRNO_NOT_SUPPORTED 1
#define ERRNO_STREAM_ENDLESS 2
#define ERRNO_SEEK_OUT_OF_BOUNDS 3

typedef int (*streamReadFunc)();
typedef void (*streamWriteFunc)(int val);
typedef void (*streamSeekFunc)(int pos, int whence);
typedef int (*streamTellFunc)();

typedef struct _stream {
    int (*read)(struct _stream* str);
    int (*write)(struct _stream* str, char val);
    int (*seek)(struct _stream* str, int pos, int whence);
    int (*tell)(struct _stream* str);
    int (*errno)(struct _stream* str);

    void* data;
} FILE;

#endif