From f260e92596622eaf25af934389e98455ed3dbf28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C5=A0alda?= Date: Mon, 18 Dec 2023 08:01:34 +0100 Subject: [PATCH] =?UTF-8?q?upravy=20=C4=8Di=C5=A1t=C4=9Bn=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CreateLicence.cpp | 99 ++++++++++++++++++++++------------------ src/LicenceELC11.cpp | 2 +- src/LicenceGenerator.cpp | 4 +- src/licenceELC21.cpp | 23 +++++----- 4 files changed, 68 insertions(+), 60 deletions(-) diff --git a/src/CreateLicence.cpp b/src/CreateLicence.cpp index ea47b8e..932b74b 100644 --- a/src/CreateLicence.cpp +++ b/src/CreateLicence.cpp @@ -9,59 +9,68 @@ /// @return int main(int argc, char *argv[]) { - // unordered_map arguments = getArguments(argc, argv); - // LicenceGenerator generatorOld = LicenceGenerator(arguments["-uid"], arguments["-cid"], arguments["-csd"], arguments["-configFileName"]); - // generatorOld.createLicenceFile(); - // return SUCCES; - - LicenceGenerator licenceGenerator = LicenceGenerator(); - - InitStructure initStructure; - initStructure.elcType = 1; - initStructure.licenceType = (int)LicenceType::EOS_EOV; - initStructure.licenceVersion = 1; - initStructure.licenceIndex = 0; - initStructure.compatibility = 1; - initStructure.licenceFilePath = ""; - initStructure.cid_csd_filePath = ""; - - // //verze #1: načtení kompletní licence a zobrazení - // if (licenceGenerator.init(initStructure)) - // { - // LicenceInfo21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31) - // int protocolId = 345; - // if (licenceGenerator.getLicenceInfo(protocolId, &info)) - // { - // std::cout << "Počet licenčních bodů pro : " << protocolId << ": " << info.reqDataPointsCount << std::endl; - // if (info.licences.count(protocolId) > 0) cout << "počet z vectoru pro : " << protocolId << info.licences.at(888) << endl; - // cout << "všechny licenční body: " << endl; - // for (const auto &pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl; } - // } - // else - // cerr << "Došlo k chybě: " << licenceGenerator.error.message; - // } - // else - // { - // cerr << "Došlo k chybě: " << licenceGenerator.error.message; - // } - - //verze #2 : iterace pro kazdý bod zvlášť - if (licenceGenerator.initread(initStructure)) + try { - int protocolId = 1; + /* code */ + // unordered_map arguments = getArguments(argc, argv); + // LicenceGenerator generatorOld = LicenceGenerator(arguments["-uid"], arguments["-cid"], arguments["-csd"], arguments["-configFileName"]); + // generatorOld.createLicenceFile(); + // return SUCCES; - LicenceItem21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31) - - if (licenceGenerator.getLicenceItemInfo(protocolId, &info)) + LicenceGenerator licenceGenerator = LicenceGenerator(); + + InitStructure initStructure; + initStructure.elcType = 2; + initStructure.licenceType = (int)LicenceType::EOS_EOV; + initStructure.licenceVersion = 1; + initStructure.licenceIndex = 0; + initStructure.compatibility = 1; + initStructure.licenceFilePath = ""; + initStructure.cid_csd_filePath = ""; + + // //verze #1: načtení kompletní licence a zobrazení + // if (licenceGenerator.init(initStructure)) + // { + // LicenceInfo21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31) + // int protocolId = 345; + // if (licenceGenerator.getLicenceInfo(protocolId, &info)) + // { + // std::cout << "Počet licenčních bodů pro : " << protocolId << ": " << info.reqDataPointsCount << std::endl; + // if (info.licences.count(protocolId) > 0) cout << "počet z vectoru pro : " << protocolId << info.licences.at(888) << endl; + // cout << "všechny licenční body: " << endl; + // for (const auto &pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl; } + // } + // else + // cerr << "Došlo k chybě: " << licenceGenerator.error.message; + // } + // else + // { + // cerr << "Došlo k chybě: " << licenceGenerator.error.message; + // } + + // verze #2 : iterace pro kazdý bod zvlášť + if (licenceGenerator.initread(initStructure)) { - std::cout << "Počet licenčních bodů pro " << info.protocolId << ": " << info.dataPointsCount << std::endl; + int protocolId = 888; + + LicenceItem21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31) + + if (licenceGenerator.getLicenceItemInfo(protocolId, &info)) + { + std::cout << "Počet licenčních bodů pro " << info.protocolId << ": " << info.dataPointsCount << std::endl; + } + else + cerr << "Došlo k chybě: " << licenceGenerator.error.message; } else + { cerr << "Došlo k chybě: " << licenceGenerator.error.message; + } } - else + + catch (...) { - cerr << "Došlo k chybě: " << licenceGenerator.error.message; + cerr << "Obecná chyba\n"; } system("pause"); diff --git a/src/LicenceELC11.cpp b/src/LicenceELC11.cpp index eee457d..fbca264 100644 --- a/src/LicenceELC11.cpp +++ b/src/LicenceELC11.cpp @@ -58,8 +58,8 @@ LicenceELC11::LicenceELC11() } LicenceELC11::LicenceELC11(LicenceIdentification &licIdentification) +: lIdentification(licIdentification) { - lIdentification = licIdentification; } LicenceELC11::LicenceELC11(string cisArg, string csdArg, string binaryType, string dataFileName) diff --git a/src/LicenceGenerator.cpp b/src/LicenceGenerator.cpp index 8cd5070..9275ddb 100644 --- a/src/LicenceGenerator.cpp +++ b/src/LicenceGenerator.cpp @@ -252,12 +252,11 @@ bool LicenceGenerator::getLicenceItemInfo(int protocolId, void *returnItemStruct case 11: { // old eoseov LicenceItem11 *resultPtr = static_cast(returnItemStructure); - resultPtr->protocolId = protocolId; // protocolId; + resultPtr->protocolId = protocolId; if (this->licenceInfo.licences.count(protocolId)) resultPtr->dataPointsCount = this->licenceInfo.licences.at(protocolId); else resultPtr->dataPointsCount = 0; - // licence21->getLicenceItemInfo(protocolId, returnItemStructure); stará verze, nová má k dispozici polozky z readLicence break; } case 21: @@ -269,7 +268,6 @@ bool LicenceGenerator::getLicenceItemInfo(int protocolId, void *returnItemStruct resultPtr->dataPointsCount = this->licenceInfo.licences.at(protocolId); else resultPtr->dataPointsCount = 0; - // licence21->getLicenceItemInfo(protocolId, returnItemStructure); stará verze, nová má k dispozici polozky z readLicence break; } case 31: diff --git a/src/licenceELC21.cpp b/src/licenceELC21.cpp index 053deb9..aec8e90 100644 --- a/src/licenceELC21.cpp +++ b/src/licenceELC21.cpp @@ -12,19 +12,22 @@ LicenceELC21::LicenceELC21() } LicenceELC21::LicenceELC21(LicenceIdentification &licIdentification, LicData &licData) +: lIdentification(licIdentification), lData(licData) { - lIdentification = licIdentification; - lData = licData; + // lIdentification = licIdentification; + // lData = licData; } LicenceELC21::LicenceELC21(LicenceIdentification &licIdentification) +: lIdentification(licIdentification) { - lIdentification = licIdentification; + // lIdentification = licIdentification; } LicenceELC21::LicenceELC21(LicData &licData) +: lData(licData) { - lData = licData; + // lData = licData; processInputConfiguration(); } @@ -41,12 +44,10 @@ bool LicenceELC21::createLicence() this->licBody.licenceIdentHeader.licItemCount = this->licBody.privateContent.dataItems.size(); this->licBody.licenceIdentHeader.publicHeaderLength = this->licBody.publicHeader.length(); - vector publicContent; - publicContent.reserve(1000); - vector privateContent; - privateContent.reserve(1000); - vector privateContentEncrypted; - privateContentEncrypted.reserve(1000); + vector publicContent(1000); + vector privateContent(1000); + vector privateContentEncrypted(1000); + publicContent.push_back(this->licBody.licId.licIdent[0]); publicContent.push_back(this->licBody.licId.licIdent[1]); @@ -260,7 +261,7 @@ bool LicenceELC21::readLicence(LicenceInfoGeneral * licences) licDataItem item; item.protoId = bytesToWord(privateContentDecrypted[index], privateContentDecrypted[index + 1]); item.licCount = bytesToWord(privateContentDecrypted[index + 2], privateContentDecrypted[index + 3]); - index = index + sizeof(licDataItem); + index += sizeof(licDataItem); this->licBody.privateContent.dataItems.push_back(item); this->licenceInfo.licences.insert(pair(item.protoId, item.licCount)); licences->licences.insert(pair(item.protoId, item.licCount));