parent
547262c464
commit
b9c7d7c5cb
@ -0,0 +1,139 @@
|
||||
#include "load.h"
|
||||
|
||||
|
||||
void load_template_load_cfg(config_u_g_p* _config, char* cmd) {
|
||||
model_clear_cfg(_config);
|
||||
int size = 0;
|
||||
char** cfg = yon_config_load(cmd, &size);
|
||||
philos_array_string_remove_char(&cfg, "\n", size);
|
||||
int size_loaded_keys = 0;
|
||||
for (int index = 0; index < size; index++) {
|
||||
char* str_key_value = yon_char_new(cfg[index]);
|
||||
char* str_key = yon_char_divide_search(str_key_value, "=",-1);
|
||||
_config->loaded_keys = yon_char_parsed_append(_config->loaded_keys, &size_loaded_keys, str_key);
|
||||
char* str_value = str_key_value;
|
||||
load_pars_keys(_config, yon_char_new(str_key), index);
|
||||
load_pars_values(_config, yon_char_new(str_value), index);
|
||||
|
||||
}
|
||||
_config->flag_set_data = 0;
|
||||
}
|
||||
|
||||
void load_pars_keys(config_u_g_p* _config, char* str_key, int index) {
|
||||
yon_char_divide_search(str_key, "[",-1);
|
||||
str_key = yon_char_divide_search(str_key, "]",-1);
|
||||
load_pars_keys_u_g(_config, str_key, index);
|
||||
load_pars_keys_p(_config, str_key, index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void load_pars_keys_u_g(config_u_g_p* _config, char* str_key, int index) {
|
||||
if (strstr(str_key, "prjquota")) {
|
||||
return;
|
||||
}
|
||||
if (yon_char_find_count(str_key, ":") || yon_char_find_count(str_key, ",")) {
|
||||
int size_point = 0;
|
||||
char** arr_keys = philos_str_split(str_key, &size_point, ":");
|
||||
char** type_quota = philos_char_parsed_append(_config->type_arr, &index, arr_keys[0]);
|
||||
int size_users = 0;
|
||||
if (yon_char_find_count(str_key, ":") == 2) {
|
||||
_config->UNIX_file = philos_char_parsed_append(_config->UNIX_file,&index, arr_keys[1]);
|
||||
}
|
||||
if (yon_char_find_count(str_key, ",")) {
|
||||
int size_comma = 0;
|
||||
char** arr_user = philos_str_split(arr_keys[size_point-1], &size_comma, ",");
|
||||
|
||||
for (int i = 0; i < size_comma; i++) {
|
||||
_config->actors = yon_char_parsed_append(_config->actors, &size_users, arr_user[i]);
|
||||
}
|
||||
_config->actors = yon_char_parsed_append(_config->actors, &size_users, NULL);
|
||||
}
|
||||
else {
|
||||
_config->actors = yon_char_parsed_append(_config->actors, &size_users, NULL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void load_pars_keys_p(config_u_g_p* _config, char* str_key, int index) {
|
||||
if (strstr(str_key, "usrquota") || strstr(str_key, "grpquota")) {
|
||||
return;
|
||||
}
|
||||
if (yon_char_find_count(str_key, ":") || yon_char_find_count(str_key, ",")) {
|
||||
int size_point = 0;
|
||||
char** arr_keys = philos_str_split(str_key, &size_point, ":");
|
||||
char** type_quota = philos_char_parsed_append(_config->type_arr,&index, arr_keys[0]);
|
||||
int size_users = 0;
|
||||
if (yon_char_find_count(str_key, ":") == 2) {
|
||||
_config->UNIX_file = philos_char_parsed_append(_config->UNIX_file,&index, arr_keys[1]);
|
||||
int size_comma = 0;
|
||||
if (yon_char_find_count(str_key, ",")) {
|
||||
char** arr_user = philos_str_split(arr_keys[size_point-1], &size_comma, ",");
|
||||
if (strstr(str_key, "AUTO")) {
|
||||
_config->number = philos_int_append(_config->number,&index, -1);
|
||||
}
|
||||
else {
|
||||
_config->number = philos_int_append(_config->number,&index, atoi(arr_user[0]));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (strstr(str_key, "AUTO")) {
|
||||
_config->number = philos_int_append(_config->number,&index, -1);
|
||||
}
|
||||
else {
|
||||
_config->number = philos_int_append(_config->number, &size_comma, atoi(arr_keys[size_point-1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void load_pars_values_status(config_u_g_p* _config, int index, char*key, char* value) {
|
||||
for (int i = 0; i < _config->size; i++) {
|
||||
if (strstr(key, _config->loaded_keys[i])) {
|
||||
if (strstr(key,"enable")) {
|
||||
_config->status[index] = 1;
|
||||
return;
|
||||
}
|
||||
else if (strstr(key,"disable")) {
|
||||
_config->status[index] = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void load_pars_values(config_u_g_p* _config, char* str_value, int index) {
|
||||
int size = 0;
|
||||
char* new_value = yon_char_new(str_value);
|
||||
char** arr_values = philos_str_split(new_value, &size, ":");
|
||||
if (yon_char_find_count(str_value, ":") == 3 || yon_char_find_count(str_value, ":") == 5) {
|
||||
philos_set_pow_size_memory(yon_char_new(arr_values[0]), &_config->soft_restriction_size, index, array_size_pow);
|
||||
philos_set_size_memory_integer(yon_char_new(arr_values[0]), &_config->soft_restriction_size_pow, index);
|
||||
philos_set_pow_size_memory(yon_char_new(arr_values[1]), &_config->soft_restriction_file, index, array_size_pow);
|
||||
philos_set_size_memory_integer(yon_char_new(arr_values[1]), &_config->soft_restriction_file, index);
|
||||
philos_set_pow_size_memory(yon_char_new(arr_values[2]), &_config->severe_limitation_size, index, array_size_pow);
|
||||
philos_set_size_memory_integer(yon_char_new(arr_values[2]), &_config->severe_limitation_size_pow, index);
|
||||
philos_set_pow_size_memory(yon_char_new(arr_values[3]), &_config->severe_limitation_file, index, array_size_pow);
|
||||
philos_set_size_memory_integer(yon_char_new(arr_values[3]), &_config->severe_limitation_file_pow, index);
|
||||
if (yon_char_find_count(str_value, ":") == 5) {
|
||||
philos_set_pow_size_memory(yon_char_new(arr_values[3]), &_config->deferring_size, index, array_size_pow);
|
||||
philos_set_size_memory_integer(yon_char_new(arr_values[3]), &_config->deferring_size_pow, index);
|
||||
philos_set_pow_size_memory(yon_char_new(arr_values[3]), &_config->deferring_file, index, array_size_pow);
|
||||
philos_set_size_memory_integer(yon_char_new(arr_values[3]), &_config->deferring_file_pow, index);
|
||||
}
|
||||
else {
|
||||
philos_set_pow_size_memory("-", &_config->deferring_size, index, array_size_pow);
|
||||
philos_set_size_memory_integer("-", &_config->deferring_size_pow, index);
|
||||
philos_set_pow_size_memory("-", &_config->deferring_file, index, array_size_pow);
|
||||
philos_set_size_memory_integer("-", &_config->deferring_file_pow, index);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
#ifndef LOAD_H
|
||||
#define LOAD_H
|
||||
#include "ubl-utils.h"
|
||||
#include "../ubl-strings.h"
|
||||
#include "model.h"
|
||||
|
||||
void load_template_load_cfg(config_u_g_p* _config, char* cmd);
|
||||
void load_pars_keys(config_u_g_p* _config, char* str_key, int index);
|
||||
void load_pars_keys_u_g(config_u_g_p* _config, char* str_key, int index);
|
||||
void load_pars_keys_p(config_u_g_p* _config, char* str_key, int index);
|
||||
void load_pars_values(config_u_g_p* _config, char* str_value, int index);
|
||||
|
||||
#endif
|
Loading…
Reference in new issue