diff --git a/source/model/load.c b/source/model/load.c index cf48cf8..10f56e5 100644 --- a/source/model/load.c +++ b/source/model/load.c @@ -9,10 +9,12 @@ void load_template_load_cfg(config_all* _all_config, char* cmd) { load_free_vector(_all_config, &_all_config->v_user); load_free_vector(_all_config, &_all_config->v_group); load_free_vector(_all_config, &_all_config->v_project); + free_remove_vector(_all_config, &_all_config->v_remove); vector_init(&_all_config->v_user); vector_init(&_all_config->v_group); vector_init(&_all_config->v_project); vector_init(&_all_config->v_disk_status); + vector_init(&_all_config->v_remove); for (int index = 0; index < size; index++) { char* str_key_value = yon_char_new(cfg[index]); char* str_key = yon_char_divide_search(str_key_value, "=",-1); @@ -45,6 +47,7 @@ void load_template_load_cfg(config_all* _all_config, char* cmd) { } _all_config->flag_set_data = 0; _all_config->flag_not_data = 1; + _all_config->flag_save = 0; } @@ -123,12 +126,12 @@ void load_pars_keys_p(config_u_g_p* _config, char* str_key, int index) { } void load_pars_values_status(disk_status* _config, char* key, char* value) { - _config->device = yon_char_new(value); - if (strstr(key,"enable")) { + _config->device = yon_char_new(key); + if (strstr(value,"enable")) { _config->status = 1; return; } - else if (strstr(key,"disable")) { + else if (strstr(value,"disable")) { _config->status = 0; return; } @@ -178,5 +181,17 @@ void load_free_vector(config_all* _all_config, vector* vec_config) { } +void free_remove_vector(config_all* _all_config, vector* vec_remove) { + if (_all_config->flag_not_data == 1) { + if (vec_remove->vectorList.total > 0) { + for (int i = 0; i < vec_remove->vectorList.total; i++) { + char* str_remove = (char*)vec_remove->pfVectorGet(vec_remove, i); + free(str_remove); + } + vec_remove->pfVectorFree(vec_remove); + } + } +} + diff --git a/source/model/load.h b/source/model/load.h index 87d7687..74a290a 100644 --- a/source/model/load.h +++ b/source/model/load.h @@ -11,6 +11,6 @@ void load_pars_keys_p(config_u_g_p* _config, char* str_key, int index); void load_pars_values(config_u_g_p* _config, char* str_value, int index); void load_free_vector(config_all* _all_config,vector* vec_config); void load_pars_values_status(disk_status* _config, char* key, char* value); - +void free_remove_vector(config_all* _all_config, vector* vec_remove); #endif \ No newline at end of file