view src/ploki/IO.h @ 8427:1fc808cd5b1f

<b_jonas> learn can\'t is the most frequent word whose pronunciation varies between /\xc9\x91\xcb\x90/ and /\xc3\xa6/ depending on dialect. The list is: advance after answer ask aunt brass can\'t cast castle chance class command dance demand draft enhance example fast father glass graph grass half last laugh mask master nasty pass past path plant rather sample shan\'t staff task vast
author HackBot
date Thu, 09 Jun 2016 21:28:47 +0000
parents ac0403686959
children
line wrap: on
line source

#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_ */