/* Written by Stone Horse. Public domain */
#ifndef IOSTREAM_H
#define IOSTREAM_H 1

#include <ansi.h>

#define O_RDONLY	0
#define O_WRONLY	1
#define O_RDWR		2
#ifdef __NetBSD__
#define O_CREAT 512
#define O_TRUNC 1024
#else
#define O_CREAT 64
#define O_TRUNC 512
#endif
#define O_APPEND 1024
#define O_NONBLOCK 2048

#ifdef __arm__
#define O_DIRECTORY 16384
#define O_CLOEXEC 524288
#define O_LARGEFILE 131072
#else
#define O_DIRECTORY 65536
#define O_CLOEXEC 524288
#define O_LARGEFILE 32768
#endif

#define F_DUPFD 0
#define F_GETFD 1
#define F_SETFD 2
#define F_GETFL 3
#define F_SETFL 4

#define AT_FDCWD -100
#define AT_SYMLINK_NOFOLLOW 256
#define AT_REMOVEDIR 512
#define AT_EMPTY_PATH 4096

#define F_OK 0
#define R_OK 4
#define W_OK 2
#define X_OK 1

#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2

_PROTOTYPE(extern int open, (_CONST char *filename, unsigned int flags));
_PROTOTYPE(extern int fcntl, (unsigned int fd, unsigned int cmd, unsigned int arg));
_PROTOTYPE(extern unsigned int get, (unsigned int fd));
_PROTOTYPE(extern int get_line, (unsigned int fd, char *buff));
_PROTOTYPE(extern int put, (unsigned int fd, _CONST char *str));
_PROTOTYPE(extern int put_line, (unsigned int fd, _CONST char *str));
_PROTOTYPE(extern int putz, (unsigned int fd, _CONST char *str));
_PROTOTYPE(extern int read, (unsigned int fd, _VOID_PTR buf, unsigned int count));
_PROTOTYPE(extern int write, (unsigned int fd, _CONST _VOID_PTR buf, unsigned int count));
_PROTOTYPE(extern int close, (unsigned int fd));
_PROTOTYPE(extern int lseek, (unsigned int fd, unsigned int offset, unsigned int whence));
_PROTOTYPE(extern int pipe, (unsigned int fds[2]));

#endif
