#ifndef	ARCH_H
#define	ARCH_H

#include <../source/TAL/objbase.h>
#include <../source/PAL/oshead.h> /* FIXME */

/*
 * Data types common for all platforms
 */
typedef enum
{
	file_mode_read,
	file_mode_write,
	file_mode_append
}	file_mode_t;

/*
 * open(...) call on directories not supported on all platforms.
 * We limit archFileOpen() fo regular files, block and character
 * devices.
 */
typedef enum
{
	file_type_reg,		/* regular file */
	file_type_blk_dev,	/* block special file */
	file_type_chr_dev,	/* character special file */
	file_type_unknown	/* unknown file type */
}	file_type_t;

/*
 * Include arch-specific macros adn data types.
 */
#if		defined(__UNIX__)
#include <../arch/generic/arch.h>
#elif	defined(__WIN32__)
#include <../arch/win32/arch.h>
#else
#error	Unknown platform !
#endif

/*
 * All arguments except whose marked as '...ARGNAME..._opt' are mandatory
 * and must NOT be null.
 */
#ifdef __cplusplus
extern "C" {
#endif	/* __cplusplus */
	/*
	 * File I/O (mandatory)
	 */
	vboolean	V_CALL	archFileExists(char *right_slashed_name);
	arch_file_t	V_CALL	archFileOpen(char *right_slashed_name,file_mode_t filemode,file_type_t *ft_ret_opt);
	file_type_t V_CALL	archGetFileType(arch_file_t file);
	vsize_t	V_CALL	archGetFileSize(arch_file_t file);
	vsize_t	V_CALL	archGetFilePointer(arch_file_t file);
	vboolean	V_CALL	archSetFilePointer(arch_file_t file,vsize_t	offset,u32_t whence);
	vboolean 	V_CALL	archFlushFileBuffers(arch_file_t file);
	vsize_t	V_CALL	archFileRead(arch_file_t file,void *buffer,vsize_t len);
	vsize_t	V_CALL	archFileWrite(arch_file_t file,void *buffer,vsize_t len);
	void		V_CALL	archFileClose(arch_file_t file);
	/*
	 * Console I/O (mandatory)
	 */
	arch_file_t	V_CALL	archOpenConsole(file_mode_t filemode);
	/*
	 * FS management (mandatory)
	 */
	vboolean	V_CALL	archGetCurrentDirectory(char *dir_ret,u32_t dir_ret_size);
	vboolean	V_CALL	archSetCurrentDirectory(char *new_dir,vboolean *dir_exist_ret_opt);
	vboolean	V_CALL	archMakeDirectory(char *new_dir);
	vboolean	V_CALL	archFindFirst(char *dir_name,struct arch_dir_s *dir);
	vboolean	V_CALL	archFindNext(struct arch_dir_s *dir);
	void		V_CALL	archFindClose(struct arch_dir_s *dir);
#ifdef	ARCH_MAPPED_IO_SUPPORTED
	/*
	 * Memory-mapped I/O (optional)
	 */

	/*
	 * Mapping length can be 0; in this case 'size'-'start' bytes will be mapped.
	 */
	void_p		V_CALL	archMapRead(arch_file_t file,vsize_t start,
		vsize_t len,struct arch_filemap_s *map);
	/*
	 * Mapping length must be non-0.
	 */
	void_p		V_CALL	archMapReadWrite(arch_file_t file,
		vsize_t start,vsize_t len,struct arch_filemap_s *map);

	void		V_CALL	archUnmap(struct arch_filemap_s *map);
#endif	/* ARCH_MAPPED_IO_SUPPORTED */
#ifdef __cplusplus
}
#endif	/* __cplusplus */

#endif	/* ARCH_H */

