/*
 * io.h --- the I/O manager abstraction
 */

typedef struct struct_io_manager *io_manager;
typedef struct struct_io_channel *io_channel;

struct struct_io_channel {
	io_manager	manager;
	char		*name;
	void		*private_data;
};

struct struct_io_manager {
	char *name;
	errcode_t (*open)(char *name, int flags, io_channel *channel);
	errcode_t (*close)(io_channel channel);
	errcode_t (*set_blksize)(io_channel channel, int blksize);
	errcode_t (*read_blk)(io_channel channel, unsigned long block,
			      int count, void *data);
	errcode_t (*write_blk)(io_channel channel, unsigned long block,
			       int count, void *data);
	errcode_t (*flush)(io_channel channel);
};

#define IO_FLAG_RW	1

/*
 * Convenience functions....
 */
#define io_channel_close(c) 		((c)->manager->close((c)))
#define io_channel_set_blksize(c,s)	((c)->manager->set_blksize((c),s))
#define io_channel_read_blk(c,b,n,d)	((c)->manager->read_blk((c),b,n,d))
#define io_channel_write_blk(c,b,n,d)	((c)->manager->write_blk((c),b,n,d))
#define io_channel_flush(c) 		((c)->manager->flush((c)))
	
extern io_manager unix_io_manager;




