// Change History
// 10/29/03 AV Production: 64 bit conversion

#ifndef _H_DRT_CIF_H_
#define _H_DRT_CIF_H_

#include "at_defs.h"
#include "drs_type.h"

//Return error codes
//const uint16 ERC_none = 0;
//const uint16 ERC_any = (uint16) -1;

class DRT_Database
{
  public:
  DRT_Database( byte *sPath, byte *sDDFile);
  ~DRT_Database();

  AT_Database       *pDatabase;
  AT_Read_Rand_File *pDTFile;
  AT_Read_Rand_File *pDIFile;
  AT_Read_Rand_File *pDDFile;
};

class DRT_IndexList
{
  public:
  DRT_IndexList( byte *sPath, byte *sDXFile);
  ~DRT_IndexList();

  uint32     IndexCount();
  AT_Index * GetIndex( uint32 lIndex);
  bool       IsIndexAvail( uint32 lIndex);

  private:
  AT_Index_List     *pIndexList;
  AT_Read_Rand_File *pDXFile;
  AT_Read_Rand_File *pDRFile;
};

#ifdef WIN16
  #define _drs_call_h _pascal
  #define _drs_call_c _pascal _export FAR
#else //Win32
  #define _drs_call_h _stdcall
  #define _drs_call_c _export FAR _stdcall __declspec(dllexport)
#endif

extern "C" // Prevent C++ name mangling
{
DLL_Erc _drs_call_h DRT_DatabaseOpen( byte *sPath, byte *sDatabaseFile, unsigned long *ppDatabase);
DLL_Erc _drs_call_c DRT_DatabaseClose( DRT_Database *pDatabase);
DLL_Erc _drs_call_c DRT_DatabaseRecordCount( DRT_Database const *pDatabase, uint32 *pRecCount);
DLL_Erc _drs_call_c DRT_DatabaseFieldCount( DRT_Database const *pDatabase, uint16 *pFieldCount);
DLL_Erc _drs_call_c DRT_DatabaseVectorIDCount( DRT_Database const *pDatabase, uint16 *pVectorIDCount);
DLL_Erc _drs_call_c DRT_DatabaseVectorPeriodCount( DRT_Database const *pDatabase, uint16 *pPeriodCount);
DLL_Erc _drs_call_c DRT_DatabaseRecordOpen( DRT_Database const *pDatabase, uint32 lRecNo, unsigned long *ppRecord);
DLL_Erc _drs_call_c DRT_DatabaseRecordClose( AT_Record const *pRecord);
DLL_Erc _drs_call_c DRT_RecordFieldGet( AT_Record const *pRecord, uint16 iField, byte *buf, uint16 iLen);
DLL_Erc _drs_call_c DRT_RecordVectorCount( AT_Record const *pRecord, uint32 *pVectorCount);
DLL_Erc _drs_call_c DRT_RecordVectorGet( AT_Record const *pRecord, uint32 lVectorIdx, uint32 *pVectorIDs, uint sz, double *pVector);
DLL_Erc _drs_call_c DRT_IndexListOpen( byte *sPath, byte *sIndexFile, unsigned long *ppIndexList);
DLL_Erc _drs_call_c DRT_IndexListClose( DRT_IndexList *pIndexList);
DLL_Erc _drs_call_c DRT_IndexListIndexCount( DRT_IndexList *pIndexList, uint32 *pIndexCount);
DLL_Erc _drs_call_c DRT_IndexListIndexAvail( DRT_IndexList *pIndexList, uint32 lIndexNo, uint16 *pIsAvail);
DLL_Erc _drs_call_c DRT_IndexOpen( DRT_IndexList *pIndexList, uint32 lIndexNo, unsigned long *ppIndex);
DLL_Erc _drs_call_c DRT_IndexClose( AT_Index *pIndex);
DLL_Erc _drs_call_c DRT_IndexHasCounts( AT_Index *pIndex, uint16 *iHasCounts);
DLL_Erc _drs_call_c DRT_IndexTermCount( AT_Index *pIndex, uint32 *lCount);
DLL_Erc _drs_call_c DRT_IndexIterOpen( AT_Index *pIndex, unsigned long * ppIter);
DLL_Erc _drs_call_c DRT_IndexIterClose( AT_Index::Iter * pIter);
DLL_Erc _drs_call_c DRT_IndexIterNext( AT_Index::Iter * pIter);
DLL_Erc _drs_call_c DRT_IndexIterPrev( AT_Index::Iter * pIter);
DLL_Erc _drs_call_c DRT_IndexIterSeek( AT_Index::Iter * pIter, long lOffset);
DLL_Erc _drs_call_c DRT_IndexIterSeekTerm( AT_Index *pIndex, AT_Index::Iter *pIter, byte *sSeekString, uint32 *pRetIdx);
DLL_Erc _drs_call_c DRT_IndexIterTermGet( AT_Index *pIndex, AT_Index::Iter * pIter, byte *sDest, uint16 iDestLen, uint32 *pOccurrences);

DLL_Erc _drs_call_c DRT_IndexIter2RecList( AT_Index::Iter * pIter, unsigned long *ppRecList);
DLL_Erc _drs_call_c DRT_RecListRecCount( AT_Record_List const * pRecList, unsigned long *pRecCount);
DLL_Erc _drs_call_c DRT_RecListClose( AT_Record_List * pRecList);
DLL_Erc _drs_call_c DRT_RecListIterOpen( AT_Record_List const * pRecList, unsigned long *ppIter);
DLL_Erc _drs_call_c DRT_RecListIterClose( AT_Record_List::Iter * pIter);
DLL_Erc _drs_call_c DRT_RecListIterRecNum( AT_Record_List::Iter * pIter, unsigned long *pRecNo);
DLL_Erc _drs_call_c DRT_RecListIterNext( AT_Record_List::Iter * pIter);
DLL_Erc _drs_call_c DRT_RecListIterPrev( AT_Record_List::Iter * pIter);
DLL_Erc _drs_call_c DRT_RecListIterSeek( AT_Record_List::Iter * pIter, long lOffset);


DLL_Erc _drs_call_c DRT_ExceptionGet( byte *sDest, uint16 iDestLen);
uint16 _drs_call_c DRT_ExceptionCount();
int16 _drs_call_c DRT_ExceptionLen();
}

#endif
