YyAuthenticationManageFile.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef __YY_AUTHENTICATION_MANAGE_FILE_H__
  2. #define __YY_AUTHENTICATION_MANAGE_FILE_H__
  3. #ifdef __cplusplus
  4. extern "C"
  5. {
  6. #endif
  7. #ifdef _WIN32
  8. #ifdef YY_DLL_IMPLEMENT
  9. #define YY_AUTHERNTICATION_EXTERN __declspec(dllexport)
  10. #else
  11. #define YY_AUTHERNTICATION_EXTERN __declspec(dllimport)
  12. #endif
  13. #else
  14. #define YY_AUTHERNTICATION_EXTERN /* nothing */
  15. #endif
  16. #define LOCAL_CONFIG_BUF 128
  17. typedef struct tm_local_config
  18. {
  19. char code[LOCAL_CONFIG_BUF];
  20. char duration[LOCAL_CONFIG_BUF];
  21. char max_bandwidth[LOCAL_CONFIG_BUF];
  22. char expire_date[LOCAL_CONFIG_BUF];
  23. char activate_date[LOCAL_CONFIG_BUF];
  24. char server_date[LOCAL_CONFIG_BUF];
  25. char low_bound_bandwidth[LOCAL_CONFIG_BUF];
  26. char server_key[LOCAL_CONFIG_BUF];
  27. char status[LOCAL_CONFIG_BUF];
  28. int productId;
  29. int category;
  30. int bandwidth;
  31. int active_state; /* 0:no_active;1:active;2:expire */
  32. int client_number;
  33. }stLocalConfig;
  34. typedef struct offline_cfg_s{
  35. char sn[32];
  36. int productId;
  37. int duration;
  38. time_t activateDate;
  39. time_t endDate;
  40. int clientNum; /*typhoon client number*/
  41. int bandwidth;
  42. int category;
  43. int traffic; /*GB*/
  44. int originTraffic; /*GB*/
  45. int appClientNum; /*application client number*/
  46. char expire_date[LOCAL_CONFIG_BUF];
  47. char activate_date[LOCAL_CONFIG_BUF];
  48. }offline_cfg_t;
  49. /*
  50. tm_read_config read configuration from local config file
  51. @file_path : local configuration file absolute path
  52. @pOutConfig: configuration information
  53. return : 0 OK
  54. non-zeor failed
  55. */
  56. YY_AUTHERNTICATION_EXTERN int tm_read_file(char *pbuff, int buff_len, int *out_len);
  57. YY_AUTHERNTICATION_EXTERN int tm_parse_file(stLocalConfig *pOutConfig, char *pfile);
  58. YY_AUTHERNTICATION_EXTERN int tm_read_config(stLocalConfig *pOutConfig);
  59. YY_AUTHERNTICATION_EXTERN int tm_set_caPath(char *caPath);
  60. YY_AUTHERNTICATION_EXTERN int tm_delete_license_file();
  61. int tm_build_json(char *pOut, stLocalConfig *pConfig);
  62. int tm_write_json_to_file(char *pJson);
  63. /*
  64. tm_write_config write configuration into local config file
  65. @pOutConfig: configuration information
  66. @file_path : local configuration file absolute path
  67. return : 0 OK
  68. non-zeor failed
  69. */
  70. YY_AUTHERNTICATION_EXTERN int tm_write_config(stLocalConfig *pConfig);
  71. YY_AUTHERNTICATION_EXTERN int write_offline_config(offline_cfg_t *pConfig);
  72. #ifdef __cplusplus
  73. }
  74. #endif
  75. #endif