sp_cfg.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. #ifndef SP_CFG_H
  2. #define SP_CFG_H
  3. #pragma once
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #include "list.h"
  8. #include "spinlock.h"
  9. #include "shm_array.h"
  10. #include "y2k_time.h"
  11. #include "sp_def.h"
  12. #define SP_CFG_MAX_SYSEVT_BUF 260
  13. #define SP_CFG_MAX_REBOOT_INFO 10
  14. typedef struct sp_cfg_start_args_t {
  15. char* start_entities; /*split with ';' for supported multi entities*/
  16. char test_mode; /*1: run as test mode, trigger test deamon entity to invoke onTest*/
  17. char debug_mode; /*trace memory alloca and cpu etc resource */
  18. char guardian_mode;
  19. char sign_verifity;
  20. char ipc_type; /*0: pipe; 1: tcp*/
  21. } sp_cfg_start_args_t;
  22. typedef struct sp_cfg_path_t {
  23. char *name;
  24. char *path;
  25. }sp_cfg_path_t;
  26. typedef struct sp_cfg_root_ini_t {
  27. char *terminal_no;
  28. char *machine_type;
  29. char *machine_model;
  30. sp_version_t machine_version;
  31. float enroll_gps_x;
  32. float enroll_gps_y;
  33. char *site;
  34. int screen;
  35. char *enroll_address;
  36. array_header_t *arr_path;
  37. char *ref_sysroot_path;
  38. char *ref_addata_path;
  39. char *ref_syslog_path;
  40. char *ref_intlog_path;
  41. char *ref_uploadvideo_path;
  42. char *ref_uploadphoto_path;
  43. char *ref_localvideo_path;
  44. char *ref_downloads_path;
  45. char *ref_upgraded_path;
  46. char *ref_tmp_path;
  47. char *ref_centersetting_path;
  48. }sp_cfg_root_ini_t;
  49. typedef struct sp_cfg_pack_info_t {
  50. char *name;
  51. y2k_time_t install_time;
  52. int state;
  53. }sp_cfg_pack_info_t;
  54. typedef struct sp_cfg_version_info_t {
  55. sp_version_t version;
  56. sp_version_t previous_version;
  57. y2k_time_t switch_time;
  58. //array_header_t *arr_pack; // history versino has no light pack install info
  59. char *install_pack;
  60. int install_state;
  61. }sp_cfg_version_info_t;
  62. typedef struct sp_cfg_install_ini_t {
  63. sp_version_t install_version;
  64. y2k_time_t install_time;
  65. y2k_time_t current_startup_time;
  66. sp_version_t latter_install_version;
  67. char *latter_install_pack;
  68. array_header_t *arr_light_pack;
  69. char *light_packs;
  70. array_header_t *arr_version; // array of sp_cfg_version_info_t
  71. int total_run_count;
  72. int today_run_count;
  73. }sp_cfg_install_ini_t;
  74. typedef struct sp_cfg_shell_entity_t sp_cfg_shell_entity_t;
  75. typedef struct sp_cfg_shell_module_t sp_cfg_shell_module_t;
  76. typedef struct sp_cfg_shell_sysevent_t sp_cfg_shell_sysevent_t;
  77. typedef struct sp_cfg_shell_ini_t sp_cfg_shell_ini_t;
  78. typedef struct sp_cfg_t sp_cfg_t;
  79. typedef struct sp_cfg_run_info_t sp_cfg_run_info_t;
  80. struct sp_cfg_shell_entity_t {
  81. int idx;
  82. char *name;
  83. int argc;
  84. char **argv;
  85. char *cmdline;
  86. int privilege;
  87. int debug_level;
  88. int devel_id;
  89. sp_cfg_shell_module_t *mod;
  90. char *issuer; // authenticode signer
  91. };
  92. struct sp_cfg_shell_module_t {
  93. int idx;
  94. char *name;
  95. char *author;
  96. char *company;
  97. int group;
  98. sp_version_t version;
  99. int mem_trace;
  100. };
  101. struct sp_cfg_shell_sysevent_t {
  102. char *name;
  103. array_header_t *arr_owner_entity;
  104. char init_value[SP_CFG_MAX_SYSEVT_BUF];
  105. int idx;
  106. };
  107. struct sp_cfg_shell_ini_t {
  108. sp_version_t software_version;
  109. array_header_t *arr_entity;
  110. array_header_t *arr_module;
  111. array_header_t *arr_sysevent;
  112. array_header_t *arr_startlist;
  113. int shell_debug_level;
  114. int shell_state;
  115. int nConsolePort; // console service port
  116. char *spbase_sign_cert_hash;
  117. };
  118. struct sp_cfg_run_info_t {
  119. y2k_time_t startup_time;
  120. };
  121. struct sp_cfg_t {
  122. char *root_ini_path;
  123. char *shell_ini_path;
  124. char *install_ini_path;
  125. char *shellvar_ini_path;
  126. sp_cfg_root_ini_t *root_ini;
  127. sp_cfg_shell_ini_t *shell_ini;
  128. sp_cfg_install_ini_t *install_ini;
  129. sp_cfg_run_info_t *run_info;
  130. sp_cfg_start_args_t* args;
  131. spinlock_t lock;
  132. };
  133. typedef struct sp_dir_t sp_dir_t;
  134. int sp_cfg_create(sp_dir_t *dir, const sp_cfg_start_args_t* args, sp_cfg_t **p_cfg);
  135. void sp_cfg_destroy(sp_cfg_t *cfg);
  136. void sp_cfg_lock(sp_cfg_t *cfg);
  137. void sp_cfg_unlock(sp_cfg_t *cfg);
  138. SPBASE_API sp_cfg_shell_entity_t *sp_cfg_get_entity_by_name(sp_cfg_t *cfg, const char *name);
  139. SPBASE_API sp_cfg_shell_entity_t *sp_cfg_get_entity_by_idx(sp_cfg_t *cfg, int idx);
  140. sp_cfg_shell_entity_t *sp_cfg_get_entity_shell(sp_cfg_t *cfg);
  141. sp_cfg_shell_module_t *sp_cfg_get_module_by_name(sp_cfg_t *cfg, const char *name);
  142. SPBASE_API sp_cfg_shell_module_t *sp_cfg_get_module_by_idx(sp_cfg_t *cfg, int idx);
  143. sp_cfg_shell_module_t *sp_cfg_get_module_shell(sp_cfg_t *cfg);
  144. sp_cfg_shell_sysevent_t*sp_cfg_get_sysevent(sp_cfg_t *cfg, const char *name);
  145. SPBASE_API sp_cfg_version_info_t* sp_cfg_find_previous_version_info(sp_cfg_t *cfg, const sp_version_t *version);
  146. SPBASE_API sp_cfg_version_info_t* sp_cfg_find_version_info(sp_cfg_t *cfg, const sp_version_t *version);
  147. char *sp_cfg_get_path(sp_cfg_t *cfg, const char *path_prefix);
  148. int sp_cfg_refresh_debug_level(sp_cfg_t *cfg, sp_cfg_shell_entity_t *cfg_ent);
  149. int sp_cfg_util_read_root_ini_version(sp_cfg_root_ini_t *ini, int major, int minor, int revision, int build);
  150. int sp_cfg_util_free_root_ini(sp_cfg_root_ini_t *ini);
  151. int sp_cfg_get_devel_id(sp_cfg_t *cfg, int idx);
  152. int sp_cfg_set_run_succeed(sp_cfg_t *cfg);
  153. int sp_cfg_is_pack_installed(sp_cfg_t *cfg, const char*pack);
  154. int read_ini_install_state(const char *file, const char *section, const char *key);
  155. #ifdef __cplusplus
  156. } // extern "C" {
  157. #endif
  158. #endif // SP_CFG_H