mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-25 23:28:09 +00:00
Rename LpConfig class into LinphoneConfig
This commit is contained in:
parent
163380c454
commit
19950099c0
2 changed files with 243 additions and 185 deletions
|
|
@ -166,15 +166,15 @@ void lp_section_add_item(LpSection *sec,LpItem *item){
|
|||
sec->items=bctbx_list_append(sec->items,(void *)item);
|
||||
}
|
||||
|
||||
void lp_config_add_section(LpConfig *lpconfig, LpSection *section){
|
||||
void linphone_config_add_section(LpConfig *lpconfig, LpSection *section){
|
||||
lpconfig->sections=bctbx_list_append(lpconfig->sections,(void *)section);
|
||||
}
|
||||
|
||||
void lp_config_add_section_param(LpSection *section, LpSectionParam *param){
|
||||
void linphone_config_add_section_param(LpSection *section, LpSectionParam *param){
|
||||
section->params = bctbx_list_append(section->params, (void *)param);
|
||||
}
|
||||
|
||||
void lp_config_remove_section(LpConfig *lpconfig, LpSection *section){
|
||||
void linphone_config_remove_section(LpConfig *lpconfig, LpSection *section){
|
||||
lpconfig->sections=bctbx_list_remove(lpconfig->sections,(void *)section);
|
||||
lp_section_destroy(section);
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ static int is_a_comment(const char *str){
|
|||
return 0;
|
||||
}
|
||||
|
||||
LpSection *lp_config_find_section(const LpConfig *lpconfig, const char *name){
|
||||
LpSection *linphone_config_find_section(const LpConfig *lpconfig, const char *name){
|
||||
LpSection *sec;
|
||||
bctbx_list_t *elem;
|
||||
/*printf("Looking for section %s\n",name);*/
|
||||
|
|
@ -254,7 +254,7 @@ LpItem *lp_section_find_item(const LpSection *sec, const char *name){
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static LpSection* lp_config_parse_line(LpConfig* lpconfig, const char* line, LpSection* cur) {
|
||||
static LpSection* linphone_config_parse_line(LpConfig* lpconfig, const char* line, LpSection* cur) {
|
||||
LpSectionParam *params = NULL;
|
||||
char *pos1,*pos2;
|
||||
int nbs;
|
||||
|
|
@ -274,10 +274,10 @@ static LpSection* lp_config_parse_line(LpConfig* lpconfig, const char* line, LpS
|
|||
nbs = sscanf(pos1+1, "%s", secname);
|
||||
if (nbs >= 1) {
|
||||
if (strlen(secname) > 0) {
|
||||
cur = lp_config_find_section (lpconfig,secname);
|
||||
cur = linphone_config_find_section (lpconfig,secname);
|
||||
if (cur == NULL) {
|
||||
cur = lp_section_new(secname);
|
||||
lp_config_add_section(lpconfig, cur);
|
||||
linphone_config_add_section(lpconfig, cur);
|
||||
}
|
||||
|
||||
if (pos2 > pos1 + 1 + strlen(secname)) {
|
||||
|
|
@ -291,7 +291,7 @@ static LpSection* lp_config_parse_line(LpConfig* lpconfig, const char* line, LpS
|
|||
*pos1 = ' ';
|
||||
if (sscanf(pos2, "%s %s", key, value) == 2) {
|
||||
params = lp_section_param_new(key, value);
|
||||
lp_config_add_section_param(cur, params);
|
||||
linphone_config_add_section_param(cur, params);
|
||||
|
||||
pos2 += strlen(key) + strlen(value) + 2; // Remove the = sign + the white space after each param
|
||||
pos1 = strchr(pos2, '=');
|
||||
|
|
@ -361,22 +361,22 @@ static LpSection* lp_config_parse_line(LpConfig* lpconfig, const char* line, LpS
|
|||
return cur;
|
||||
}
|
||||
|
||||
void lp_config_parse(LpConfig *lpconfig, bctbx_vfs_file_t* pFile){
|
||||
void linphone_config_parse(LpConfig *lpconfig, bctbx_vfs_file_t* pFile){
|
||||
char tmp[MAX_LEN]= {'\0'};
|
||||
LpSection* current_section = NULL;
|
||||
int size =0;
|
||||
if (pFile==NULL) return;
|
||||
while(( size = bctbx_file_get_nxtline(pFile, tmp, MAX_LEN)) > 0){
|
||||
//tmp[size] = '\0';
|
||||
current_section = lp_config_parse_line(lpconfig, tmp, current_section);
|
||||
current_section = linphone_config_parse_line(lpconfig, tmp, current_section);
|
||||
}
|
||||
}
|
||||
|
||||
LpConfig * lp_config_new(const char *filename){
|
||||
return lp_config_new_with_factory(filename, NULL);
|
||||
LpConfig * linphone_config_new(const char *filename){
|
||||
return linphone_config_new_with_factory(filename, NULL);
|
||||
}
|
||||
|
||||
LpConfig * lp_config_new_from_buffer(const char *buffer){
|
||||
LpConfig * linphone_config_new_from_buffer(const char *buffer){
|
||||
LpConfig* conf = lp_new0(LpConfig,1);
|
||||
LpSection* current_section = NULL;
|
||||
|
||||
|
|
@ -387,7 +387,7 @@ LpConfig * lp_config_new_from_buffer(const char *buffer){
|
|||
conf->refcnt=1;
|
||||
|
||||
while( line != NULL ){
|
||||
current_section = lp_config_parse_line(conf,line,current_section);
|
||||
current_section = linphone_config_parse_line(conf,line,current_section);
|
||||
line = strtok_r(NULL, "\n", &strtok_storage);
|
||||
}
|
||||
|
||||
|
|
@ -396,7 +396,7 @@ LpConfig * lp_config_new_from_buffer(const char *buffer){
|
|||
return conf;
|
||||
}
|
||||
|
||||
LpConfig *lp_config_new_with_factory(const char *config_filename, const char *factory_config_filename) {
|
||||
LpConfig *linphone_config_new_with_factory(const char *config_filename, const char *factory_config_filename) {
|
||||
LpConfig *lpconfig=lp_new0(LpConfig,1);
|
||||
lpconfig->g_bctbx_vfs = bctbx_vfs_get_default();
|
||||
|
||||
|
|
@ -438,14 +438,14 @@ LpConfig *lp_config_new_with_factory(const char *config_filename, const char *fa
|
|||
}
|
||||
#endif
|
||||
if (lpconfig->pFile != NULL){
|
||||
lp_config_parse(lpconfig, lpconfig->pFile);
|
||||
linphone_config_parse(lpconfig, lpconfig->pFile);
|
||||
bctbx_file_close(lpconfig->pFile);
|
||||
lpconfig->pFile = NULL;
|
||||
lpconfig->modified=0;
|
||||
}
|
||||
}
|
||||
if (factory_config_filename != NULL) {
|
||||
lp_config_read_file(lpconfig, factory_config_filename);
|
||||
linphone_config_read_file(lpconfig, factory_config_filename);
|
||||
}
|
||||
return lpconfig;
|
||||
|
||||
|
|
@ -454,12 +454,12 @@ fail:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int lp_config_read_file(LpConfig *lpconfig, const char *filename){
|
||||
int linphone_config_read_file(LpConfig *lpconfig, const char *filename){
|
||||
char* path = lp_realpath(filename, NULL);
|
||||
bctbx_vfs_file_t* pFile = bctbx_file_open(lpconfig->g_bctbx_vfs, path, "r");
|
||||
if (pFile != NULL){
|
||||
ms_message("Reading config information from %s", path);
|
||||
lp_config_parse(lpconfig, pFile);
|
||||
linphone_config_parse(lpconfig, pFile);
|
||||
bctbx_file_close(pFile);
|
||||
ms_free(path);
|
||||
return 0;
|
||||
|
|
@ -476,7 +476,7 @@ void lp_item_set_value(LpItem *item, const char *value){
|
|||
}
|
||||
|
||||
|
||||
static void _lp_config_destroy(LpConfig *lpconfig){
|
||||
static void _linphone_config_destroy(LpConfig *lpconfig){
|
||||
if (lpconfig->filename!=NULL) ortp_free(lpconfig->filename);
|
||||
if (lpconfig->tmpfilename) ortp_free(lpconfig->tmpfilename);
|
||||
bctbx_list_for_each(lpconfig->sections,(void (*)(void*))lp_section_destroy);
|
||||
|
|
@ -484,25 +484,25 @@ static void _lp_config_destroy(LpConfig *lpconfig){
|
|||
free(lpconfig);
|
||||
}
|
||||
|
||||
LpConfig *lp_config_ref(LpConfig *lpconfig){
|
||||
LpConfig *linphone_config_ref(LpConfig *lpconfig){
|
||||
lpconfig->refcnt++;
|
||||
return lpconfig;
|
||||
}
|
||||
|
||||
void lp_config_unref(LpConfig *lpconfig){
|
||||
void linphone_config_unref(LpConfig *lpconfig){
|
||||
lpconfig->refcnt--;
|
||||
if (lpconfig->refcnt==0)
|
||||
_lp_config_destroy(lpconfig);
|
||||
_linphone_config_destroy(lpconfig);
|
||||
}
|
||||
|
||||
void lp_config_destroy(LpConfig *lpconfig){
|
||||
lp_config_unref(lpconfig);
|
||||
void linphone_config_destroy(LpConfig *lpconfig){
|
||||
linphone_config_unref(lpconfig);
|
||||
}
|
||||
|
||||
const char *lp_config_get_section_param_string(const LpConfig *lpconfig, const char *section, const char *key, const char *default_value){
|
||||
const char *linphone_config_get_section_param_string(const LpConfig *lpconfig, const char *section, const char *key, const char *default_value){
|
||||
LpSection *sec;
|
||||
LpSectionParam *param;
|
||||
sec = lp_config_find_section(lpconfig, section);
|
||||
sec = linphone_config_find_section(lpconfig, section);
|
||||
if (sec != NULL) {
|
||||
param = lp_section_find_param(sec, key);
|
||||
if (param != NULL) return param->value;
|
||||
|
|
@ -510,10 +510,10 @@ const char *lp_config_get_section_param_string(const LpConfig *lpconfig, const c
|
|||
return default_value;
|
||||
}
|
||||
|
||||
const char *lp_config_get_string(const LpConfig *lpconfig, const char *section, const char *key, const char *default_string){
|
||||
const char *linphone_config_get_string(const LpConfig *lpconfig, const char *section, const char *key, const char *default_string){
|
||||
LpSection *sec;
|
||||
LpItem *item;
|
||||
sec=lp_config_find_section(lpconfig,section);
|
||||
sec=linphone_config_find_section(lpconfig,section);
|
||||
if (sec!=NULL){
|
||||
item=lp_section_find_item(sec,key);
|
||||
if (item!=NULL) return item->value;
|
||||
|
|
@ -521,9 +521,9 @@ const char *lp_config_get_string(const LpConfig *lpconfig, const char *section,
|
|||
return default_string;
|
||||
}
|
||||
|
||||
bctbx_list_t * lp_config_get_string_list(const LpConfig *lpconfig, const char *section, const char *key, bctbx_list_t *default_list) {
|
||||
bctbx_list_t * linphone_config_get_string_list(const LpConfig *lpconfig, const char *section, const char *key, bctbx_list_t *default_list) {
|
||||
LpItem *item;
|
||||
LpSection *sec = lp_config_find_section(lpconfig, section);
|
||||
LpSection *sec = linphone_config_find_section(lpconfig, section);
|
||||
if (sec != NULL) {
|
||||
item = lp_section_find_item(sec, key);
|
||||
if (item != NULL) {
|
||||
|
|
@ -546,8 +546,8 @@ bctbx_list_t * lp_config_get_string_list(const LpConfig *lpconfig, const char *s
|
|||
return default_list;
|
||||
}
|
||||
|
||||
bool_t lp_config_get_range(const LpConfig *lpconfig, const char *section, const char *key, int *min, int *max, int default_min, int default_max) {
|
||||
const char *str = lp_config_get_string(lpconfig, section, key, NULL);
|
||||
bool_t linphone_config_get_range(const LpConfig *lpconfig, const char *section, const char *key, int *min, int *max, int default_min, int default_max) {
|
||||
const char *str = linphone_config_get_string(lpconfig, section, key, NULL);
|
||||
if (str != NULL) {
|
||||
char *minusptr = strchr(str, '-');
|
||||
if ((minusptr == NULL) || (minusptr == str)) {
|
||||
|
|
@ -566,8 +566,8 @@ bool_t lp_config_get_range(const LpConfig *lpconfig, const char *section, const
|
|||
}
|
||||
|
||||
|
||||
int lp_config_get_int(const LpConfig *lpconfig,const char *section, const char *key, int default_value){
|
||||
const char *str=lp_config_get_string(lpconfig,section,key,NULL);
|
||||
int linphone_config_get_int(const LpConfig *lpconfig,const char *section, const char *key, int default_value){
|
||||
const char *str=linphone_config_get_string(lpconfig,section,key,NULL);
|
||||
if (str!=NULL) {
|
||||
int ret=0;
|
||||
|
||||
|
|
@ -580,8 +580,8 @@ int lp_config_get_int(const LpConfig *lpconfig,const char *section, const char *
|
|||
else return default_value;
|
||||
}
|
||||
|
||||
int64_t lp_config_get_int64(const LpConfig *lpconfig,const char *section, const char *key, int64_t default_value){
|
||||
const char *str=lp_config_get_string(lpconfig,section,key,NULL);
|
||||
int64_t linphone_config_get_int64(const LpConfig *lpconfig,const char *section, const char *key, int64_t default_value){
|
||||
const char *str=linphone_config_get_string(lpconfig,section,key,NULL);
|
||||
if (str!=NULL) {
|
||||
#ifdef _WIN32
|
||||
return (int64_t)_atoi64(str);
|
||||
|
|
@ -592,18 +592,18 @@ int64_t lp_config_get_int64(const LpConfig *lpconfig,const char *section, const
|
|||
else return default_value;
|
||||
}
|
||||
|
||||
float lp_config_get_float(const LpConfig *lpconfig,const char *section, const char *key, float default_value){
|
||||
const char *str=lp_config_get_string(lpconfig,section,key,NULL);
|
||||
float linphone_config_get_float(const LpConfig *lpconfig,const char *section, const char *key, float default_value){
|
||||
const char *str=linphone_config_get_string(lpconfig,section,key,NULL);
|
||||
float ret=default_value;
|
||||
if (str==NULL) return default_value;
|
||||
sscanf(str,"%f",&ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool_t lp_config_get_overwrite_flag_for_entry(const LpConfig *lpconfig, const char *section, const char *key) {
|
||||
bool_t linphone_config_get_overwrite_flag_for_entry(const LpConfig *lpconfig, const char *section, const char *key) {
|
||||
LpSection *sec;
|
||||
LpItem *item;
|
||||
sec = lp_config_find_section(lpconfig, section);
|
||||
sec = linphone_config_find_section(lpconfig, section);
|
||||
if (sec != NULL){
|
||||
item = lp_section_find_item(sec, key);
|
||||
if (item != NULL) return item->overwrite;
|
||||
|
|
@ -611,19 +611,19 @@ bool_t lp_config_get_overwrite_flag_for_entry(const LpConfig *lpconfig, const ch
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
bool_t lp_config_get_overwrite_flag_for_section(const LpConfig *lpconfig, const char *section) {
|
||||
bool_t linphone_config_get_overwrite_flag_for_section(const LpConfig *lpconfig, const char *section) {
|
||||
LpSection *sec;
|
||||
sec = lp_config_find_section(lpconfig, section);
|
||||
sec = linphone_config_find_section(lpconfig, section);
|
||||
if (sec != NULL){
|
||||
return sec->overwrite;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool_t lp_config_get_skip_flag_for_entry(const LpConfig *lpconfig, const char *section, const char *key) {
|
||||
bool_t linphone_config_get_skip_flag_for_entry(const LpConfig *lpconfig, const char *section, const char *key) {
|
||||
LpSection *sec;
|
||||
LpItem *item;
|
||||
sec = lp_config_find_section(lpconfig, section);
|
||||
sec = linphone_config_find_section(lpconfig, section);
|
||||
if (sec != NULL){
|
||||
item = lp_section_find_item(sec, key);
|
||||
if (item != NULL) return item->skip;
|
||||
|
|
@ -631,18 +631,18 @@ bool_t lp_config_get_skip_flag_for_entry(const LpConfig *lpconfig, const char *s
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
bool_t lp_config_get_skip_flag_for_section(const LpConfig *lpconfig, const char *section) {
|
||||
bool_t linphone_config_get_skip_flag_for_section(const LpConfig *lpconfig, const char *section) {
|
||||
LpSection *sec;
|
||||
sec = lp_config_find_section(lpconfig, section);
|
||||
sec = linphone_config_find_section(lpconfig, section);
|
||||
if (sec != NULL){
|
||||
return sec->skip;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *key, const char *value){
|
||||
void linphone_config_set_string(LpConfig *lpconfig,const char *section, const char *key, const char *value){
|
||||
LpItem *item;
|
||||
LpSection *sec=lp_config_find_section(lpconfig,section);
|
||||
LpSection *sec=linphone_config_find_section(lpconfig,section);
|
||||
if (sec!=NULL){
|
||||
item=lp_section_find_item(sec,key);
|
||||
if (item!=NULL){
|
||||
|
|
@ -655,13 +655,13 @@ void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *ke
|
|||
}
|
||||
}else if (value!=NULL && value[0] != '\0'){
|
||||
sec=lp_section_new(section);
|
||||
lp_config_add_section(lpconfig,sec);
|
||||
linphone_config_add_section(lpconfig,sec);
|
||||
lp_section_add_item(sec,lp_item_new(key,value));
|
||||
}
|
||||
lpconfig->modified++;
|
||||
}
|
||||
|
||||
void lp_config_set_string_list(LpConfig *lpconfig, const char *section, const char *key, const bctbx_list_t *value) {
|
||||
void linphone_config_set_string_list(LpConfig *lpconfig, const char *section, const char *key, const bctbx_list_t *value) {
|
||||
char *strvalue = NULL;
|
||||
char *tmp = NULL;
|
||||
const bctbx_list_t *elem;
|
||||
|
|
@ -673,72 +673,72 @@ void lp_config_set_string_list(LpConfig *lpconfig, const char *section, const ch
|
|||
}
|
||||
else strvalue = ms_strdup((const char *)elem->data);
|
||||
}
|
||||
lp_config_set_string(lpconfig, section, key, strvalue);
|
||||
linphone_config_set_string(lpconfig, section, key, strvalue);
|
||||
if (strvalue) ms_free(strvalue);
|
||||
}
|
||||
|
||||
void lp_config_set_range(LpConfig *lpconfig, const char *section, const char *key, int min_value, int max_value) {
|
||||
void linphone_config_set_range(LpConfig *lpconfig, const char *section, const char *key, int min_value, int max_value) {
|
||||
char tmp[30];
|
||||
snprintf(tmp, sizeof(tmp), "%i-%i", min_value, max_value);
|
||||
lp_config_set_string(lpconfig, section, key, tmp);
|
||||
linphone_config_set_string(lpconfig, section, key, tmp);
|
||||
}
|
||||
|
||||
void lp_config_set_int(LpConfig *lpconfig,const char *section, const char *key, int value){
|
||||
void linphone_config_set_int(LpConfig *lpconfig,const char *section, const char *key, int value){
|
||||
char tmp[30];
|
||||
snprintf(tmp,sizeof(tmp),"%i",value);
|
||||
lp_config_set_string(lpconfig,section,key,tmp);
|
||||
linphone_config_set_string(lpconfig,section,key,tmp);
|
||||
}
|
||||
|
||||
void lp_config_set_int_hex(LpConfig *lpconfig,const char *section, const char *key, int value){
|
||||
void linphone_config_set_int_hex(LpConfig *lpconfig,const char *section, const char *key, int value){
|
||||
char tmp[30];
|
||||
snprintf(tmp,sizeof(tmp),"0x%x",value);
|
||||
lp_config_set_string(lpconfig,section,key,tmp);
|
||||
linphone_config_set_string(lpconfig,section,key,tmp);
|
||||
}
|
||||
|
||||
void lp_config_set_int64(LpConfig *lpconfig,const char *section, const char *key, int64_t value){
|
||||
void linphone_config_set_int64(LpConfig *lpconfig,const char *section, const char *key, int64_t value){
|
||||
char tmp[30];
|
||||
snprintf(tmp,sizeof(tmp),"%lli",(long long)value);
|
||||
lp_config_set_string(lpconfig,section,key,tmp);
|
||||
linphone_config_set_string(lpconfig,section,key,tmp);
|
||||
}
|
||||
|
||||
|
||||
void lp_config_set_float(LpConfig *lpconfig,const char *section, const char *key, float value){
|
||||
void linphone_config_set_float(LpConfig *lpconfig,const char *section, const char *key, float value){
|
||||
char tmp[30];
|
||||
snprintf(tmp,sizeof(tmp),"%f",value);
|
||||
lp_config_set_string(lpconfig,section,key,tmp);
|
||||
linphone_config_set_string(lpconfig,section,key,tmp);
|
||||
}
|
||||
|
||||
void lp_config_set_overwrite_flag_for_entry(LpConfig *lpconfig, const char *section, const char *key, bool_t value) {
|
||||
void linphone_config_set_overwrite_flag_for_entry(LpConfig *lpconfig, const char *section, const char *key, bool_t value) {
|
||||
LpSection *sec;
|
||||
LpItem *item;
|
||||
sec = lp_config_find_section(lpconfig, section);
|
||||
sec = linphone_config_find_section(lpconfig, section);
|
||||
if (sec != NULL) {
|
||||
item = lp_section_find_item(sec, key);
|
||||
if (item != NULL) item->overwrite = value;
|
||||
}
|
||||
}
|
||||
|
||||
void lp_config_set_overwrite_flag_for_section(LpConfig *lpconfig, const char *section, bool_t value) {
|
||||
void linphone_config_set_overwrite_flag_for_section(LpConfig *lpconfig, const char *section, bool_t value) {
|
||||
LpSection *sec;
|
||||
sec = lp_config_find_section(lpconfig, section);
|
||||
sec = linphone_config_find_section(lpconfig, section);
|
||||
if (sec != NULL) {
|
||||
sec->overwrite = value;
|
||||
}
|
||||
}
|
||||
|
||||
void lp_config_set_skip_flag_for_entry(LpConfig *lpconfig, const char *section, const char *key, bool_t value) {
|
||||
void linphone_config_set_skip_flag_for_entry(LpConfig *lpconfig, const char *section, const char *key, bool_t value) {
|
||||
LpSection *sec;
|
||||
LpItem *item;
|
||||
sec = lp_config_find_section(lpconfig, section);
|
||||
sec = linphone_config_find_section(lpconfig, section);
|
||||
if (sec != NULL) {
|
||||
item = lp_section_find_item(sec, key);
|
||||
if (item != NULL) item->skip = value;
|
||||
}
|
||||
}
|
||||
|
||||
void lp_config_set_skip_flag_for_section(LpConfig *lpconfig, const char *section, bool_t value) {
|
||||
void linphone_config_set_skip_flag_for_section(LpConfig *lpconfig, const char *section, bool_t value) {
|
||||
LpSection *sec;
|
||||
sec = lp_config_find_section(lpconfig, section);
|
||||
sec = linphone_config_find_section(lpconfig, section);
|
||||
if (sec != NULL) {
|
||||
sec->skip = value;
|
||||
}
|
||||
|
|
@ -783,7 +783,7 @@ void lp_section_write(LpSection *sec,LpConfig *lpconfig){
|
|||
|
||||
}
|
||||
|
||||
int lp_config_sync(LpConfig *lpconfig){
|
||||
int linphone_config_sync(LpConfig *lpconfig){
|
||||
bctbx_vfs_file_t *pFile = NULL;
|
||||
if (lpconfig->filename==NULL) return -1;
|
||||
if (lpconfig->readonly) return 0;
|
||||
|
|
@ -817,12 +817,12 @@ int lp_config_sync(LpConfig *lpconfig){
|
|||
return 0;
|
||||
}
|
||||
|
||||
int lp_config_has_section(const LpConfig *lpconfig, const char *section){
|
||||
if (lp_config_find_section(lpconfig,section)!=NULL) return 1;
|
||||
int linphone_config_has_section(const LpConfig *lpconfig, const char *section){
|
||||
if (linphone_config_find_section(lpconfig,section)!=NULL) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void lp_config_for_each_section(const LpConfig *lpconfig, void (*callback)(const char *section, void *ctx), void *ctx) {
|
||||
void linphone_config_for_each_section(const LpConfig *lpconfig, void (*callback)(const char *section, void *ctx), void *ctx) {
|
||||
LpSection *sec;
|
||||
bctbx_list_t *elem;
|
||||
for (elem=lpconfig->sections;elem!=NULL;elem=bctbx_list_next(elem)){
|
||||
|
|
@ -831,10 +831,10 @@ void lp_config_for_each_section(const LpConfig *lpconfig, void (*callback)(const
|
|||
}
|
||||
}
|
||||
|
||||
void lp_config_for_each_entry(const LpConfig *lpconfig, const char *section, void (*callback)(const char *entry, void *ctx), void *ctx) {
|
||||
void linphone_config_for_each_entry(const LpConfig *lpconfig, const char *section, void (*callback)(const char *entry, void *ctx), void *ctx) {
|
||||
LpItem *item;
|
||||
bctbx_list_t *elem;
|
||||
LpSection *sec=lp_config_find_section(lpconfig,section);
|
||||
LpSection *sec=linphone_config_find_section(lpconfig,section);
|
||||
if (sec!=NULL){
|
||||
for (elem=sec->items;elem!=NULL;elem=bctbx_list_next(elem)){
|
||||
item=(LpItem*)elem->data;
|
||||
|
|
@ -844,50 +844,50 @@ void lp_config_for_each_entry(const LpConfig *lpconfig, const char *section, voi
|
|||
}
|
||||
}
|
||||
|
||||
void lp_config_clean_section(LpConfig *lpconfig, const char *section){
|
||||
LpSection *sec=lp_config_find_section(lpconfig,section);
|
||||
void linphone_config_clean_section(LpConfig *lpconfig, const char *section){
|
||||
LpSection *sec=linphone_config_find_section(lpconfig,section);
|
||||
if (sec!=NULL){
|
||||
lp_config_remove_section(lpconfig,sec);
|
||||
linphone_config_remove_section(lpconfig,sec);
|
||||
}
|
||||
lpconfig->modified++;
|
||||
}
|
||||
|
||||
int lp_config_needs_commit(const LpConfig *lpconfig){
|
||||
int linphone_config_needs_commit(const LpConfig *lpconfig){
|
||||
return lpconfig->modified>0;
|
||||
}
|
||||
|
||||
static const char *DEFAULT_VALUES_SUFFIX = "_default_values";
|
||||
|
||||
int lp_config_get_default_int(const LpConfig *lpconfig, const char *section, const char *key, int default_value) {
|
||||
int linphone_config_get_default_int(const LpConfig *lpconfig, const char *section, const char *key, int default_value) {
|
||||
char default_section[MAX_LEN];
|
||||
strcpy(default_section, section);
|
||||
strcat(default_section, DEFAULT_VALUES_SUFFIX);
|
||||
|
||||
return lp_config_get_int(lpconfig, default_section, key, default_value);
|
||||
return linphone_config_get_int(lpconfig, default_section, key, default_value);
|
||||
}
|
||||
|
||||
int64_t lp_config_get_default_int64(const LpConfig *lpconfig, const char *section, const char *key, int64_t default_value) {
|
||||
int64_t linphone_config_get_default_int64(const LpConfig *lpconfig, const char *section, const char *key, int64_t default_value) {
|
||||
char default_section[MAX_LEN];
|
||||
strcpy(default_section, section);
|
||||
strcat(default_section, DEFAULT_VALUES_SUFFIX);
|
||||
|
||||
return lp_config_get_int64(lpconfig, default_section, key, default_value);
|
||||
return linphone_config_get_int64(lpconfig, default_section, key, default_value);
|
||||
}
|
||||
|
||||
float lp_config_get_default_float(const LpConfig *lpconfig, const char *section, const char *key, float default_value) {
|
||||
float linphone_config_get_default_float(const LpConfig *lpconfig, const char *section, const char *key, float default_value) {
|
||||
char default_section[MAX_LEN];
|
||||
strcpy(default_section, section);
|
||||
strcat(default_section, DEFAULT_VALUES_SUFFIX);
|
||||
|
||||
return lp_config_get_float(lpconfig, default_section, key, default_value);
|
||||
return linphone_config_get_float(lpconfig, default_section, key, default_value);
|
||||
}
|
||||
|
||||
const char* lp_config_get_default_string(const LpConfig *lpconfig, const char *section, const char *key, const char *default_value) {
|
||||
const char* linphone_config_get_default_string(const LpConfig *lpconfig, const char *section, const char *key, const char *default_value) {
|
||||
char default_section[MAX_LEN];
|
||||
strcpy(default_section, section);
|
||||
strcat(default_section, DEFAULT_VALUES_SUFFIX);
|
||||
|
||||
return lp_config_get_string(lpconfig, default_section, key, default_value);
|
||||
return linphone_config_get_string(lpconfig, default_section, key, default_value);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -902,7 +902,7 @@ const char* lp_config_get_default_string(const LpConfig *lpconfig, const char *s
|
|||
* the returned pointer.
|
||||
* 3. Do not feed it after midnight
|
||||
*/
|
||||
static const char *_lp_config_dirname(char *path) {
|
||||
static const char *_linphone_config_dirname(char *path) {
|
||||
#ifdef _MSC_VER
|
||||
char drive[_MAX_DRIVE];
|
||||
char dir[_MAX_DIR];
|
||||
|
|
@ -917,13 +917,13 @@ static const char *_lp_config_dirname(char *path) {
|
|||
#endif
|
||||
}
|
||||
|
||||
bool_t lp_config_relative_file_exists(const LpConfig *lpconfig, const char *filename) {
|
||||
bool_t linphone_config_relative_file_exists(const LpConfig *lpconfig, const char *filename) {
|
||||
bctbx_vfs_file_t *pFile;
|
||||
if (lpconfig->filename == NULL) {
|
||||
return FALSE;
|
||||
} else {
|
||||
char *conf_path = ms_strdup(lpconfig->filename);
|
||||
const char *dir = _lp_config_dirname(conf_path);
|
||||
const char *dir = _linphone_config_dirname(conf_path);
|
||||
char *filepath = ms_strdup_printf("%s/%s", dir, filename);
|
||||
char *realfilepath = lp_realpath(filepath, NULL);
|
||||
|
||||
|
|
@ -941,7 +941,7 @@ bool_t lp_config_relative_file_exists(const LpConfig *lpconfig, const char *file
|
|||
}
|
||||
}
|
||||
|
||||
void lp_config_write_relative_file(const LpConfig *lpconfig, const char *filename, const char *data) {
|
||||
void linphone_config_write_relative_file(const LpConfig *lpconfig, const char *filename, const char *data) {
|
||||
char *dup_config_file = NULL;
|
||||
const char *dir = NULL;
|
||||
char *filepath = NULL;
|
||||
|
|
@ -956,7 +956,7 @@ void lp_config_write_relative_file(const LpConfig *lpconfig, const char *filenam
|
|||
}
|
||||
|
||||
dup_config_file = ms_strdup(lpconfig->filename);
|
||||
dir = _lp_config_dirname(dup_config_file);
|
||||
dir = _linphone_config_dirname(dup_config_file);
|
||||
filepath = ms_strdup_printf("%s/%s", dir, filename);
|
||||
realfilepath = lp_realpath(filepath, NULL);
|
||||
if(realfilepath == NULL) {
|
||||
|
|
@ -978,7 +978,7 @@ end:
|
|||
if(realfilepath) ms_free(realfilepath);
|
||||
}
|
||||
|
||||
int lp_config_read_relative_file(const LpConfig *lpconfig, const char *filename, char *data, size_t max_length) {
|
||||
int linphone_config_read_relative_file(const LpConfig *lpconfig, const char *filename, char *data, size_t max_length) {
|
||||
char *dup_config_file = NULL;
|
||||
const char *dir = NULL;
|
||||
char *filepath = NULL;
|
||||
|
|
@ -989,7 +989,7 @@ int lp_config_read_relative_file(const LpConfig *lpconfig, const char *filename,
|
|||
if (lpconfig->filename == NULL) return -1;
|
||||
|
||||
dup_config_file = ms_strdup(lpconfig->filename);
|
||||
dir = _lp_config_dirname(dup_config_file);
|
||||
dir = _linphone_config_dirname(dup_config_file);
|
||||
filepath = ms_strdup_printf("%s/%s", dir, filename);
|
||||
realfilepath = lp_realpath(filepath, NULL);
|
||||
if(realfilepath == NULL) {
|
||||
|
|
@ -1023,7 +1023,7 @@ err:
|
|||
return -1;
|
||||
}
|
||||
|
||||
const char** lp_config_get_sections_names(LpConfig *lpconfig) {
|
||||
const char** linphone_config_get_sections_names(LpConfig *lpconfig) {
|
||||
const char **sections_names;
|
||||
const bctbx_list_t *sections = lpconfig->sections;
|
||||
size_t ndev;
|
||||
|
|
@ -1041,7 +1041,7 @@ const char** lp_config_get_sections_names(LpConfig *lpconfig) {
|
|||
return sections_names;
|
||||
}
|
||||
|
||||
char* lp_config_dump_as_xml(const LpConfig *lpconfig) {
|
||||
char* linphone_config_dump_as_xml(const LpConfig *lpconfig) {
|
||||
char *buffer;
|
||||
|
||||
lpc2xml_context *ctx = lpc2xml_context_new(NULL, NULL);
|
||||
|
|
@ -1060,7 +1060,7 @@ struct _entry_data {
|
|||
|
||||
static void dump_entry(const char *entry, void *data) {
|
||||
struct _entry_data *d = (struct _entry_data *) data;
|
||||
const char *value = lp_config_get_string(d->conf, d->section, entry, "");
|
||||
const char *value = linphone_config_get_string(d->conf, d->section, entry, "");
|
||||
*d->buffer = ms_strcat_printf(*d->buffer, "\t%s=%s\n", entry, value);
|
||||
}
|
||||
|
||||
|
|
@ -1068,21 +1068,21 @@ static void dump_section(const char *section, void *data) {
|
|||
struct _entry_data *d = (struct _entry_data *) data;
|
||||
d->section = section;
|
||||
*d->buffer = ms_strcat_printf(*d->buffer, "[%s]\n", section);
|
||||
lp_config_for_each_entry(d->conf, section, dump_entry, d);
|
||||
linphone_config_for_each_entry(d->conf, section, dump_entry, d);
|
||||
}
|
||||
|
||||
char* lp_config_dump(const LpConfig *lpconfig) {
|
||||
char* linphone_config_dump(const LpConfig *lpconfig) {
|
||||
char* buffer = NULL;
|
||||
struct _entry_data d = { lpconfig, NULL, &buffer };
|
||||
lp_config_for_each_section(lpconfig, dump_section, &d);
|
||||
linphone_config_for_each_section(lpconfig, dump_section, &d);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void lp_config_clean_entry(LpConfig *lpconfig, const char *section, const char *key) {
|
||||
void linphone_config_clean_entry(LpConfig *lpconfig, const char *section, const char *key) {
|
||||
LpSection *sec;
|
||||
LpItem *item;
|
||||
sec=lp_config_find_section(lpconfig,section);
|
||||
sec=linphone_config_find_section(lpconfig,section);
|
||||
if (sec!=NULL){
|
||||
item=lp_section_find_item(sec,key);
|
||||
if (item!=NULL)
|
||||
|
|
@ -1090,9 +1090,9 @@ void lp_config_clean_entry(LpConfig *lpconfig, const char *section, const char *
|
|||
}
|
||||
return ;
|
||||
}
|
||||
int lp_config_has_entry(const LpConfig *lpconfig, const char *section, const char *key) {
|
||||
int linphone_config_has_entry(const LpConfig *lpconfig, const char *section, const char *key) {
|
||||
LpSection *sec;
|
||||
sec=lp_config_find_section(lpconfig,section);
|
||||
sec=linphone_config_find_section(lpconfig,section);
|
||||
if (sec!=NULL){
|
||||
return lp_section_find_item(sec,key) != NULL;
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* The LpConfig object is used to manipulate a configuration file.
|
||||
* The LinphoneConfig object is used to manipulate a configuration file.
|
||||
*
|
||||
* The format of the configuration file is a .ini like format:
|
||||
* - sections are defined in []
|
||||
|
|
@ -55,66 +55,75 @@
|
|||
* enabled=1
|
||||
* @endcode
|
||||
**/
|
||||
typedef struct _LpConfig LpConfig;
|
||||
typedef struct _LpConfig LinphoneConfig;
|
||||
|
||||
/**
|
||||
* Define old struct name for backward compatibility
|
||||
*/
|
||||
#define LpConfig LinphoneConfig
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Instantiates a LpConfig object from a user config file.
|
||||
* The caller of this constructor owns a reference. lp_config_unref() must be called when this object is no longer needed.
|
||||
* @param filename the filename of the config file to read to fill the instantiated LpConfig
|
||||
* @see lp_config_new_with_factory
|
||||
* Instantiates a LinphoneConfig object from a user config file.
|
||||
* The caller of this constructor owns a reference. linphone_config_unref() must be called when this object is no longer needed.
|
||||
* @ingroup misc
|
||||
* @param filename the filename of the config file to read to fill the instantiated LinphoneConfig
|
||||
* @see linphone_config_new_with_factory
|
||||
*/
|
||||
LINPHONE_PUBLIC LpConfig * lp_config_new(const char *filename);
|
||||
LINPHONE_PUBLIC LinphoneConfig * linphone_config_new(const char *filename);
|
||||
|
||||
/**
|
||||
* Instantiates a LpConfig object from a user provided buffer.
|
||||
* The caller of this constructor owns a reference. lp_config_unref() must be called when this object is no longer needed.
|
||||
* @param buffer the buffer from which the lpconfig will be retrieved. We expect the buffer to be null-terminated.
|
||||
* @see lp_config_new_with_factory
|
||||
* @see lp_config_new
|
||||
* Instantiates a LinphoneConfig object from a user provided buffer.
|
||||
* The caller of this constructor owns a reference. linphone_config_unref() must be called when this object is no longer needed.
|
||||
* @ingroup misc
|
||||
* @param buffer the buffer from which the LinphoneConfig will be retrieved. We expect the buffer to be null-terminated.
|
||||
* @see linphone_config_new_with_factory
|
||||
* @see linphone_config_new
|
||||
*/
|
||||
LINPHONE_PUBLIC LpConfig * lp_config_new_from_buffer(const char *buffer);
|
||||
LINPHONE_PUBLIC LinphoneConfig * linphone_config_new_from_buffer(const char *buffer);
|
||||
|
||||
/**
|
||||
* Instantiates a LpConfig object from a user config file and a factory config file.
|
||||
* The caller of this constructor owns a reference. lp_config_unref() must be called when this object is no longer needed.
|
||||
* @param config_filename the filename of the user config file to read to fill the instantiated LpConfig
|
||||
* @param factory_config_filename the filename of the factory config file to read to fill the instantiated LpConfig
|
||||
* @see lp_config_new
|
||||
* Instantiates a LinphoneConfig object from a user config file and a factory config file.
|
||||
* The caller of this constructor owns a reference. linphone_config_unref() must be called when this object is no longer needed.
|
||||
* @ingroup misc
|
||||
* @param config_filename the filename of the user config file to read to fill the instantiated LinphoneConfig
|
||||
* @param factory_config_filename the filename of the factory config file to read to fill the instantiated LinphoneConfig
|
||||
* @see linphone_config_new
|
||||
*
|
||||
* The user config file is read first to fill the LpConfig and then the factory config file is read.
|
||||
* The user config file is read first to fill the LinphoneConfig and then the factory config file is read.
|
||||
* Therefore the configuration parameters defined in the user config file will be overwritten by the parameters
|
||||
* defined in the factory config file.
|
||||
*/
|
||||
LINPHONE_PUBLIC LpConfig * lp_config_new_with_factory(const char *config_filename, const char *factory_config_filename);
|
||||
LINPHONE_PUBLIC LinphoneConfig * linphone_config_new_with_factory(const char *config_filename, const char *factory_config_filename);
|
||||
|
||||
/**
|
||||
* Reads a user config file and fill the LpConfig with the read config values.
|
||||
* @param lpconfig The LpConfig object to fill with the content of the file
|
||||
* @param filename The filename of the config file to read to fill the LpConfig
|
||||
* Reads a user config file and fill the LinphoneConfig with the read config values.
|
||||
* @ingroup misc
|
||||
* @param lpconfig The LinphoneConfig object to fill with the content of the file
|
||||
* @param filename The filename of the config file to read to fill the LinphoneConfig
|
||||
*/
|
||||
LINPHONE_PUBLIC int lp_config_read_file(LpConfig *lpconfig, const char *filename);
|
||||
LINPHONE_PUBLIC int linphone_config_read_file(LinphoneConfig *lpconfig, const char *filename);
|
||||
|
||||
/**
|
||||
* Retrieves a configuration item as a string, given its section, key, and default value.
|
||||
*
|
||||
* The default value string is returned if the config item isn't found.
|
||||
**/
|
||||
LINPHONE_PUBLIC const char *lp_config_get_string(const LpConfig *lpconfig, const char *section, const char *key, const char *default_string);
|
||||
LINPHONE_PUBLIC const char *linphone_config_get_string(const LinphoneConfig *lpconfig, const char *section, const char *key, const char *default_string);
|
||||
|
||||
/**
|
||||
* Retrieves a configuration item as a list of strings, given its section, key, and default value.
|
||||
* The default value is returned if the config item is not found.
|
||||
* @param[in] lpconfig A LpConfig object
|
||||
* @param[in] lpconfig A #LinphoneConfig object
|
||||
* @param[in] section The section from which to retrieve a configuration item
|
||||
* @param[in] key The name of the configuration item to retrieve
|
||||
* @param[in] default_list \bctbx_list{const char *}
|
||||
* @return \bctbx_list{const char *}
|
||||
*/
|
||||
LINPHONE_PUBLIC bctbx_list_t * lp_config_get_string_list(const LpConfig *lpconfig, const char *section, const char *key, bctbx_list_t *default_list);
|
||||
LINPHONE_PUBLIC bctbx_list_t * linphone_config_get_string_list(const LinphoneConfig *lpconfig, const char *section, const char *key, bctbx_list_t *default_list);
|
||||
|
||||
/**
|
||||
* Retrieves a configuration item as a range, given its section, key, and default min and max values.
|
||||
|
|
@ -122,237 +131,237 @@ LINPHONE_PUBLIC bctbx_list_t * lp_config_get_string_list(const LpConfig *lpconfi
|
|||
* @return TRUE if the value is successfully parsed as a range, FALSE otherwise.
|
||||
* If FALSE is returned, min and max are filled respectively with default_min and default_max values.
|
||||
*/
|
||||
LINPHONE_PUBLIC bool_t lp_config_get_range(const LpConfig *lpconfig, const char *section, const char *key, int *min, int *max, int default_min, int default_max);
|
||||
LINPHONE_PUBLIC bool_t linphone_config_get_range(const LinphoneConfig *lpconfig, const char *section, const char *key, int *min, int *max, int default_min, int default_max);
|
||||
|
||||
/**
|
||||
* Retrieves a configuration item as an integer, given its section, key, and default value.
|
||||
*
|
||||
* The default integer value is returned if the config item isn't found.
|
||||
**/
|
||||
LINPHONE_PUBLIC int lp_config_get_int(const LpConfig *lpconfig,const char *section, const char *key, int default_value);
|
||||
LINPHONE_PUBLIC int linphone_config_get_int(const LinphoneConfig *lpconfig,const char *section, const char *key, int default_value);
|
||||
|
||||
/**
|
||||
* Retrieves a configuration item as a 64 bit integer, given its section, key, and default value.
|
||||
*
|
||||
* The default integer value is returned if the config item isn't found.
|
||||
**/
|
||||
LINPHONE_PUBLIC int64_t lp_config_get_int64(const LpConfig *lpconfig,const char *section, const char *key, int64_t default_value);
|
||||
LINPHONE_PUBLIC int64_t linphone_config_get_int64(const LinphoneConfig *lpconfig,const char *section, const char *key, int64_t default_value);
|
||||
|
||||
/**
|
||||
* Retrieves a configuration item as a float, given its section, key, and default value.
|
||||
*
|
||||
* The default float value is returned if the config item isn't found.
|
||||
**/
|
||||
LINPHONE_PUBLIC float lp_config_get_float(const LpConfig *lpconfig,const char *section, const char *key, float default_value);
|
||||
LINPHONE_PUBLIC float linphone_config_get_float(const LinphoneConfig *lpconfig,const char *section, const char *key, float default_value);
|
||||
|
||||
/**
|
||||
* Sets a string config item
|
||||
**/
|
||||
LINPHONE_PUBLIC void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *key, const char *value);
|
||||
LINPHONE_PUBLIC void linphone_config_set_string(LinphoneConfig *lpconfig,const char *section, const char *key, const char *value);
|
||||
|
||||
/**
|
||||
* Sets a string list config item
|
||||
* @param[in] lpconfig A LpConfig object
|
||||
* @param[in] lpconfig A #LinphoneConfig object
|
||||
* @param[in] section The name of the section to put the configuration item into
|
||||
* @param[in] key The name of the configuration item to set
|
||||
* @param[in] value \bctbx_list{const char *} The value to set
|
||||
*/
|
||||
LINPHONE_PUBLIC void lp_config_set_string_list(LpConfig *lpconfig, const char *section, const char *key, const bctbx_list_t *value);
|
||||
LINPHONE_PUBLIC void linphone_config_set_string_list(LinphoneConfig *lpconfig, const char *section, const char *key, const bctbx_list_t *value);
|
||||
|
||||
/**
|
||||
* Sets a range config item
|
||||
*/
|
||||
LINPHONE_PUBLIC void lp_config_set_range(LpConfig *lpconfig, const char *section, const char *key, int min_value, int max_value);
|
||||
LINPHONE_PUBLIC void linphone_config_set_range(LinphoneConfig *lpconfig, const char *section, const char *key, int min_value, int max_value);
|
||||
|
||||
/**
|
||||
* Sets an integer config item
|
||||
**/
|
||||
LINPHONE_PUBLIC void lp_config_set_int(LpConfig *lpconfig,const char *section, const char *key, int value);
|
||||
LINPHONE_PUBLIC void linphone_config_set_int(LinphoneConfig *lpconfig,const char *section, const char *key, int value);
|
||||
|
||||
/**
|
||||
* Sets an integer config item, but store it as hexadecimal
|
||||
**/
|
||||
LINPHONE_PUBLIC void lp_config_set_int_hex(LpConfig *lpconfig,const char *section, const char *key, int value);
|
||||
LINPHONE_PUBLIC void linphone_config_set_int_hex(LinphoneConfig *lpconfig,const char *section, const char *key, int value);
|
||||
|
||||
/**
|
||||
* Sets a 64 bits integer config item
|
||||
**/
|
||||
LINPHONE_PUBLIC void lp_config_set_int64(LpConfig *lpconfig,const char *section, const char *key, int64_t value);
|
||||
LINPHONE_PUBLIC void linphone_config_set_int64(LinphoneConfig *lpconfig,const char *section, const char *key, int64_t value);
|
||||
|
||||
/**
|
||||
* Sets a float config item
|
||||
**/
|
||||
LINPHONE_PUBLIC void lp_config_set_float(LpConfig *lpconfig,const char *section, const char *key, float value);
|
||||
LINPHONE_PUBLIC void linphone_config_set_float(LinphoneConfig *lpconfig,const char *section, const char *key, float value);
|
||||
|
||||
/**
|
||||
* Writes the config file to disk.
|
||||
**/
|
||||
LINPHONE_PUBLIC int lp_config_sync(LpConfig *lpconfig);
|
||||
LINPHONE_PUBLIC int linphone_config_sync(LinphoneConfig *lpconfig);
|
||||
|
||||
/**
|
||||
* Returns 1 if a given section is present in the configuration.
|
||||
**/
|
||||
LINPHONE_PUBLIC int lp_config_has_section(const LpConfig *lpconfig, const char *section);
|
||||
LINPHONE_PUBLIC int linphone_config_has_section(const LinphoneConfig *lpconfig, const char *section);
|
||||
|
||||
/**
|
||||
* Removes every pair of key,value in a section and remove the section.
|
||||
**/
|
||||
LINPHONE_PUBLIC void lp_config_clean_section(LpConfig *lpconfig, const char *section);
|
||||
LINPHONE_PUBLIC void linphone_config_clean_section(LinphoneConfig *lpconfig, const char *section);
|
||||
|
||||
/**
|
||||
* Returns 1 if a given section with a given key is present in the configuration.
|
||||
* @param[in] lpconfig The LpConfig object
|
||||
* @param[in] lpconfig The LinphoneConfig object
|
||||
* @param[in] section
|
||||
* @param[in] key
|
||||
**/
|
||||
LINPHONE_PUBLIC int lp_config_has_entry(const LpConfig *lpconfig, const char *section, const char *key);
|
||||
LINPHONE_PUBLIC int linphone_config_has_entry(const LinphoneConfig *lpconfig, const char *section, const char *key);
|
||||
|
||||
/**
|
||||
* Removes entries for key,value in a section.
|
||||
* @param[in] lpconfig The LpConfig object
|
||||
* @param[in] lpconfig The LinphoneConfig object
|
||||
* @param[in] section
|
||||
* @param[in] key
|
||||
**/
|
||||
LINPHONE_PUBLIC void lp_config_clean_entry(LpConfig *lpconfig, const char *section, const char *key);
|
||||
LINPHONE_PUBLIC void linphone_config_clean_entry(LinphoneConfig *lpconfig, const char *section, const char *key);
|
||||
|
||||
/**
|
||||
* Returns the list of sections' names in the LpConfig.
|
||||
* @param[in] lpconfig The LpConfig object
|
||||
* Returns the list of sections' names in the LinphoneConfig.
|
||||
* @param[in] lpconfig The LinphoneConfig object
|
||||
* @return a null terminated static array of strings
|
||||
**/
|
||||
LINPHONE_PUBLIC const char** lp_config_get_sections_names(LpConfig *lpconfig);
|
||||
LINPHONE_PUBLIC const char** linphone_config_get_sections_names(LinphoneConfig *lpconfig);
|
||||
|
||||
/**
|
||||
* Call a function for each section present in the configuration.
|
||||
**/
|
||||
void lp_config_for_each_section(const LpConfig *lpconfig, void (*callback)(const char *section, void *ctx), void *ctx);
|
||||
void linphone_config_for_each_section(const LinphoneConfig *lpconfig, void (*callback)(const char *section, void *ctx), void *ctx);
|
||||
|
||||
/**
|
||||
* Call a function for each entry present in a section configuration.
|
||||
**/
|
||||
void lp_config_for_each_entry(const LpConfig *lpconfig, const char *section, void (*callback)(const char *entry, void *ctx), void *ctx);
|
||||
void linphone_config_for_each_entry(const LinphoneConfig *lpconfig, const char *section, void (*callback)(const char *entry, void *ctx), void *ctx);
|
||||
|
||||
/*tells whether uncommited (with lp_config_sync()) modifications exist*/
|
||||
int lp_config_needs_commit(const LpConfig *lpconfig);
|
||||
/*tells whether uncommited (with linphone_config_sync()) modifications exist*/
|
||||
int linphone_config_needs_commit(const LinphoneConfig *lpconfig);
|
||||
|
||||
LINPHONE_PUBLIC void lp_config_destroy(LpConfig *cfg);
|
||||
LINPHONE_PUBLIC void linphone_config_destroy(LinphoneConfig *cfg);
|
||||
|
||||
/**
|
||||
* Retrieves a default configuration item as an integer, given its section, key, and default value.
|
||||
* The default integer value is returned if the config item isn't found.
|
||||
**/
|
||||
LINPHONE_PUBLIC int lp_config_get_default_int(const LpConfig *lpconfig, const char *section, const char *key, int default_value);
|
||||
LINPHONE_PUBLIC int linphone_config_get_default_int(const LinphoneConfig *lpconfig, const char *section, const char *key, int default_value);
|
||||
|
||||
/**
|
||||
* Retrieves a default configuration item as a 64 bit integer, given its section, key, and default value.
|
||||
* The default integer value is returned if the config item isn't found.
|
||||
**/
|
||||
LINPHONE_PUBLIC int64_t lp_config_get_default_int64(const LpConfig *lpconfig, const char *section, const char *key, int64_t default_value);
|
||||
LINPHONE_PUBLIC int64_t linphone_config_get_default_int64(const LinphoneConfig *lpconfig, const char *section, const char *key, int64_t default_value);
|
||||
|
||||
/**
|
||||
* Retrieves a default configuration item as a float, given its section, key, and default value.
|
||||
* The default float value is returned if the config item isn't found.
|
||||
**/
|
||||
LINPHONE_PUBLIC float lp_config_get_default_float(const LpConfig *lpconfig, const char *section, const char *key, float default_value);
|
||||
LINPHONE_PUBLIC float linphone_config_get_default_float(const LinphoneConfig *lpconfig, const char *section, const char *key, float default_value);
|
||||
|
||||
/**
|
||||
* Retrieves a default configuration item as a string, given its section, key, and default value.
|
||||
* The default value string is returned if the config item isn't found.
|
||||
**/
|
||||
LINPHONE_PUBLIC const char* lp_config_get_default_string(const LpConfig *lpconfig, const char *section, const char *key, const char *default_value);
|
||||
LINPHONE_PUBLIC const char* linphone_config_get_default_string(const LinphoneConfig *lpconfig, const char *section, const char *key, const char *default_value);
|
||||
|
||||
/**
|
||||
* Retrieves a section parameter item as a string, given its section and key.
|
||||
* The default value string is returned if the config item isn't found.
|
||||
**/
|
||||
LINPHONE_PUBLIC const char* lp_config_get_section_param_string(const LpConfig *lpconfig, const char *section, const char *key, const char *default_value);
|
||||
LINPHONE_PUBLIC const char* linphone_config_get_section_param_string(const LinphoneConfig *lpconfig, const char *section, const char *key, const char *default_value);
|
||||
|
||||
/**
|
||||
* increment reference count
|
||||
**/
|
||||
LINPHONE_PUBLIC LpConfig *lp_config_ref(LpConfig *lpconfig);
|
||||
LINPHONE_PUBLIC LinphoneConfig *linphone_config_ref(LinphoneConfig *lpconfig);
|
||||
|
||||
/**
|
||||
* Decrement reference count, which will eventually free the object.
|
||||
**/
|
||||
LINPHONE_PUBLIC void lp_config_unref(LpConfig *lpconfig);
|
||||
LINPHONE_PUBLIC void linphone_config_unref(LinphoneConfig *lpconfig);
|
||||
|
||||
/**
|
||||
* Write a string in a file placed relatively with the Linphone configuration file.
|
||||
* @param lpconfig LpConfig instance used as a reference
|
||||
* @param lpconfig LinphoneConfig instance used as a reference
|
||||
* @param filename Name of the file where to write data. The name is relative to the place of the config file
|
||||
* @param data String to write
|
||||
*/
|
||||
LINPHONE_PUBLIC void lp_config_write_relative_file(const LpConfig *lpconfig, const char *filename, const char *data);
|
||||
LINPHONE_PUBLIC void linphone_config_write_relative_file(const LinphoneConfig *lpconfig, const char *filename, const char *data);
|
||||
|
||||
/**
|
||||
* Read a string from a file placed beside the Linphone configuration file
|
||||
* @param lpconfig LpConfig instance used as a reference
|
||||
* @param lpconfig LinphoneConfig instance used as a reference
|
||||
* @param filename Name of the file where data will be read from. The name is relative to the place of the config file
|
||||
* @param data Buffer where read string will be stored
|
||||
* @param max_length Length of the buffer
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
LINPHONE_PUBLIC int lp_config_read_relative_file(const LpConfig *lpconfig, const char *filename, char *data, size_t max_length);
|
||||
LINPHONE_PUBLIC int linphone_config_read_relative_file(const LinphoneConfig *lpconfig, const char *filename, char *data, size_t max_length);
|
||||
|
||||
/**
|
||||
* @return TRUE if file exists relative to the to the current location
|
||||
**/
|
||||
LINPHONE_PUBLIC bool_t lp_config_relative_file_exists(const LpConfig *lpconfig, const char *filename);
|
||||
LINPHONE_PUBLIC bool_t linphone_config_relative_file_exists(const LinphoneConfig *lpconfig, const char *filename);
|
||||
|
||||
/**
|
||||
* Dumps the LpConfig as XML into a buffer
|
||||
* @param[in] lpconfig The LpConfig object
|
||||
* Dumps the LinphoneConfig as XML into a buffer
|
||||
* @param[in] lpconfig The LinphoneConfig object
|
||||
* @return The buffer that contains the XML dump
|
||||
**/
|
||||
LINPHONE_PUBLIC char* lp_config_dump_as_xml(const LpConfig *lpconfig);
|
||||
LINPHONE_PUBLIC char* linphone_config_dump_as_xml(const LinphoneConfig *lpconfig);
|
||||
|
||||
/**
|
||||
* Dumps the LpConfig as INI into a buffer
|
||||
* @param[in] lpconfig The LpConfig object
|
||||
* Dumps the LinphoneConfig as INI into a buffer
|
||||
* @param[in] lpconfig The LinphoneConfig object
|
||||
* @return The buffer that contains the config dump
|
||||
**/
|
||||
LINPHONE_PUBLIC char* lp_config_dump(const LpConfig *lpconfig);
|
||||
LINPHONE_PUBLIC char* linphone_config_dump(const LinphoneConfig *lpconfig);
|
||||
|
||||
/**
|
||||
* Retrieves the overwrite flag for a config item
|
||||
**/
|
||||
LINPHONE_PUBLIC bool_t lp_config_get_overwrite_flag_for_entry(const LpConfig *lpconfig, const char *section, const char *key);
|
||||
LINPHONE_PUBLIC bool_t linphone_config_get_overwrite_flag_for_entry(const LinphoneConfig *lpconfig, const char *section, const char *key);
|
||||
|
||||
/**
|
||||
* Sets the overwrite flag for a config item (used when dumping config as xml)
|
||||
**/
|
||||
LINPHONE_PUBLIC void lp_config_set_overwrite_flag_for_entry(LpConfig *lpconfig, const char *section, const char *key, bool_t value);
|
||||
LINPHONE_PUBLIC void linphone_config_set_overwrite_flag_for_entry(LinphoneConfig *lpconfig, const char *section, const char *key, bool_t value);
|
||||
|
||||
/**
|
||||
* Retrieves the overwrite flag for a config section
|
||||
**/
|
||||
LINPHONE_PUBLIC bool_t lp_config_get_overwrite_flag_for_section(const LpConfig *lpconfig, const char *section);
|
||||
LINPHONE_PUBLIC bool_t linphone_config_get_overwrite_flag_for_section(const LinphoneConfig *lpconfig, const char *section);
|
||||
|
||||
/**
|
||||
* Sets the overwrite flag for a config section (used when dumping config as xml)
|
||||
**/
|
||||
LINPHONE_PUBLIC void lp_config_set_overwrite_flag_for_section(LpConfig *lpconfig, const char *section, bool_t value);
|
||||
LINPHONE_PUBLIC void linphone_config_set_overwrite_flag_for_section(LinphoneConfig *lpconfig, const char *section, bool_t value);
|
||||
|
||||
/**
|
||||
* Retrieves the skip flag for a config item
|
||||
**/
|
||||
LINPHONE_PUBLIC bool_t lp_config_get_skip_flag_for_entry(const LpConfig *lpconfig, const char *section, const char *key);
|
||||
LINPHONE_PUBLIC bool_t linphone_config_get_skip_flag_for_entry(const LinphoneConfig *lpconfig, const char *section, const char *key);
|
||||
|
||||
/**
|
||||
* Sets the skip flag for a config item (used when dumping config as xml)
|
||||
**/
|
||||
LINPHONE_PUBLIC void lp_config_set_skip_flag_for_entry(LpConfig *lpconfig, const char *section, const char *key, bool_t value);
|
||||
LINPHONE_PUBLIC void linphone_config_set_skip_flag_for_entry(LinphoneConfig *lpconfig, const char *section, const char *key, bool_t value);
|
||||
|
||||
/**
|
||||
* Retrieves the skip flag for a config section
|
||||
**/
|
||||
LINPHONE_PUBLIC bool_t lp_config_get_skip_flag_for_section(const LpConfig *lpconfig, const char *section);
|
||||
LINPHONE_PUBLIC bool_t linphone_config_get_skip_flag_for_section(const LinphoneConfig *lpconfig, const char *section);
|
||||
|
||||
/**
|
||||
* Sets the skip flag for a config section (used when dumping config as xml)
|
||||
**/
|
||||
LINPHONE_PUBLIC void lp_config_set_skip_flag_for_section(LpConfig *lpconfig, const char *section, bool_t value);
|
||||
LINPHONE_PUBLIC void linphone_config_set_skip_flag_for_section(LinphoneConfig *lpconfig, const char *section, bool_t value);
|
||||
|
||||
/**
|
||||
* Converts a config section into a dictionary.
|
||||
|
|
@ -370,4 +379,53 @@ LINPHONE_PUBLIC void lp_config_load_dict_to_section( LpConfig* lpconfig, const c
|
|||
}
|
||||
#endif
|
||||
|
||||
// Define old function names for backward compatibility
|
||||
#define lp_config_new linphone_config_new
|
||||
#define lp_config_new_from_buffer linphone_config_new_from_buffer
|
||||
#define lp_config_new_with_factory linphone_config_new_with_factory
|
||||
#define lp_config_read_file linphone_config_read_file
|
||||
#define lp_config_get_string linphone_config_get_string
|
||||
#define lp_config_get_string_list linphone_config_get_string_list
|
||||
#define lp_config_get_range linphone_config_get_range
|
||||
#define lp_config_get_int linphone_config_get_int
|
||||
#define lp_config_get_int64 linphone_config_get_int64
|
||||
#define lp_config_get_float linphone_config_get_float
|
||||
#define lp_config_set_string linphone_config_set_string
|
||||
#define lp_config_set_string_list linphone_config_set_string_list
|
||||
#define lp_config_set_range linphone_config_set_range
|
||||
#define lp_config_set_int linphone_config_set_int
|
||||
#define lp_config_set_int_hex linphone_config_set_int_hex
|
||||
#define lp_config_set_int64 linphone_config_set_int64
|
||||
#define lp_config_set_float linphone_config_set_float
|
||||
#define lp_config_sync linphone_config_sync
|
||||
#define lp_config_has_section linphone_config_has_section
|
||||
#define lp_config_clean_section linphone_config_clean_section
|
||||
#define lp_config_has_entry linphone_config_has_entry
|
||||
#define lp_config_clean_entry linphone_config_clean_entry
|
||||
#define lp_config_get_sections_names linphone_config_get_sections_names
|
||||
#define lp_config_for_each_section linphone_config_for_each_section
|
||||
#define lp_config_for_each_entry linphone_config_for_each_entry
|
||||
#define lp_config_needs_commit linphone_config_needs_commit
|
||||
#define lp_config_destroy linphone_config_destroy
|
||||
#define lp_config_get_default_int linphone_config_get_default_int
|
||||
#define lp_config_get_default_int64 linphone_config_get_default_int64
|
||||
#define lp_config_get_default_float linphone_config_get_default_float
|
||||
#define lp_config_get_default_string linphone_config_get_default_string
|
||||
#define lp_config_get_section_param_string linphone_config_get_section_param_string
|
||||
#define lp_config_ref linphone_config_ref
|
||||
#define lp_config_unref linphone_config_unref
|
||||
#define lp_config_write_relative_file linphone_config_write_relative_file
|
||||
#define lp_config_read_relative_file linphone_config_read_relative_file
|
||||
#define lp_config_relative_file_exists linphone_config_relative_file_exists
|
||||
#define lp_config_dump_as_xml linphone_config_dump_as_xml
|
||||
#define lp_config_dump linphone_config_dump
|
||||
#define lp_config_get_overwrite_flag_for_entry linphone_config_get_overwrite_flag_for_entry
|
||||
#define lp_config_set_overwrite_flag_for_entry linphone_config_set_overwrite_flag_for_entry
|
||||
#define lp_config_get_overwrite_flag_for_section linphone_config_get_overwrite_flag_for_section
|
||||
#define lp_config_set_overwrite_flag_for_section linphone_config_set_overwrite_flag_for_section
|
||||
#define lp_config_get_skip_flag_for_entry linphone_config_get_skip_flag_for_entry
|
||||
#define lp_config_set_skip_flag_for_entry linphone_config_set_skip_flag_for_entry
|
||||
#define lp_config_get_skip_flag_for_section linphone_config_get_skip_flag_for_section
|
||||
#define lp_config_set_skip_flag_for_section linphone_config_set_skip_flag_for_section
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue