|
|
|
@ -18,7 +18,7 @@ typedef struct yon_config_parameter
|
|
|
|
|
|
|
|
|
|
|
|
yon_config_parameter *yon_config_parameter_new_with_data(char *key, void *data){
|
|
|
|
yon_config_parameter *yon_config_parameter_new_with_data(char *key, void *data){
|
|
|
|
yon_config_parameter *param = yon_remalloc(NULL,sizeof(yon_config_parameter));
|
|
|
|
yon_config_parameter *param = yon_remalloc(NULL,sizeof(yon_config_parameter));
|
|
|
|
param->data=data;
|
|
|
|
param->data=yon_char_new(data);
|
|
|
|
param->data_type=DICTIONARY_CHAR_TYPE;
|
|
|
|
param->data_type=DICTIONARY_CHAR_TYPE;
|
|
|
|
param->first=param;
|
|
|
|
param->first=param;
|
|
|
|
param->flag1=1;
|
|
|
|
param->flag1=1;
|
|
|
|
@ -149,6 +149,17 @@ int yon_config_check_ignore(char *key){
|
|
|
|
else return 0;
|
|
|
|
else return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int yon_config_check_default(char *key){
|
|
|
|
|
|
|
|
check_default_config{
|
|
|
|
|
|
|
|
for_default_config{
|
|
|
|
|
|
|
|
if (!strcmp(temp->key,key)){
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int yon_config_load_register_no_cleaning(YON_CONFIG_TYPE config_type,char *section,char *parameter, ...){
|
|
|
|
int yon_config_load_register_no_cleaning(YON_CONFIG_TYPE config_type,char *section,char *parameter, ...){
|
|
|
|
if (config_type!=YON_CONFIG_BOTH){
|
|
|
|
if (config_type!=YON_CONFIG_BOTH){
|
|
|
|
va_list args;
|
|
|
|
va_list args;
|
|
|
|
@ -280,6 +291,24 @@ int yon_config_command_prepare(config_str *commands, int *commands_size,char *co
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int yon_config_command_get_section_pos(config_str parsed, int size){
|
|
|
|
|
|
|
|
for (int i=0;i<size-1;i++){
|
|
|
|
|
|
|
|
if (!strcmp(parsed[i],"get")||!strcmp(parsed[i],"set")||!strcmp(parsed[i],"remove")){
|
|
|
|
|
|
|
|
return i+1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *yon_config_command_get_section(const char *command){
|
|
|
|
|
|
|
|
int size;
|
|
|
|
|
|
|
|
config_str parsed = yon_char_parse((char*)command,&size," ");
|
|
|
|
|
|
|
|
int section_pos = yon_config_command_get_section_pos(parsed,size);
|
|
|
|
|
|
|
|
char *section = yon_char_new(parsed[section_pos]);
|
|
|
|
|
|
|
|
yon_char_parsed_free(parsed,size);
|
|
|
|
|
|
|
|
return section;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int yon_config_load_config(YON_CONFIG_TYPE config_type, ...){
|
|
|
|
int yon_config_load_config(YON_CONFIG_TYPE config_type, ...){
|
|
|
|
if (config_type!=YON_CONFIG_BOTH){
|
|
|
|
if (config_type!=YON_CONFIG_BOTH){
|
|
|
|
va_list args;
|
|
|
|
va_list args;
|
|
|
|
@ -412,11 +441,12 @@ int yon_config_remove_by_key(char *key){
|
|
|
|
check_config{
|
|
|
|
check_config{
|
|
|
|
dictionary *dict = yon_dictionary_get((dictionary**)&__yon__config__strings,key);
|
|
|
|
dictionary *dict = yon_dictionary_get((dictionary**)&__yon__config__strings,key);
|
|
|
|
if (dict){
|
|
|
|
if (dict){
|
|
|
|
if (!yon_dictionary_get(&__yon_config_ignored,dict->key)){
|
|
|
|
// if (!yon_dictionary_get(&__yon_config_ignored,dict->key)){
|
|
|
|
|
|
|
|
yon_config_remove_ignore(dict->key);
|
|
|
|
((yon_config_parameter*)dict)->flag1=-1;
|
|
|
|
((yon_config_parameter*)dict)->flag1=-1;
|
|
|
|
dict->data="";
|
|
|
|
dict->data="";
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
} else return 0;
|
|
|
|
// } else return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
@ -648,222 +678,201 @@ int yon_config_clean(){
|
|
|
|
else return 0;
|
|
|
|
else return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void yon_config_register(char *key, char *config_load, void *data){
|
|
|
|
enum YON_CONFIG_SAVED_TYPE yon_config_register(char *key,char *config_load, char *data){
|
|
|
|
if (!yon_char_is_empty(key)){
|
|
|
|
if (yon_char_is_empty(key)||yon_char_is_empty(config_load)) return YON_CONFIG_SAVED_ERROR;
|
|
|
|
key=yon_char_new(key);
|
|
|
|
|
|
|
|
config_load=yon_char_new(config_load);
|
|
|
|
|
|
|
|
yon_config_parameter *current = NULL;
|
|
|
|
|
|
|
|
if (data){
|
|
|
|
|
|
|
|
if (!__yon__config__strings||!(current=(yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key))){
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (__yon__config__strings){
|
|
|
|
enum YON_CONFIG_SAVED_TYPE save_type = YON_CONFIG_SAVED_NEW;
|
|
|
|
char *data_copy = yon_char_new(data);
|
|
|
|
|
|
|
|
yon_config_parameter* dict=NULL;
|
|
|
|
|
|
|
|
for_dictionaries(dict,__yon__config__strings){
|
|
|
|
|
|
|
|
if (!dict->next){
|
|
|
|
|
|
|
|
__yon__config__strings=dict;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
__yon__config__strings=yon_config_parameter_append_with_data(__yon__config__strings,key,data_copy);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
yon_config_parameter *current = NULL;
|
|
|
|
else {
|
|
|
|
check_config{
|
|
|
|
char *data_copy = yon_char_new(data);
|
|
|
|
current = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key);
|
|
|
|
__yon__config__strings=yon_config_parameter_new_with_data(key,yon_char_new(data));
|
|
|
|
if (!current){
|
|
|
|
}
|
|
|
|
yon_config_parameter_add_or_create_if_exists_with_data(__yon__config__strings,key,data);
|
|
|
|
}
|
|
|
|
current = (yon_config_parameter*)yon_dictionary_get_last((dictionary *)__yon__config__strings);
|
|
|
|
__yon__config__strings = (yon_config_parameter*)yon_dictionary_get_last((dictionary*)__yon__config__strings);
|
|
|
|
} else if (!yon_char_is_empty(data)&&!strcmp((char*)current->data,(char*)data)){
|
|
|
|
__yon__config__strings->flag1=1;
|
|
|
|
save_type=YON_CONFIG_SAVED_EXIST;
|
|
|
|
__yon__config__strings->data_type=DICTIONARY_CHAR_TYPE;
|
|
|
|
return save_type;
|
|
|
|
__yon__config__strings->load_command=config_load;
|
|
|
|
|
|
|
|
if (yon_dictionary_get(&__yon_config_ignored, key)){
|
|
|
|
|
|
|
|
__yon_config_ignored = yon_dictionary_rip(__yon_config_ignored);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int size=0;
|
|
|
|
|
|
|
|
config_str section = yon_char_parse(config_load,&size," ");
|
|
|
|
|
|
|
|
__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))){
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if ((current = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__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__strings||!(current=(yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key))){
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (__yon__config__strings){
|
|
|
|
|
|
|
|
yon_config_parameter* dict=NULL;
|
|
|
|
|
|
|
|
for_dictionaries(dict,__yon__config__strings){
|
|
|
|
|
|
|
|
if (!dict->next){
|
|
|
|
|
|
|
|
__yon__config__strings=dict;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
__yon__config__strings=yon_config_parameter_append_with_data(__yon__config__strings,key,NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
__yon__config__strings=yon_config_parameter_new_with_data(key,NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
yon_config_set_ignore(key);
|
|
|
|
|
|
|
|
__yon__config__strings = (yon_config_parameter*)yon_dictionary_get_last((dictionary*)__yon__config__strings);
|
|
|
|
|
|
|
|
__yon__config__strings->flag1=0;
|
|
|
|
|
|
|
|
__yon__config__strings->data_type=DICTIONARY_CHAR_TYPE;
|
|
|
|
|
|
|
|
__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[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))){
|
|
|
|
|
|
|
|
if ((current->data&&data!=__yon__config__strings->data&&strcmp(__yon__config__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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
yon_config_parameter_add_or_create_if_exists_with_data(__yon__config__strings,key,data);
|
|
|
|
|
|
|
|
current = __yon__config__strings;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yon_config_parameter *default_parameter = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__default__strings,key);
|
|
|
|
|
|
|
|
if (default_parameter){
|
|
|
|
|
|
|
|
__yon__config__default__strings = (yon_config_parameter*)yon_dictionary_rip((dictionary*)default_parameter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(current->flag1){
|
|
|
|
|
|
|
|
case -1: save_type = YON_CONFIG_SAVED_REMOVED;
|
|
|
|
|
|
|
|
case 1: save_type = YON_CONFIG_SAVED_CHANGED;
|
|
|
|
|
|
|
|
default: save_type = YON_CONFIG_SAVED_NEW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
config_load = yon_char_new(config_load);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
current->data_type=DICTIONARY_CHAR_TYPE;
|
|
|
|
|
|
|
|
current->load_command = config_load;
|
|
|
|
|
|
|
|
current->section = yon_config_command_get_section(config_load);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data){
|
|
|
|
|
|
|
|
yon_config_remove_ignore(key);
|
|
|
|
|
|
|
|
current->flag1=1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
yon_config_set_ignore(key);
|
|
|
|
|
|
|
|
current->flag1 = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return save_type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void yon_config_register_default(char *key, char *config_load, void *data){
|
|
|
|
enum YON_CONFIG_SAVED_TYPE yon_config_register_default(char *key,char *config_load, char *data){
|
|
|
|
if (!yon_char_is_empty(key)){
|
|
|
|
if (yon_char_is_empty(key)||yon_char_is_empty(config_load)) return YON_CONFIG_SAVED_ERROR;
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
enum YON_CONFIG_SAVED_TYPE save_type = YON_CONFIG_SAVED_NEW;
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
yon_config_parameter *current = NULL;
|
|
|
|
else {
|
|
|
|
check_default_config{
|
|
|
|
__yon__config__default__strings=yon_config_parameter_new_with_data(key,NULL);
|
|
|
|
current = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__default__strings,key);
|
|
|
|
}
|
|
|
|
if (!current){
|
|
|
|
}
|
|
|
|
yon_config_parameter_add_or_create_if_exists_with_data(__yon__config__default__strings,key,data);
|
|
|
|
yon_config_set_ignore(key);
|
|
|
|
current = (yon_config_parameter*)yon_dictionary_get_last((dictionary *)__yon__config__default__strings);
|
|
|
|
__yon__config__default__strings = (yon_config_parameter*)yon_dictionary_get_last((dictionary*)__yon__config__default__strings);
|
|
|
|
} else if (!yon_char_is_empty(data)&&!strcmp((char*)current->data,(char*)data)){
|
|
|
|
__yon__config__default__strings->flag1=0;
|
|
|
|
save_type=YON_CONFIG_SAVED_EXIST;
|
|
|
|
__yon__config__default__strings->data_type=DICTIONARY_CHAR_TYPE;
|
|
|
|
return save_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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
yon_config_parameter_add_or_create_if_exists_with_data(__yon__config__default__strings,key,data);
|
|
|
|
|
|
|
|
current = __yon__config__default__strings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(current->flag1){
|
|
|
|
|
|
|
|
case -1: save_type = YON_CONFIG_SAVED_REMOVED;
|
|
|
|
|
|
|
|
case 1: save_type = YON_CONFIG_SAVED_CHANGED;
|
|
|
|
|
|
|
|
default: save_type = YON_CONFIG_SAVED_NEW;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
config_load = yon_char_new(config_load);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
current->data_type=DICTIONARY_CHAR_TYPE;
|
|
|
|
|
|
|
|
current->load_command = config_load;
|
|
|
|
|
|
|
|
current->section = yon_config_command_get_section(config_load);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data){
|
|
|
|
|
|
|
|
yon_config_remove_ignore(key);
|
|
|
|
|
|
|
|
current->flag1=1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
yon_config_set_ignore(key);
|
|
|
|
|
|
|
|
current->flag1 = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return save_type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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){
|
|
|
|
config_str yon_config_load(char *command, int *str_len){
|
|
|
|
FILE *output = popen(command, "r");
|
|
|
|
FILE *output = popen(command, "r");
|
|
|
|
char **output_strings = NULL;
|
|
|
|
char **output_strings = NULL;
|
|
|
|
|