//---------------------------------------------------------------------------

#ifndef nist_demo_main_formH
#define nist_demo_main_formH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ExtCtrls.hpp>
//---------------------------------------------------------------------------



// File access routines
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <ComCtrls.hpp>
#include <dir.h>


TOpenDialog *open_dialog;

HINSTANCE hNIST_library;

//NIST library declaration of functions
typedef int (*RegisterNIST)();
typedef int (*CreateNewNISTFile)();
typedef int (*WriteNISTToFile)(const char *filename);
typedef unsigned char* (*ReadNISTByteArray)();
typedef int (*ReadSizeOfNISTByteArray)();
typedef int (*ReadNISTFromFile)(const char *filename);
typedef int (*ReadNISTFromMemory)(unsigned char* input_byte_array, int size_of_input_byte_array);
typedef int (*CheckIfRecordTypeExists)(int record_type_number);
typedef int (*ReadNumberOfRecords)(int record_type_number);
typedef int (*ReadIDCofRecord)(int record_type_number, int record_number);
typedef char* (*ReadRecordTxtField)(int record_type_number, int idc, int record_field_number, const char *record_field_name);
typedef int (*ReadSizeOfRecordTxtField)(int record_type_number, int idc, int record_field_number, const char *record_field_name);
typedef char* (*ReadRecordTxtFieldName)(int record_type_number, int idc, int record_field_number);
typedef int (*ReadSizeOfRecordTxtFieldName)(int record_type_number, int idc, int record_field_number, const char *record_field_name);
typedef char* (*ReadRecordTxtFieldDescription)(int record_type_number, int idc, int record_field_number, const char *record_field_name);
typedef int (*ReadSizeOfRecordTxtFieldDescription)(int record_type_number, int idc, int record_field_number, const char *record_field_name);
typedef char* (*ReadRecordExportedTxtFields)(int record_type_number, int idc);
typedef int (*ReadSizeOfRecordExportedTxtFields)(int record_type_number, int idc);
typedef unsigned char* (*ReadRecordBinaryField)(int record_type_number, int idc);
typedef int (*ReadSizeOfRecordBinaryField)(int record_type_number, int idc);
typedef HBITMAP (*CreateHBITMAPfromRecordBinaryField)(int record_type_number, int idc);
typedef int (*InsertRecordBinaryFieldFromFile)(int record_type_number, int idc, const char *filename);
typedef int (*InsertRecordBinaryFieldFromMemory)(int record_type_number, int idc, unsigned char* input_byte_array, int size_of_input_byte_array, const char* CGA, int CGA_int, int HLL, int VLL);
typedef int (*InsertRecordTxtField)(int record_type_number, int idc, int record_field_number, const char *record_field_name, const char * input_data);
typedef int (*DeleteRecord)(int record_type_number, int idc);





RegisterNIST pRegisterNIST;
CreateNewNISTFile pCreateNewNISTFile;
WriteNISTToFile pWriteNISTToFile;
ReadNISTByteArray pReadNISTByteArray;
ReadSizeOfNISTByteArray pReadSizeOfNISTByteArray;
ReadNISTFromFile pReadNISTFromFile;
ReadNISTFromMemory pReadNISTFromMemory;
CheckIfRecordTypeExists pCheckIfRecordTypeExists;
ReadNumberOfRecords pReadNumberOfRecords;
ReadIDCofRecord pReadIDCofRecord;
ReadRecordTxtField pReadRecordTxtField;
ReadSizeOfRecordTxtField pReadSizeOfRecordTxtField;
ReadRecordTxtFieldName pReadRecordTxtFieldName;
ReadSizeOfRecordTxtFieldName pReadSizeOfRecordTxtFieldName;
ReadRecordTxtFieldDescription pReadRecordTxtFieldDescription;
ReadSizeOfRecordTxtFieldDescription pReadSizeOfRecordTxtFieldDescription;
ReadRecordExportedTxtFields pReadRecordExportedTxtFields;
ReadSizeOfRecordExportedTxtFields pReadSizeOfRecordExportedTxtFields;
ReadRecordBinaryField pReadRecordBinaryField;
ReadSizeOfRecordBinaryField pReadSizeOfRecordBinaryField;
CreateHBITMAPfromRecordBinaryField pCreateHBITMAPfromRecordBinaryField;
InsertRecordBinaryFieldFromFile pInsertRecordBinaryFieldFromFile;
InsertRecordBinaryFieldFromMemory pInsertRecordBinaryFieldFromMemory;
InsertRecordTxtField pInsertRecordTxtField;
DeleteRecord pDeleteRecord;







int ret, n;
FILE *infp, *outfp;
int handle;

wchar_t program_file_path[MAXPATH];
wchar_t filename_incomplete[MAXPATH];
wchar_t filedirectory[MAXPATH];
wchar_t filename[MAXPATH];
char* p_image_compression_code;
char image_compression_code[128];
char output_message[16384];
int size;
int idc;
int idc_current;
char* nist_txt_field;
int nist_int_field;
char int_converted_to_string[64];
unsigned char* nist_binary_field;
unsigned char* byte_array;
int size_of_byte_array;
int type_2_number_of_records;
int type_3_number_of_records;
int type_4_number_of_records;
int type_5_number_of_records;
int type_6_number_of_records;
int type_7_number_of_records;
int type_8_number_of_records;
int type_9_number_of_records;
int type_10_number_of_records;
int type_13_number_of_records;
int type_14_number_of_records;
int type_15_number_of_records;
int type_16_number_of_records;
int type_17_number_of_records;
int type_99_number_of_records;



//---------------------------------------------------------------------------
class TMainForm : public TForm
{
__published:	// IDE-managed Components
	TImage *OutputImage;
	TButton *CreateAndInsertButton;
	TButton *ReadSingleFieldButton;
	TButton *DeleteSingleFieldButton;
	TButton *ReadAndModifyButton;
	TButton *ReadAndExportButton;
	TButton *RegisterButton;
	void __fastcall FormDestroy(TObject *Sender);
	void __fastcall FormShow(TObject *Sender);
	void __fastcall FormCreate(TObject *Sender);
	void __fastcall RegisterButtonClick(TObject *Sender);
	void __fastcall CreateAndInsertButtonClick(TObject *Sender);
	void __fastcall ReadAndModifyButtonClick(TObject *Sender);
	void __fastcall ReadAndExportButtonClick(TObject *Sender);
	void __fastcall ReadSingleFieldButtonClick(TObject *Sender);
	void __fastcall DeleteSingleFieldButtonClick(TObject *Sender);
private:	// User declarations
public:		// User declarations
	__fastcall TMainForm(TComponent* Owner);

			HBITMAP hBitmap;

};
//---------------------------------------------------------------------------
extern PACKAGE TMainForm *MainForm;
//---------------------------------------------------------------------------
#endif
