mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-24 22:58:13 +00:00
Added a way to not dump some chosen sections/entries when converting lpc to xml
This commit is contained in:
parent
c440e2d0e8
commit
be6d6b47b3
3 changed files with 83 additions and 3 deletions
|
|
@ -166,6 +166,11 @@ static void processSection_cb(const char *entry, struct __processSectionCtx *ctx
|
|||
ctx->ret = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (lp_config_get_skip_flag_for_entry(ctx->ctx->lpc, ctx->section, entry)) {
|
||||
lpc2xml_log(ctx->ctx, LPC2XML_WARNING, "Skipped entry %s", entry);
|
||||
return;
|
||||
}
|
||||
|
||||
node = xmlNewChild(ctx->node, NULL, (const xmlChar *)"entry", NULL);
|
||||
if(node == NULL) {
|
||||
|
|
@ -200,8 +205,15 @@ struct __processConfigCtx {
|
|||
|
||||
static void processConfig_cb(const char *section, struct __processConfigCtx *ctx) {
|
||||
if(ctx->ret == 0) {
|
||||
xmlNode *node = xmlNewChild(ctx->node, NULL, (const xmlChar *)"section", NULL);
|
||||
xmlNode *node;
|
||||
xmlAttr *name_attr;
|
||||
|
||||
if (lp_config_get_skip_flag_for_section(ctx->ctx->lpc, section)) {
|
||||
lpc2xml_log(ctx->ctx, LPC2XML_WARNING, "Skipped section %s", section);
|
||||
return;
|
||||
}
|
||||
|
||||
node = xmlNewChild(ctx->node, NULL, (const xmlChar *)"section", NULL);
|
||||
if(node == NULL) {
|
||||
lpc2xml_log(ctx->ctx, LPC2XML_ERROR, "Can't create \"section\" element");
|
||||
ctx->ret = -1;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ typedef struct _LpItem{
|
|||
char *value;
|
||||
int is_comment;
|
||||
bool_t overwrite; // If set to true, will add overwrite=true when converted to xml
|
||||
bool_t skip; // If set to true, won't be dumped when converted to xml
|
||||
} LpItem;
|
||||
|
||||
typedef struct _LpSectionParam{
|
||||
|
|
@ -75,6 +76,7 @@ typedef struct _LpSection{
|
|||
MSList *items;
|
||||
MSList *params;
|
||||
bool_t overwrite; // If set to true, will add overwrite=true to all items of this section when converted to xml
|
||||
bool_t skip; // If set to true, won't be dumped when converted to xml
|
||||
} LpSection;
|
||||
|
||||
struct _LpConfig{
|
||||
|
|
@ -576,7 +578,7 @@ bool_t lp_config_get_overwrite_flag_for_entry(const LpConfig *lpconfig, const ch
|
|||
item = lp_section_find_item(sec, key);
|
||||
if (item != NULL) return item->overwrite;
|
||||
}
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool_t lp_config_get_overwrite_flag_for_section(const LpConfig *lpconfig, const char *section) {
|
||||
|
|
@ -585,7 +587,27 @@ bool_t lp_config_get_overwrite_flag_for_section(const LpConfig *lpconfig, const
|
|||
if (sec != NULL){
|
||||
return sec->overwrite;
|
||||
}
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool_t lp_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);
|
||||
if (sec != NULL){
|
||||
item = lp_section_find_item(sec, key);
|
||||
if (item != NULL) return item->skip;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool_t lp_config_get_skip_flag_for_section(const LpConfig *lpconfig, const char *section) {
|
||||
LpSection *sec;
|
||||
sec = lp_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){
|
||||
|
|
@ -658,6 +680,24 @@ void lp_config_set_overwrite_flag_for_section(LpConfig *lpconfig, const char *se
|
|||
}
|
||||
}
|
||||
|
||||
void lp_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);
|
||||
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) {
|
||||
LpSection *sec;
|
||||
sec = lp_config_find_section(lpconfig, section);
|
||||
if (sec != NULL) {
|
||||
sec->skip = value;
|
||||
}
|
||||
}
|
||||
|
||||
void lp_item_write(LpItem *item, FILE *file){
|
||||
if (item->is_comment)
|
||||
fprintf(file,"%s\n",item->value);
|
||||
|
|
|
|||
|
|
@ -348,6 +348,34 @@ LINPHONE_PUBLIC bool_t lp_config_get_overwrite_flag_for_section(const LpConfig *
|
|||
**/
|
||||
LINPHONE_PUBLIC void lp_config_set_overwrite_flag_for_section(LpConfig *lpconfig, const char *section, bool_t value);
|
||||
|
||||
/**
|
||||
* Retrieves the skip flag for a config item
|
||||
*
|
||||
* @ingroup misc
|
||||
**/
|
||||
LINPHONE_PUBLIC bool_t lp_config_get_skip_flag_for_entry(const LpConfig *lpconfig, const char *section, const char *key);
|
||||
|
||||
/**
|
||||
* Sets the skip flag for a config item (used when dumping config as xml)
|
||||
*
|
||||
* @ingroup misc
|
||||
**/
|
||||
LINPHONE_PUBLIC void lp_config_set_skip_flag_for_entry(LpConfig *lpconfig, const char *section, const char *key, bool_t value);
|
||||
|
||||
/**
|
||||
* Retrieves the skip flag for a config section
|
||||
*
|
||||
* @ingroup misc
|
||||
**/
|
||||
LINPHONE_PUBLIC bool_t lp_config_get_skip_flag_for_section(const LpConfig *lpconfig, const char *section);
|
||||
|
||||
/**
|
||||
* Sets the skip flag for a config section (used when dumping config as xml)
|
||||
*
|
||||
* @ingroup misc
|
||||
**/
|
||||
LINPHONE_PUBLIC void lp_config_set_skip_flag_for_section(LpConfig *lpconfig, const char *section, bool_t value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue