//---------------------------------------------------------------------------------
#ifndef __iosupp_h__
#define __iosupp_h__
//---------------------------------------------------------------------------------

#include <reent.h>

enum	{
	STD_IN,
	STD_OUT,
	STD_ERR,
	STD_MAX = 16
};


typedef struct {
	int device;
	void *fileStruct;
} __handle;

typedef struct {
	const char *name;
	int	structSize;
	int (*open_r)(struct _reent *r, void *fileStruct, const char *path,int flags,int mode);
	int (*close_r)(struct _reent *r,int fd);
	int (*write_r)(struct _reent *r,int fd,const char *ptr,int len);
	int (*read_r)(struct _reent *r,int fd,char *ptr,int len);
	int (*seek_r)(struct _reent *r,int fd,int pos,int dir);
	int (*fstat_r)(struct _reent *r,int fd,struct stat *st);
	int (*stat_r)(struct _reent *r,const char *file,struct stat *st);
	int (*link_r)(struct _reent *r,const char *existing, const char  *new);
	int (*unlink_r)(struct _reent *r,const char *name);
	int (*chdir_r)(struct _reent *r,const char *name);
} devoptab_t;

extern const devoptab_t *devoptab_list[];

int AddDevice( const devoptab_t* device);
int FindDevice(const char* name);
int RemoveDevice(const char* name);
void setDefaultDevice( int device );

//---------------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------------
