@ -1417,7 +1417,8 @@ int yon_config_load_config(YON_CONFIG_TYPE config_type, ...){
int command_parsed_size = 0 ;
config_str command_parsed = yon_char_parse ( command [ i ] , & command_parsed_size , " " ) ;
if ( config_type = = YON_CONFIG_DEFAULT & & ! strstr ( command_parsed [ 5 ] , " [*] " ) ) {
yon_config_register ( command_parsed [ 5 ] , command [ i ] , NULL ) ;
if ( config_type = = YON_CONFIG_DEFAULT )
yon_config_register_default ( command_parsed [ 5 ] , command [ i ] , NULL ) ;
}
yon_char_parsed_free ( command_parsed , command_parsed_size ) ;
if ( parsed_size > 0 ) {
@ -1432,7 +1433,10 @@ int yon_config_load_config(YON_CONFIG_TYPE config_type, ...){
char * cur_data = config ( key ) ;
int cur_ignore = yon_config_check_ignore ( key ) ;
if ( ( cur_ignore & & current_value ) | | ( ! cur_ignore ) )
yon_config_register ( key , current_command , current_value ) ;
if ( config_type = = YON_CONFIG_DEFAULT )
yon_config_register_default ( key , current_command , current_value ) ;
else
yon_config_register ( key , current_command , current_value ) ;
if ( config_type = = YON_CONFIG_DEFAULT ) {
yon_config_set_ignore ( key ) ;
yon_config_set_status ( key , - 2 ) ;
@ -1466,14 +1470,14 @@ int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *par
char * command = NULL ;
dictionary * dict ;
for_dictionaries ( dict , sections ) {
command = yon_char_unite ( ubconfig_load_command_old , config_type = = YON_CONFIG_GLOBAL ? " global get " : config_type = = YON_CONFIG_LOCAL ? " system get " : " default get " , dict - > key , " " , yon_dictionary_get_data ( dict , char * ) , NULL ) ;
command = yon_char_unite ( ubconfig_load_command_old , config_type = = YON_CONFIG_GLOBAL ? " global get " : config_type = = YON_CONFIG_LOCAL ? " system get " : " default get " , dict - > key , " " , yon_dictionary_get_data ( dict , char * ) , NULL ) ;
FILE * output = popen ( command , " r " ) ;
int i = 0 ;
char str [ 4096 ] ;
memset ( str , 0 , 4096 ) ;
while ( fgets ( str , 4096 , output ) )
{
if ( ! yon_char_is_empty ( str ) & & strcmp ( str , " (null) \n " ) ! = 0 )
if ( strcmp ( str , " " ) ! = 0 & & strcmp ( str , " (null) \n " ) ! = 0 )
{
char * key = yon_char_divide_search ( str , " = " , - 1 ) ;
char * final_str = yon_char_divide_search ( str , " \n " , - 1 ) ;
@ -1482,24 +1486,25 @@ int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *par
free ( yon_char_divide ( final_str , 0 ) ) ;
}
dictionary * dicte = yon_dictionary_get ( ( dictionary * * ) & __yon__config__strings , key ) ;
yon_config_parameter * cur_config = ( config_type ! = YON_CONFIG_DEFAULT ? __yon__config__strings : __yon__config__default__strings ) ;
dictionary * dicte = yon_dictionary_get ( ( dictionary * * ) & cur_config , key ) ;
if ( ! dicte ) {
yon_config_parameter_add_or_create_if_exists_with_data ( __yon__config__strings , key , yon_char_new ( final_str ) ) ;
yon_config_parameter_add_or_create_if_exists_with_data ( cur_config , key , yon_char_new ( final_str ) ) ;
} else {
if ( strcmp ( ( char * ) __yon__config__strings - > data , final_str ) ) {
__yon__config__strings - > data = final_str ;
if ( strcmp ( ( char * ) dicte - > data , final_str ) ) {
cur_config - > data = final_str ;
} else {
continue ;
}
}
__yon__config__strings - > flag1 = 0 ;
cur_config - > flag1 = 0 ;
yon_config_remove_ignore ( key ) ;
if ( config_type = = YON_CONFIG_DEFAULT ) {
__yon__config__strings - > flag1 = - 2 ;
cur_config - > flag1 = - 2 ;
yon_config_set_ignore ( key ) ;
}
__yon__config__strings - > data_type = DICTIONARY_CHAR_TYPE ;
__yon__config__strings - > section = dict - > key ;
cur_config - > data_type = DICTIONARY_CHAR_TYPE ;
cur_config - > section = dict - > key ;
}
}
free ( command ) ;
@ -1786,7 +1791,9 @@ void yon_config_register(char *key, char *config_load, void *data){
}
else if ( ( current = ( yon_config_parameter * ) yon_dictionary_get ( ( dictionary * * ) & __yon__config__strings , key ) ) ) {
yon_config_parameter * cur_default = ( yon_config_parameter * ) yon_dictionary_get ( ( dictionary * * ) & __yon__config__default__strings , current - > key ) ;
if ( ( current - > data & & data ! = __yon__config__strings - > data & & strcmp ( __yon__config__strings - > data , data ) ) | | ! current - > data ) {
if ( ( cur_default & & ( ( yon_config_parameter * ) current ) - > flag1 = = 1 & & ! strcmp ( ( char * ) cur_default - > data , ( char * ) data ) ) ) {
yon_config_remove_by_key ( current - > key ) ;
} else if ( ( current - > data & & data ! = __yon__config__strings - > data & & strcmp ( __yon__config__strings - > data , data ) ) | | ! current - > data ) {
current - > data = yon_char_new ( data ) ;
current - > flag1 = 1 ;
current - > data_type = DICTIONARY_CHAR_TYPE ;
@ -1798,9 +1805,6 @@ void yon_config_register(char *key, char *config_load, void *data){
config_str section = yon_char_parse ( config_load , & size , " " ) ;
current - > section = yon_char_new ( section [ yon_char_parsed_check_exist ( section , size , " get " ) + 1 ] ) ;
yon_char_parsed_free ( section , size ) ;
if ( ! cur_default | | ( cur_default & & strcmp ( ( char * ) cur_default - > data , ( char * ) current - > data ) ) ) {
yon_config_remove_by_key ( current - > key ) ;
}
}
}
} else if ( ( current = ( yon_config_parameter * ) yon_dictionary_get ( ( dictionary * * ) & __yon__config__strings , key ) ) ) {
@ -1860,6 +1864,115 @@ void yon_config_register(char *key, char *config_load, void *data){
}
}
void yon_config_register_default ( char * key , char * config_load , void * data ) {
if ( ! yon_char_is_empty ( key ) ) {
key = yon_char_new ( key ) ;
config_load = yon_char_new ( config_load ) ;
yon_config_parameter * current = NULL ;
if ( data ) {
if ( ! __yon__config__default__strings | | ! ( current = ( yon_config_parameter * ) yon_dictionary_get ( ( dictionary * * ) & __yon__config__default__strings , key ) ) ) {
{
if ( __yon__config__default__strings ) {
char * data_copy = yon_char_new ( data ) ;
yon_config_parameter * dict = NULL ;
for_dictionaries ( dict , __yon__config__default__strings ) {
if ( ! dict - > next ) {
__yon__config__default__strings = dict ;
}
}
__yon__config__default__strings = yon_config_parameter_append_with_data ( __yon__config__default__strings , key , data_copy ) ;
}
else {
char * data_copy = yon_char_new ( data ) ;
__yon__config__strings = yon_config_parameter_new_with_data ( key , yon_char_new ( data ) ) ;
}
}
__yon__config__default__strings = ( yon_config_parameter * ) yon_dictionary_get_last ( ( dictionary * ) __yon__config__default__strings ) ;
__yon__config__default__strings - > flag1 = 1 ;
__yon__config__default__strings - > data_type = DICTIONARY_CHAR_TYPE ;
__yon__config__default__strings - > load_command = config_load ;
int size = 0 ;
config_str section = yon_char_parse ( config_load , & size , " " ) ;
__yon__config__default__strings - > section = yon_char_new ( section [ yon_char_parsed_check_exist ( section , size , " get " ) + 1 ] ) ;
yon_char_parsed_free ( section , size ) ;
}
else if ( ( current = ( yon_config_parameter * ) yon_dictionary_get ( ( dictionary * * ) & __yon__config__default__strings , key ) ) ) {
yon_config_parameter * cur_default = ( yon_config_parameter * ) yon_dictionary_get ( ( dictionary * * ) & __yon__config__default__strings , current - > key ) ;
if ( ( current - > data & & data ! = __yon__config__default__strings - > data & & strcmp ( __yon__config__default__strings - > data , data ) ) | | ! current - > data ) {
current - > data = yon_char_new ( data ) ;
current - > flag1 = 1 ;
current - > data_type = DICTIONARY_CHAR_TYPE ;
current - > load_command = config_load ;
if ( yon_dictionary_get ( & __yon_config_ignored , current - > key ) ) {
__yon_config_ignored = yon_dictionary_rip ( __yon_config_ignored ) ;
}
int size = 0 ;
config_str section = yon_char_parse ( config_load , & size , " " ) ;
current - > section = yon_char_new ( section [ yon_char_parsed_check_exist ( section , size , " get " ) + 1 ] ) ;
yon_char_parsed_free ( section , size ) ;
if ( ( cur_default & & strcmp ( ( char * ) cur_default - > data , ( char * ) current - > data ) ) ) {
yon_config_remove_by_key ( current - > key ) ;
}
}
}
} else if ( ( current = ( yon_config_parameter * ) yon_dictionary_get ( ( dictionary * * ) & __yon__config__default__strings , key ) ) ) {
current - > data = NULL ;
current - > flag1 = 0 ;
current - > data_type = DICTIONARY_CHAR_TYPE ;
current - > load_command = config_load ;
int size = 0 ;
config_str section = yon_char_parse ( config_load , & size , " " ) ;
current - > section = yon_char_new ( section [ yon_char_parsed_check_exist ( section , size , " get " ) + 1 ] ) ;
yon_char_parsed_free ( section , size ) ;
} else {
if ( ! __yon__config__default__strings | | ! ( current = ( yon_config_parameter * ) yon_dictionary_get ( ( dictionary * * ) & __yon__config__default__strings , key ) ) ) {
{
if ( __yon__config__default__strings ) {
yon_config_parameter * dict = NULL ;
for_dictionaries ( dict , __yon__config__default__strings ) {
if ( ! dict - > next ) {
__yon__config__default__strings = dict ;
}
}
__yon__config__default__strings = yon_config_parameter_append_with_data ( __yon__config__default__strings , key , NULL ) ;
}
else {
__yon__config__default__strings = yon_config_parameter_new_with_data ( key , NULL ) ;
}
}
yon_config_set_ignore ( key ) ;
__yon__config__default__strings = ( yon_config_parameter * ) yon_dictionary_get_last ( ( dictionary * ) __yon__config__default__strings ) ;
__yon__config__default__strings - > flag1 = 0 ;
__yon__config__default__strings - > data_type = DICTIONARY_CHAR_TYPE ;
__yon__config__default__strings - > load_command = config_load ;
int size = 0 ;
config_str section = yon_char_parse ( config_load , & size , " " ) ;
__yon__config__default__strings - > section = yon_char_new ( section [ yon_char_parsed_check_exist ( section , size , " get " ) + 1 ] ) ;
yon_char_parsed_free ( section , size ) ;
}
else if ( ( current = ( yon_config_parameter * ) yon_dictionary_get ( ( dictionary * * ) & __yon__config__default__strings , key ) ) ) {
if ( ( current - > data & & data ! = __yon__config__default__strings - > data & & strcmp ( __yon__config__default__strings - > data , data ) ) | | ! current - > data ) {
yon_config_set_ignore ( key ) ;
current - > data = NULL ;
current - > flag1 = 0 ;
current - > data_type = DICTIONARY_CHAR_TYPE ;
current - > load_command = config_load ;
if ( yon_dictionary_get ( & __yon_config_ignored , current - > key ) ) {
__yon_config_ignored = yon_dictionary_rip ( __yon_config_ignored ) ;
}
int size = 0 ;
config_str section = yon_char_parse ( config_load , & size , " " ) ;
current - > section = yon_char_new ( section [ yon_char_parsed_check_exist ( section , size , " get " ) + 1 ] ) ;
yon_char_parsed_free ( section , size ) ;
}
}
}
}
}
config_str yon_config_load ( char * command , int * str_len ) {
FILE * output = popen ( command , " r " ) ;
char * * output_strings = NULL ;