|
|
|
|
@ -134,48 +134,108 @@ struct loaded_config *yon_save_window_get_saved_parameters(template_saving_windo
|
|
|
|
|
|
|
|
|
|
config_str yon_loaded_config_convert_to_save_command(struct loaded_config *target, int *size,char *path){
|
|
|
|
|
(*size)=0;
|
|
|
|
|
dictionary *sections = NULL;
|
|
|
|
|
|
|
|
|
|
config_str final_commands = NULL;
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
struct yon_temp_command_sections {
|
|
|
|
|
dictionary_fields(yon_temp_command_sections);
|
|
|
|
|
int status;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct yon_temp_command_sections *sections = NULL;
|
|
|
|
|
struct loaded_config *current;
|
|
|
|
|
for_dictionaries(current,target){
|
|
|
|
|
dictionary *cur_section=NULL;
|
|
|
|
|
if (sections&&(cur_section=yon_dictionary_get(§ions,current->section))){
|
|
|
|
|
char *temp = yon_char_unite((char*)cur_section->data," ", current->key,"=\'",(char*)current->data,"\'",NULL);
|
|
|
|
|
struct yon_temp_command_sections *cur_section=NULL, *found = NULL;
|
|
|
|
|
if (sections){
|
|
|
|
|
for_dictionaries(cur_section,sections){
|
|
|
|
|
if (!strcmp(current->section,cur_section->key)){
|
|
|
|
|
int status = yon_config_get_status(current->key);
|
|
|
|
|
if ((status==-1&&cur_section->status==-1)||(status>-1)&&cur_section->status>-1){
|
|
|
|
|
found = cur_section;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cur_section = found;
|
|
|
|
|
}
|
|
|
|
|
if (cur_section){
|
|
|
|
|
char *parameters_for_current_command = NULL;
|
|
|
|
|
if (yon_config_get_status(current->key)==-1){
|
|
|
|
|
parameters_for_current_command = yon_char_unite((char*)cur_section->data," ", current->key,NULL);
|
|
|
|
|
} else {
|
|
|
|
|
parameters_for_current_command = yon_char_unite((char*)cur_section->data," ", current->key,"=\'",(char*)current->data,"\'",NULL);
|
|
|
|
|
}
|
|
|
|
|
free(current->data);
|
|
|
|
|
cur_section->data = temp;
|
|
|
|
|
cur_section->data = parameters_for_current_command;
|
|
|
|
|
} else {
|
|
|
|
|
char *parameters = yon_char_unite(current->key,"=\'",(char*)current->data,"\'",NULL);
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(sections,current->section,parameters);
|
|
|
|
|
char *parameters_for_current_command = NULL;
|
|
|
|
|
if (yon_config_get_status(current->key)==-1){
|
|
|
|
|
parameters_for_current_command = current->key;
|
|
|
|
|
} else {
|
|
|
|
|
parameters_for_current_command = yon_char_unite(current->key,"=\'",(char*)current->data,"\'",NULL);
|
|
|
|
|
}
|
|
|
|
|
dictionary *sections_dict = (dictionary*)sections;
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(sections_dict,current->section,parameters_for_current_command);
|
|
|
|
|
sections = realloc(sections_dict,sizeof(struct yon_temp_command_sections));
|
|
|
|
|
|
|
|
|
|
sections->status=yon_config_get_status(current->key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
config_str commands = NULL;
|
|
|
|
|
{
|
|
|
|
|
dictionary *current;
|
|
|
|
|
for_dictionaries(current,sections){
|
|
|
|
|
char *dull_command = ubconfig_set_command_full(path,current->key,(char*)current->data);
|
|
|
|
|
char *command = yon_config_parameter_prepare_command(dull_command,NULL,current->key,NULL);
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(commands,size,command);
|
|
|
|
|
free(command);
|
|
|
|
|
config_str commands = NULL;
|
|
|
|
|
{
|
|
|
|
|
struct yon_temp_command_sections *current;
|
|
|
|
|
for_dictionaries(current,sections){
|
|
|
|
|
char *dull_command = NULL;
|
|
|
|
|
if (current->status>=0){
|
|
|
|
|
dull_command = ubconfig_set_command_full(path,current->key,(char*)current->data);
|
|
|
|
|
} else {
|
|
|
|
|
dull_command = ubconfig_remove_command_full(path,current->key,(char*)current->data);
|
|
|
|
|
}
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(commands,size,dull_command);
|
|
|
|
|
free(dull_command);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return commands;
|
|
|
|
|
}
|
|
|
|
|
return commands;
|
|
|
|
|
// dictionary *sections = NULL;
|
|
|
|
|
// {
|
|
|
|
|
// struct loaded_config *current;
|
|
|
|
|
// for_dictionaries(current,target){
|
|
|
|
|
// dictionary *cur_section=NULL;
|
|
|
|
|
// if (sections&&(cur_section=yon_dictionary_get(§ions,current->section))){
|
|
|
|
|
// if (yon_config_get_status(current->key)==-1){
|
|
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
// char *temp = yon_char_unite((char*)cur_section->data," ", current->key,"=\'",(char*)current->data,"\'",NULL);
|
|
|
|
|
// free(current->data);
|
|
|
|
|
// cur_section->data = temp;
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// char *parameters = yon_char_unite(current->key,"=\'",(char*)current->data,"\'",NULL);
|
|
|
|
|
// yon_dictionary_add_or_create_if_exists_with_data(sections,current->section,parameters);
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// config_str commands = NULL;
|
|
|
|
|
// {
|
|
|
|
|
// dictionary *current;
|
|
|
|
|
// for_dictionaries(current,sections){
|
|
|
|
|
// char *dull_command = ubconfig_set_command_full(path,current->key,(char*)current->data);
|
|
|
|
|
// char *command = yon_config_parameter_prepare_command(dull_command,NULL,current->key,NULL);
|
|
|
|
|
// yon_char_parsed_add_or_create_if_exists(commands,size,command);
|
|
|
|
|
// free(command);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int yon_config_parameter_prepare_elements(struct loaded_config *target){
|
|
|
|
|
int yon_config_parameter_prepare_elements(config_str target, int *size){
|
|
|
|
|
int success = 0;
|
|
|
|
|
struct loaded_config *current = NULL;
|
|
|
|
|
for_dictionaries(current,target){
|
|
|
|
|
char *parameter = current->key;
|
|
|
|
|
if (strstr(parameter,"[")){
|
|
|
|
|
char *param = yon_char_divide_search(parameter,"[",-1);
|
|
|
|
|
char *param_key = yon_char_divide_search(parameter,"]",-1);
|
|
|
|
|
free(parameter);
|
|
|
|
|
parameter = yon_char_unite(param,"[\"",param_key,"\"]",NULL);
|
|
|
|
|
current->key = parameter;
|
|
|
|
|
success=1;
|
|
|
|
|
}
|
|
|
|
|
for (int i=0;i<(*size);i++){
|
|
|
|
|
char *start_bracket_replaced_string = yon_char_replace(target[i],"[","[\"");
|
|
|
|
|
char *end_bracket_replaced_string = yon_char_replace(start_bracket_replaced_string,"]","\"]");
|
|
|
|
|
target[i] = end_bracket_replaced_string;
|
|
|
|
|
}
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
@ -187,10 +247,10 @@ void on_save_parameters(GtkWidget *self, template_saving_window *window){
|
|
|
|
|
|
|
|
|
|
int saved_size;
|
|
|
|
|
struct loaded_config *saved_parameters = yon_save_window_get_saved_parameters(window);
|
|
|
|
|
yon_config_parameter_prepare_elements(saved_parameters);
|
|
|
|
|
|
|
|
|
|
int size=0;
|
|
|
|
|
config_str commands = yon_loaded_config_convert_to_save_command(saved_parameters,&size,window->type!=YON_CONFIG_CUSTOM? yon_config_get_type_path(window->type):window->custom_save_path);
|
|
|
|
|
yon_config_parameter_prepare_elements(commands,&size);
|
|
|
|
|
|
|
|
|
|
char *final_command = yon_char_parsed_to_string(commands,size,";");
|
|
|
|
|
pthread_t thread_id;
|
|
|
|
|
|