@ -70,6 +70,13 @@ struct loaded_config *yon_save_window_get_saved_parameters(template_saving_windo
return final ;
return final ;
}
}
// struct __yon_save_section{
// int save_size;
// config_str save_config;
// int remove_size;
// config_str remove_config;
// } __yon_save_section;
config_str yon_loaded_config_convert_to_save_command ( struct loaded_config * target , int * size , char * path ) {
config_str yon_loaded_config_convert_to_save_command ( struct loaded_config * target , int * size , char * path ) {
( * size ) = 0 ;
( * size ) = 0 ;
@ -138,13 +145,24 @@ config_str yon_loaded_config_convert_to_save_command(struct loaded_config *targe
for_dictionaries ( current , sections ) {
for_dictionaries ( current , sections ) {
char * dull_command = NULL ;
char * dull_command = NULL ;
if ( current - > status > = 0 ) {
if ( current - > status > = 0 ) {
dull_command = ubconfig_set_command_full ( path , current - > key , ( char * ) current - > data ) ;
dull_command = ! commands ? ubconfig_set_command_full ( path , current - > key , ( char * ) current - > data ) : yon_char_unite ( " -- set " , current - > key , " " , ( char * ) current - > data , NULL ) ;
} else {
} else {
dull_command = ubconfig_remove_command_full ( path , current - > key , ( char * ) current - > data ) ;
dull_command = ! commands ? ubconfig_remove_command_full ( path , current - > key , ( char * ) current - > data ) : yon_char_unite ( " -- remove " , current - > key , " " , ( char * ) current - > data , NULL ) ;
}
}
yon_char_parsed_add_or_create_if_exists ( commands , size , dull_command ) ;
yon_char_parsed_add_or_create_if_exists ( commands , size , dull_command ) ;
free ( dull_command ) ;
free ( dull_command ) ;
}
}
// 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 ;
}
}
@ -378,29 +396,38 @@ struct loaded_config *yon_config_convert_parameter(config_str parsed, int size){
for ( int i = 0 ; i < size ; i + + ) {
for ( int i = 0 ; i < size ; i + + ) {
char * value = yon_char_new ( parsed [ i ] ) ;
char * value = yon_char_new ( parsed [ i ] ) ;
char * key = yon_char_divide_search ( value , " = " , - 1 ) ;
char * key = yon_char_divide_search ( value , " = " , - 1 ) ;
char * section = NULL ;
if ( key [ 0 ] = = ' [ ' ) {
section = yon_char_divide_search ( key , " " , - 1 ) ;
free ( yon_char_divide ( section , yon_char_find_last ( section , ' / ' ) ) ) ;
yon_char_remove_last_symbol ( section , ' ] ' ) ;
}
if ( ! yon_char_is_empty ( value ) ) {
if ( ! yon_char_is_empty ( value ) ) {
yon_char_remove_brackets ( value ) ;
yon_char_remove_brackets ( value ) ;
}
}
if ( ! loaded ) {
if ( ! loaded ) {
loaded = ( struct loaded_config * ) malloc ( sizeof ( struct loaded_config ) ) ;
loaded = ( struct loaded_config * ) malloc ( sizeof ( struct loaded_config ) ) ;
loaded - > key = key ;
loaded - > key = yon_char_new ( key ) ;
loaded - > first = loaded ;
loaded - > first = loaded ;
loaded - > next = NULL ;
loaded - > next = NULL ;
loaded - > prev = NULL ;
loaded - > prev = NULL ;
loaded - > section = NULL ;
loaded - > section = yon_char_new ( section ) ;
loaded - > data = value ;
loaded - > data = yon_char_new ( value ) ;
} else {
} else {
loaded - > next = ( struct loaded_config * ) malloc ( sizeof ( struct loaded_config ) ) ;
loaded - > next = ( struct loaded_config * ) malloc ( sizeof ( struct loaded_config ) ) ;
struct loaded_config * next = loaded - > next ;
struct loaded_config * next = loaded - > next ;
next - > first = loaded - > first ;
next - > first = loaded - > first ;
next - > prev = loaded ;
next - > prev = loaded ;
next - > key = key ;
next - > key = yon_char_new ( key ) ;
next - > first = loaded - > first ;
next - > first = loaded - > first ;
next - > next = NULL ;
next - > next = NULL ;
next - > section = NULL ;
next - > section = yon_char_new ( section ) ;
next - > data = value ;
next - > data = yon_char_new ( value ) ;
loaded = next ;
loaded = next ;
}
}
if ( ! yon_char_is_empty ( value ) ) free ( value ) ;
if ( ! yon_char_is_empty ( key ) ) free ( key ) ;
if ( ! yon_char_is_empty ( section ) ) free ( section ) ;
}
}
return loaded ;
return loaded ;
}
}
@ -464,7 +491,7 @@ struct loaded_config *yon_config_get_compared(char *command){
if ( config & & size > 0 ) {
if ( config & & size > 0 ) {
for ( int i = 0 ; i < size ; i + + ) {
for ( int i = 0 ; i < size ; i + + ) {
if ( ! yon_char_is_empty ( config [ i ] ) & & strcmp ( config [ i ] , " (null) \n " ) ) {
if ( ! yon_char_is_empty ( config [ i ] ) & & strcmp ( config [ i ] , " (null) \n " ) ) {
if ( config [ i ] [ strlen ( config [ i ] ) - 1 ] = = ' \n ' ) config [ i ] [ strlen ( config [ i ] ) - 1 ] = ' \0 ' ;
yon_char_remove_last_symbol ( config [ i ] , ' \n ' ) ;
yon_char_parsed_add_or_create_if_exists ( temporary , & temp_size , config [ i ] ) ;
yon_char_parsed_add_or_create_if_exists ( temporary , & temp_size , config [ i ] ) ;
}
}
}
}
@ -473,17 +500,17 @@ struct loaded_config *yon_config_get_compared(char *command){
if ( ! temporary ) return NULL ;
if ( ! temporary ) return NULL ;
struct loaded_config * loaded = yon_config_convert_parameter ( temporary , temp_size ) ;
struct loaded_config * loaded = yon_config_convert_parameter ( temporary , temp_size ) ;
int parsed_size ;
// int parsed_size;
config_str parsed_command = yon_char_parse ( command , & parsed_size , " ; " ) ;
// config_str parsed_command = yon_char_parse(command,&parsed_size,";");
dictionary * sections = NULL ;
// dictionary *sections = NULL;
for ( int i = 0 ; i < parsed_size ; i + + ) {
// for (int i=0;i<parsed_size;i++){
int dull_size ;
// int dull_size;
yon_dictionary_add_or_create_if_exists_with_data ( sections , yon_command_get_section ( parsed_command [ i ] ) , yon_command_get_parameters ( command , & dull_size ) ) ;
// yon_dictionary_add_or_create_if_exists_with_data(sections,yon_command_get_section(parsed_command[i]),yon_command_get_parameters(command,&dull_size));
}
// }
yon_loaded_config_set_sections_from_sections_dictionary ( loaded , sections ) ;
// yon_loaded_config_set_sections_from_sections_dictionary(loaded,sections);
yon_dictionary_free_all ( sections , free ) ;
// yon_dictionary_free_all(sections,free);
return loaded ;
return loaded ;
}
}
@ -543,7 +570,7 @@ void on_save_parameters(GtkWidget *self, template_saving_window *window){
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 ) ;
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 ) ;
yon_config_parameter_prepare_elements ( commands , & size ) ;
char * final_command = yon_char_parsed_to_string ( commands , size , " ; " ) ;
char * final_command = yon_char_parsed_to_string ( commands , size , " " ) ;
char * new_str_closed = yon_char_replace ( final_command , " \n " , " \\ n " ) ;
char * new_str_closed = yon_char_replace ( final_command , " \n " , " \\ n " ) ;
if ( presave_function )
if ( presave_function )