Исправлено отображение данных в таблице при загрузки конфигурации

pull/4/head
Igor Belitskiy 2 years ago
parent 6d4a32bc22
commit 1fd2f78f25

@ -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.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_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.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.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.quota_volume_size, main_config.size_tree_view);
@ -302,9 +303,19 @@ void template_cfg(char* cmd) {
} }
if (main_config.size_tree_view != 0) { if (main_config.size_tree_view != 0) {
fill_tree_view(0, 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) { void str_split_key(char* value, int index) {
yon_char_divide_search(value, "[", -1); yon_char_divide_search(value, "[", -1);
@ -371,6 +382,7 @@ void str_split_value(char* values, int index) {
if (arr_values == NULL) { if (arr_values == NULL) {
return; return;
} }
init_cfg_array(index);
char* value_i = NULL; char* value_i = NULL;
for (int index_1 = 0; index_1 < size; index_1++) { for (int index_1 = 0; index_1 < size; index_1++) {
value = arr_values[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) { 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 {
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 {
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 {
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 {
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 {
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 {
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) {
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) { if (strstr(str_find,"K") != NULL) {
*array_size = philos_int_append(*array_size, &index, 0); *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--; 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);
str_find = yon_char_divide(str_find, length-1);
str_find = yon_char_unite(str_find," ", STR_MB);
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);
str_find = yon_char_divide(str_find, length-1);
str_find = yon_char_unite(str_find," ", STR_GB);
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);
str_find = yon_char_divide(str_find, length-1);
str_find = yon_char_unite(str_find," ", STR_TB);
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);
str_find = yon_char_divide(str_find, length-1);
index--; index--;
}
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) {
*array_data = yon_char_parsed_append(*array_data, &index, "-");
}
else {
if (str_find[0] == '\"') { if (str_find[0] == '\"') {
yon_char_divide(str_find, 0); yon_char_divide(str_find, 0);
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-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); *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() { void main_cbx_2_event() {
int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtMainInfo)); 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_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 === О
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],

@ -73,6 +73,7 @@ typedef struct {
config_str cpu_limit; config_str cpu_limit;
config_str i_o_limit_read; config_str i_o_limit_read;
config_str i_o_limit_write; config_str i_o_limit_write;
config_str disk;
int* type_quota_size; int* type_quota_size;
int* quota_volume_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 set_pow_size(char* str_find, int** array_size, char*** array_data, int index);
void str_split_key(char* value, int index); void str_split_key(char* value, int index);
void fill_tree_view(int start, int size, int flag_gui_add); void fill_tree_view(int start, int size, int flag_gui_add);
void clear_array(); void clear_array();
void init_cfg_array(int index);

@ -28,6 +28,11 @@
#define STR_PROCESS _("Process") #define STR_PROCESS _("Process")
#define STR_SLICE _("Slice") #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 GLOBAL_LOAD_SUCCESS _("Global configuration loading succseeded.")
#define LOCAL_LOAD_SUCCESS _("Local configuration loading succseeded.") #define LOCAL_LOAD_SUCCESS _("Local configuration loading succseeded.")

@ -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) { void edit_set_limit_cpu(char* str_value, int pow_mem) {
edit_temp_set(str_value,pow_mem, edit_widgets->chkCPULimitEdit, edit_temp_set(str_value,pow_mem, edit_widgets->chkCPULimitEdit,
edit_widgets->spinCPULimitEdit, edit_widgets->spinCPULimitEdit,
edit_widgets->lblCPULimitEdit); NULL);
} }
void edit_set_limit_swap(char* str_value, int pow_mem) { void edit_set_limit_swap(char* str_value, int pow_mem) {
edit_temp_set(str_value,pow_mem, edit_widgets->chkPaddingFLEdit, 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) { void edit_temp_set(char* str_value, int pow_mem, GtkWidget* cheek, GtkWidget* spin, GtkWidget* combo_box_text) {
char* search = "-"; char* search = "-";
char* mem_size_pow = yon_char_new(str_value); 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)); int value = atoi(yon_char_divide_search(mem_size_pow, " ", -1));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), value); gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), value);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cheek), 1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cheek), 1);

@ -174,48 +174,48 @@
</object> </object>
<object class="GtkAdjustment" id="adjustment1"> <object class="GtkAdjustment" id="adjustment1">
<property name="lower">1</property> <property name="lower">1</property>
<property name="upper">1000</property> <property name="upper">100000</property>
<property name="value">1</property> <property name="value">1</property>
<property name="step-increment">1</property> <property name="step-increment">1</property>
<property name="page-increment">10</property> <property name="page-increment">10</property>
</object> </object>
<object class="GtkAdjustment" id="adjustment2"> <object class="GtkAdjustment" id="adjustment2">
<property name="upper">100</property> <property name="upper">10000</property>
<property name="step-increment">1</property> <property name="step-increment">1</property>
<property name="page-increment">10</property> <property name="page-increment">10</property>
</object> </object>
<object class="GtkAdjustment" id="adjustment3"> <object class="GtkAdjustment" id="adjustment3">
<property name="upper">100</property> <property name="upper">10000</property>
<property name="step-increment">1</property> <property name="step-increment">1</property>
<property name="page-increment">10</property> <property name="page-increment">10</property>
</object> </object>
<object class="GtkAdjustment" id="adjustment4"> <object class="GtkAdjustment" id="adjustment4">
<property name="upper">1023</property> <property name="upper">1000023</property>
<property name="step-increment">1</property> <property name="step-increment">1</property>
<property name="page-increment">10</property> <property name="page-increment">10</property>
</object> </object>
<object class="GtkAdjustment" id="adjustment5"> <object class="GtkAdjustment" id="adjustment5">
<property name="upper">100</property> <property name="upper">10000</property>
<property name="step-increment">1</property> <property name="step-increment">1</property>
<property name="page-increment">10</property> <property name="page-increment">10</property>
</object> </object>
<object class="GtkAdjustment" id="adjustment6"> <object class="GtkAdjustment" id="adjustment6">
<property name="upper">1023</property> <property name="upper">100023</property>
<property name="step-increment">1</property> <property name="step-increment">1</property>
<property name="page-increment">10</property> <property name="page-increment">10</property>
</object> </object>
<object class="GtkAdjustment" id="adjustment7"> <object class="GtkAdjustment" id="adjustment7">
<property name="upper">1023</property> <property name="upper">100023</property>
<property name="step-increment">1</property> <property name="step-increment">1</property>
<property name="page-increment">10</property> <property name="page-increment">10</property>
</object> </object>
<object class="GtkAdjustment" id="adjustment8"> <object class="GtkAdjustment" id="adjustment8">
<property name="upper">100</property> <property name="upper">10000</property>
<property name="step-increment">1</property> <property name="step-increment">1</property>
<property name="page-increment">10</property> <property name="page-increment">10</property>
</object> </object>
<object class="GtkAdjustment" id="adjustment9"> <object class="GtkAdjustment" id="adjustment9">
<property name="upper">100</property> <property name="upper">10000</property>
<property name="step-increment">1</property> <property name="step-increment">1</property>
<property name="page-increment">10</property> <property name="page-increment">10</property>
</object> </object>

Loading…
Cancel
Save