// Change History
// 03/18/04 AV Development: Add DRS_VectorVirtualPeriodCount, DRS_VectorVirtualPeriodDescr
// 12/10/03 AV Development: Add ProcessCount, DRS_ProcessClearCache, DRS_ProcessCachedNames funcs
// 11/19/03 AV Development: Remove development version of the DRS_FieldMaxSize func
// 11/19/03 AV Development: Merge Production version 9
// 11/05/03 AV Production: Add  DRS_FieldMaxSize( DRS_Field const *pField, uint * Size)
// 10/23/03 AV Development: Add macro def services

#ifndef _H_DDP_CIF_H_
#define _H_DDP_CIF_H_

#include <windows.h>
#include <utility>
#include "drs/drs_type.h"

// Calling conventions
#ifdef WIN16
  #define _ddp_call_h _pascal
  #define _ddp_call_c _pascal _export FAR
#else //Win32
  #define _ddp_call_h __declspec(dllexport) _stdcall
  #define _ddp_call_c _stdcall
#endif

extern "C" // Prevent C++ name mangling
{
//Initialization/Termination
DLL_Erc _ddp_call_h DDP_SessionOpen( DLL_Handle appl);
void _ddp_call_h DDP_SessionClose();
DLL_Handle _ddp_call_h DDP_SessionGet();

DLL_Erc _ddp_call_h DDP_ProcessCount(uint16 * iCount);
DLL_Erc _ddp_call_h DDP_ProcessClearCache();
DLL_Erc _ddp_call_h DDP_ProcessCachedNames(byte * buf, uint16 sz, uint16 * iCount);

// Field Def
DLL_Erc _ddp_call_h DDP_FieldCount( uint16 *pCount);
DLL_Erc _ddp_call_h DDP_FieldGet( uint16 iField, DLL_HandlePtr pField);
DLL_Erc _ddp_call_h DDP_FieldUserNameSet( DLL_Handle hField, const byte * name);
DLL_Erc _ddp_call_h DDP_FieldOpen( uint16 iField, DLL_HandlePtr pField);
DLL_Erc _ddp_call_h DDP_FieldClose( DLL_HandlePtr pField);

// Vector Def
DLL_Erc _ddp_call_h DDP_VectorDefOpen( uint16 iVectorID, VectorAddress VectorAddress[], uint Formula, uint Period, DLL_HandlePtr hVectorDef);
DLL_Erc _ddp_call_h DDP_VectorDefIndexState( DLL_Handle hVectorDef, uint IndexState);
DLL_Erc _ddp_call_h DDP_VectorDefUserNameSet( DLL_Handle hVectorDef, const byte * name);
DLL_Erc _ddp_call_h DDP_VectorDecimalsSet( DLL_Handle hVectorDef, uint iDecimals);
DLL_Erc _ddp_call_h DDP_VectorDefClose( DLL_Handle hVectorDef);

// Export Field
DLL_Erc _ddp_call_h DDP_ExportFieldUserNameSet( DLL_Handle hExpField, const byte * name);
DLL_Erc _ddp_call_h DDP_ExportFieldActionSet( DLL_Handle hExpField, uint Action);
DLL_Erc _ddp_call_h DDP_ExportFieldSortSet( DLL_Handle hExpField, uint Sort);

// Macro Def
DLL_Erc _ddp_call_h DDP_MacroRecord( const byte * fn);
DLL_Erc _ddp_call_h DDP_MacroStop( void);
DLL_Erc _ddp_call_h DDP_MacroRun( const byte * fn);

DLL_Erc _ddp_call_h DDP_RecList_Dump( DLL_Handle pRecList, char *file);

//Reports
DLL_Erc _ddp_call_h DDP_ReportDumpParams(DLL_Handle pRecordList, DLL_Handle Fields, DLL_Handle Vectors);

// Browse Export
DLL_Erc _ddp_call_h DDP_BrowseDumpParams(DLL_Handle pIndex, DLL_Handle Fields,
    const byte * FieldTypes, const byte * FileName, const byte * ExpType);

//Exports
DLL_Erc _ddp_call_h DDP_ExportDumpParams(DLL_Handle pRecordList, DLL_Handle Fields,
    const byte * FieldTypes, DLL_Handle SplitFields, const byte * FileName,
        const byte * ExpType, byte AutoSave);

//Process
DLL_Erc _ddp_call_h DDP_InitProcess();
DLL_Erc _ddp_call_h DDP_ProcessParamSet( const byte * key, const byte * value);
DLL_Erc _ddp_call_h DDP_ProcessParamObjectSet( const byte * key, DLL_Handle object, uint size);
DLL_Erc _ddp_call_h DDP_StartProcess();

// Exceptions
uint16 _ddp_call_h DDP_ErrorPop( byte *sDest, uint16 iDestLen);
DLL_Erc _ddp_call_h DDP_ErrorGet( uint16 num, byte *sDest, uint16 iDestLen);
uint16 _ddp_call_h DDP_ErrorCount();

} // Extern "C"
#endif
