|
|
|
|
@ -332,6 +332,71 @@ dictionary *yon_dictionary_get_nth(dictionary *dict, int place)
|
|
|
|
|
} else return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dictionary *yon_dictionary_sort(dictionary *dict){
|
|
|
|
|
dictionary *first = dict->first;
|
|
|
|
|
dictionary *prev = first;
|
|
|
|
|
dictionary *current = first->next;
|
|
|
|
|
while (current){
|
|
|
|
|
if (current!=prev&&strcmp(current->key,prev->key)<0){
|
|
|
|
|
if (current->next)
|
|
|
|
|
current->next->prev=prev;
|
|
|
|
|
prev->next=current->next;
|
|
|
|
|
current->next=prev;
|
|
|
|
|
current->prev=prev->prev;
|
|
|
|
|
if (prev->prev)
|
|
|
|
|
prev->prev->next=current;
|
|
|
|
|
prev->prev=current;
|
|
|
|
|
if (prev==prev->first){
|
|
|
|
|
yon_dictionary_make_first(current);
|
|
|
|
|
}
|
|
|
|
|
dictionary *temp = prev;
|
|
|
|
|
prev = current;
|
|
|
|
|
current=temp;
|
|
|
|
|
}
|
|
|
|
|
prev=prev->next;
|
|
|
|
|
current = current->next;
|
|
|
|
|
}
|
|
|
|
|
return first;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int _yon_dictionary_check_loops(dictionary *_REG_DICT,dictionary *link){
|
|
|
|
|
if (_REG_DICT){
|
|
|
|
|
dictionary *dict;
|
|
|
|
|
for_dictionaries(dict,_REG_DICT){
|
|
|
|
|
if (dict->data==link){
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dictionary *yon_dictionary_check_loops(dictionary *target){
|
|
|
|
|
dictionary *found = NULL;
|
|
|
|
|
dictionary *dict;
|
|
|
|
|
for_dictionaries(dict,target){
|
|
|
|
|
if (_yon_dictionary_check_loops(found,dict)){
|
|
|
|
|
return dict;
|
|
|
|
|
} else {
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(found,NULL,dict);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
yon_dictionary_free_all(found,NULL);
|
|
|
|
|
|
|
|
|
|
found = NULL;
|
|
|
|
|
dict=yon_dictionary_get_last(target);
|
|
|
|
|
for(;dict;dict=dict->prev){
|
|
|
|
|
if (_yon_dictionary_check_loops(found,dict)){
|
|
|
|
|
return dict;
|
|
|
|
|
} else {
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(found,NULL,dict);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
yon_dictionary_free_all(found,NULL);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// char functions
|
|
|
|
|
|
|
|
|
|
int yon_char_find_last(char *source, char find){
|
|
|
|
|
@ -858,7 +923,7 @@ config_str yon_dir_get_contents(char *dir_path, int *size){
|
|
|
|
|
|
|
|
|
|
config_str yon_dir_get_by_mask(char *path, char *mask, int *size){
|
|
|
|
|
(*size)=0;
|
|
|
|
|
if (yon_char_find_count(mask,"*")<=1){
|
|
|
|
|
if (yon_char_count(mask,"*")<=1){
|
|
|
|
|
char *lpart;
|
|
|
|
|
char *rpart=yon_char_new(mask);
|
|
|
|
|
lpart = yon_char_divide_search(rpart,"*",-1);
|
|
|
|
|
|