oddělení, čištění, kontrola ELC1
This commit is contained in:
2
Makefile
2
Makefile
@@ -8,7 +8,7 @@ CXX = g++
|
||||
|
||||
# define any compile-time flags
|
||||
# CXXFLAGS := -std=c++17 -Wall -Wextra -g -lssl -lcrypto -w
|
||||
CXXFLAGS := -Wall -Wextra -g -lssl -lcrypto -w
|
||||
CXXFLAGS := -Wall -Wextra -g -lssl -lcrypto
|
||||
|
||||
# define library paths in addition to /usr/lib
|
||||
# if I wanted to include libraries not in /usr/lib I'd specify
|
||||
|
||||
@@ -11,6 +11,12 @@ RUN chmod 755 /app/start.sh
|
||||
COPY ./startok.sh /app/
|
||||
RUN chmod 755 /app/startok.sh
|
||||
|
||||
COPY ./lread.sh /app/
|
||||
RUN chmod 755 /app/lread.sh
|
||||
|
||||
COPY ./lgen.sh /app/
|
||||
RUN chmod 755 /app/lgen.sh
|
||||
|
||||
COPY ./Makefile /app/
|
||||
|
||||
ENTRYPOINT ["tail"]
|
||||
|
||||
7
docker/lgen.sh
Normal file
7
docker/lgen.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
chmod 777 output/generate
|
||||
|
||||
#./output/generate -cid=9f54495344434954615ad803c50171bf -csd=400e00325b5900003be77f800a400043 -outputType=file -configFileName=licData.xml
|
||||
|
||||
cd output
|
||||
./generate -cid=9f54495344434954615ad803c50171bf -csd=400e00325b5900003be77f800a400043 -outputType=file -configFileName=licData.xml
|
||||
7
docker/lread.sh
Normal file
7
docker/lread.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
chmod 777 output/read
|
||||
|
||||
#./output/read -cid=0353445355313647801b1a9f6600c747 -csd=0353445355313647801b1a9f6600c747 -outputType=file -configFileName=licData.xml
|
||||
|
||||
cd output
|
||||
./read -cid=0353445355313647801b1a9f6600c747 -csd=0353445355313647801b1a9f6600c747 -outputType=file -configFileName=licData.xml
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
chmod 777 output/licenceGenerator
|
||||
|
||||
#./output/licenceGenerator -cid=0353445355313647801b1a9f6600c747 -csd=400e00325b59000076b27f800a404013 -outputType=file -configFileName=licData.xml -licenceFileName=ezlic_eovosv0_vaxvcpalxjx.lic -licenceVersion=1 -licenceType=EOV_OSV
|
||||
#./output/licenceGenerator -cid=0353445355313647801b1a9f6600c747 -csd=0353445355313647801b1a9f6600c747 -outputType=file -configFileName=licData.xml
|
||||
|
||||
cd output
|
||||
./licenceGenerator -cid=0353445355313647801b1a9f6600c747 -csd=400e00325b59000076b27f800a404013 -outputType=file -configFileName=licData.xml -licenceFileName=ezlic_eovosv0_vaxvcpalxjx.lic -licenceVersion=1 -licenceType=EOV_OSV
|
||||
./licenceGenerator -cid=0353445355313647801b1a9f6600c747 -csd=0353445355313647801b1a9f6600c747 -outputType=file -configFileName=licData.xml
|
||||
@@ -47,15 +47,6 @@ enum class GeneralError
|
||||
ItemsCountMismatch = 61
|
||||
};
|
||||
|
||||
// unordered_map<GeneralError, string> mapGeneralErrors = {
|
||||
// {GeneralError::SDCardReadError, "Nepodařilo se načíst SD kartu."},
|
||||
// {GeneralError::ItemsCountMismatch, "Nesouhlasí počet položek licence."},
|
||||
// {GeneralError::LicenceSizeMismatch, "Nesouhlasí velikost souboru licence."},
|
||||
// {GeneralError::LicenceSizeCardMismatch, "Nesouhlasí velikost SD karty."},
|
||||
// {GeneralError::LicenceMismatch, "Nesouhlasí licence."},
|
||||
// {GeneralError::ItemsCountMismatch, "Nesouhlasí počet položek licence."}
|
||||
// };
|
||||
|
||||
enum class ELCType
|
||||
{
|
||||
ELC1 = 1,
|
||||
@@ -120,14 +111,19 @@ struct LicenceIdentification
|
||||
uint8_t licenceVersion = 1; // verze licence, určuje kodování, pojmenování souborů
|
||||
uint8_t licenceIndex = 0;
|
||||
uint8_t revision;
|
||||
uint8_t licCompatibility = 1; // identikator hlavního ELC
|
||||
|
||||
uint8_t licCompatibility = 0; // identikator hlavního ELC. 0 = nedefinová a vrací se defaultní k danému ELC
|
||||
uint16_t licItemsCount = 0;
|
||||
|
||||
string cid_cds_path = "";
|
||||
string licenceFilePath = "";
|
||||
};
|
||||
|
||||
/// @brief obecná struktura pro reader
|
||||
struct LicenceInfoGeneral
|
||||
{
|
||||
int reqDataPointsCount = 0;
|
||||
unordered_map<int, int> licences = {};
|
||||
};
|
||||
|
||||
/// @brief obecná struktura polozky licence, defaultní kompatibilita
|
||||
struct LicenceItem
|
||||
{
|
||||
@@ -135,103 +131,54 @@ struct LicenceItem
|
||||
int dataPointsCount = 0;
|
||||
};
|
||||
|
||||
/// @brief struktura polozky licence, kompatibilita 1
|
||||
struct LicenceItemCompatibility1
|
||||
{
|
||||
int protocolId = -1;
|
||||
int dataPointsCount = 0;
|
||||
};
|
||||
|
||||
/// @brief struktura polozky licence, kompatibilita 2
|
||||
struct LicenceItemCompatibility2
|
||||
{
|
||||
int protocolId = -1;
|
||||
int dataPointsCount = 0;
|
||||
};
|
||||
|
||||
/// @brief struktura polozky licence, kompatibilita 3
|
||||
struct LicenceItemCompatibility3
|
||||
{
|
||||
int protocolId = -1;
|
||||
int dataPointsCount = 0;
|
||||
};
|
||||
|
||||
|
||||
struct LicenceItem11
|
||||
{
|
||||
int protocolId = -1;
|
||||
int dataPointsCount = 0;
|
||||
};
|
||||
|
||||
struct LicenceItem21
|
||||
{
|
||||
int protocolId = -1;
|
||||
int dataPointsCount = 0;
|
||||
};
|
||||
|
||||
struct LicenceItem31
|
||||
{
|
||||
int protocolId = -1;
|
||||
int dataPointsCount = 0;
|
||||
};
|
||||
|
||||
/// @brief základní struktura, seznam polozek licencí
|
||||
struct LicenceInfo
|
||||
{
|
||||
int reqDataPointsCount = 0;
|
||||
unordered_map<int, int> licences = {};
|
||||
};
|
||||
|
||||
/// @brief základní struktura, seznam polozek licencí, kompatibilita 1
|
||||
struct LicenceInfoCompatibility1
|
||||
{
|
||||
int reqDataPointsCount = 0;
|
||||
unordered_map<int, int> licences = {};
|
||||
};
|
||||
|
||||
/// @brief základní struktura, seznam polozek licencí, kompatibilita 2
|
||||
struct LicenceInfoCompatibility2
|
||||
{
|
||||
int reqDataPointsCount = 0;
|
||||
unordered_map<int, int> licences = {};
|
||||
};
|
||||
|
||||
/// @brief základní struktura, seznam polozek licencí, kompatibilita 3
|
||||
struct LicenceInfoCompatibility3
|
||||
{
|
||||
int reqDataPointsCount = 0;
|
||||
unordered_map<int, int> licences = {};
|
||||
};
|
||||
|
||||
struct LicenceInfo1
|
||||
/* struktury pro ELC 1 */
|
||||
//defaultní struktura pro ELC 1
|
||||
struct LicenceELC1Info
|
||||
{
|
||||
bool isValid {false};
|
||||
};
|
||||
|
||||
struct LicenceInfo11
|
||||
//struktura ELC1, kompatibilita 1
|
||||
struct LicenceELC1Info_1
|
||||
{
|
||||
int reqDataPointsCount = 0;
|
||||
unordered_map<int, int> licences = {};
|
||||
};
|
||||
|
||||
struct LicenceInfo21
|
||||
//defaultni struktura polozky licence ELC 1
|
||||
struct LicenceELC1Item
|
||||
{
|
||||
int protocolId = -1;
|
||||
int dataPointsCount = 0;
|
||||
};
|
||||
|
||||
|
||||
/* struktury pro ELC 2 */
|
||||
//defaultní struktura pro ELC 2
|
||||
struct LicenceELC2Info
|
||||
{
|
||||
int reqDataPointsCount = 0;
|
||||
unordered_map<int, int> licences = {};
|
||||
};
|
||||
|
||||
struct LicenceInfo31
|
||||
struct LicenceELC2Info_1
|
||||
{
|
||||
int reqDataPointsCount = 0;
|
||||
unordered_map<int, int> licences = {};
|
||||
};
|
||||
|
||||
struct LicenceInfoGeneral
|
||||
//defaultni struktura polozky ELC 2
|
||||
struct LicenceELC2Item
|
||||
{
|
||||
int reqDataPointsCount = 0;
|
||||
unordered_map<int, int> licences = {};
|
||||
int protocolId = -1;
|
||||
int dataPointsCount = 0;
|
||||
};
|
||||
|
||||
//struktura polozky ELC 2,
|
||||
struct LicenceELC2Item_1
|
||||
{
|
||||
int protocolId = -1;
|
||||
int dataPointsCount = 0;
|
||||
};
|
||||
|
||||
|
||||
class LicenceException : public std::exception
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
//#define LINUX 1
|
||||
#define WINDOWS 1
|
||||
|
||||
#ifndef UTILS_H_
|
||||
#define UTILS_H_
|
||||
|
||||
@@ -12,6 +9,7 @@
|
||||
#include <format>
|
||||
#include <libgen.h> // dirname
|
||||
#include <climits>
|
||||
#include <unistd.h>
|
||||
|
||||
typedef uint8_t BYTE;
|
||||
typedef uint16_t WORD;
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include <stdint.h>
|
||||
#include "pugixml.hpp"
|
||||
#include "licenceCommon.h"
|
||||
#include "licenceELC11.h"
|
||||
#include "licenceELC21.h"
|
||||
#include "licenceELC31.h"
|
||||
// #include "licenceELC11.h"
|
||||
// #include "licenceELC21.h"
|
||||
// #include "licenceELC31.h"
|
||||
|
||||
#include "licGenELC1.h"
|
||||
#include "licGenELC2.h"
|
||||
@@ -20,6 +20,7 @@ using namespace std;
|
||||
class LicenceGenerator
|
||||
{
|
||||
|
||||
public:
|
||||
struct LicData
|
||||
{
|
||||
string station = "";
|
||||
@@ -32,31 +33,27 @@ class LicenceGenerator
|
||||
pugi::xml_document *doc;
|
||||
};
|
||||
|
||||
public:
|
||||
LicData licData;
|
||||
int elcSwitchType;
|
||||
string operationErrors = "";
|
||||
pugi::xml_document doc;
|
||||
bool argumentsCorrect = false;
|
||||
ErrorMessage error;
|
||||
LicenceELC11 *licence11;
|
||||
LicenceELC21 *licence21;
|
||||
LicenceELC31 *licence31;
|
||||
// LicenceELC11 *licence11;
|
||||
// LicenceELC21 *licence21;
|
||||
// LicenceELC31 *licence31;
|
||||
Mapping mapping;
|
||||
|
||||
|
||||
LicenceGenerator();
|
||||
~LicenceGenerator();
|
||||
LicenceGenerator(string uid, string cid, string csd, string dataFileName);
|
||||
|
||||
void createLicenceFile();
|
||||
|
||||
|
||||
LicenceInfoGeneral licenceInfo;
|
||||
|
||||
|
||||
private:
|
||||
LicenceIdentification licIdentification;
|
||||
LicData licData;
|
||||
string configFileName = "";
|
||||
|
||||
void *licence = nullptr;
|
||||
@@ -66,7 +63,6 @@ private:
|
||||
void createLicenceELC1();
|
||||
void createLicenceELC2();
|
||||
void createLicenceELC3();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -944,13 +944,17 @@ namespace pugi
|
||||
char _memory[192];
|
||||
|
||||
// Non-copyable semantics
|
||||
xml_document(const xml_document&);
|
||||
xml_document& operator=(const xml_document&);
|
||||
// xml_document(const xml_document&);
|
||||
// xml_document& operator=(const xml_document&);
|
||||
|
||||
void create();
|
||||
void destroy();
|
||||
|
||||
public:
|
||||
|
||||
xml_document(const xml_document&);
|
||||
xml_document& operator=(const xml_document&);
|
||||
|
||||
// Default constructor, makes empty document
|
||||
xml_document();
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Reader
|
||||
{
|
||||
public:
|
||||
|
||||
LicenceInfo21 licenceInfo;
|
||||
LicenceELC1Info licenceInfo;
|
||||
|
||||
Licence1();
|
||||
~Licence1();
|
||||
|
||||
@@ -13,15 +13,13 @@ namespace Reader
|
||||
class Licence2 : public LicenceELC2
|
||||
{
|
||||
public:
|
||||
LicenceInfo21 licenceInfo;
|
||||
|
||||
LicenceELC2Info licenceInfo;
|
||||
|
||||
Licence2();
|
||||
~Licence2();
|
||||
Licence2(LicenceIdentification &licIdentification);
|
||||
|
||||
bool readLicence(LicenceInfoGeneral *licences);
|
||||
int getDataPointsCount(int protocolId);
|
||||
bool getLicenceInfo(void *ptr);
|
||||
bool getLicenceItemInfo(int protocolId, void *returnItemStructure);
|
||||
void getLicenceItems();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
0353445355313647801b1a9f6600c747
|
||||
9f54495344434954615ad803c50171bf
|
||||
6 . x4 <20><><EFBFBD> .. nt$6 &<26> manfid 6 <20><><EFBFBD>
|
||||
cid "6 <10> fwrev 6 Jm<4A> csd ,6 gEd$
|
||||
subsystem 46 <20><><EFBFBD>%
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
400e00325b59000076b27f800a404013
|
||||
400e00325b5900003be77f800a400043
|
||||
|
||||
BIN
output/ezlic_eovosv0_jjacdgpdxpb.lic
Normal file
BIN
output/ezlic_eovosv0_jjacdgpdxpb.lic
Normal file
Binary file not shown.
BIN
output/ezlic_eovosv0_wqxcyjpdxji.lic
Normal file
BIN
output/ezlic_eovosv0_wqxcyjpdxji.lic
Normal file
Binary file not shown.
BIN
output/generate
Normal file
BIN
output/generate
Normal file
Binary file not shown.
5
output/lcis/cis
Normal file
5
output/lcis/cis
Normal file
@@ -0,0 +1,5 @@
|
||||
0353445355313647801b1a9f6600c747
|
||||
6 . x4 <20><><EFBFBD> .. nt$6 &<26> manfid 6 <20><><EFBFBD>
|
||||
cid "6 <10> fwrev 6 Jm<4A> csd ,6 gEd$
|
||||
subsystem 46 <20><><EFBFBD>%
|
||||
driver (6 <20><><EFBFBD>- ocr -6 <20><><EFBFBD>? power *6 <>4L type 6 <20>1M date #6 <20>rTP hwrev )6 n<>yR dsr '6 <20>` serial 6 NN<4E>m erase_size <20>6 <20>6<EFBFBD>m block 6 <20><><EFBFBD>n uevent 6 <18><>o ssr 6 <1E>q scr &6 &<26><>y oemid !6 <20><><EFBFBD>y ( preferred_erase_size %6 <20><><EFBFBD> name
|
||||
2
output/lcis/csd
Normal file
2
output/lcis/csd
Normal file
@@ -0,0 +1,2 @@
|
||||
400e00325b59000076b27f800a404013
|
||||
|
||||
BIN
output/lcis/ezlic_eovosv0_wqxcyjpdxji.lic
Normal file
BIN
output/lcis/ezlic_eovosv0_wqxcyjpdxji.lic
Normal file
Binary file not shown.
37
output/lcis/licData.xml
Normal file
37
output/lcis/licData.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<licence elc="2" xmlVersion="1" revision="1" compatibility="1">
|
||||
<licenceType licenceVersion="1" licenceIndex="0">EOV_OSV</licenceType>
|
||||
<plcType>WAGO</plcType>
|
||||
<licenceName>Licence pro EOV_OSV</licenceName>
|
||||
<station>eov.ceskatrebova.ddts.cz</station>
|
||||
<distributor>eov2</distributor>
|
||||
<project>Projekt XXX stanice YYY</project>
|
||||
<items>
|
||||
<item>
|
||||
<name>Položka licence 1</name>
|
||||
<protoId>111</protoId>
|
||||
<dataPointsCount>100</dataPointsCount>
|
||||
</item>
|
||||
<item>
|
||||
<name>Položka licence 2</name>
|
||||
<protoId>222</protoId>
|
||||
<dataPointsCount>200</dataPointsCount>
|
||||
</item>
|
||||
<item>
|
||||
<name>Položka licence 3</name>
|
||||
<protoId>333</protoId>
|
||||
<dataPointsCount>300</dataPointsCount>
|
||||
</item>
|
||||
<item>
|
||||
<name>Položka licence 4</name>
|
||||
<protoId>555</protoId>
|
||||
<dataPointsCount>666</dataPointsCount>
|
||||
</item>
|
||||
<item>
|
||||
<name>Položka licence 5</name>
|
||||
<protoId>666</protoId>
|
||||
<dataPointsCount>9998</dataPointsCount>
|
||||
</item>
|
||||
</items>
|
||||
|
||||
</licence>
|
||||
BIN
output/lcis/temp/ezlic_eovosv0_xjxvxgalxab.lic
Normal file
BIN
output/lcis/temp/ezlic_eovosv0_xjxvxgalxab.lic
Normal file
Binary file not shown.
@@ -1,36 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<licence elc="1" xmlVersion="1" revision="1" compatibility="1">
|
||||
<licence elc="2" xmlVersion="1" revision="1" compatibility="1">
|
||||
<licenceType licenceVersion="1" licenceIndex="0">EOV_OSV</licenceType>
|
||||
<plcType>WAGO</plcType>
|
||||
<licenceName>Licence pro EOV_OSV</licenceName>
|
||||
<station>eov.ceskatrebova.ddts.cz</station>
|
||||
<distributor>eov2</distributor>
|
||||
<station>odb.zaluzi.drt.cz</station>
|
||||
<distributor>POZ8</distributor>
|
||||
<project>Projekt XXX stanice YYY</project>
|
||||
<items>
|
||||
<item>
|
||||
<name>Položka licence 1</name>
|
||||
<protoId>111</protoId>
|
||||
<dataPointsCount>100</dataPointsCount>
|
||||
<dataPointsCount>7454</dataPointsCount>
|
||||
</item>
|
||||
<item>
|
||||
<name>Položka licence 2</name>
|
||||
<protoId>222</protoId>
|
||||
<dataPointsCount>200</dataPointsCount>
|
||||
<dataPointsCount>6477</dataPointsCount>
|
||||
</item>
|
||||
<item>
|
||||
<name>Položka licence 3</name>
|
||||
<protoId>333</protoId>
|
||||
<dataPointsCount>300</dataPointsCount>
|
||||
</item>
|
||||
<item>
|
||||
<name>Položka licence 3</name>
|
||||
<protoId>444</protoId>
|
||||
<dataPointsCount>1600</dataPointsCount>
|
||||
</item>
|
||||
<item>
|
||||
<name>Položka licence 4</name>
|
||||
<protoId>555</protoId>
|
||||
<dataPointsCount>666</dataPointsCount>
|
||||
<dataPointsCount>7844</dataPointsCount>
|
||||
</item>
|
||||
</items>
|
||||
|
||||
|
||||
Binary file not shown.
BIN
output/read
Normal file
BIN
output/read
Normal file
Binary file not shown.
@@ -1,3 +1,6 @@
|
||||
#define LINUX 1
|
||||
//#define WINDOWS 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include "licenceGenerator.h"
|
||||
|
||||
@@ -5,7 +8,7 @@
|
||||
/// @param argc
|
||||
/// @param argv parametry pro generování licence
|
||||
/// @return
|
||||
int main5(int argc, char *argv[])
|
||||
int main6(int argc, char *argv[])
|
||||
{
|
||||
unordered_map<string, string> arguments = getArguments(argc, argv);
|
||||
try
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#define LINUX 1
|
||||
// #define WINDOWS 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include "licenceReader.h"
|
||||
|
||||
@@ -13,15 +16,16 @@ int main()
|
||||
initStructure.licenceType = (int)LicenceType::EOS_EOV;
|
||||
initStructure.licenceVersion = 1;
|
||||
initStructure.licenceIndex = 0;
|
||||
initStructure.compatibility = 1;
|
||||
initStructure.licenceFilePath = "";
|
||||
initStructure.cid_csd_filePath = "";
|
||||
initStructure.licenceFilePath = ""; // cesta k licenčnímu souboru
|
||||
// initStructure.compatibility = 0; v případě kompatibility 0 či nezadané je výstup defaultní.
|
||||
// pro ELC 1 LicenceELC1Info s výstupem isValid, pro ELC 2 strukura { int protocolId = -1; int dataPointsCount = 0; }
|
||||
initStructure.cid_csd_filePath = ""; // cesta k cidu/csd pro načtení a kontorlu licence
|
||||
|
||||
// verze původní ELC 1
|
||||
LicenceReader licenceReaderELC1{};
|
||||
if (licenceReaderELC1.initread(1, initStructure)) //iniciacni nacteni
|
||||
if (licenceReaderELC1.initread(1, initStructure)) // iniciacni nacteni
|
||||
{
|
||||
LicenceInfo1 info; // struktura pro ELC1. Nemá tam asi nic jiného smysl nez true/false
|
||||
LicenceELC1Info info; // struktura pro ELC1. Nemá tam asi nic jiného smysl nez true/false
|
||||
if (licenceReaderELC1.getLicenceInfo(&info))
|
||||
{
|
||||
if (info.isValid)
|
||||
@@ -40,10 +44,23 @@ int main()
|
||||
// verze ELC 2 pro jeden protokol
|
||||
LicenceReader licenceReaderELC2{};
|
||||
|
||||
if (licenceReaderELC2.initread(2, initStructure)) //iniciacni nacteni
|
||||
if (licenceReaderELC2.initread(2, initStructure)) // iniciacni nacteni
|
||||
{
|
||||
LicenceItem21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
|
||||
int protocolId = 444;
|
||||
// v případě kompatibility 0, či nezadané výstup nativně je defaultní.
|
||||
// v případně nenulové kompatibility, třeba 1, přidáme číslo kompatibility. Tedy pro ELC1 to bude LicenceELC1_1, pro ELC LicenceELC2_1
|
||||
LicenceELC2Item info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
|
||||
// if ()
|
||||
int protocolId = 333;
|
||||
|
||||
// if (initStructure.compatibility == 1) //ukazka kompatibilita
|
||||
// {
|
||||
// LicenceELC2Item_1 info; //jiná struktura, zbytek stejný
|
||||
// if (licenceReaderELC2.getLicenceItemInfo(protocolId, &info))
|
||||
// {
|
||||
// cout << "Pocet licencních bodu pro " << info.protocolId << ": " << info.dataPointsCount << std::endl;
|
||||
// }
|
||||
//...........
|
||||
// }
|
||||
|
||||
if (licenceReaderELC2.getLicenceItemInfo(protocolId, &info))
|
||||
{
|
||||
@@ -60,15 +77,17 @@ int main()
|
||||
LicenceReader licenceReaderCompleteELC2{};
|
||||
|
||||
// verze ELC 2 kompletní načtení
|
||||
if (licenceReaderCompleteELC2.init(2, initStructure)) //iniciacni nacteni
|
||||
if (licenceReaderCompleteELC2.init(2, initStructure)) // iniciacni nacteni
|
||||
{
|
||||
LicenceInfo21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
|
||||
LicenceELC2Info info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
|
||||
int protocolId = 333;
|
||||
|
||||
if (licenceReaderCompleteELC2.getLicenceInfo(&info))
|
||||
{
|
||||
if (info.licences.count(protocolId) > 0) cout << "Pocet bodu z vectoru pro protokol : " << protocolId << ": " << info.licences.at(protocolId) << "\n";
|
||||
else cout << "Pro tento protokol nejsou definovay licencni body\n";
|
||||
if (info.licences.count(protocolId) > 0)
|
||||
cout << "Pocet bodu z vectoru pro protokol : " << protocolId << ": " << info.licences.at(protocolId) << "\n";
|
||||
else
|
||||
cout << "Pro tento protokol nejsou definovay licencni body\n";
|
||||
cout << "Vypis vsech licencnich bodu: " << endl;
|
||||
for (const auto &pair : info.licences)
|
||||
{
|
||||
@@ -91,3 +110,6 @@ int main()
|
||||
// system("pause");
|
||||
return SUCCES;
|
||||
}
|
||||
|
||||
// cid: 0353445355313647801b1a9f6600c747 csd: 400e00325b59000076b27f800a404013
|
||||
// https://sprava.app.elzel.cz/device/417 cid: 9f54495344434954615ad803c50171bf csd: 400e00325b5900003be77f800a400043
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,7 +3,6 @@
|
||||
#include <openssl/ssl.h> /* core library */
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
const std::string base64_chars =
|
||||
@@ -117,8 +116,8 @@ int encrypt(const unsigned char *plaintext, int plaintext_len, unsigned char *ke
|
||||
int ciphertext_len;
|
||||
|
||||
/* Create and initialise the context */
|
||||
if (!(ctx = EVP_CIPHER_CTX_new())) return -1;
|
||||
|
||||
if (!(ctx = EVP_CIPHER_CTX_new()))
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* Initialise the encryption operation. IMPORTANT - ensure you use a key
|
||||
@@ -180,7 +179,7 @@ int decrypt(const unsigned char *ciphertext, int ciphertext_len, unsigned char *
|
||||
* EVP_DecryptUpdate can be called multiple times if necessary.
|
||||
*/
|
||||
if (1 != EVP_DecryptUpdate(ctx, plaintext, &len, ciphertext, ciphertext_len))
|
||||
return -1;
|
||||
return -1;
|
||||
plaintext_len = len;
|
||||
|
||||
/*
|
||||
@@ -188,7 +187,7 @@ int decrypt(const unsigned char *ciphertext, int ciphertext_len, unsigned char *
|
||||
* this stage.
|
||||
*/
|
||||
if (1 != EVP_DecryptFinal_ex(ctx, plaintext + len, &len))
|
||||
return -1;
|
||||
return -1;
|
||||
|
||||
plaintext_len += len;
|
||||
|
||||
@@ -316,17 +315,17 @@ string getCompletePath(string fileName)
|
||||
#ifdef WINDOWS
|
||||
return fileName;
|
||||
#else
|
||||
//warning TODO filesystem
|
||||
char path[PATH_MAX+1] = {};
|
||||
ssize_t length = readlink("/proc/self/exe", path, PATH_MAX);
|
||||
path[length] = '\0';
|
||||
string result = string(dirname(path)) + "/" + fileName;
|
||||
return result;
|
||||
//return std::string( result, (count > 0) ? count : 0 );
|
||||
// std::filesystem::path exePath = std::filesystem::canonical("/proc/self/exe"); // / std::filesystem::path(argv[0]));
|
||||
// std::filesystem::path fullPathOther = exePath.parent_path() / fileName;
|
||||
// std::string fullPathStrOther = fullPathOther.string();
|
||||
// return fullPathStrOther;
|
||||
|
||||
char path[PATH_MAX + 1] = {};
|
||||
ssize_t length = readlink("/proc/self/exe", path, PATH_MAX);
|
||||
path[length] = '\0';
|
||||
string result = string(dirname(path)) + "/" + fileName;
|
||||
return result;
|
||||
// return std::string( result, (count > 0) ? count : 0 );
|
||||
// std::filesystem::path exePath = std::filesystem::canonical("/proc/self/exe"); // / std::filesystem::path(argv[0]));
|
||||
// std::filesystem::path fullPathOther = exePath.parent_path() / fileName;
|
||||
// std::string fullPathStrOther = fullPathOther.string();
|
||||
// return fullPathStrOther;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,9 +1,8 @@
|
||||
src/generator/LicenceGenerator.o: src/generator/LicenceGenerator.cpp \
|
||||
include/generator/licenceGenerator.h include/generator/pugixml.hpp \
|
||||
include/generator/pugiconfig.hpp include/common/licenceCommon.h \
|
||||
include/licenceELC11.h include/common/SDCard.h include/licenceELC21.h \
|
||||
include/common/utils.h include/generator/pugixml.hpp \
|
||||
include/licenceELC31.h include/generator/licGenELC1.h \
|
||||
include/generator/licGenELC1.h include/common/utils.h \
|
||||
include/common/licenceELC1.h include/common/licenceCommon.h \
|
||||
include/common/SDCard.h include/generator/licGenELC2.h \
|
||||
include/common/licenceELC2.h include/generator/licGenELC3.h
|
||||
include/common/SDCard.h include/common/SDCard.h \
|
||||
include/generator/licGenELC2.h include/common/licenceELC2.h \
|
||||
include/generator/licGenELC3.h include/generator/pugixml.hpp
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -13,118 +13,10 @@ LicenceReader::LicenceReader()
|
||||
{
|
||||
}
|
||||
|
||||
// LicenceReader::LicenceReader(string uid, string cid, string csd, string dataFileName)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (dataFileName.empty())
|
||||
// throw std::runtime_error("Missing dataFileName par.");
|
||||
|
||||
// if (uid.empty() == false)
|
||||
// {
|
||||
// this->licData.uid = uid;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (cid.empty())
|
||||
// throw std::runtime_error("Missing CID par.");
|
||||
// if (csd.empty())
|
||||
// throw std::runtime_error("Missing CSD par.");
|
||||
// }
|
||||
// }
|
||||
// catch (const std::exception &e)
|
||||
// {
|
||||
// this->argumentsCorrect = false;
|
||||
// std::cerr << "error: " << e.what() << endl;
|
||||
// return;
|
||||
// }
|
||||
|
||||
// this->configFileName = dataFileName;
|
||||
// this->licData.cid = cid;
|
||||
// this->licData.csd = csd;
|
||||
|
||||
// this->argumentsCorrect = true;
|
||||
|
||||
// if (processInputConfiguration() == false)
|
||||
// {
|
||||
// cerr << "Chyba: " << error.message << endl;
|
||||
// }
|
||||
// }
|
||||
|
||||
// LicenceReader::LicenceReader(int elcType, int licenceType, int licenceVersion, int licenceIndex, int compatibility)
|
||||
// {
|
||||
// this->licIdentification.licElcType = (ELCType)elcType;
|
||||
// this->licIdentification.licLicenceType = (LicenceType)licenceType;
|
||||
// this->licIdentification.licenceVersion = licenceVersion;
|
||||
// this->licIdentification.licenceIndex = licenceIndex;
|
||||
// this->licIdentification.licCompatibility = compatibility;
|
||||
// }
|
||||
|
||||
/// @brief inicializace generátoru a načtení licenčních bodů do obecné struktury
|
||||
/// @brief provede pouze inicialazaci čtecí třídy
|
||||
/// @param elcType
|
||||
/// @param licenceType
|
||||
/// @param licenceVersion
|
||||
/// @param licenceIndex
|
||||
/// @param compatibility
|
||||
/// @param initStructure
|
||||
/// @return
|
||||
bool LicenceReader::initread(int elcType, InitStructure &initStructure) // TOTO
|
||||
{
|
||||
try
|
||||
{
|
||||
elcSwitchType = elcType * 10 + licCompatibility;
|
||||
|
||||
if (init(elcType, initStructure))
|
||||
{
|
||||
switch (elcSwitchType)
|
||||
{
|
||||
case 11:
|
||||
{ // old eoseov
|
||||
Reader::Licence1 licenceELC1 = Reader::Licence1(this->licIdentification);
|
||||
this->licence1 = &licenceELC1;
|
||||
licenceELC1.cid_cdsPath = initStructure.cid_csd_filePath;
|
||||
licenceELC1.licenceFilePath = initStructure.licenceFilePath;
|
||||
|
||||
try
|
||||
{
|
||||
this->licence1->readLicence(&this->licenceInfo);
|
||||
}
|
||||
catch (const LicenceException &ex)
|
||||
{
|
||||
error.code = ex.getErrorCode();
|
||||
error.message = ex.getErrorMessage();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 21:
|
||||
{
|
||||
Reader::Licence2 licenceELC2 = Reader::Licence2(this->licIdentification);
|
||||
this->licence2 = &licenceELC2;
|
||||
licenceELC2.cid_cdsPath = initStructure.cid_csd_filePath;
|
||||
licenceELC2.licenceFilePath = initStructure.licenceFilePath;
|
||||
this->licence2->readLicence(&this->licenceInfo);
|
||||
break;
|
||||
}
|
||||
case 31:
|
||||
{
|
||||
// LicenceELC31 licence = LicenceELC31(this->licIdentification);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
catch (const LicenceException &ex)
|
||||
{
|
||||
error.code = ex.getErrorCode();
|
||||
error.message = ex.getErrorMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // TODO testy
|
||||
}
|
||||
|
||||
bool LicenceReader::init(int elcType, InitStructure &initStructure)
|
||||
{
|
||||
try
|
||||
@@ -154,6 +46,72 @@ bool LicenceReader::init(int elcType, InitStructure &initStructure)
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @brief provede inicializaci čtecí třídy a zároveň načte licenční body do obecné struktury
|
||||
/// @param elcType
|
||||
/// @param licenceType
|
||||
/// @param licenceVersion
|
||||
/// @param licenceIndex
|
||||
/// @param compatibility
|
||||
/// @return
|
||||
bool LicenceReader::initread(int elcType, InitStructure &initStructure)
|
||||
{
|
||||
try
|
||||
{
|
||||
elcSwitchType = elcType * 10 + initStructure.compatibility;
|
||||
|
||||
if (init(elcType, initStructure))
|
||||
{
|
||||
switch (this->licIdentification.licElcType)
|
||||
{
|
||||
case ELCType::ELC1:
|
||||
{ // old eoseov
|
||||
Reader::Licence1 licenceELC1 = Reader::Licence1(this->licIdentification);
|
||||
this->licence1 = &licenceELC1;
|
||||
licenceELC1.cid_cdsPath = initStructure.cid_csd_filePath;
|
||||
licenceELC1.licenceFilePath = initStructure.licenceFilePath;
|
||||
|
||||
try
|
||||
{
|
||||
this->licence1->readLicence(&this->licenceInfo);
|
||||
}
|
||||
catch (const LicenceException &ex)
|
||||
{
|
||||
error.code = ex.getErrorCode();
|
||||
error.message = ex.getErrorMessage();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ELCType::ELC2:
|
||||
{
|
||||
Reader::Licence2 licenceELC2 = Reader::Licence2(this->licIdentification);
|
||||
this->licence2 = &licenceELC2;
|
||||
licenceELC2.cid_cdsPath = initStructure.cid_csd_filePath;
|
||||
licenceELC2.licenceFilePath = initStructure.licenceFilePath;
|
||||
this->licence2->readLicence(&this->licenceInfo);
|
||||
break;
|
||||
}
|
||||
case ELCType::ELC3:
|
||||
{
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw LicenceException((int)GeneralError::ELCNotImplemented, "Toto ELC není implementováno");
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
catch (const LicenceException &ex)
|
||||
{
|
||||
error.code = ex.getErrorCode();
|
||||
error.message = ex.getErrorMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // TODO testy
|
||||
}
|
||||
|
||||
/// @brief vrací informace o licenčím bodu na základě id protocolu a předané návratové struktury
|
||||
/// @param protocolId
|
||||
/// @param returnItemStructure
|
||||
@@ -162,28 +120,51 @@ bool LicenceReader::getLicenceItemInfo(int protocolId, void *returnItemStructure
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (elcSwitchType)
|
||||
switch (this->licIdentification.licElcType)
|
||||
{
|
||||
case 11:
|
||||
case ELCType::ELC1:
|
||||
{
|
||||
LicenceInfo1 *resultPtr = static_cast<LicenceInfo1 *>(returnItemStructure);
|
||||
if (this->licenceInfo.licences.count(1)) resultPtr->isValid = true; //stare eov melo natvrdo "id" 1.
|
||||
else resultPtr->isValid = false;
|
||||
break;
|
||||
}
|
||||
case 21:
|
||||
{
|
||||
LicenceItem21 *resultPtr = static_cast<LicenceItem21 *>(returnItemStructure);
|
||||
resultPtr->protocolId = protocolId; // protocolId;
|
||||
if (this->licenceInfo.licences.count(protocolId))
|
||||
resultPtr->dataPointsCount = this->licenceInfo.licences.at(protocolId);
|
||||
if (!this->licIdentification.licCompatibility) // defaultní kompatibilita
|
||||
{
|
||||
LicenceELC1Info *resultPtr = static_cast<LicenceELC1Info *>(returnItemStructure);
|
||||
if (this->licenceInfo.licences.count(1)) // stare eov má natvrdo "id" 1.
|
||||
resultPtr->isValid = true;
|
||||
else
|
||||
resultPtr->isValid = false;
|
||||
}
|
||||
else
|
||||
resultPtr->dataPointsCount = 0;
|
||||
{
|
||||
LicenceException((int)GeneralError::CompatibilityTypeNotImplemented, "Kompatibilita není implementována.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 31:
|
||||
case ELCType::ELC2:
|
||||
{
|
||||
if (!this->licIdentification.licCompatibility) // defaultní kompatibilita
|
||||
{
|
||||
LicenceELC2Item *resultPtr = static_cast<LicenceELC2Item *>(returnItemStructure);
|
||||
resultPtr->protocolId = protocolId; // protocolId;
|
||||
if (this->licenceInfo.licences.count(protocolId))
|
||||
resultPtr->dataPointsCount = this->licenceInfo.licences.at(protocolId);
|
||||
else
|
||||
resultPtr->dataPointsCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (this->licIdentification.licCompatibility)
|
||||
{
|
||||
case 1:
|
||||
// kod pro kompatibilitu 1
|
||||
break;
|
||||
default:
|
||||
LicenceException((int)GeneralError::CompatibilityTypeNotImplemented, "Kompatibilita není implementována.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ELCType::ELC3:
|
||||
{
|
||||
// LicenceELC31 licence = LicenceELC31(this->licIdentification);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -211,66 +192,61 @@ bool LicenceReader::getLicenceInfo(void *returnStructure)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (elcSwitchType)
|
||||
switch (this->licIdentification.licElcType)
|
||||
{
|
||||
case 11:
|
||||
{ // old eoseov
|
||||
|
||||
LicenceInfo1 *resultPtr = static_cast<LicenceInfo1 *>(returnStructure);
|
||||
|
||||
if (this->licenceInfo.licences.count(1))
|
||||
case ELCType::ELC1:
|
||||
{ // old eoseov
|
||||
if (!this->licIdentification.licCompatibility) // defaultní kompatibilita
|
||||
{
|
||||
resultPtr->isValid = true;
|
||||
LicenceELC1Info *resultPtr = static_cast<LicenceELC1Info *>(returnStructure);
|
||||
|
||||
if (this->licenceInfo.licences.count(1)) // starý EOS má natvrdo "id" 1
|
||||
{
|
||||
resultPtr->isValid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultPtr->isValid = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
resultPtr->isValid = false;
|
||||
switch (this->licIdentification.licCompatibility)
|
||||
{
|
||||
case 1:
|
||||
// kod pro kompatibilitu 1
|
||||
break;
|
||||
default:
|
||||
LicenceException((int)GeneralError::CompatibilityTypeNotImplemented, "Kompatibilita není implementována.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case 21:
|
||||
case ELCType::ELC2:
|
||||
{
|
||||
|
||||
Reader::Licence2 licenceELC2 = Reader::Licence2(this->licIdentification);
|
||||
licenceELC2.readLicence(&this->licenceInfo);
|
||||
return licenceELC2.getLicenceInfo(returnStructure);
|
||||
|
||||
// catch (const LicenceException &ex)
|
||||
// {
|
||||
// error.code = ex.getErrorCode();
|
||||
// error.message = ex.getErrorMessage();
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// LicenceELC21 licence = LicenceELC21(this->licIdentification);
|
||||
// try
|
||||
// {
|
||||
// licence.readLicence(&this->licenceInfo);
|
||||
// return licence.getLicenceInfo(returnStructure);
|
||||
// }
|
||||
// catch (const LicenceException &ex)
|
||||
// {
|
||||
// error.code = ex.getErrorCode();
|
||||
// error.message = ex.getErrorMessage();
|
||||
// return false;
|
||||
// }
|
||||
if (!this->licIdentification.licCompatibility) // defaultní kompatibilita
|
||||
{
|
||||
Reader::Licence2 licenceELC2 = Reader::Licence2(this->licIdentification);
|
||||
licenceELC2.readLicence(&this->licenceInfo);
|
||||
licenceELC2.getLicenceInfo(returnStructure);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (this->licIdentification.licCompatibility)
|
||||
{
|
||||
case 1:
|
||||
// kod pro kompatibilitu 1
|
||||
break;
|
||||
default:
|
||||
LicenceException((int)GeneralError::CompatibilityTypeNotImplemented, "Kompatibilita není implementována.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 31:
|
||||
case ELCType::ELC3:
|
||||
{
|
||||
// LicenceELC31 licence = LicenceELC31(this->licIdentification);
|
||||
// try
|
||||
// {
|
||||
// licence.readLicence();
|
||||
// return licence.getLicenceInfo(returnStructure);
|
||||
// }
|
||||
// catch (const LicenceException &ex)
|
||||
// {
|
||||
// error.code = ex.getErrorCode();
|
||||
// error.message = ex.getErrorMessage();
|
||||
// return false;
|
||||
// }
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -281,6 +257,7 @@ bool LicenceReader::getLicenceInfo(void *returnStructure)
|
||||
error.message = ex.getErrorMessage();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
LicenceReader::~LicenceReader()
|
||||
|
||||
Binary file not shown.
@@ -10,6 +10,9 @@ namespace Reader
|
||||
{
|
||||
}
|
||||
|
||||
/// @brief načte seznam licenčních bodů do obecné struktury
|
||||
/// @param licences
|
||||
/// @return
|
||||
bool Licence1::readLicence(LicenceInfoGeneral *licences)
|
||||
{
|
||||
sdCard = SDCard(this->cid_cdsPath);
|
||||
@@ -20,11 +23,6 @@ namespace Reader
|
||||
|
||||
if (getSDData() == false) throw LicenceException((int)GeneralError::SDCardReadError, "Chyba při čtení SD karty, cesta: " + cid_cdsPath);
|
||||
|
||||
for (unsigned int i = 0; i < sdCard.cidString.length(); i++)
|
||||
this->cid[i] = sdCard.cidString[i]; // nutné pro původní algoritmus
|
||||
for (unsigned int i = 0; i < sdCard.csdString.length(); i++)
|
||||
this->csd[i] = sdCard.csdString[i]; // nutné pro původní algoritmus
|
||||
|
||||
string licFileName = getLicenceName(0);
|
||||
string licFilePath = this->licenceFilePath + licFileName;
|
||||
|
||||
@@ -34,12 +32,12 @@ namespace Reader
|
||||
FILE *licenceFile;
|
||||
char ch;
|
||||
|
||||
licenceFile = fopen(licFileNameToRead, "rb"); // read mode
|
||||
licenceFile = fopen(licFileNameToRead, "rb");
|
||||
|
||||
if (licenceFile == nullptr) throw LicenceException((int)GeneralError::LicenceReadError, "LicenceReadError: " + licFilePath);
|
||||
|
||||
fseek(licenceFile, 0, SEEK_END); // seek to end of file
|
||||
const int size = ftell(licenceFile); // get current file pointer
|
||||
fseek(licenceFile, 0, SEEK_END);
|
||||
const int size = ftell(licenceFile);
|
||||
fseek(licenceFile, 0, SEEK_SET);
|
||||
|
||||
if (size <= 0) throw LicenceException((int)GeneralError::LicenceSizeMismatch, "LicenceSizeMismatch: " + licFilePath);
|
||||
@@ -75,7 +73,7 @@ namespace Reader
|
||||
if (licenceHeader.licHeader.licSubType == cEzLic_p78ou3_SubType_10_10)
|
||||
{
|
||||
initCrypto();
|
||||
// CryptData cryptData = initCrypto(sdData, licIdent.licIDType);
|
||||
|
||||
unsigned char decrypted[2000] = {};
|
||||
int decrypted_len = decrypt(encryptedData, sizeof(encryptedData), cryptData.aesKey, cryptData.aesInitVector, decrypted);
|
||||
|
||||
@@ -85,7 +83,6 @@ namespace Reader
|
||||
}
|
||||
else
|
||||
{
|
||||
// memset(&licEncryptedData, 0, sizeof(licEncryptedData));
|
||||
memcpy(&licEncryptedData, decrypted, sizeof(licEncryptedData));
|
||||
|
||||
if (licEncryptedData.id.version == cEzLic_p78ou3_HeaderType_10 && licEncryptedData.header.licVersion == cEzLic_p78ou3_HeaderType_10)
|
||||
@@ -101,7 +98,7 @@ namespace Reader
|
||||
}
|
||||
else
|
||||
{
|
||||
throw LicenceException((int)GeneralError::LicenceSizeCardMismatch, "Size card info mismatch");
|
||||
throw LicenceException((int)GeneralError::ItemsCountMismatch, "ItemsCountMismatch");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -3,15 +3,15 @@
|
||||
namespace Reader
|
||||
{
|
||||
|
||||
Licence2::Licence2(){}
|
||||
Licence2::Licence2() {}
|
||||
|
||||
Licence2::~Licence2(){}
|
||||
Licence2::~Licence2() {}
|
||||
|
||||
Licence2::Licence2(LicenceIdentification &licIdentification) : LicenceELC2(licIdentification)
|
||||
{
|
||||
}
|
||||
|
||||
/// @brief načte licence do obecné struktury ELC2
|
||||
/// @brief načte seznam licenčních bodů do obecné struktury
|
||||
/// @param licences
|
||||
/// @return
|
||||
bool Licence2::readLicence(LicenceInfoGeneral *licences)
|
||||
@@ -90,23 +90,23 @@ namespace Reader
|
||||
}
|
||||
|
||||
bool Licence2::getLicenceInfo(void *returnStructure)
|
||||
{
|
||||
if (returnStructure != nullptr)
|
||||
{
|
||||
LicenceInfo21 *resultPtr = static_cast<LicenceInfo21 *>(returnStructure);
|
||||
for (auto item : this->licBody.privateContent.dataItems)
|
||||
if (returnStructure != nullptr)
|
||||
{
|
||||
resultPtr->licences.insert(pair<int, int>(item.protoId, item.licCount));
|
||||
LicenceELC2Info *resultPtr = static_cast<LicenceELC2Info *>(returnStructure);
|
||||
for (auto item : this->licBody.privateContent.dataItems)
|
||||
{
|
||||
resultPtr->licences.insert(pair<int, int>(item.protoId, item.licCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessage.code = 1;
|
||||
errorMessage.message = "Error: Null pointer!";
|
||||
return false;
|
||||
else
|
||||
{
|
||||
errorMessage.code = 1;
|
||||
errorMessage.message = "Error: Null pointer!";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user