diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c index 8d88574..b68601b 100644 --- a/source/ubl-settings-resourcequota.c +++ b/source/ubl-settings-resourcequota.c @@ -269,6 +269,7 @@ void clear_array() { 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_string_array(&main_config.disk, 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); @@ -302,9 +303,19 @@ void template_cfg(char* cmd) { } if (main_config.size_tree_view != 0) { fill_tree_view(0, main_config.size_tree_view, 0); - } - - + } +} + +void init_cfg_array(int index) { + main_config.disk = yon_char_parsed_append(main_config.disk, &index, "-"); + index--; + 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); + set_pow_size("-", &main_config.soft_raw_limit_size, &main_config.soft_raw_limit, index); + set_pow_size("-", &main_config.hard_raw_limit_size, &main_config.hard_raw_limit, index); + set_pow_size("-", &main_config.swap_size, &main_config.swap, index); + 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_write_size, &main_config.i_o_limit_write, index); } void str_split_key(char* value, int index) { yon_char_divide_search(value, "[", -1); @@ -371,6 +382,7 @@ void str_split_value(char* values, int index) { if (arr_values == NULL) { return; } + init_cfg_array(index); char* value_i = NULL; for (int index_1 = 0; index_1 < size; index_1++) { value = arr_values[index_1]; @@ -378,85 +390,84 @@ void str_split_value(char* values, int index) { if (yon_char_find_count(key, "MemoryHigh") != 0) { set_pow_size(value, &main_config.soft_raw_limit_size, &main_config.soft_raw_limit, index); } - else { - set_pow_size("-", &main_config.soft_raw_limit_size, &main_config.soft_raw_limit, index); - } if (yon_char_find_count(key, "MemoryMax") != 0) { set_pow_size(value, &main_config.hard_raw_limit_size, &main_config.hard_raw_limit, index); } - else { - set_pow_size("-", &main_config.hard_raw_limit_size, &main_config.hard_raw_limit, index); - } if (yon_char_find_count(key, "MemorySwapMax") != 0) { set_pow_size(value, &main_config.swap_size, &main_config.swap, index); } - else { - set_pow_size("-", &main_config.swap_size, &main_config.swap, index); - } if (yon_char_find_count(key, "CPUQuota") != 0) { set_pow_size(value, &main_config.cpu_limit_size, &main_config.cpu_limit, index); } - else { - set_pow_size("-", &main_config.cpu_limit_size, &main_config.cpu_limit, index); - } 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); } - else { - 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) { set_pow_size(value, &main_config.i_o_limit_write_size, &main_config.i_o_limit_write, index); } - else { - 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) { + char* disk = NULL; + if (strstr(str_find,"\"") != NULL) { + yon_char_divide(str_find, 0); + size_t length = strlen(str_find); + str_find = yon_char_divide(str_find, length-2); + if (str_find[0] == '\"') { + if (strstr(str_find, " ") != NULL) { + disk = yon_char_divide_search(str_find, " ", -1); + *array_data = yon_char_parsed_append(*array_data, &index, disk); + } + } + } + size_t length = strlen(str_find); if (strstr(str_find,"K") != NULL) { *array_size = philos_int_append(*array_size, &index, 0); + str_find = yon_char_divide(str_find, length-1); + str_find = yon_char_unite(str_find, " ", STR_KB); index--; } else if (strstr(str_find,"M") != NULL) { *array_size = philos_int_append(*array_size, &index, 1); + str_find = yon_char_divide(str_find, length-1); + str_find = yon_char_unite(str_find," ", STR_MB); index--; } else if (strstr(str_find,"G") != NULL) { *array_size = philos_int_append(*array_size, &index, 2); + str_find = yon_char_divide(str_find, length-1); + str_find = yon_char_unite(str_find," ", STR_GB); index--; } else if (strstr(str_find,"T") != NULL) { *array_size = philos_int_append(*array_size, &index, 3); + str_find = yon_char_divide(str_find, length-1); + str_find = yon_char_unite(str_find," ", STR_TB); index--; } 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--; - } - else if (strstr(str_find,"\"") != NULL) { - } else if (strstr(str_find,"-") != NULL) { *array_size = philos_int_append(*array_size, &index, -1); index--; } - if (strstr(str_find, "-") == NULL) { + if (strstr(str_find, "-") != NULL) { + *array_data = yon_char_parsed_append(*array_data, &index, "-"); + } + else { if (str_find[0] == '\"') { yon_char_divide(str_find, 0); size_t length = strlen(str_find); str_find = yon_char_divide(str_find, length-2); } - size_t length = strlen(str_find); - str_find = yon_char_divide(str_find, length-1); *array_data = yon_char_parsed_append(*array_data, &index, str_find); - } - else { - *array_data = yon_char_parsed_append(*array_data, &index, "-"); - } -} + } +} void main_cbx_2_event() { int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtMainInfo)); @@ -547,7 +558,6 @@ void fill_tree_view(int start, int size, int flag_gui_add) { gtk_list_store_append(main_config.list,&iter); gtk_list_store_set(main_config.list,&iter,0,main_config.type_quota[index], 1,main_config.quota_volume[index], - // === NULL === О 2,main_config.soft_raw_limit[index], 3,main_config.hard_raw_limit[index], 4,main_config.swap[index], diff --git a/source/ubl-settings-resourcequota.h b/source/ubl-settings-resourcequota.h index 2d4447a..7bb9f2e 100755 --- a/source/ubl-settings-resourcequota.h +++ b/source/ubl-settings-resourcequota.h @@ -73,6 +73,7 @@ typedef struct { config_str cpu_limit; config_str i_o_limit_read; config_str i_o_limit_write; + config_str disk; int* type_quota_size; int* quota_volume_size; @@ -184,4 +185,5 @@ void str_split_value(char* values, int index); void set_pow_size(char* str_find, int** array_size, char*** array_data, int index); void str_split_key(char* value, int index); void fill_tree_view(int start, int size, int flag_gui_add); -void clear_array(); \ No newline at end of file +void clear_array(); +void init_cfg_array(int index); diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 2d732c4..b5cca97 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -28,6 +28,11 @@ #define STR_PROCESS _("Process") #define STR_SLICE _("Slice") +#define STR_KB _("Kb") +#define STR_MB _("Mb") +#define STR_GB _("Gb") +#define STR_TB _("Tb") + #define GLOBAL_LOAD_SUCCESS _("Global configuration loading succseeded.") #define LOCAL_LOAD_SUCCESS _("Local configuration loading succseeded.") diff --git a/source/view_edit.c b/source/view_edit.c index 7127154..6695813 100644 --- a/source/view_edit.c +++ b/source/view_edit.c @@ -201,7 +201,7 @@ void edit_set_hard(char* str_value, int pow_mem) { void edit_set_limit_cpu(char* str_value, int pow_mem) { edit_temp_set(str_value,pow_mem, edit_widgets->chkCPULimitEdit, edit_widgets->spinCPULimitEdit, - edit_widgets->lblCPULimitEdit); + NULL); } void edit_set_limit_swap(char* str_value, int pow_mem) { edit_temp_set(str_value,pow_mem, edit_widgets->chkPaddingFLEdit, @@ -211,7 +211,7 @@ void edit_set_limit_swap(char* str_value, int pow_mem) { void edit_temp_set(char* str_value, int pow_mem, GtkWidget* cheek, GtkWidget* spin, GtkWidget* combo_box_text) { char* search = "-"; char* mem_size_pow = yon_char_new(str_value); - if (yon_char_find_count(mem_size_pow, search) == 0) { + if (strstr(mem_size_pow, search) == 0) { int value = atoi(yon_char_divide_search(mem_size_pow, " ", -1)); gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), value); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cheek), 1); diff --git a/ubl-settings-resourcequota.glade b/ubl-settings-resourcequota.glade index c9045b9..1107ca6 100644 --- a/ubl-settings-resourcequota.glade +++ b/ubl-settings-resourcequota.glade @@ -174,48 +174,48 @@ 1 - 1000 + 100000 1 1 10 - 100 + 10000 1 10 - 100 + 10000 1 10 - 1023 + 1000023 1 10 - 100 + 10000 1 10 - 1023 + 100023 1 10 - 1023 + 100023 1 10 - 100 + 10000 1 10 - 100 + 10000 1 10