#include "stdafx.h"
#include <stdio.h>
#include <memory.h>
#include <iostream>
#include "IKlvLib.h"
#include "Windows.h"
#define BUFFER_SIZE 2048
int _tmain(int argc, _TCHAR* argv[])
{
char* pEncChunk;
size_t encodedLength = 0;
size_t encodedLength2 = 0;
char klvBuffer[BUFFER_SIZE];
char klvBuffer2[BUFFER_SIZE];
memset( klvBuffer, 0x0, BUFFER_SIZE );
try
{
klvEncoder->
SetOuterKey(
"060E2B34020101010E01010201010000");
unsigned __int64 val_64 = 1231798102000000;
char keyArr[16] = { 0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x03, 0x07, 0x02, 0x01, 0x01, 0x01, 0x05, 0x00, 0x00 };
unsigned short val_16 = 0x71C2;
klvEncoder->
AddKlvItem(
"060E2B34010101070701100106000000", val_16);
val_16 = 0xFD3D;
klvEncoder->
AddKlvItem(
"060E2B34010101070701100105000000", val_16);
val_16 = 0x08B8;
klvEncoder->
AddKlvItem(
"060E2B34010101070701100104000000", val_16);
unsigned int val_32 = 0x5595B66D;
klvEncoder->
AddKlvItem(
"060E2B34010101030701020102040200", val_32);
val_32 = 0x5B5360C4;
klvEncoder->
AddKlvItem(
"060E2B34010101030701020102060200", val_32);
val_16 = 0xC221;
klvEncoder->
AddKlvItem(
"060E2B34010101010701020102020000", val_16);
val_16 = 0xCD9C;
klvEncoder->
AddKlvItem(
"060E2B34010101020420020101080000", val_16);
val_16 = 0xD917;
klvEncoder->
AddKlvItem(
"060E2B340101010704200201010A0100", val_16);
val_32 = 0x724A0A20;
klvEncoder->
AddKlvItem(
"060E2B34010101010E01010204000000", val_32);
val_32 = 0x87F84B86;
klvEncoder->
AddKlvItem(
"060E2B34010101010E01010205000000", val_32);
val_32 = 0x00000000;
klvEncoder->
AddKlvItem(
"060E2B34010101010E01010206000000", val_32);
val_32 = 0x03830926;
klvEncoder->
AddKlvItem(
"060E2B34010101010701080101000000", val_32);
val_16 = 0x1281;
klvEncoder->
AddKlvItem(
"060E2B34010101010701090201000000", val_16);
val_32 = 0xF101A229;
klvEncoder->
AddKlvItem(
"060E2B34010101010701020103020000", val_32);
val_32 = 0x14BC082B;
klvEncoder->
AddKlvItem(
"060E2B34010101010701020103040000", val_32);
val_16 = 0x34F3;
klvEncoder->
AddKlvItem(
"060E2B340101010A0701020103160000", val_16);
unsigned char val_8 = 0x02;
klvEncoder->
AddKlvItem(
"060E2B34010101010E01020303000000", val_8);
pEncChunk = klvEncoder->
Encode(encodedLength);
if( encodedLength )
{
memcpy(klvBuffer, pEncChunk, encodedLength);
}
val_64 = 1231798102000000;
val_32 = 0x5595B66D;
klvEncoder->
AddKlvItem(
"060E2B34010101030701020102040200", val_32);
val_32 = 0x5B5360C4;
klvEncoder->
AddKlvItem(
"060E2B34010101030701020102060200", val_32);
val_16 = 0xC221;
klvEncoder->
AddKlvItem(
"060E2B34010101010701020102020000", val_16);
pEncChunk = klvEncoder->
Encode(encodedLength2);
if( encodedLength2 )
{
memcpy(klvBuffer2, pEncChunk, encodedLength2);
}
delete klvEncoder;
{
int itemCount;
char valueStr[256];
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;
}