84 lines
2.5 KiB
C++
84 lines
2.5 KiB
C++
#include <iostream>
|
|
#include <stdlib.h>
|
|
#include <chrono>
|
|
#include <bitset>
|
|
#include <map>
|
|
|
|
|
|
#define PEM_BUFSIZE_TEXT 1024
|
|
#define BitVal(data, y) ((data >> y) & 1) /** Return Data.Y value **/
|
|
#define SetBit(data, y) data |= (1 << y) /** Set Data.Y to 1 **/
|
|
#define ClearBit(data, y) data &= ~(1 << y) /** Clear Data.Y to 0 **/
|
|
#define TogleBit(data, y) (data ^= BitVal(y)) /** Togle Data.Y value **/
|
|
#define Togle(data) (data = ~data) /** Togle Data value **/
|
|
|
|
#define PEM_BUFSIZE_TEXT 1024
|
|
|
|
#ifndef BYTE
|
|
typedef uint8_t BYTE;
|
|
#endif
|
|
|
|
#ifndef WORD
|
|
typedef uint16_t WORD;
|
|
#endif
|
|
|
|
#ifndef DWORD
|
|
typedef uint32_t DWORD;
|
|
#endif
|
|
|
|
#ifndef DATE
|
|
typedef uint32_t DATE;
|
|
#endif
|
|
|
|
using namespace std;
|
|
|
|
struct DateAndTime {
|
|
uint16_t date; // DATE data type in CODESYS
|
|
uint16_t time; // TIME data type in CODESYS
|
|
};
|
|
|
|
void TestFunction(int);
|
|
void generatePause();
|
|
string getXmlContentFromString(string source, string xmlTag);
|
|
float byteArrayToFloat(const BYTE* byteArray);
|
|
std::string right(const std::string& sourceString, size_t numChars);
|
|
std::tm dt_to_date(const std::chrono::system_clock::time_point& tp);
|
|
void getCharsFromString(string source, char *charArray);
|
|
std::string parseCID(const std::string& cidHex);
|
|
void bitsToCharArray(const std::string& bitsStr, char* charArray);
|
|
uint16_t calculateCRC16(const uint8_t* data, size_t length);
|
|
uint16_t calculateCrc(const uint8_t* data, size_t length);
|
|
WORD getCurrentDateAsCODESYSDate();
|
|
DWORD getCurrentDateAsCODESYSDateDword();
|
|
DateAndTime getCurrentDateTimeAsCODESYSDateTime();
|
|
uint16_t convertToCODESYSDate(int day, int month, int year);
|
|
uint16_t convertToCODESYSTime(int hour, int minute);
|
|
DATE getLicDate();
|
|
int encrypt(unsigned char *plaintext, int plaintext_len, unsigned char *key, unsigned char *iv, unsigned char *ciphertext);
|
|
bool CompareFiles(const char *fileName, const char *fileName1);
|
|
unsigned short crc16(const unsigned char* data_p, unsigned char length);
|
|
int decrypt(unsigned char *ciphertext, int ciphertext_len, unsigned char *key, unsigned char *iv, unsigned char *plaintext);
|
|
string convertToString(char* a, int size);
|
|
std::string base64_encode_ai(const std::string &input);
|
|
std::string base64_decode_ai(const std::string &encoded);
|
|
map<string, string> getArguments(int argc, char *argv[]);
|
|
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, int length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|