|
|
|
@ -450,7 +450,7 @@ void set_pow_size(char* str_find, int** array_size, char*** array_data , int ind
|
|
|
|
|
str_find = yon_char_unite(str_find," ", STR_TB, NULL);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
else if (strstr(str_find,"\%") != NULL) {
|
|
|
|
|
else if (strstr(str_find,"%%") != NULL) {
|
|
|
|
|
*array_size = philos_int_append(*array_size, &index, -1);
|
|
|
|
|
str_find = yon_char_divide(str_find, length-1);
|
|
|
|
|
index--;
|
|
|
|
@ -771,72 +771,132 @@ void tree_view_del_line() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void wrapper_all_save() {
|
|
|
|
|
wrapper_template_save("all");
|
|
|
|
|
// template_format_str_save(main_config.load_global_cfg, CMD_LOAD_GLOBAL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wrapper_global_save() {
|
|
|
|
|
wrapper_template_save("global");
|
|
|
|
|
template_format_str_save(main_config.load_global_cfg, CMD_SAVE_GLOBAL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wrapper_system_save() {
|
|
|
|
|
wrapper_template_save("system");
|
|
|
|
|
template_format_str_save(main_config.load_system_cfg, CMD_SAVE_SYSTEM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wrapper_template_save(char* check_flag) {
|
|
|
|
|
puts(check_flag);
|
|
|
|
|
template_format_str_save();
|
|
|
|
|
|
|
|
|
|
char* save_format_key(int index) {
|
|
|
|
|
char* key = NULL;
|
|
|
|
|
if (strstr(main_config.quota_volume[index], "-") == NULL) {
|
|
|
|
|
key = yon_char_unite("CGROUP_QUOTA[", main_config.quota_volume[index] , "]", NULL);
|
|
|
|
|
}
|
|
|
|
|
return key;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void template_format_str_save() {
|
|
|
|
|
yon_dictionary_free_all(main_config.save_cfg_gui, NULL);
|
|
|
|
|
for (size_t i = 0; i < main_config.size_tree_view; i++) {
|
|
|
|
|
char* key = NULL;
|
|
|
|
|
char* value = "";
|
|
|
|
|
char split_simvol[2] = {0};
|
|
|
|
|
if (strstr(main_config.quota_volume[i], "-") == NULL) {
|
|
|
|
|
key = yon_char_unite("CGROUP_QUOTA[", &main_config.type_quota[i] , "]", NULL);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
key = yon_char_unite("CGROUP_QUOTA[", &main_config.type_quota[i], ".", &main_config.quota_volume[i], "]", NULL);
|
|
|
|
|
}
|
|
|
|
|
split_simvol[0] = 0;
|
|
|
|
|
split_simvol[1] = 0;
|
|
|
|
|
if (strstr(main_config.soft_raw_limit[i], "-") != NULL) {
|
|
|
|
|
value = yon_char_unite(value, main_config.soft_raw_limit[i], NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (strstr(main_config.hard_raw_limit[i], "-") != NULL) {
|
|
|
|
|
value = yon_char_unite(value, split_simvol, main_config.hard_raw_limit[i], NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (strstr(main_config.swap[i], "-") != NULL) {
|
|
|
|
|
value = yon_char_unite(value, split_simvol, main_config.swap[i], NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (strstr(main_config.cpu_limit[i], "-") != NULL) {
|
|
|
|
|
value = yon_char_unite(value, split_simvol, main_config.cpu_limit[i], NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (strstr(main_config.i_o_limit_read[i], "-") != NULL) {
|
|
|
|
|
value = yon_char_unite(value, split_simvol, main_config.i_o_limit_read[i], NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
char* save_format_value(int index) {
|
|
|
|
|
char* value = NULL;
|
|
|
|
|
char split_simvol[2] = {0};
|
|
|
|
|
split_simvol[0] = 0;
|
|
|
|
|
split_simvol[1] = 0;
|
|
|
|
|
if (strstr(main_config.soft_raw_limit[index], "-") == NULL) {
|
|
|
|
|
value = yon_char_unite(philos_format_cfg_str_size_memory("MemoryHigh", main_config.soft_raw_limit[index],main_config.soft_raw_limit_size[index]),NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (strstr(main_config.hard_raw_limit[index], "-") == NULL) {
|
|
|
|
|
value = yon_char_unite(value ,split_simvol, philos_format_cfg_str_size_memory("MemoryMax", main_config.hard_raw_limit[index],main_config.hard_raw_limit_size[index]), NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (strstr(main_config.swap[index], "-") == NULL) {
|
|
|
|
|
value = yon_char_unite(value ,split_simvol, philos_format_cfg_str_size_memory("MemorySwapMax", main_config.swap[index],main_config.swap_size[index]), NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (strstr(main_config.cpu_limit[index], "-") == NULL) {
|
|
|
|
|
value = yon_char_unite(value ,split_simvol, philos_format_cfg_str_size_memory("CPUQuota", main_config.cpu_limit[index],main_config.cpu_limit_size[index]), NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (strstr(main_config.i_o_limit_read[index], "-") == NULL) {
|
|
|
|
|
value = yon_char_unite(value ,split_simvol, philos_format_cfg_str_size_memory("IOReadBandwidthMax", main_config.i_o_limit_read[index],main_config.i_o_limit_read_size[index]), NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (strstr(main_config.i_o_limit_write[index], "-") == NULL) {
|
|
|
|
|
value = yon_char_unite(value ,split_simvol, philos_format_cfg_str_size_memory("IOWriteBandwidthMax", main_config.i_o_limit_write[index],main_config.i_o_limit_write_size[index]), NULL);
|
|
|
|
|
}
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pars_terminal() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int check_save(dictionary* load_cfg) {
|
|
|
|
|
dictionary* ptr_dict_gui = NULL;
|
|
|
|
|
dictionary* ptr_dict_load = NULL;
|
|
|
|
|
char* key_gui = NULL;
|
|
|
|
|
char* value_gui = NULL;
|
|
|
|
|
char* key_load = NULL;
|
|
|
|
|
char* value_load = NULL;
|
|
|
|
|
int flag_check_key = 0;
|
|
|
|
|
int flag_check_value = 0;
|
|
|
|
|
size_t size_cfg_gui = yon_dict_len(main_config.save_cfg_gui);
|
|
|
|
|
size_t size_cfg_load = yon_dict_len(load_cfg);
|
|
|
|
|
if (size_cfg_gui!=size_cfg_load) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
for_dictionaries(ptr_dict_gui, main_config.save_cfg_gui) {
|
|
|
|
|
for_dictionaries(ptr_dict_load, load_cfg) {
|
|
|
|
|
key_gui = ptr_dict_gui->key;
|
|
|
|
|
value_gui = (char*)ptr_dict_gui->data;
|
|
|
|
|
key_load = ptr_dict_load->key;
|
|
|
|
|
value_load = (char*)ptr_dict_load->data;
|
|
|
|
|
|
|
|
|
|
if (key_gui == key_load) {
|
|
|
|
|
flag_check_key = 1;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
if (value_gui == value_load) {
|
|
|
|
|
// TODO: check
|
|
|
|
|
flag_check_value = 1;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (strstr(main_config.i_o_limit_write[i], "-") != NULL) {
|
|
|
|
|
value = yon_char_unite(value, split_simvol, main_config.i_o_limit_write[i], NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
if (flag_check_key == 0 || flag_check_value == 0) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void template_format_str_save(dictionary* load_cfg, char* source_cmd) {
|
|
|
|
|
yon_dictionary_free_all(main_config.save_cfg_gui, NULL);
|
|
|
|
|
char* cmd = yon_char_new(source_cmd);
|
|
|
|
|
main_config.save_cfg_gui = yon_dictionary_create_empty();
|
|
|
|
|
int flag_save = 0;
|
|
|
|
|
for (size_t index = 0; index < main_config.size_tree_view; index++) {
|
|
|
|
|
char* key = NULL;
|
|
|
|
|
char* value = NULL;
|
|
|
|
|
key = save_format_key(index);
|
|
|
|
|
value = save_format_value(index);
|
|
|
|
|
main_config.save_cfg_gui = yon_dictionary_create_with_data_connected(main_config.save_cfg_gui, key, yon_char_new(value));
|
|
|
|
|
check_save(load_cfg);
|
|
|
|
|
if (key != NULL && value != NULL) {
|
|
|
|
|
cmd = yon_char_unite(cmd, " " , key, "=" , value, " ", NULL);
|
|
|
|
|
flag_save = 1;
|
|
|
|
|
}
|
|
|
|
|
puts(key);
|
|
|
|
|
free(key);
|
|
|
|
|
free(value);
|
|
|
|
|
}
|
|
|
|
|
if (flag_save) {
|
|
|
|
|
puts(cmd);
|
|
|
|
|
yon_config_save(cmd);
|
|
|
|
|
}
|
|
|
|
|
free(cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void main_fill_tree_view_after_remove() {
|
|
|
|
|
for (int index= 0; index < main_config.size_tree_view; index++) {
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|