|
|
|
|
@ -809,6 +809,7 @@ typedef struct yon_config_parameter
|
|
|
|
|
DICT_TYPE data_type;
|
|
|
|
|
int flag1;
|
|
|
|
|
char *section;
|
|
|
|
|
int ignore;
|
|
|
|
|
} yon_config_parameter;
|
|
|
|
|
|
|
|
|
|
yon_config_parameter *yon_config_parameter_new_with_data(char *key, void *data){
|
|
|
|
|
@ -821,6 +822,7 @@ yon_config_parameter *yon_config_parameter_new_with_data(char *key, void *data){
|
|
|
|
|
param->next=NULL;
|
|
|
|
|
param->prev=NULL;
|
|
|
|
|
param->section=NULL;
|
|
|
|
|
param->ignore=0;
|
|
|
|
|
return param;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -834,11 +836,23 @@ yon_config_parameter *yon_config_parameter_append_with_data(yon_config_parameter
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static yon_config_parameter *__yon__config__strings = NULL;
|
|
|
|
|
dictionary *__yon_config_ignored = NULL;
|
|
|
|
|
#define check_config if(__yon__config__strings&&__yon__config__strings->data_type==DICTIONARY_CHAR_TYPE)
|
|
|
|
|
#define for_config dictionary *temp = NULL; for_dictionaries(temp,(dictionary*)__yon__config__strings)
|
|
|
|
|
#define yon_config_parameter_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_config_parameter_new_with_data(key,data); \
|
|
|
|
|
else dict=yon_config_parameter_append_with_data(dict,key,data);}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int yon_config_set_ignore(char *key){
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(__yon_config_ignored,key,NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int yon_config_check_ignore(char *key){
|
|
|
|
|
dictionary *dict = yon_dictionary_get(&__yon_config_ignored,key);
|
|
|
|
|
if (dict) return 1;
|
|
|
|
|
else return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *parameter, ...){
|
|
|
|
|
if (__yon__config__strings){
|
|
|
|
|
__yon__config__strings = yon_dictionary_free_all((dictionary*)__yon__config__strings,NULL);
|
|
|
|
|
@ -964,6 +978,23 @@ void *yon_config_get_all_by_key(char *key, int *size){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void *yon_config_get_all_by_key_no_ignored(char *key, int *size){
|
|
|
|
|
check_config{
|
|
|
|
|
(*size)=0;
|
|
|
|
|
config_str ret_data=NULL;
|
|
|
|
|
dictionary *dict = NULL;
|
|
|
|
|
for_dictionaries(dict, (dictionary*)__yon__config__strings){
|
|
|
|
|
if (strstr(dict->key,key)&&((yon_config_parameter*)dict)->flag1!=-1&&yon_config_check_ignore(dict->key)==0) {
|
|
|
|
|
char *ret_string = yon_char_unite(dict->key,"=",(char*)dict->data,NULL);
|
|
|
|
|
if (ret_data) ret_data = yon_char_parsed_append(ret_data,size,ret_string);
|
|
|
|
|
else ret_data = yon_char_parsed_new(size,ret_string,NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ret_data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config_str yon_config_get_all_keys(int *size){
|
|
|
|
|
check_config{
|
|
|
|
|
*size=0;
|
|
|
|
|
@ -977,6 +1008,21 @@ config_str yon_config_get_all_keys(int *size){
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config_str yon_config_get_all_keys_no_ignored(int *size){
|
|
|
|
|
check_config{
|
|
|
|
|
*size=0;
|
|
|
|
|
config_str final = NULL;
|
|
|
|
|
for_config{
|
|
|
|
|
if (yon_config_check_ignore(temp->key)){
|
|
|
|
|
if (!final) final = yon_char_parsed_new(size,temp->key,NULL);
|
|
|
|
|
else final = yon_char_parsed_append(final,size,temp->key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return final;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int yon_config_set(char *key, void *data){
|
|
|
|
|
check_config{
|
|
|
|
|
yon_config_parameter *dict = (yon_config_parameter*)yon_dictionary_get((dictionary**)&__yon__config__strings,key);
|
|
|
|
|
@ -1129,6 +1175,25 @@ config_str yon_config_get_all(int *size){
|
|
|
|
|
} else return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
config_str yon_config_get_all_no_ignored(int *size){
|
|
|
|
|
check_config{
|
|
|
|
|
*size = 1;
|
|
|
|
|
config_str conf = NULL;
|
|
|
|
|
dictionary *dict = NULL;
|
|
|
|
|
for_dictionaries(dict,(dictionary*)__yon__config__strings){
|
|
|
|
|
if (yon_config_check_ignore(dict->key)==0){
|
|
|
|
|
conf = yon_remalloc(conf,sizeof(char*)*(*size));
|
|
|
|
|
conf[(*size)-1] = yon_char_unite(dict->key,"=",(char*)dict->data,NULL);
|
|
|
|
|
(*size)++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
conf = yon_remalloc(conf,sizeof(char*)*(*size));
|
|
|
|
|
conf[*size-1] = NULL;
|
|
|
|
|
(*size)=(*size)-1;
|
|
|
|
|
return conf;
|
|
|
|
|
} else return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *yon_config_get_parameter(config_str parameters, int size, char *param)
|
|
|
|
|
{
|
|
|
|
|
if (param[0]==' ')
|
|
|
|
|
|