#ifndef	IOBASE_H
#define	IOBASE_H

#include <../source/TAL/objbase.h>

/*
 * I/O port object. This object can later be passed to
 * fileXXXX routines (they just check the handle and then
 * call member functions).
 * This object used in numerous routines in VFS and PAL.
 */
typedef struct ioport_base_s
{
	/* Note: destroy() is in ancestor */
	libv_object_t base;
	/*	Character-dev and block-dev IO */
	vsize_t	(V_CALL *read)(vhandle_t self,void *buf,vsize_t len);
	vsize_t	(V_CALL *write)(vhandle_t self,void *buf,vsize_t len);
	/*	Block-dev IO only */
	vsize_t	(V_CALL *seek)(vhandle_t self,vssize_t offset,int whence);
	vsize_t	(V_CALL *tell)(vhandle_t self);
	/*	ioctl(); error condition must be signaled as '-1' */
	int		(V_CALL	*ioctl)(vhandle_t self,unsigned code,void *parameters);
}	ioport_base_t, *ioport_base_p;

#ifdef	CHECKED_BUILD
#define	IOPORT_MAGIC	0x46494C45			/* {'F','I','L','E'} */
#endif	/* CHECKED_BUILD */

#ifdef	__cplusplus
extern "C" {
#endif	/* __cplusplus */
	/*
	 * ioAllocPort() - helper function, used internally by IO manager.
	 * It allocates memory for derived object (for example, file port) 
	 * and sets all methods in file->vtbl to stubs; all stubs just 
	 * print message 'method not supported'.
	 * Arguments:
	 *   'size_of_real_port' - size of descendant object.
	 */
	void_p	V_CALL	ioAllocPort(vsize_t size_of_real_port);
#ifdef	__cplusplus
}
#endif	/* __cplusplus */

#endif	/* IOBASE_H */
