oddělení generatoru od readeru
This commit is contained in:
78
include/common/utils.h
Normal file
78
include/common/utils.h
Normal file
@@ -0,0 +1,78 @@
|
||||
//#define LINUX 1
|
||||
#define WINDOWS 1
|
||||
|
||||
#ifndef UTILS_H_
|
||||
#define UTILS_H_
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
#include <format>
|
||||
#include <libgen.h> // dirname
|
||||
#include <climits>
|
||||
|
||||
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[]);
|
||||
unordered_map<string, const char*> mapArguments(int argc, char *argv[]);
|
||||
char* getCharArray(string source);
|
||||
void getCharsFromString1(string source, char *charArray);
|
||||
void getCharsFromString(string& source, char *charArray, size_t length);
|
||||
string getCompletePath(string fileName);
|
||||
char* getFileContent(string fileName);
|
||||
void appendStringToVector(const std::string& str, std::vector<unsigned char>& charVector);
|
||||
uint16_t calculateCRC16(std::vector<unsigned char>& charVector);
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user