|
|
|
|
@ -449,32 +449,11 @@ void yon_config_set_last_command(char *command){
|
|
|
|
|
config_last_load_command=yon_char_new(command);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int yon_config_load_config(YON_CONFIG_TYPE config_type, ...){
|
|
|
|
|
if (config_type == YON_CONFIG_BOTH) return 0;
|
|
|
|
|
|
|
|
|
|
char *current;
|
|
|
|
|
va_list args;
|
|
|
|
|
va_start(args,config_type);
|
|
|
|
|
|
|
|
|
|
int commands_size;
|
|
|
|
|
config_str commands = NULL;
|
|
|
|
|
while ((current=va_arg(args,char*))){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(commands,&commands_size,current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *final_command = yon_config_command_get_full(commands,commands_size);
|
|
|
|
|
yon_config_set_last_command(final_command);
|
|
|
|
|
if (yon_char_is_empty(final_command)) return 0;
|
|
|
|
|
int parameters_size;
|
|
|
|
|
config_str parameters = yon_config_load(final_command,¶meters_size);
|
|
|
|
|
int yon_config_import_string(YON_CONFIG_TYPE config_type, char *string){
|
|
|
|
|
if (!strcmp(string,"(null)\n")) return 0;
|
|
|
|
|
char *section = NULL;
|
|
|
|
|
if (!strstr(final_command," -ea ")){
|
|
|
|
|
section = yon_config_command_get_section(final_command);
|
|
|
|
|
}
|
|
|
|
|
for (int i=0;i<parameters_size;i++){
|
|
|
|
|
if (!strcmp(parameters[i],"(null)\n")) continue;
|
|
|
|
|
yon_char_remove_last_symbol(parameters[i],'\n');
|
|
|
|
|
char *value = yon_char_new(parameters[i]);
|
|
|
|
|
yon_char_remove_last_symbol(string,'\n');
|
|
|
|
|
char *value = yon_char_new(string);
|
|
|
|
|
char *parameter = yon_char_divide_search(value,"=",-1);
|
|
|
|
|
if (parameter[0]=='['){
|
|
|
|
|
section = yon_char_divide_search(parameter," ",-1);
|
|
|
|
|
@ -506,6 +485,34 @@ int yon_config_load_config(YON_CONFIG_TYPE config_type, ...){
|
|
|
|
|
yon_config_set_status(parameter,0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int yon_config_load_config(YON_CONFIG_TYPE config_type, ...){
|
|
|
|
|
if (config_type == YON_CONFIG_BOTH) return 0;
|
|
|
|
|
|
|
|
|
|
char *current;
|
|
|
|
|
va_list args;
|
|
|
|
|
va_start(args,config_type);
|
|
|
|
|
|
|
|
|
|
int commands_size;
|
|
|
|
|
config_str commands = NULL;
|
|
|
|
|
while ((current=va_arg(args,char*))){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(commands,&commands_size,current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *final_command = yon_config_command_get_full(commands,commands_size);
|
|
|
|
|
yon_config_set_last_command(final_command);
|
|
|
|
|
if (yon_char_is_empty(final_command)) return 0;
|
|
|
|
|
int parameters_size;
|
|
|
|
|
config_str parameters = yon_config_load(final_command,¶meters_size);
|
|
|
|
|
// char *section = NULL;
|
|
|
|
|
// if (!strstr(final_command," -ea ")){
|
|
|
|
|
// section = yon_config_command_get_section(final_command);
|
|
|
|
|
// }
|
|
|
|
|
for (int i=0;i<parameters_size;i++){
|
|
|
|
|
if (!strcmp(parameters[i],"(null)\n")) continue;
|
|
|
|
|
yon_config_import_string(config_type,parameters[i]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -781,7 +788,7 @@ void *yon_config_get_by_key(char *key){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *yon_config_default_get_by_key(char *key){
|
|
|
|
|
check_config{
|
|
|
|
|
check_default_config{
|
|
|
|
|
dictionary *dict = NULL;
|
|
|
|
|
for_dictionaries(dict, (dictionary*)__yon__config__default__strings){
|
|
|
|
|
if (strcmp(dict->key,key)==0&&((yon_config_parameter*)dict)->flag1!=-1){
|
|
|
|
|
@ -971,11 +978,13 @@ int yon_config_clean(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int yon_config_default_remove(char *key){
|
|
|
|
|
check_default_config{
|
|
|
|
|
yon_config_parameter *default_parameter = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__default__strings,key);
|
|
|
|
|
if (default_parameter){
|
|
|
|
|
__yon__config__default__strings = (yon_config_parameter*)yon_dictionary_rip((dictionary*)default_parameter);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1246,11 +1255,12 @@ config_str yon_config_get_save_parameters_by_list(int *size, config_str paramete
|
|
|
|
|
current_size = &removed_size;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
case 0:
|
|
|
|
|
action = "set";
|
|
|
|
|
current = &updated;
|
|
|
|
|
current_size = &updated_size;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
int position = yon_char_parsed_find_element(*current,*current_size,((yon_config_parameter*)temp)->section);
|
|
|
|
|
if (position>=0){
|
|
|
|
|
@ -1317,7 +1327,6 @@ config_str yon_config_get_save_parameters_by_key(int *size,...){
|
|
|
|
|
current = &removed;
|
|
|
|
|
current_size = &removed_size;
|
|
|
|
|
break;
|
|
|
|
|
case 0:
|
|
|
|
|
case 1:
|
|
|
|
|
action = "set";
|
|
|
|
|
current = &updated;
|
|
|
|
|
@ -1412,10 +1421,15 @@ char *yon_config_save_simple(YON_CONFIG_TYPE target, char *path){
|
|
|
|
|
int file_size=0;
|
|
|
|
|
config_str file_output = yon_config_load_file(file,&file_size);
|
|
|
|
|
if (file_output){
|
|
|
|
|
char *final_string = yon_char_parsed_to_string(file_output,file_size,"");
|
|
|
|
|
char *output_string = yon_char_parsed_to_string(file_output,file_size,"");
|
|
|
|
|
yon_char_parsed_free(file_output,file_size);
|
|
|
|
|
char *final_string = yon_char_unite(final_command,"\n",output_string,NULL);
|
|
|
|
|
free(output_string);
|
|
|
|
|
if (!yon_char_is_empty(final_string)){
|
|
|
|
|
return final_string;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
yon_char_parsed_free(file_output,file_size);
|
|
|
|
|
}
|
|
|
|
|
fclose(file);
|
|
|
|
|
}
|
|
|
|
|
@ -1436,10 +1450,15 @@ char *yon_config_save_list_simple(config_str parameters_keys, size_t size, char
|
|
|
|
|
int file_size=0;
|
|
|
|
|
config_str file_output = yon_config_load_file(file,&file_size);
|
|
|
|
|
if (file_output){
|
|
|
|
|
char *final_string = yon_char_parsed_to_string(file_output,file_size,"");
|
|
|
|
|
char *output_string = yon_char_parsed_to_string(file_output,file_size,"");
|
|
|
|
|
yon_char_parsed_free(file_output,file_size);
|
|
|
|
|
char *final_string = yon_char_unite(command,"\n",output_string,NULL);
|
|
|
|
|
free(output_string);
|
|
|
|
|
if (!yon_char_is_empty(final_string)){
|
|
|
|
|
return final_string;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
yon_char_parsed_free(file_output,file_size);
|
|
|
|
|
}
|
|
|
|
|
fclose(file);
|
|
|
|
|
}
|
|
|
|
|
|