diff --git a/source/libublsettings.c b/source/libublsettings.c index c7dc8be..f3213c4 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -878,6 +878,37 @@ char *yon_char_parsed_to_string(config_str parsed, int size, char *divider_repla } else if (size==0&&!parsed) return ""; } +char *yon_char_parsed_to_string_for_iters(config_str parsed, int size, char *divider_replace,int iterations){ + if (parsed && size>0&& iterations>0){ + char *final_string = ""; + char *temp; + for (int i=0;ipos){ + config_str new_parsed = malloc(sizeof(char*)*pos); + for (int i=0;i5){ - for (int j=5;jget_place+2){ + for (int j=get_place+2;jload_command=config_load; int size=0; config_str section = yon_char_parse(config_load,&size," "); - __yon__config__strings->section=yon_char_new(section[4]); + __yon__config__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__strings,key))){ @@ -1700,7 +1735,7 @@ void yon_config_register(char *key, char *config_load, void *data){ } int size=0; config_str section = yon_char_parse(config_load,&size," "); - current->section=yon_char_new(section[4]); + current->section=yon_char_new(section[yon_char_parsed_check_exist(section,size,"get")+1]); yon_char_parsed_free(section,size); } } @@ -1711,7 +1746,7 @@ void yon_config_register(char *key, char *config_load, void *data){ current->load_command=config_load; int size=0; config_str section = yon_char_parse(config_load,&size," "); - current->section=yon_char_new(section[4]); + 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__strings||!(current=(yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key))){ @@ -1737,7 +1772,7 @@ void yon_config_register(char *key, char *config_load, void *data){ __yon__config__strings->load_command=config_load; int size=0; config_str section = yon_char_parse(config_load,&size," "); - __yon__config__strings->section=yon_char_new(section[4]); + __yon__config__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__strings,key))){ @@ -1753,7 +1788,7 @@ void yon_config_register(char *key, char *config_load, void *data){ } int size=0; config_str section = yon_char_parse(config_load,&size," "); - current->section=yon_char_new(section[4]); + current->section=yon_char_new(section[yon_char_parsed_check_exist(section,size,"get")+1]); yon_char_parsed_free(section,size); } } @@ -2038,29 +2073,31 @@ char *yon_config_parameter_prepare_command(char *command, char *path, char *sect if (!yon_char_is_empty(command)){ int size=0; config_str parsed = yon_char_parse(command,&size," "); + int source_pos=yon_char_parsed_check_exist(parsed,size,"--source"); + int get_pos = yon_char_parsed_check_exist(parsed,size,"get"); if (path&&!strcmp(path,"")){ - if (size>4&&!strcmp(parsed[1],"--source")){ - free(parsed[1]); - parsed[1]=yon_char_new(""); - free(parsed[2]); - parsed[2]=yon_char_new(""); + if (source_pos>-1&&size>source_pos+1){ + free(parsed[source_pos]); + parsed[source_pos]=yon_char_new(""); + free(parsed[source_pos+1]); + parsed[source_pos+1]=yon_char_new(""); } } else if (path){ - if (size>4&&!strcmp(parsed[1],"--source")){ - free(parsed[2]); - parsed[2]=yon_char_new(path); + if (source_pos>-1&&size>source_pos+1){ + free(parsed[source_pos+1]); + parsed[source_pos+1]=yon_char_new(path); } } if (section){ - if (size>4){ - free(parsed[4]); - parsed[4]=yon_char_new(section); + if (size>get_pos+2){ + free(parsed[get_pos+1]); + parsed[get_pos+1]=yon_char_new(section); } } if (parameter){ - if (size>5){ - free(parsed[5]); - parsed[5] = yon_char_new(parameter); + if (size>get_pos+3){ + free(parsed[get_pos+2]); + parsed[get_pos+2] = yon_char_new(parameter); } } char *final = yon_char_parsed_to_string(parsed,size," "); diff --git a/source/libublsettings.h b/source/libublsettings.h index dcc84a8..6004abc 100644 --- a/source/libublsettings.h +++ b/source/libublsettings.h @@ -527,6 +527,9 @@ dictionary *yon_char_parsed_convert_copy_to_dictionary(config_str parsed, int si char *yon_char_parsed_to_string(config_str parsed, int size, char *divider_replace); +char *yon_char_parsed_to_string_for_iters(config_str parsed, int size, char *divider_replace,int iterations); + +config_str yonchar_parsed_cut(config_str *parsed, int size, int pos); /**yon_ubl_check_root() * [EN] *