#ifndef Include_icDecPDF417M_h
#define Include_icDecPDF417M_h

//#define USE_NAMESPACE
#ifdef USE_NAMESPACE
namespace twodtg_mpdf417 {
#endif
const int
// ############################################################################
	MPDF417_OK                       = 0,
	MPDF417_Rectangle_Error          = -1,
	MPDF417_Invalid_Argument         = -2,
	MPDF417_NotFound                 = -3,
   MPDF417_Geometry_Error           = -13,
   MPDF417_ErasuresLimit_Error      = - 7,
   MPDF417_RS_Error                 = - 8,
   MPDF417_CharEncodation_Error     = - 9,
	MPDF417_NOMEMORY                 = -99,
	MPDF417_UNKNOWN                  = -100,
	MPDF417_DISCONNECTED             = -200;

#define Default_SpeedMode SP_Robust
enum TMPDF417_SpeedMode
{
  SP_Slow   = 2,
  SP_Fast   = 1,
  SP_Robust = 0
};
//---------------------------------------------------------------------------
#define Default_DirectMode DM_All
enum TMPDF417_DirectMode
{
  DM_LeftRight  = 0,
  DM_Horizontal = 1,
  DM_All        = 2,
  DM_Vertical   = 3
};
//---------------------------------------------------------------------------
struct TMPDF417_OptMode
{
  TMPDF417_SpeedMode SpeedMode;   // RESERVED FOR FUTURE!
  TMPDF417_DirectMode DirectMode; // RESERVED FOR FUTURE!
};
//---------------------------------------------------------------------------

typedef void* PMPDF417_Decoder;
typedef void* PMPDF417_Options;

struct TMPDF417_Info // result of decoding per MicroPDF417 symbol
{ 
  int rowcols[8];    //<! symbol corners
  int rcFlag;        //<! true if a qudrangle symbol was found
  int RSErrorCount;  //<! number of Reed Solomon errors
  int ColCount;      //<! horizontal dimension (from 1 to 4)
  int RowCount;      //<! vertical dimension   (from 1 to 44)
  int pchlen;        //<! length of decoded byte array
  char* pch;         //<! decoded byte array
};

struct TMPDF417_ImageInfo
{
    int RejectionReason;   // Result of decoding
};

#if (defined WIN32) || (defined _WIN64)
#define CALL_TYPE __stdcall
#else
#define CALL_TYPE
#endif 

#ifdef __cplusplus
#define EXTERN extern "C"
#else
#define EXTERN
#endif

// Create the decoder object.
//	Return the decoder object or NULL.
EXTERN PMPDF417_Decoder CALL_TYPE Connect_MPDF417_Decoder(int MaxRow, int MaxCol);

// Create the options object.
// Return the options object or NULL.
EXTERN PMPDF417_Options CALL_TYPE Create_MPDF417_Options(PMPDF417_Decoder dec, TMPDF417_OptMode opt);

// Decode array the pixels of the image. WARNING: function UPDATE the pbits array!
// Return MPDF417_OK if decoding is completed. In other cases, returns an error code.
// Result of decoding can find out call Get_MPDF417_ImageInfo.
EXTERN int              CALL_TYPE Decode_MPDF417_Bits(PMPDF417_Options, int rowcount, int colcount, unsigned char**pbits);

// Destroy the options object.
EXTERN void             CALL_TYPE Delete_MPDF417_Options(PMPDF417_Options opt);

// Destroy the decoder object.
EXTERN void             CALL_TYPE Disconnect_MPDF417_Decoder(PMPDF417_Decoder dec);

// Returns a structure describing the result of decoding.
// If the sucess decoding field RejectionReason == MPDF417_OK.
EXTERN TMPDF417_ImageInfo* CALL_TYPE Get_MPDF417_ImageInfo(PMPDF417_Options opt);

// Returns a structure with data of the symbology if the sucess decoding else return NULL.
EXTERN TMPDF417_Info*   CALL_TYPE Get_MPDF417_Info(PMPDF417_Options opt);

// Return the version of the library.
EXTERN const char*      CALL_TYPE MPDF417_GetVersion(void);
#ifdef USE_NAMESPACE
}
#endif
#endif
