#ifndef __MIFARE_FUNCTION_LIB_H__
#define __MIFARE_FUNCTION_LIB_H__


/********************************************************************************************************************************************************/
/*! \ingroup   groupLibReturn
*	\{
*/
#define MIFARE_OK								0x00		
#define MIFARE_ERROR							0x01		
#define MIFARE_WRONG_EPSO_FRAME					0x04		
#define	MIFARE_NEW_CARD_NOT_FOUND				0X05		
#define	MIFARE_WRONG_KEY						0x06		
#define	MIFARE_WRONG_BLOCK						0x07		
#define MIFARE_WRONG_PAGE						0x08		
#define MIFARE_WRONG_SECTOR						0x09	
/*!
*	\}
*/


/*!
*	\ingroup  groupMfSettings
*	\{
*/
#define MF_CLASSIC_KEY_TYPE_A					0x00		
#define MF_CLASSIC_KEY_TYPE_B					0x01		
#define VALUE_BLOCK_INCREMENT					0x00		
#define VALUE_BLOCK_DECREMENT					0x01		
#define VALUE_BLOCK_RESTORE						0x02		

/*!
*	\}
*/



/********************************************************************************************************************************************************/

#ifndef ROGER_MIFARE_LIB
	#define		MIFARE_LIB_ATTRIBUTE  __declspec(dllimport)	
#else
	#define		MIFARE_LIB_ATTRIBUTE  __declspec(dllexport)	
#endif

typedef  DWORD MIFARERETURN;								/*!< Type zwracany przez biblotekę */	
#define	 MIFARECALLING	

/********************************************************************************************************************************************************/

extern "C" 
{
	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING
							mifareLibVer( 
										__inout LPTSTR,
										__in size_t
										);

	
/******************************************** Card functions ******************************************************************************************/
	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							readCardBufferHost(
										__in BYTE,
										__out PCHAR,
										__out PBYTE
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							readCardBufferTerminal(
										__in BYTE,
										__in PCHAR,
										__in BYTE,
										__out PCHAR
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							readCardIDHost(
										__in BYTE,
										__out PCHAR,
										__out PBYTE
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							readCardIDTerminal( 
										__in BYTE,
										__in PCHAR,
										__in BYTE,
										__out PBYTE,
										__out PBYTE
										);

/******************************************** Mifare Classic ******************************************************************************************/

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfClassicReadHost(
										__in BYTE,
										__in BYTE,
										__in BYTE,
										__in PBYTE,
										__in BYTE,
										__out PCHAR,
										__out PBYTE
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfClassicReadTerminal(
										__in BYTE,
										__in PCHAR,
										__in BYTE,
										__out PBYTE
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  
							MIFARECALLING mfClassicWriteHost(
										__in BYTE,
										__in BYTE,
										__in BYTE,
										__in PBYTE,
										__in PBYTE,
										__in BYTE,
										__out PCHAR,
										__out PBYTE
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfClassicWriteTerminal( 
										__in BYTE,
										__in PCHAR,
										__in BYTE
										);

/******************************************** Mifare Classic Value Block**************************************************************************************/

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfCreateValueBlockHost(
										__in BYTE Id,
										__in BYTE Sector,
										__in BYTE Block,
										__in PBYTE ValueBlock,
										__in BYTE Adr,
										__in PBYTE Key,
										__in BYTE KeyType,
										__out PCHAR Frame,
										__out PBYTE FrameLength
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfCreateValueBlockTerminal(
										__in BYTE Id,
										__in PCHAR Frame,
										__in BYTE FrameLength
										);
	
	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfIncrementHost(
										__in BYTE	Id,
										__in BYTE	vbSector,
										__in BYTE	vbBlock,
										__in PBYTE	vbOperand,
										__in PBYTE	vbKey,
										__in BYTE	vbKeyType,
										__in BYTE	tranSector,
										__in BYTE	tranBlock,
										__in PBYTE	tranKey,
										__in BYTE	tranKeyType,
										__out PCHAR	Frame,
										__out PBYTE FrameLength
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfIncrementTerminal(
										__in BYTE	Id,
										__in PCHAR	Frame,
										__in BYTE	FrameLength
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfDecrementHost(
										__in BYTE	Id,
										__in BYTE	vbSector,
										__in BYTE	vbBlock,
										__in PBYTE	vbOperand,
										__in PBYTE	vbKey,
										__in BYTE	vbKeyType,
										__in BYTE	tranSector,
										__in BYTE	tranBlock,
										__in PBYTE	tranKey,
										__in BYTE	tranKeyType,
										__out PCHAR	Frame,
										__out PBYTE FrameLength
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfDecrementTerminal(
										__in BYTE	Id,
										__in PCHAR	Frame,
										__in BYTE	FrameLength
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfRestoreHost(
										__in BYTE	Id,
										__in BYTE	vbSector,
										__in BYTE	vbBlock,
										__in PBYTE	vbKey,
										__in BYTE	vbKeyType,
										__in BYTE	tranSector,
										__in BYTE	tranBlock,
										__in PBYTE	tranKey,
										__in BYTE	tranKeyType,
										__out PCHAR	Frame,
										__out PBYTE FrameLength
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfRestoreTerminal(
										__in BYTE	Id,
										__in PCHAR	Frame,
										__in BYTE	FrameLength
										);

/******************************************** Mifare Ultra Light**************************************************************************************/
	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfULReadHost(	
										__in BYTE	Id,
										__in BYTE	Page,
										__out PCHAR Frame,
										__out PBYTE FrameLength
										);
	
	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfULReadTerminal( 
										__in BYTE	Id,
										__in PCHAR	Frame,
										__in BYTE	FrameLength,
										__out PBYTE Data
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfULWriteHost(
										__in BYTE	Id,
										__in BYTE	Page,
										__in PBYTE	Data,
										__out PCHAR Frame,
										__out PBYTE FrameLength
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfULWriteTerminal( 
										__in BYTE	Id,
										__in PCHAR	Frame,
										__in BYTE	FrameLength
										);

 /******************************************** Mifare Ultra Light**************************************************************************************/
	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfRssSetHost(
										__in BYTE	Id,
										__in BYTE	Sector,
										__in PBYTE	Key,
										__in BYTE	KeyType,
										__out PCHAR Frame,
										__out PBYTE FrameLength
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfRssSetTerminal( 
										__in BYTE	Id,
										__in PCHAR	Frame,
										__in BYTE	FrameLength 
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfRssDelHost(
										__in BYTE	Id,
										__in BYTE	Sector,
										__out PCHAR Frame,
										__out PBYTE FrameLength
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfRssDelTerminal( 
										__in BYTE	Id,
										__in PCHAR	Frame,
										__in BYTE	FrameLength
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfRssReadHost(
										__in BYTE	Id,
										__in BYTE	Sector,
										__in BYTE	Block,
										__out PCHAR Frame,
										__out PBYTE FrameLength
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfRssReadTerminal( 
										__in BYTE	Id,
										__in PCHAR	Frame,
										__in BYTE	FrameLength,
										__out PBYTE Data 
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfRssWriteHost(
										__in BYTE	Id,
										__in BYTE	Sector,
										__in BYTE	Block,
										__in PBYTE	Data,
										__out PCHAR Frame,
										__out PBYTE FrameLength
										);

	MIFARE_LIB_ATTRIBUTE MIFARERETURN  MIFARECALLING 
							mfRssWriteTerminal( 
										__in BYTE	Id,
										__in PCHAR	Frame,
										__in BYTE	FrameLength
										);


}
#endif