|
|
|
@ -260,7 +260,7 @@ void load_global_cfg() {
|
|
|
|
|
|
|
|
|
|
void template_cfg(char* cmd) {
|
|
|
|
|
int size = 0;
|
|
|
|
|
int index = 0;
|
|
|
|
|
int index_quotas = 0;
|
|
|
|
|
char** cfg = yon_config_load(cmd, &size);
|
|
|
|
|
for (int index = 0; index < size; index++) {
|
|
|
|
|
char* str_key_value = yon_char_new(cfg[index]);
|
|
|
|
@ -271,12 +271,73 @@ void template_cfg(char* cmd) {
|
|
|
|
|
size_t length = strlen(str_key_value);
|
|
|
|
|
str_key_value = yon_char_divide(str_key_value, length-2);
|
|
|
|
|
}
|
|
|
|
|
str_split_key(str_key, index_quotas);
|
|
|
|
|
str_split_value(str_key_value, index);
|
|
|
|
|
index++;
|
|
|
|
|
index_quotas++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (index_quotas != 0) {
|
|
|
|
|
fill_tree_view(0, size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void str_split_key(char* value, int index) {
|
|
|
|
|
yon_char_divide_search(value, "[", -1);
|
|
|
|
|
value = yon_char_divide_search(value, "]", -1);
|
|
|
|
|
if (strstr(value, ".") != NULL) {
|
|
|
|
|
if (strstr(value, ".slice") != NULL) {
|
|
|
|
|
main_config.quota_volume = yon_char_parsed_append(main_config.quota_volume, &index, value);
|
|
|
|
|
index--;
|
|
|
|
|
main_config.type_quota_size = philos_int_append(main_config.type_quota_size, &index, 4);
|
|
|
|
|
index--;
|
|
|
|
|
main_config.quota_volume = yon_char_parsed_append(main_config.type_quota, &index, STR_PROCESS);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
else if (strstr(value, ".service") != NULL) {
|
|
|
|
|
main_config.quota_volume = yon_char_parsed_append(main_config.quota_volume, &index, value);
|
|
|
|
|
index--;
|
|
|
|
|
main_config.type_quota_size = philos_int_append(main_config.type_quota_size, &index, 3);
|
|
|
|
|
index--;
|
|
|
|
|
main_config.quota_volume = yon_char_parsed_append(main_config.type_quota, &index, STR_SLICE);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
main_config.quota_volume = yon_char_parsed_append(main_config.quota_volume, &index, value);
|
|
|
|
|
index--;
|
|
|
|
|
main_config.type_quota_size = philos_int_append(main_config.type_quota_size, &index, -1);
|
|
|
|
|
index--;
|
|
|
|
|
main_config.quota_volume = yon_char_parsed_append(main_config.type_quota, &index, "-");
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
int user_size = 0;
|
|
|
|
|
char** arr_users = philos_list_user(&user_size);
|
|
|
|
|
for (int user_index = 0; user_index < user_size; user_index++) {
|
|
|
|
|
// Пользователь
|
|
|
|
|
if (strcmp(arr_users[user_index], value) != 0) {
|
|
|
|
|
main_config.type_quota_size = philos_int_append(main_config.type_quota_size, &index, 0);
|
|
|
|
|
index--;
|
|
|
|
|
main_config.quota_volume = yon_char_parsed_append(main_config.quota_volume, &index, value);
|
|
|
|
|
index--;
|
|
|
|
|
main_config.quota_volume = yon_char_parsed_append(main_config.type_quota, &index, STR_USER);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
// Группа
|
|
|
|
|
else {
|
|
|
|
|
main_config.type_quota_size = philos_int_append(main_config.type_quota_size, &index, 1);
|
|
|
|
|
index--;
|
|
|
|
|
main_config.quota_volume = yon_char_parsed_append(main_config.quota_volume, &index, value);
|
|
|
|
|
index--;
|
|
|
|
|
main_config.quota_volume = yon_char_parsed_append(main_config.type_quota, &index, STR_GROUP);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void str_split_value(char* values, int index) {
|
|
|
|
|
char* new_value = yon_char_new(values);
|
|
|
|
|
int size = 0;
|
|
|
|
@ -358,6 +419,11 @@ void set_pow_size(char* str_find, int* array_size, char** array_data , int index
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
if (strstr(str_find,"-") == NULL) {
|
|
|
|
|
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-2);
|
|
|
|
|
array_data = yon_char_parsed_append(array_data, &index, str_find);
|
|
|
|
@ -365,16 +431,6 @@ void set_pow_size(char* str_find, int* array_size, char** array_data , int index
|
|
|
|
|
else {
|
|
|
|
|
array_data = yon_char_parsed_append(array_data, &index, "-");
|
|
|
|
|
}
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
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],
|
|
|
|
|
2,main_config.soft_raw_limit[index],
|
|
|
|
|
3,main_config.hard_raw_limit[index],
|
|
|
|
|
4,main_config.swap[index],
|
|
|
|
|
5,main_config.cpu_limit[index],
|
|
|
|
|
6,main_config.i_o_limit_read[index],
|
|
|
|
|
7,main_config.i_o_limit_write[index],-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -453,6 +509,11 @@ 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.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());
|
|
|
|
|
fill_tree_view(main_config.size_tree_view-1, main_config.size_tree_view);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fill_tree_view(int start, int size) {
|
|
|
|
|
for (int index = start; index < size; index++) {
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
gtk_list_store_append(main_config.list,&iter);
|
|
|
|
|
gtk_list_store_set(main_config.list,&iter,0,main_config.type_quota[index],
|
|
|
|
@ -463,7 +524,9 @@ void tree_view_add(int index) {
|
|
|
|
|
5,main_config.cpu_limit[index],
|
|
|
|
|
6,main_config.i_o_limit_read[index],
|
|
|
|
|
7,main_config.i_o_limit_write[index],-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int tree_view_edit() {
|
|
|
|
|
int index = 0;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|