Commit 07fd8f61 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Added methods to set/get overwrite flag in LpConfig (used when dumping config as xml)

parent 47662ce9
...@@ -101,6 +101,10 @@ static int processEntry(const char *section, const char *entry, xmlNode *node, l ...@@ -101,6 +101,10 @@ static int processEntry(const char *section, const char *entry, xmlNode *node, l
lpc2xml_log(ctx, LPC2XML_MESSAGE, "Set %s|%s = %s", section, entry, content); lpc2xml_log(ctx, LPC2XML_MESSAGE, "Set %s|%s = %s", section, entry, content);
xmlNodeSetContent(node, (const xmlChar *) content); xmlNodeSetContent(node, (const xmlChar *) content);
if (lp_config_get_overwrite_flag_for_entry(ctx->lpc, section, entry)) {
xmlSetProp(node, (const xmlChar *)"overwrite", (const xmlChar *) "true");
}
return 0; return 0;
} }
......
...@@ -62,6 +62,7 @@ typedef struct _LpItem{ ...@@ -62,6 +62,7 @@ typedef struct _LpItem{
char *key; char *key;
char *value; char *value;
int is_comment; int is_comment;
bool_t overwrite; // If set to true, will add overwrite=true when converted to xml
} LpItem; } LpItem;
typedef struct _LpSectionParam{ typedef struct _LpSectionParam{
...@@ -566,6 +567,17 @@ float lp_config_get_float(const LpConfig *lpconfig,const char *section, const ch ...@@ -566,6 +567,17 @@ float lp_config_get_float(const LpConfig *lpconfig,const char *section, const ch
return ret; return ret;
} }
bool_t lp_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);
if (sec != NULL){
item = lp_section_find_item(sec, key);
if (item != NULL) return item->overwrite;
}
return 0;
}
void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *key, const char *value){ void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *key, const char *value){
LpItem *item; LpItem *item;
LpSection *sec=lp_config_find_section(lpconfig,section); LpSection *sec=lp_config_find_section(lpconfig,section);
...@@ -618,6 +630,16 @@ void lp_config_set_float(LpConfig *lpconfig,const char *section, const char *key ...@@ -618,6 +630,16 @@ void lp_config_set_float(LpConfig *lpconfig,const char *section, const char *key
lp_config_set_string(lpconfig,section,key,tmp); lp_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) {
LpSection *sec;
LpItem *item;
sec = lp_config_find_section(lpconfig, section);
if (sec != NULL){
item = lp_section_find_item(sec, key);
if (item != NULL) item->overwrite = value;
}
}
void lp_item_write(LpItem *item, FILE *file){ void lp_item_write(LpItem *item, FILE *file){
if (item->is_comment) if (item->is_comment)
fprintf(file,"%s\n",item->value); fprintf(file,"%s\n",item->value);
......
...@@ -311,6 +311,20 @@ LINPHONE_PUBLIC bool_t lp_config_relative_file_exists(const LpConfig *lpconfig, ...@@ -311,6 +311,20 @@ LINPHONE_PUBLIC bool_t lp_config_relative_file_exists(const LpConfig *lpconfig,
**/ **/
LINPHONE_PUBLIC char* lp_config_dump_as_xml(const LpConfig *lpconfig); LINPHONE_PUBLIC char* lp_config_dump_as_xml(const LpConfig *lpconfig);
/**
* Retrieves the overwrite flag for a config item
*
* @ingroup misc
**/
LINPHONE_PUBLIC bool_t lp_config_get_overwrite_flag_for_entry(const LpConfig *lpconfig, const char *section, const char *key);
/**
* Sets the overwrite flag for a config item (used when dumping config as xml)
*
* @ingroup misc
**/
LINPHONE_PUBLIC void lp_config_set_overwrite_flag_for_entry(LpConfig *lpconfig, const char *section, const char *key, bool_t value);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment