123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- #ifndef SP_CFG_H
- #define SP_CFG_H
- #pragma once
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include "list.h"
- #include "spinlock.h"
- #include "shm_array.h"
- #include "y2k_time.h"
- #include "sp_def.h"
- #define SP_CFG_MAX_SYSEVT_BUF 260
- #define SP_CFG_MAX_REBOOT_INFO 10
- typedef struct sp_cfg_start_args_t {
- char* start_entities; /*split with ';' for supported multi entities*/
- char test_mode; /*1: run as test mode, trigger test deamon entity to invoke onTest*/
- char debug_mode; /*trace memory alloca and cpu etc resource */
- char guardian_mode;
- char sign_verifity;
- char ipc_type; /*0: pipe; 1: tcp*/
- } sp_cfg_start_args_t;
- typedef struct sp_cfg_path_t {
- char *name;
- char *path;
- }sp_cfg_path_t;
- typedef struct sp_cfg_root_ini_t {
- char *terminal_no;
- char *machine_type;
- char *machine_model;
- sp_version_t machine_version;
- float enroll_gps_x;
- float enroll_gps_y;
- char *site;
- int screen;
- char *enroll_address;
- array_header_t *arr_path;
- char *ref_sysroot_path;
- char *ref_addata_path;
- char *ref_syslog_path;
- char *ref_intlog_path;
- char *ref_uploadvideo_path;
- char *ref_uploadphoto_path;
- char *ref_localvideo_path;
- char *ref_downloads_path;
- char *ref_upgraded_path;
- char *ref_tmp_path;
- char *ref_centersetting_path;
- }sp_cfg_root_ini_t;
- typedef struct sp_cfg_pack_info_t {
- char *name;
- y2k_time_t install_time;
- int state;
- }sp_cfg_pack_info_t;
- typedef struct sp_cfg_version_info_t {
- sp_version_t version;
- sp_version_t previous_version;
- y2k_time_t switch_time;
- //array_header_t *arr_pack; // history versino has no light pack install info
- char *install_pack;
- int install_state;
- }sp_cfg_version_info_t;
- typedef struct sp_cfg_install_ini_t {
- sp_version_t install_version;
- y2k_time_t install_time;
- y2k_time_t current_startup_time;
- sp_version_t latter_install_version;
- char *latter_install_pack;
- array_header_t *arr_light_pack;
- char *light_packs;
- array_header_t *arr_version; // array of sp_cfg_version_info_t
- int total_run_count;
- int today_run_count;
- }sp_cfg_install_ini_t;
- typedef struct sp_cfg_shell_entity_t sp_cfg_shell_entity_t;
- typedef struct sp_cfg_shell_module_t sp_cfg_shell_module_t;
- typedef struct sp_cfg_shell_sysevent_t sp_cfg_shell_sysevent_t;
- typedef struct sp_cfg_shell_ini_t sp_cfg_shell_ini_t;
- typedef struct sp_cfg_t sp_cfg_t;
- typedef struct sp_cfg_run_info_t sp_cfg_run_info_t;
- struct sp_cfg_shell_entity_t {
- int idx;
- char *name;
- int argc;
- char **argv;
- char *cmdline;
- int privilege;
- int debug_level;
- int devel_id;
-
- sp_cfg_shell_module_t *mod;
- char *issuer; // authenticode signer
- };
- struct sp_cfg_shell_module_t {
- int idx;
- char *name;
- char *author;
- char *company;
- int group;
- sp_version_t version;
- int mem_trace;
- };
- struct sp_cfg_shell_sysevent_t {
- char *name;
- array_header_t *arr_owner_entity;
- char init_value[SP_CFG_MAX_SYSEVT_BUF];
- int idx;
- };
- struct sp_cfg_shell_ini_t {
- sp_version_t software_version;
- array_header_t *arr_entity;
- array_header_t *arr_module;
- array_header_t *arr_sysevent;
- array_header_t *arr_startlist;
- int shell_debug_level;
- int shell_state;
- int nConsolePort; // console service port
- char *spbase_sign_cert_hash;
- };
- struct sp_cfg_run_info_t {
- y2k_time_t startup_time;
- };
- struct sp_cfg_t {
- char *root_ini_path;
- char *shell_ini_path;
- char *install_ini_path;
- char *shellvar_ini_path;
- sp_cfg_root_ini_t *root_ini;
- sp_cfg_shell_ini_t *shell_ini;
- sp_cfg_install_ini_t *install_ini;
- sp_cfg_run_info_t *run_info;
- sp_cfg_start_args_t* args;
- spinlock_t lock;
- };
- typedef struct sp_dir_t sp_dir_t;
- int sp_cfg_create(sp_dir_t *dir, const sp_cfg_start_args_t* args, sp_cfg_t **p_cfg);
- void sp_cfg_destroy(sp_cfg_t *cfg);
- void sp_cfg_lock(sp_cfg_t *cfg);
- void sp_cfg_unlock(sp_cfg_t *cfg);
- SPBASE_API sp_cfg_shell_entity_t *sp_cfg_get_entity_by_name(sp_cfg_t *cfg, const char *name);
- SPBASE_API sp_cfg_shell_entity_t *sp_cfg_get_entity_by_idx(sp_cfg_t *cfg, int idx);
- sp_cfg_shell_entity_t *sp_cfg_get_entity_shell(sp_cfg_t *cfg);
- sp_cfg_shell_module_t *sp_cfg_get_module_by_name(sp_cfg_t *cfg, const char *name);
- SPBASE_API sp_cfg_shell_module_t *sp_cfg_get_module_by_idx(sp_cfg_t *cfg, int idx);
- sp_cfg_shell_module_t *sp_cfg_get_module_shell(sp_cfg_t *cfg);
- sp_cfg_shell_sysevent_t*sp_cfg_get_sysevent(sp_cfg_t *cfg, const char *name);
- SPBASE_API sp_cfg_version_info_t* sp_cfg_find_previous_version_info(sp_cfg_t *cfg, const sp_version_t *version);
- SPBASE_API sp_cfg_version_info_t* sp_cfg_find_version_info(sp_cfg_t *cfg, const sp_version_t *version);
- char *sp_cfg_get_path(sp_cfg_t *cfg, const char *path_prefix);
- int sp_cfg_refresh_debug_level(sp_cfg_t *cfg, sp_cfg_shell_entity_t *cfg_ent);
- int sp_cfg_util_read_root_ini_version(sp_cfg_root_ini_t *ini, int major, int minor, int revision, int build);
- int sp_cfg_util_free_root_ini(sp_cfg_root_ini_t *ini);
- int sp_cfg_get_devel_id(sp_cfg_t *cfg, int idx);
- int sp_cfg_set_run_succeed(sp_cfg_t *cfg);
- int sp_cfg_is_pack_installed(sp_cfg_t *cfg, const char*pack);
- int read_ini_install_state(const char *file, const char *section, const char *key);
- #ifdef __cplusplus
- } // extern "C" {
- #endif
- #endif // SP_CFG_H
|