#ifndef SAVE_H #define SAVE_H #include "save.h" char* template_format_save(config_u_g_p* config, char* cmd) { for (int i = 0; i < config->size; i++) { char* key = save_format_key(config, i); char* value = save_format_str_value(config, i); char* value_status = save_format_status_cmd(config, i); if (key!= NULL) { // key = yon_char_unite(cmd, " " , key, "=\"" , value, "\" ", NULL); cmd = yon_char_unite(cmd, key, "=" , value, " ", NULL); cmd = yon_char_unite(cmd, key, "=" , value_status, " ", NULL); free(key); free(value); free(value_status); } } return cmd; } char* save_format_key(config_u_g_p* config, int index) { if (config->status_set[index] == 1) { return NULL; } char* cmd = yon_char_new(""); char* value = yon_char_new(""); char* key = yon_char_new(""); int number = config->number[index]; key = yon_char_unite("CGROUP_QUOTA[", config->type_arr[index], ":", NULL); if (strstr(config->type_arr[index], "prjquota")) { if (number!=-1) { key = yon_char_unite(config->UNIX_file[index],":",yon_char_from_int(number), NULL); } else { key = yon_char_unite(config->UNIX_file[index],":AUTO", NULL); } } else { key = yon_char_unite(config->UNIX_file[index], NULL); } key = yon_char_unite(key, save_str_users(config, index) , "]", NULL); return cmd; } char* save_format_str_value(config_u_g_p* config, int index) { if (config->status_set[index] == 1) { return NULL; } char* value = yon_char_new(""); value = philos_format_cfg_str_size_memory(value, config->soft_restriction_size[index],config->soft_restriction_size_pow[index]); value = yon_char_unite(value, ","); philos_format_cfg_str_size_memory(value, config->soft_restriction_file[index],config->soft_restriction_file_pow[index]); value = yon_char_unite(value, ","); philos_format_cfg_str_size_memory(value, config->severe_limitation_size[index],config->severe_limitation_size_pow[index]); value = yon_char_unite(value, ","); philos_format_cfg_str_size_memory(value, config->severe_limitation_file[index], config->severe_limitation_file_pow[index]); value = yon_char_unite(value, ","); philos_format_cfg_str_size_memory(value, config->deferring_size[index], config->deferring_size_pow[index]); value = yon_char_unite(value, ","); value = philos_format_cfg_str_size_memory(value, config->deferring_file[index], config->deferring_file_pow[index]); return value; } char* save_str_users(config_u_g_p* config, int index) { char* cmd = yon_char_new(""); char split_simvol[2] = {0}; split_simvol[0] = 0; split_simvol[1] = 0; if (strstr(config->type_arr[index], "prjquota")) { for (int i=0; config->actors[i]; i++) { cmd = yon_char_unite(":", split_simvol, config->actors[i], NULL); split_simvol[0] = ','; split_simvol[1] = '\0'; } } else { } } char* save_format_status_cmd(config_u_g_p* config, int index) { if (config->status_set[index] == 1) { return NULL; } if (config->status[index]) { return yon_char_new("enable"); } else { return yon_char_new("disable"); } return yon_char_new("disable"); } #endif