|
|
|
@ -214,6 +214,7 @@ dictionary *yon_dictionary_new_with_data(char *key, void *data)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void *yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipulation)(void*)){
|
|
|
|
void *yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipulation)(void*)){
|
|
|
|
|
|
|
|
if (dictionary_to_free){
|
|
|
|
dictionary *dict=NULL;
|
|
|
|
dictionary *dict=NULL;
|
|
|
|
for_dictionaries(dict,dictionary_to_free){
|
|
|
|
for_dictionaries(dict,dictionary_to_free){
|
|
|
|
if(data_manipulation)
|
|
|
|
if(data_manipulation)
|
|
|
|
@ -223,6 +224,7 @@ void *yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipul
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(dict);
|
|
|
|
free(dict);
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data)
|
|
|
|
dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data)
|
|
|
|
@ -711,6 +713,18 @@ dictionary *yon_char_parsed_convert_copy_to_dictionary(config_str parsed, int si
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *yon_char_parsed_to_string(config_str parsed, int size, char *divider_replace){
|
|
|
|
|
|
|
|
if (parsed && size>0){
|
|
|
|
|
|
|
|
char *final_string = "";
|
|
|
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
|
|
|
yon_char_unite(final_string,yon_char_is_empty(final_string)?"":divider_replace,parsed[i],NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!yon_char_is_empty(final_string)){
|
|
|
|
|
|
|
|
return final_string;
|
|
|
|
|
|
|
|
} else return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int yon_ubl_check_root(){
|
|
|
|
int yon_ubl_check_root(){
|
|
|
|
if (getuid()==0) return 1;
|
|
|
|
if (getuid()==0) return 1;
|
|
|
|
else return 0;
|
|
|
|
else return 0;
|
|
|
|
@ -968,24 +982,40 @@ int yon_config_remove_by_key(char *key){
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int yon_config_remove_element(char *key, char *deleted){
|
|
|
|
int yon_config_remove_element(char *key, char *delete, char *divider){
|
|
|
|
check_config{
|
|
|
|
check_config{
|
|
|
|
|
|
|
|
int found = 0;
|
|
|
|
yon_config_parameter *dict = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key);
|
|
|
|
yon_config_parameter *dict = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key);
|
|
|
|
char *data = (char*)dict->data;
|
|
|
|
if (dict){
|
|
|
|
char *found = strstr(data,deleted);
|
|
|
|
int size;
|
|
|
|
int size=strlen(data)-strlen(found)+1;
|
|
|
|
config_str parsed = yon_char_parse((char*)dict->data,&size,divider);
|
|
|
|
char *new_data = malloc(size);
|
|
|
|
config_str final = NULL;
|
|
|
|
memset(new_data,0,size);
|
|
|
|
for(int i=0;i<size;i++){
|
|
|
|
if (strlen(found)!=strlen(deleted)){
|
|
|
|
if (!strcmp(parsed[i],delete)){
|
|
|
|
memcpy(new_data,data,size-1);
|
|
|
|
parsed = yon_char_parsed_rip(parsed,&size,i--);
|
|
|
|
new_data = yon_char_append(new_data,found+strlen(deleted)+1);
|
|
|
|
found = 1;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
memcpy(new_data,data,size-2);
|
|
|
|
|
|
|
|
new_data = yon_char_append(new_data,found+strlen(deleted));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dict->data=(void*)(new_data);
|
|
|
|
}
|
|
|
|
dict->flag1=1;
|
|
|
|
char *final_string = yon_char_parsed_to_string(parsed,size,divider);
|
|
|
|
|
|
|
|
if (final_string){
|
|
|
|
|
|
|
|
free(dict->data);
|
|
|
|
|
|
|
|
dict->data=final_string;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
} else return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int yon_config_append_element(char *key, char *append, char *divider){
|
|
|
|
|
|
|
|
check_config{
|
|
|
|
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
yon_config_parameter *dict = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key);
|
|
|
|
|
|
|
|
if (dict){
|
|
|
|
|
|
|
|
yon_char_unite((char*)dict->data,divider,append,NULL);
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else return 0;
|
|
|
|
} else return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1175,14 +1205,18 @@ int yon_config_save_registered(char *path){
|
|
|
|
for_dictionaries(dct,sections_add){
|
|
|
|
for_dictionaries(dct,sections_add){
|
|
|
|
char *command = yon_dictionary_get_data(dct,char*);
|
|
|
|
char *command = yon_dictionary_get_data(dct,char*);
|
|
|
|
yon_launch(command);
|
|
|
|
yon_launch(command);
|
|
|
|
|
|
|
|
yon_dictionary_free_all(sections_add,free);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sections_remove)
|
|
|
|
if (sections_remove)
|
|
|
|
for_dictionaries(dct,sections_remove){
|
|
|
|
for_dictionaries(dct,sections_remove){
|
|
|
|
char *command = yon_dictionary_get_data(dct,char*);
|
|
|
|
char *command = yon_dictionary_get_data(dct,char*);
|
|
|
|
yon_launch(command);
|
|
|
|
yon_launch(command);
|
|
|
|
|
|
|
|
yon_dictionary_free_all(sections_remove,free);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sections_add||sections_remove)
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
} else return 1;
|
|
|
|
else return 0;
|
|
|
|
|
|
|
|
} else return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int yon_config_force_save_registered(char *path){
|
|
|
|
int yon_config_force_save_registered(char *path){
|
|
|
|
|