sd generator

This commit is contained in:
2023-08-17 09:04:39 +02:00
parent 4dc964360e
commit d531f56828
166 changed files with 44705 additions and 1 deletions

124
src/CreateLicence.cpp Normal file
View File

@@ -0,0 +1,124 @@
#include <stdio.h>
#include <map>
#include <cstring>
#include "plcLicence.h"
#include "utils.h"
#include <csignal>
#define FILEBUFFER 300
#define TWO_HOURSE_SECONDS 7200
void signalHandler(int signum) {
if (signum == SIGSEGV) {
std::cerr << "Caught segmentation fault (SIGSEGV)" << std::endl;
// You can perform some recovery actions here if needed
}
}
/// @brief hlavní funkce
/// @param argc
/// @param argv parametry pro generování licence
/// 1-cid, 2-csd, 3-stanice 4-rozvadec 5-typ licence
/// @return
int main(int argc, char *argv[])
{
std::signal(SIGSEGV, signalHandler);
// a segmentation fault
//int* ptr = nullptr;
//*ptr = 42; // This will trigger a segmentation fault
//map<string, const char *> arguments = mapArguments(argc, argv);
map<string, string> argumentsString = getArguments(argc, argv);
// std::cout << "Number of arguments: " << argc << std::endl;
// if (argc > 1)
// {
// for (int i = 1; i < argc; ++i)
// {
// arguments.insert(make_pair(to_string(i), argv[i]));
// }
// }
// else
// cerr << "Invalid arguments count";
// for (auto it = argumentsString.begin(); it != argumentsString.end(); ++it)
// {
// std::cout << "Key: " << it->first << ", Value: " << it->second << std::endl;
// }
// generatePause();
// return 1;
// for (int i = 0; i < argc; ++i)
// {
// std::cout << "Argument " << i << ": " << argv[i] << std::endl;
// cout << "size: " << strlen(argv[i]);
// }
// generatePause();
// return 1;
// if (argc >= 5)
// {
// cid = argv[1];
// csd = argv[2];
// stationName = argv[3];
// switchName = argv[4];
// licenceType = argv[5];
// }
// else
// {
// cout << "Par count error" << endl;
// }
// if (argc <= 1)
// {
// cid = "9f544930303030300000000b47015423";
// csd = "400e00325b5900003a0d7f800a40008d";
// stationName = "ceskatrebova";
// switchName = "RO1";
// licenceType = "2";
// binaryType = "2";
// }
// else
// {
// cid = argv[1];
// csd = argv[2];
// }
// cid = "9f544930303030300000000b47015423";
// csd = "400e00325b5900003a0d7f800a40008d";
// stationName = "ceskatrebova";
// switchName = "RO1";
// licenceType = "2";
// binaryType = "2";
// cout << "binaryType: " << binaryType;
// cout << "CID:" << argumentsString["-cid"];
const int cidLength = argumentsString["-cid"].length();
char cidArg[cidLength] = {};
getCharsFromString(argumentsString["-cid"], cidArg);
const int csdLength = argumentsString["-csd"].length();
char csdArg[csdLength] = {};
getCharsFromString(argumentsString["-csd"], csdArg);
//char cidTest = getCharArray(argumentsString["-cid"]);
//PlcLicence plcWriteLicence = PlcLicence(argumentsString);
//PlcLicence plcWriteLicence = PlcLicence(cidArg, csdArg, stationName, switchName, licenceType, binaryType, nullptr);
PlcLicence plcWriteLicence = PlcLicence(cidArg, csdArg, argumentsString["-outputType"], argumentsString["-configFileName"]);
// PlcLicence plcWriteLicence = PlcLicence(arguments["-cid"], arguments["-csd"], stationName, switchName, licenceType, binaryType, nullptr);
if (plcWriteLicence.CreateLicence() == false)
{
cerr << "Licence creation failed";
}
return EXIT_SUCCESS;
}