#include "stdafx.h"
#include <stdio.h>
#include <memory.h>
#include <iostream>
#include "IKlvLib.h"
#include "Windows.h"
#include <fstream>
#include <fstream>
#define BUFFER_SIZE 2048
void WriteBinData(const char* path, char* data, size_t len);
int _tmain(int argc, _TCHAR* argv[])
{
char* pEncChunk;
size_t encodedLength = 0;
size_t encodedLength2 = 0;
char klvBuffer[BUFFER_SIZE];
char klvBuffer2[BUFFER_SIZE];
unsigned __int64 val_64;
unsigned int val_32;
unsigned short val_16;
unsigned char val_8;
char key;
memset( klvBuffer, 0x0, BUFFER_SIZE );
memset( klvBuffer2, 0x0, BUFFER_SIZE );
try
{
klvEncoder->
SetOuterKey(
"060E2B34020B01010E01030101000000");
val_64 = 1231798102000000;
key = 2;
val_16 = 0x71C2;
key = 5;
val_16 = 0xFD3D;
key = 6;
val_16 = 0x08B8;
key = 7;
val_32 = 0x5595B66D;
key = 13;
val_32 = 0x5B5360C4;
key = 14;
val_16 = 0xC221;
key = 15;
val_16 = 0xCD9C;
key = 16;
val_16 = 0xD917;
key = 17;
val_32 = 0x724A0A20;
key = 18;
val_32 = 0x87F84B86;
key = 19;
val_32 = 0x00000000;
key = 20;
val_32 = 0x03830926;
key = 21;
val_16 = 0x1281;
key = 22;
val_32 = 0xF101A229;
key = 23;
val_32 = 0x14BC082B;
key = 24;
val_16 = 0x34F3;
key = 25;
val_8 = 0x02;
key = 65;
pEncChunk = klvEncoder->
Encode(encodedLength);
if( encodedLength )
{
memcpy(klvBuffer, pEncChunk, encodedLength);
WriteBinData("data.bin", klvBuffer, encodedLength);
}
val_64 = 1231798102000000;
key = 2;
val_32 = 0x5595B66D;
key = 13;
val_32 = 0x5B5360C4;
key = 14;
val_16 = 0xC221;
key = 15;
pEncChunk = klvEncoder->
Encode(encodedLength2);
if( encodedLength2 )
{
memcpy(klvBuffer2, pEncChunk, encodedLength2);
}
delete klvEncoder;
{
int itemCount;
char valueStr[1024];
for(int i = 0; i < itemCount; i++)
{
unsigned char* value = (unsigned char* )itemArray[i]->GetValue();
for(int i=0; i<length; i++)
sprintf(valueStr + i*2, "%02X", *(value+i));
cout << keyStr << ": Ox" << valueStr << endl;
}
}
delete klvDecoder;
}
catch(char * str )
{
cout << "Exception raised: " << str << '\n';
}
getchar();
return 0;
}
void WriteBinData(const char* path, char* data, size_t len)
{
ofstream myFile (path, ios::out | ios::binary);
myFile.write (data, len);
}