#ifndef	ARCH_GENERIC_H
#define	ARCH_GENERIC_H

#ifndef	ARCH_H
#error	Master header is $(libv_root)/arch/arch.h; #include _it_ first !
#endif	/* ARCH_H */

/*
 * Enable/disable some features
 */
#include "./platform.h"

/*
 * Win32 - specific defines and structures
 */
#define	ARCH_INVALID_FILE		INVALID_HANDLE_VALUE
typedef HANDLE					arch_file_t;
typedef	unsigned				vsize_t;

struct arch_dir_s
{
	/*
	 * Win32 - specific part
	 */
	HANDLE			sh;
	WIN32_FIND_DATA	ffd;
	/*
	 * Common part
	 */
	char			*name;	/* entry name */
	vboolean		is_dir;	/* == true if 'name' is a directory name */
	file_type_t		ftype;	/* meaningful only if 'name' is a file name */
};

#ifdef	ARCH_MAPPED_IO_SUPPORTED

struct arch_filemap_s
{
	void_p	base_addr;
	HANDLE	mapping_handle;
};

#endif	/* ARCH_MAPPED_IO_SUPPORTED */


#ifdef	ARCH_IPC_SUPPORTED

#define	IPC_MSG_LEN			512

typedef struct arch_pipe_s
{
	HANDLE slot;
	HANDLE ev_data;
}	arch_pipe_t, *arch_pipe_p;

#endif	/* ARCH_IPC_SUPPORTED */


/*
 * Extra functions
 */
void V_CALL	dos_name_to_unix_name(char *name,char *native);
void V_CALL	unix_name_to_dos_name(char *native,char *name);

/*
 * Debug output
 */

#ifdef	ARCH_VERBOSE

#define	SYSCALL_FAILED(syscall) \
		conlPrintf(LOG_ERROR, \
			"%s(): %s() failed (GetLastError() == %u).\n", \
			arch_caller_name,syscall,GetLastError());

#define	SYSCALL_FAILED_1STR(syscall,str_arg1) \
		conlPrintf(LOG_ERROR, \
			"%s(): %s(%s) failed (GetLastError() == %u).\n", \
			arch_caller_name,syscall,str_arg1,GetLastError());

#else	/* !ARCH_VERBOSE */

#define	SYSCALL_FAILED(syscall)
#define	SYSCALL_FAILED_1STR(syscall,str_arg1)

#endif	/* !ARCH_VERBOSE */

#endif /* ARCH_GENERIC_H */

