licence final

This commit is contained in:
2023-08-17 14:30:11 +02:00
parent d531f56828
commit c07db22aba
4 changed files with 56 additions and 26 deletions

View File

@@ -9,11 +9,13 @@
#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
}
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
@@ -24,14 +26,13 @@ void signalHandler(int signum) {
int main(int argc, char *argv[])
{
std::signal(SIGSEGV, signalHandler);
std::signal(SIGSEGV, signalHandler);
// a segmentation fault
//int* ptr = nullptr;
//*ptr = 42; // This will trigger a segmentation fault
// a segmentation fault
// int* ptr = nullptr;
//*ptr = 42; // This will trigger a segmentation fault
//map<string, const char *> arguments = mapArguments(argc, argv);
// map<string, const char *> arguments = mapArguments(argc, argv);
map<string, string> argumentsString = getArguments(argc, argv);
// std::cout << "Number of arguments: " << argc << std::endl;
@@ -48,6 +49,7 @@ std::signal(SIGSEGV, signalHandler);
// for (auto it = argumentsString.begin(); it != argumentsString.end(); ++it)
// {
// std::cout << "Key: " << it->first << ", Value: " << it->second << std::endl;
// std::cout << it->second.length() << std::endl;
// }
// generatePause();
@@ -100,21 +102,35 @@ std::signal(SIGSEGV, signalHandler);
// cout << "binaryType: " << binaryType;
// cout << "CID:" << argumentsString["-cid"];
const int cidLength = argumentsString["-cid"].length();
char cidArg[cidLength] = {};
getCharsFromString(argumentsString["-cid"], cidArg);
// cout << "final-cids: " << argumentsString["-cid"].length() << endl;
// cout << "final-cds: " << argumentsString["-csd"].length() << endl;
// cout << "-----------------------------------\n";
const int csdLength = argumentsString["-csd"].length();
char csdArg[csdLength] = {};
getCharsFromString(argumentsString["-csd"], csdArg);
char csdArg[32] = {};
getCharsFromString(argumentsString["-csd"], csdArg, csdLength);
//cout << "csd delka pred: " << strlen(csdArg) << "\n";
//cout << "csd delka po: " << strlen(csdArg) << "\n";
//cout << "csd:" << csdArg << "\n";
const int cidLength = argumentsString["-cid"].length();
char cidArg[32] = {};
getCharsFromString(argumentsString["-cid"], cidArg, cidLength);
//cout << "cid delka pred: " << strlen(cidArg) << "\n";
//for (int i=0;i<32;i++) cidArg[i]=argumentsString["-cid"][i];
//cout << "cid delka po: " << strlen(cidArg) << "\n";
//cout << "cid delka sizeof po: " << sizeof(cidArg) << "\n";
//cout << "cid:" << cidArg;
//char cidTest = getCharArray(argumentsString["-cid"]);
// char cidTest = getCharArray(argumentsString["-cid"]);
// PlcLicence plcWriteLicence = PlcLicence(argumentsString);
// PlcLicence plcWriteLicence = PlcLicence(cidArg, csdArg, stationName, switchName, licenceType, binaryType, nullptr);
// PlcLicence plcWriteLicence = PlcLicence(arguments["-cid"], arguments["-csd"], stationName, switchName, licenceType, binaryType, nullptr);
//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";