| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #ifndef __COMM_H
- #define __COMM_H
- #include <string>
- #include <sstream>
- #include <cstdio>
- #include <vector>
- #include <cstring>
- #include <cmath>
- #include<iostream>
- #include <fstream>
- #include <algorithm>
- using namespace std;
- #define EVENT_MOD_INITIALIZER_MK_LOADED 0x50900001 // 主密钥初始化成功
- #define EVENT_MOD_INITIALIZER_MK_FAILED 0x50980002 // 主密钥初始化失败
- #define PUKFILENAME_RSA "RVCPubKey.ini"
- #define PUKFILENAME_SM2 "RVCSM2PubKey.ini"
- #define PFKEYFILENAME_DES "CMBRVCKeys.dat"
- #define PFKEYFILENAME_SM4 "CMBRVCSm4Keys.dat"
- typedef unsigned char BYTE;
- void GetNewForm(const char* form, char* newForm);
- string GetOutPutStr(const char* form, ...);
- int no_begin_with(const char strA[], const char strB[]);
- int str2int(const string str, int& ret);
- vector<string> split_str(string strA, string strB);
- int ip2byte(const string str, BYTE ip[]);
- char* Hex2Str(const char* src, int& dstLen);
- char* Str2Hex(const char* str, int strLen);
- #ifdef __linux__
- #define RUNTIME_PATH "/opt/run/runinfo/runcfg"
- #include <sys/types.h>
- #include <ifaddrs.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <unistd.h>
- int getIPFromLinux(char* ip);
- bool get_cpu_id_by_asm(std::string& cpu_id);
- bool get_cpu_id_by_system(std::string& cpu_id, const string save_path = RUNTIME_PATH);
- bool get_board_serial_by_system(std::string& board_serial, const string save_path = RUNTIME_PATH);
- bool get_disk_serial_by_system(std::vector<string>& serial_no, int &errCode,const string save_path = RUNTIME_PATH);
- bool file_is_exist(string filePath);
- bool dir_is_exist(string dirPath);
- int file_create(string filePath);
- int dir_create(string dirPath);
- int remove_file(string filePath);
- int remove_dir(string dirPath);
- #include<sys/time.h>
- #include <time.h>
- typedef struct {
- int year;
- int month;
- int day;
- int hour;
- int minute;
- int second;
- } TIME;
- bool set_system_time(TIME* _time);
- extern "C" bool set_system_time_by_sec(int sec);
- TIME* get_system_time();
- #endif //__linux__
- #endif // !__COMM_H
|