#pragma once

//#ifndef __XSTDIO_H
//#define __XSTDIO_H

#ifdef __WATCOMC__
#pragma library("system.lib")
#endif

#ifdef __cplusplus
extern "C" {
#endif
//---------------------------------------------------------------------------//
#include <stdio.h>
#include "system/xstdlib.h"

typedef struct s_XFILE XFILE;

struct s_XFILE
{
	DWORD length,position;
	BYTE *buff;
};

XFILE *xfopen( char *filename, char *mode);
int xfclose( XFILE *xfile);
int xfseek( XFILE *xfile, int pos, int where);
int xftell( XFILE *xf);
int xfeof( XFILE *xf);
int xfread( void *ptr, int elsize, int length, XFILE *xfile);

BYTE xfr_byte( XFILE *f);

WORD xfrbe_word( XFILE *f);
DWORD xfrbe_dword( XFILE *f);
float xfrbe_float( XFILE *f);

WORD xfrle_word( XFILE *f);
DWORD xfrle_dword( XFILE *f);
float xfrle_float( XFILE *f);
/*
void xfw_byte( XFILE *f, BYTE data);

void xfwbe_word( XFILE *f, WORD data);
void xfwbe_dword( XFILE *f, DWORD data);
void xfwbe_float( XFILE *f, float data);

void xfwle_word( XFILE *f, WORD data);
void xfwle_dword( XFILE *f, DWORD data);
void xfwle_float( XFILE *f, float data);
*/

BYTE fr_byte( FILE *f);

WORD frbe_word( FILE *f);
DWORD frbe_dword( FILE *f);
float frbe_float( FILE *f);

WORD frle_word( FILE *f);
DWORD frle_dword( FILE *f);
float frle_float( FILE *f);

void fw_byte( FILE *f, BYTE data);

void fwbe_word( FILE *f, WORD data);
void fwbe_dword( FILE *f, DWORD data);
void fwbe_float( FILE *f, float data);

void fwle_word( FILE *f, WORD data);
void fwle_dword( FILE *f, DWORD data);
void fwle_float( FILE *f, float data);

BYTE *fload( char *filename, DWORD *length);
int fsave( char *filename, BYTE *data, DWORD length);
DWORD flength( FILE *file);

BYTE *xfload( char *filename, DWORD *length);
//---------------------------------------------------------------------------//
#ifdef __cplusplus
}
#endif
//#endif
