1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #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_ACCESSAUTH_SUCCEED 0x50200001 // 准入成功
- #define EVENT_ACCESSAUTH_FAILED 0x50280002 // 准入失败
- #define EVENT_ACCESSAUTH_TIMEOUT 0x50280003 // 准入超时
- #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);
- int str2int(const string str);
- 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();
- string time2str(const TIME * tim);
- TIME* str2time(string str);
- #endif //__linux__
- #endif // !__COMM_H
|