|
|
@ -252,15 +252,39 @@ void main_update_information() {
|
|
|
|
|
|
|
|
|
|
|
|
void load_system_cfg() {
|
|
|
|
void load_system_cfg() {
|
|
|
|
template_cfg(CMD_LOAD_SYSTEM);
|
|
|
|
template_cfg(CMD_LOAD_SYSTEM);
|
|
|
|
|
|
|
|
yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS, BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void load_global_cfg() {
|
|
|
|
void load_global_cfg() {
|
|
|
|
template_cfg(CMD_LOAD_GLOBAL);
|
|
|
|
template_cfg(CMD_LOAD_GLOBAL);
|
|
|
|
|
|
|
|
yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void clear_array() {
|
|
|
|
|
|
|
|
philos_free_string_array(&main_config.type_quota, main_config.size_tree_view);
|
|
|
|
|
|
|
|
philos_free_string_array(&main_config.quota_volume , main_config.size_tree_view);
|
|
|
|
|
|
|
|
philos_free_string_array(&main_config.soft_raw_limit , main_config.size_tree_view);
|
|
|
|
|
|
|
|
philos_free_string_array(&main_config.hard_raw_limit , main_config.size_tree_view);
|
|
|
|
|
|
|
|
philos_free_string_array(&main_config.swap , main_config.size_tree_view);
|
|
|
|
|
|
|
|
philos_free_string_array(&main_config.cpu_limit , main_config.size_tree_view);
|
|
|
|
|
|
|
|
philos_free_string_array(&main_config.i_o_limit_read , main_config.size_tree_view);
|
|
|
|
|
|
|
|
philos_free_string_array(&main_config.i_o_limit_write , main_config.size_tree_view);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
philos_free_int_array(&main_config.type_quota_size, main_config.size_tree_view);
|
|
|
|
|
|
|
|
philos_free_int_array(&main_config.quota_volume_size, main_config.size_tree_view);
|
|
|
|
|
|
|
|
philos_free_int_array(&main_config.soft_raw_limit_size, main_config.size_tree_view);
|
|
|
|
|
|
|
|
philos_free_int_array(&main_config.hard_raw_limit_size, main_config.size_tree_view);
|
|
|
|
|
|
|
|
philos_free_int_array(&main_config.swap_size, main_config.size_tree_view);
|
|
|
|
|
|
|
|
philos_free_int_array(&main_config.cpu_limit_size, main_config.size_tree_view);
|
|
|
|
|
|
|
|
philos_free_int_array(&main_config.i_o_limit_read_size, main_config.size_tree_view);
|
|
|
|
|
|
|
|
philos_free_int_array(&main_config.i_o_limit_write_size, main_config.size_tree_view);
|
|
|
|
|
|
|
|
gtk_list_store_clear(main_config.list);
|
|
|
|
|
|
|
|
main_config.size_tree_view = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void template_cfg(char* cmd) {
|
|
|
|
void template_cfg(char* cmd) {
|
|
|
|
|
|
|
|
clear_array();
|
|
|
|
int size = 0;
|
|
|
|
int size = 0;
|
|
|
|
int index_quotas = 0;
|
|
|
|
|
|
|
|
char** cfg = yon_config_load(cmd, &size);
|
|
|
|
char** cfg = yon_config_load(cmd, &size);
|
|
|
|
for (int index = 0; index < size; index++) {
|
|
|
|
for (int index = 0; index < size; index++) {
|
|
|
|
char* str_key_value = yon_char_new(cfg[index]);
|
|
|
|
char* str_key_value = yon_char_new(cfg[index]);
|
|
|
@ -271,13 +295,13 @@ void template_cfg(char* cmd) {
|
|
|
|
size_t length = strlen(str_key_value);
|
|
|
|
size_t length = strlen(str_key_value);
|
|
|
|
str_key_value = yon_char_divide(str_key_value, length-2);
|
|
|
|
str_key_value = yon_char_divide(str_key_value, length-2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
str_split_key(str_key, index_quotas);
|
|
|
|
str_split_key(str_key, main_config.size_tree_view);
|
|
|
|
str_split_value(str_key_value, index);
|
|
|
|
str_split_value(str_key_value, main_config.size_tree_view);
|
|
|
|
index_quotas++;
|
|
|
|
main_config.size_tree_view++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (index_quotas != 0) {
|
|
|
|
if (main_config.size_tree_view != 0) {
|
|
|
|
fill_tree_view(0, size);
|
|
|
|
fill_tree_view(0, main_config.size_tree_view, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -352,70 +376,70 @@ void str_split_value(char* values, int index) {
|
|
|
|
value = arr_values[index_1];
|
|
|
|
value = arr_values[index_1];
|
|
|
|
key = yon_char_divide_search(value, "=", -1);
|
|
|
|
key = yon_char_divide_search(value, "=", -1);
|
|
|
|
if (yon_char_find_count(key, "MemoryHigh") != 0) {
|
|
|
|
if (yon_char_find_count(key, "MemoryHigh") != 0) {
|
|
|
|
set_pow_size(value, main_config.soft_raw_limit_size, main_config.soft_raw_limit, index);
|
|
|
|
set_pow_size(value, &main_config.soft_raw_limit_size, &main_config.soft_raw_limit, index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
set_pow_size("-", main_config.soft_raw_limit_size, main_config.soft_raw_limit, index);
|
|
|
|
set_pow_size("-", &main_config.soft_raw_limit_size, &main_config.soft_raw_limit, index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (yon_char_find_count(key, "MemoryMax") != 0) {
|
|
|
|
if (yon_char_find_count(key, "MemoryMax") != 0) {
|
|
|
|
set_pow_size(value, main_config.hard_raw_limit_size, main_config.hard_raw_limit, index);
|
|
|
|
set_pow_size(value, &main_config.hard_raw_limit_size, &main_config.hard_raw_limit, index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
set_pow_size("-", main_config.hard_raw_limit_size, main_config.hard_raw_limit, index);
|
|
|
|
set_pow_size("-", &main_config.hard_raw_limit_size, &main_config.hard_raw_limit, index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (yon_char_find_count(key, "MemorySwapMax") != 0) {
|
|
|
|
if (yon_char_find_count(key, "MemorySwapMax") != 0) {
|
|
|
|
set_pow_size(value, main_config.swap_size, main_config.swap, index);
|
|
|
|
set_pow_size(value, &main_config.swap_size, &main_config.swap, index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
set_pow_size("-", main_config.swap_size, main_config.swap, index);
|
|
|
|
set_pow_size("-", &main_config.swap_size, &main_config.swap, index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (yon_char_find_count(key, "CPUQuota") != 0) {
|
|
|
|
if (yon_char_find_count(key, "CPUQuota") != 0) {
|
|
|
|
set_pow_size(value, main_config.cpu_limit_size, main_config.cpu_limit, index);
|
|
|
|
set_pow_size(value, &main_config.cpu_limit_size, &main_config.cpu_limit, index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
set_pow_size("-", main_config.cpu_limit_size, main_config.cpu_limit, index);
|
|
|
|
set_pow_size("-", &main_config.cpu_limit_size, &main_config.cpu_limit, index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (yon_char_find_count(key, "IOReadBandwidthMax") != 0) {
|
|
|
|
if (yon_char_find_count(key, "IOReadBandwidthMax") != 0) {
|
|
|
|
set_pow_size(value, main_config.i_o_limit_read_size, main_config.i_o_limit_read, index);
|
|
|
|
set_pow_size(value, &main_config.i_o_limit_read_size, &main_config.i_o_limit_read, index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
set_pow_size("-", main_config.i_o_limit_read_size, main_config.i_o_limit_read, index);
|
|
|
|
set_pow_size("-", &main_config.i_o_limit_read_size, &main_config.i_o_limit_read, index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (yon_char_find_count(key, "IOWriteBandwidthMax") != 0) {
|
|
|
|
if (yon_char_find_count(key, "IOWriteBandwidthMax") != 0) {
|
|
|
|
set_pow_size(value, main_config.i_o_limit_write_size, main_config.i_o_limit_write, index);
|
|
|
|
set_pow_size(value, &main_config.i_o_limit_write_size, &main_config.i_o_limit_write, index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
set_pow_size("-", main_config.i_o_limit_write_size, main_config.i_o_limit_write, index);
|
|
|
|
set_pow_size("-", &main_config.i_o_limit_write_size, &main_config.i_o_limit_write, index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void set_pow_size(char* str_find, int* array_size, char** array_data , int index) {
|
|
|
|
void set_pow_size(char* str_find, int** array_size, char*** array_data , int index) {
|
|
|
|
if (strstr(str_find,"K") != NULL) {
|
|
|
|
if (strstr(str_find,"K") != NULL) {
|
|
|
|
array_size = philos_int_append(array_size, &index, 0);
|
|
|
|
*array_size = philos_int_append(*array_size, &index, 0);
|
|
|
|
index--;
|
|
|
|
index--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strstr(str_find,"M") != NULL) {
|
|
|
|
else if (strstr(str_find,"M") != NULL) {
|
|
|
|
array_size = philos_int_append(array_size, &index, 1);
|
|
|
|
*array_size = philos_int_append(*array_size, &index, 1);
|
|
|
|
index--;
|
|
|
|
index--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strstr(str_find,"G") != NULL) {
|
|
|
|
else if (strstr(str_find,"G") != NULL) {
|
|
|
|
array_size = philos_int_append(array_size, &index, 2);
|
|
|
|
*array_size = philos_int_append(*array_size, &index, 2);
|
|
|
|
index--;
|
|
|
|
index--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strstr(str_find,"T") != NULL) {
|
|
|
|
else if (strstr(str_find,"T") != NULL) {
|
|
|
|
array_size = philos_int_append(array_size, &index, 3);
|
|
|
|
*array_size = philos_int_append(*array_size, &index, 3);
|
|
|
|
index--;
|
|
|
|
index--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strstr(str_find,"\%") != NULL) {
|
|
|
|
else if (strstr(str_find,"\%") != NULL) {
|
|
|
|
array_size = philos_int_append(array_size, &index, -1);
|
|
|
|
*array_size = philos_int_append(*array_size, &index, -1);
|
|
|
|
index--;
|
|
|
|
index--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strstr(str_find,"\"") != NULL) {
|
|
|
|
else if (strstr(str_find,"\"") != NULL) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strstr(str_find,"-") != NULL) {
|
|
|
|
else if (strstr(str_find,"-") != NULL) {
|
|
|
|
array_size = philos_int_append(array_size, &index, -1);
|
|
|
|
*array_size = philos_int_append(*array_size, &index, -1);
|
|
|
|
index--;
|
|
|
|
index--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (strstr(str_find, "-") == NULL) {
|
|
|
|
if (strstr(str_find, "-") == NULL) {
|
|
|
@ -425,11 +449,11 @@ void set_pow_size(char* str_find, int* array_size, char** array_data , int index
|
|
|
|
str_find = yon_char_divide(str_find, length-2);
|
|
|
|
str_find = yon_char_divide(str_find, length-2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
size_t length = strlen(str_find);
|
|
|
|
size_t length = strlen(str_find);
|
|
|
|
str_find = yon_char_divide(str_find, length-2);
|
|
|
|
str_find = yon_char_divide(str_find, length-1);
|
|
|
|
array_data = yon_char_parsed_append(array_data, &index, str_find);
|
|
|
|
*array_data = yon_char_parsed_append(*array_data, &index, str_find);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
array_data = yon_char_parsed_append(array_data, &index, "-");
|
|
|
|
*array_data = yon_char_parsed_append(*array_data, &index, "-");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -509,16 +533,21 @@ void tree_view_add(int index) {
|
|
|
|
main_config.i_o_limit_read_size = philos_int_append(main_config.i_o_limit_read_size, &main_config.size_tree_view, add_get_read_device_size());
|
|
|
|
main_config.i_o_limit_read_size = philos_int_append(main_config.i_o_limit_read_size, &main_config.size_tree_view, add_get_read_device_size());
|
|
|
|
main_config.size_tree_view--;
|
|
|
|
main_config.size_tree_view--;
|
|
|
|
main_config.i_o_limit_write_size = philos_int_append(main_config.i_o_limit_write_size, &main_config.size_tree_view, add_get_write_device_size());
|
|
|
|
main_config.i_o_limit_write_size = philos_int_append(main_config.i_o_limit_write_size, &main_config.size_tree_view, add_get_write_device_size());
|
|
|
|
fill_tree_view(main_config.size_tree_view-1, main_config.size_tree_view);
|
|
|
|
fill_tree_view(main_config.size_tree_view-1, main_config.size_tree_view, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void fill_tree_view(int start, int size) {
|
|
|
|
void fill_tree_view(int start, int size, int flag_gui_add) {
|
|
|
|
|
|
|
|
GtkTreeModel *model = GTK_TREE_MODEL(main_config.list);
|
|
|
|
|
|
|
|
if (flag_gui_add == 0) {
|
|
|
|
|
|
|
|
g_object_ref(main_config.list);
|
|
|
|
|
|
|
|
gtk_list_store_clear(main_config.list);
|
|
|
|
|
|
|
|
}
|
|
|
|
for (int index = start; index < size; index++) {
|
|
|
|
for (int index = start; index < size; index++) {
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gtk_list_store_append(main_config.list,&iter);
|
|
|
|
gtk_list_store_append(main_config.list,&iter);
|
|
|
|
gtk_list_store_set(main_config.list,&iter,0,main_config.type_quota[index],
|
|
|
|
gtk_list_store_set(main_config.list,&iter,0,main_config.type_quota[index],
|
|
|
|
1,main_config.quota_volume[index],
|
|
|
|
1,main_config.quota_volume[index],
|
|
|
|
// === NULL === Ошибка
|
|
|
|
// === NULL === О
|
|
|
|
2,main_config.soft_raw_limit[index],
|
|
|
|
2,main_config.soft_raw_limit[index],
|
|
|
|
3,main_config.hard_raw_limit[index],
|
|
|
|
3,main_config.hard_raw_limit[index],
|
|
|
|
4,main_config.swap[index],
|
|
|
|
4,main_config.swap[index],
|
|
|
@ -526,6 +555,9 @@ void fill_tree_view(int start, int size) {
|
|
|
|
6,main_config.i_o_limit_read[index],
|
|
|
|
6,main_config.i_o_limit_read[index],
|
|
|
|
7,main_config.i_o_limit_write[index],-1);
|
|
|
|
7,main_config.i_o_limit_write[index],-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag_gui_add != 0) {
|
|
|
|
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->treeViewMain), model);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int tree_view_edit() {
|
|
|
|
int tree_view_edit() {
|
|
|
|