75 lines
2.0 KiB
C++
75 lines
2.0 KiB
C++
#ifndef EZ_APPLICATION_LICENCE_DISABLE
|
|
|
|
#ifndef UTILS_H_
|
|
#define UTILS_H_
|
|
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
#include <chrono>
|
|
#include <libgen.h>
|
|
#include <unistd.h>
|
|
|
|
typedef uint8_t BYTE;
|
|
typedef uint16_t WORD;
|
|
typedef uint32_t DWORD;
|
|
typedef uint32_t DATE;
|
|
|
|
using namespace std;
|
|
|
|
struct DateAndTime {
|
|
uint16_t date; // DATE data type in CODESYS
|
|
uint16_t time; // TIME data type in CODESYS
|
|
};
|
|
|
|
void generatePause();
|
|
std::string right(const std::string& sourceString, size_t numChars);
|
|
void getCharsFromString(const string source, char *charArray);
|
|
uint16_t calculateCRC16(const uint8_t* data, size_t length);
|
|
WORD getCurrentDateAsCODESYSDate();
|
|
DWORD getCurrentDateAsCODESYSDateDword();
|
|
DateAndTime getCurrentDateTimeAsCODESYSDateTime();
|
|
DATE getLicDate();
|
|
string getDate();
|
|
int encrypt(const unsigned char *plaintext, int plaintext_len, unsigned char *key, unsigned char *iv, unsigned char *ciphertext);
|
|
unsigned short crc16(const unsigned char* data_p, unsigned char length);
|
|
int decrypt(const unsigned char *ciphertext, int ciphertext_len, unsigned char *key, unsigned char *iv, unsigned char *plaintext);
|
|
string convertToString(char* a, int size);
|
|
string base64_encode_ai(const std::string &input);
|
|
unordered_map<string, string> getArguments(int argc, char *argv[]);
|
|
void getCharsFromString(string& source, char *charArray, size_t length);
|
|
string getCompletePath(string fileName);
|
|
void appendStringToVector(const std::string& str, std::vector<unsigned char>& charVector);
|
|
uint16_t calculateCRC16(std::vector<unsigned char>& charVector);
|
|
uint16_t calculateCRC16(std::vector<char> &charVector);
|
|
uint16_t calculateCRC16(std::vector<unsigned char> &charVector, int removeCount);
|
|
uint32_t bytesToDword(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4);
|
|
uint32_t bytesToWord(uint8_t byte1, uint8_t byte2);
|
|
vector<unsigned char> joinVectors(const std::vector<unsigned char>& vector1, const std::vector<unsigned char>& vector2);
|
|
bool readFile(string fileName, vector<char> &output);
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|