#include "stdafx.h"
#include <stdio.h>
#include <memory.h>
#include <iostream>
#include "IKlvLib.h"
#include "Windows.h"
#include <fstream>
#include <string>
const char LDS_KEY[16] = { 0x06, 0x0E, 0x2B, 0x34, 0x02, 0x0B, 0x01, 0x01, 0x0E, 0x01, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00 };
const char UDS_KEY[16] = { 0x06, 0x0E, 0x2B, 0x34, 0x02, 0x01, 0x01, 0x01, 0x0E, 0x01, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00 };
char* ReadBinData(const char* path, int& l);
int _tmain(int argc, _TCHAR* argv[])
{
try
{
cout << "Please enter bin file path:" << endl;
string path;
getline (cin, path);
int l;
char* buf = ReadBinData(path.c_str(), l);
else
else
{
cout << "Unknown designator key";
return 0;
}
{
int itemCount;
IKlvItem** itemArray = klvDecoder->GetItemList(itemCount);
char valueStr[128000];
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;
delete[] buf;
}
catch(char * str )
{
cout << "Exception raised: " << str << '\n';
}
getchar();
return 0;
}
char* ReadBinData(const char* path, int& l)
{
char * buffer;
ifstream is;
is.open(path, ios::in|ios::out|ios::binary|ios::ate);
if ( ! is.is_open() )
{
throw "open failed";
}
is.seekg (0, ios::end);
l = is.tellg();
is.seekg (0, ios::beg);
buffer = new char [l];
is.read (buffer,l);
is.close();
return buffer;
}