|
|
|
|
@ -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);
|
|
|
|
|
@ -505,6 +484,34 @@ int yon_config_load_config(YON_CONFIG_TYPE config_type, ...){
|
|
|
|
|
yon_config_default_remove(parameter);
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
@ -1414,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);
|
|
|
|
|
}
|
|
|
|
|
@ -1438,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);
|
|
|
|
|
}
|
|
|
|
|
|