upravy čištění

This commit is contained in:
2023-12-18 08:01:34 +01:00
parent 3954e0f6a5
commit f260e92596
4 changed files with 68 additions and 60 deletions

View File

@@ -9,59 +9,68 @@
/// @return /// @return
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// unordered_map<string, string> arguments = getArguments(argc, argv); try
// 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))
{ {
int protocolId = 1; /* code */
// unordered_map<string, string> 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) LicenceGenerator licenceGenerator = LicenceGenerator();
if (licenceGenerator.getLicenceItemInfo(protocolId, &info)) 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 else
{
cerr << "Došlo k chybě: " << licenceGenerator.error.message; cerr << "Došlo k chybě: " << licenceGenerator.error.message;
}
} }
else
catch (...)
{ {
cerr << "Došlo k chybě: " << licenceGenerator.error.message; cerr << "Obecná chyba\n";
} }
system("pause"); system("pause");

View File

@@ -58,8 +58,8 @@ LicenceELC11::LicenceELC11()
} }
LicenceELC11::LicenceELC11(LicenceIdentification &licIdentification) LicenceELC11::LicenceELC11(LicenceIdentification &licIdentification)
: lIdentification(licIdentification)
{ {
lIdentification = licIdentification;
} }
LicenceELC11::LicenceELC11(string cisArg, string csdArg, string binaryType, string dataFileName) LicenceELC11::LicenceELC11(string cisArg, string csdArg, string binaryType, string dataFileName)

View File

@@ -252,12 +252,11 @@ bool LicenceGenerator::getLicenceItemInfo(int protocolId, void *returnItemStruct
case 11: case 11:
{ // old eoseov { // old eoseov
LicenceItem11 *resultPtr = static_cast<LicenceItem11 *>(returnItemStructure); LicenceItem11 *resultPtr = static_cast<LicenceItem11 *>(returnItemStructure);
resultPtr->protocolId = protocolId; // protocolId; resultPtr->protocolId = protocolId;
if (this->licenceInfo.licences.count(protocolId)) if (this->licenceInfo.licences.count(protocolId))
resultPtr->dataPointsCount = this->licenceInfo.licences.at(protocolId); resultPtr->dataPointsCount = this->licenceInfo.licences.at(protocolId);
else else
resultPtr->dataPointsCount = 0; resultPtr->dataPointsCount = 0;
// licence21->getLicenceItemInfo(protocolId, returnItemStructure); stará verze, nová má k dispozici polozky z readLicence
break; break;
} }
case 21: case 21:
@@ -269,7 +268,6 @@ bool LicenceGenerator::getLicenceItemInfo(int protocolId, void *returnItemStruct
resultPtr->dataPointsCount = this->licenceInfo.licences.at(protocolId); resultPtr->dataPointsCount = this->licenceInfo.licences.at(protocolId);
else else
resultPtr->dataPointsCount = 0; resultPtr->dataPointsCount = 0;
// licence21->getLicenceItemInfo(protocolId, returnItemStructure); stará verze, nová má k dispozici polozky z readLicence
break; break;
} }
case 31: case 31:

View File

@@ -12,19 +12,22 @@ LicenceELC21::LicenceELC21()
} }
LicenceELC21::LicenceELC21(LicenceIdentification &licIdentification, LicData &licData) LicenceELC21::LicenceELC21(LicenceIdentification &licIdentification, LicData &licData)
: lIdentification(licIdentification), lData(licData)
{ {
lIdentification = licIdentification; // lIdentification = licIdentification;
lData = licData; // lData = licData;
} }
LicenceELC21::LicenceELC21(LicenceIdentification &licIdentification) LicenceELC21::LicenceELC21(LicenceIdentification &licIdentification)
: lIdentification(licIdentification)
{ {
lIdentification = licIdentification; // lIdentification = licIdentification;
} }
LicenceELC21::LicenceELC21(LicData &licData) LicenceELC21::LicenceELC21(LicData &licData)
: lData(licData)
{ {
lData = licData; // lData = licData;
processInputConfiguration(); processInputConfiguration();
} }
@@ -41,12 +44,10 @@ bool LicenceELC21::createLicence()
this->licBody.licenceIdentHeader.licItemCount = this->licBody.privateContent.dataItems.size(); this->licBody.licenceIdentHeader.licItemCount = this->licBody.privateContent.dataItems.size();
this->licBody.licenceIdentHeader.publicHeaderLength = this->licBody.publicHeader.length(); this->licBody.licenceIdentHeader.publicHeaderLength = this->licBody.publicHeader.length();
vector<unsigned char> publicContent; vector<unsigned char> publicContent(1000);
publicContent.reserve(1000); vector<unsigned char> privateContent(1000);
vector<unsigned char> privateContent; vector<unsigned char> privateContentEncrypted(1000);
privateContent.reserve(1000);
vector<unsigned char> privateContentEncrypted;
privateContentEncrypted.reserve(1000);
publicContent.push_back(this->licBody.licId.licIdent[0]); publicContent.push_back(this->licBody.licId.licIdent[0]);
publicContent.push_back(this->licBody.licId.licIdent[1]); publicContent.push_back(this->licBody.licId.licIdent[1]);
@@ -260,7 +261,7 @@ bool LicenceELC21::readLicence(LicenceInfoGeneral * licences)
licDataItem item; licDataItem item;
item.protoId = bytesToWord(privateContentDecrypted[index], privateContentDecrypted[index + 1]); item.protoId = bytesToWord(privateContentDecrypted[index], privateContentDecrypted[index + 1]);
item.licCount = bytesToWord(privateContentDecrypted[index + 2], privateContentDecrypted[index + 3]); item.licCount = bytesToWord(privateContentDecrypted[index + 2], privateContentDecrypted[index + 3]);
index = index + sizeof(licDataItem); index += sizeof(licDataItem);
this->licBody.privateContent.dataItems.push_back(item); this->licBody.privateContent.dataItems.push_back(item);
this->licenceInfo.licences.insert(pair<int, int>(item.protoId, item.licCount)); this->licenceInfo.licences.insert(pair<int, int>(item.protoId, item.licCount));
licences->licences.insert(pair<int, int>(item.protoId, item.licCount)); licences->licences.insert(pair<int, int>(item.protoId, item.licCount));