comm.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef __COMM_H
  2. #define __COMM_H
  3. #include <string>
  4. #include <sstream>
  5. #include <cstdio>
  6. #include <vector>
  7. #include <cstring>
  8. #include <cmath>
  9. #include<iostream>
  10. #include <fstream>
  11. #include <algorithm>
  12. using namespace std;
  13. #define EVENT_ACCESSAUTH_SUCCEED 0x50200001 // 准入成功
  14. #define EVENT_ACCESSAUTH_FAILED 0x50280002 // 准入失败
  15. #define EVENT_ACCESSAUTH_TIMEOUT 0x50280003 // 准入超时
  16. #define EVENT_MOD_INITIALIZER_MK_LOADED 0x50900001 // 主密钥初始化成功
  17. #define EVENT_MOD_INITIALIZER_MK_FAILED 0x50980002 // 主密钥初始化失败
  18. #define PUKFILENAME_RSA "RVCPubKey.ini"
  19. #define PUKFILENAME_SM2 "RVCSM2PubKey.ini"
  20. #define PFKEYFILENAME_DES "CMBRVCKeys.dat"
  21. #define PFKEYFILENAME_SM4 "CMBRVCSm4Keys.dat"
  22. typedef unsigned char BYTE;
  23. void GetNewForm(const char* form, char* newForm);
  24. string GetOutPutStr(const char* form, ...);
  25. int str2int(const string str, int& ret);
  26. int str2int(const string str);
  27. #ifdef __linux__
  28. #define RUNTIME_PATH "/opt/run/runinfo/runcfg"
  29. #include <sys/types.h>
  30. #include <ifaddrs.h>
  31. #include <netinet/in.h>
  32. #include <arpa/inet.h>
  33. #include <unistd.h>
  34. bool get_cpu_id_by_asm(std::string & cpu_id);
  35. bool get_cpu_id_by_system(std::string& cpu_id, const string save_path = RUNTIME_PATH);
  36. bool get_board_serial_by_system(std::string& board_serial, const string save_path = RUNTIME_PATH);
  37. bool get_disk_serial_by_system(std::vector<string>& serial_no, int& errCode, const string save_path = RUNTIME_PATH);
  38. bool dir_is_exist(string dirPath);
  39. int dir_create(string dirPath);
  40. #include<sys/time.h>
  41. #include <time.h>
  42. typedef struct {
  43. int year;
  44. int month;
  45. int day;
  46. int hour;
  47. int minute;
  48. int second;
  49. } TIME;
  50. extern "C" bool set_system_time_by_sec(int sec);
  51. #endif //__linux__
  52. #endif // !__COMM_H