Mercurial > repo
diff src/ploki/IO.h @ 4223:ac0403686959
<oerjan> rm -rf src/ploki; mv ploki src
author | HackBot |
---|---|
date | Fri, 20 Dec 2013 22:18:50 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ploki/IO.h Fri Dec 20 22:18:50 2013 +0000 @@ -0,0 +1,65 @@ +#ifndef IO_H_ +#define IO_H_ + +#include "config.h" +#include "Str.h" + +#include <stdio.h> + +typedef struct IO IO; + +enum io_flags { + IO_BINARY = 1, + IO_READ = 2 * IO_BINARY, + IO_WRITE = 2 * IO_READ, + IO_APPEND = 2 * IO_WRITE, + IO_TRUNCATE = 2 * IO_APPEND, + IO_BUFFERED = 2 * IO_TRUNCATE, + IO_AUTOFLUSH = 2 * IO_BUFFERED +}; + +enum io_whence { + IOS_START = SEEK_SET, + IOS_CUR = SEEK_CUR, + IOS_END = SEEK_END +}; + +void io_init(void); +void io_end(void); +const char *io_name(const IO *, String *); +IO *io_enter(const char *, FILE *, enum io_flags); +IO *io_open(const char *, enum io_flags); +IO *io_incr(IO *); +void io_decr(IO *); +int io_close(IO *); + +ATTR_PURE +int io_bufred(const IO *); +void io_unbuffer(IO *); +const char *io_bufptr(IO *); + +ATTR_PURE +FILE *io_fp(const IO *); + +int io_flush(IO *); +ATTR_PURE +int io_err(const IO *); +ATTR_PURE +int io_eof(const IO *); +int io_peek(IO *, size_t); +int io_cmppeek(IO *, size_t, const void *, size_t); +int io_xcmp(IO *, size_t, size_t, size_t); + +size_t io_read(IO *, String *, size_t); +int io_getc(IO *); +size_t io_getline(IO *, String *); +size_t io_write(IO *, const String *); +size_t io_write_m(IO *, const void *, size_t); +size_t io_write_s(IO *, const char *); +int io_putc(IO *, int); + +long io_tell(IO *); +int io_seek(IO *, long, enum io_whence); +void io_clearerr(IO *); + +#endif /* IO_H_ */