mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-21 14:58:29 +00:00
lpconfig: add lp_config_dump
This commit is contained in:
parent
2d3d975425
commit
1537a5228a
2 changed files with 43 additions and 7 deletions
|
|
@ -923,26 +923,53 @@ const char** lp_config_get_sections_names(LpConfig *lpconfig) {
|
||||||
const MSList *sections = lpconfig->sections;
|
const MSList *sections = lpconfig->sections;
|
||||||
int ndev;
|
int ndev;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ndev = ms_list_size(sections);
|
ndev = ms_list_size(sections);
|
||||||
sections_names = ms_malloc((ndev + 1) * sizeof(const char *));
|
sections_names = ms_malloc((ndev + 1) * sizeof(const char *));
|
||||||
|
|
||||||
for (i = 0; sections != NULL; sections = sections->next, i++) {
|
for (i = 0; sections != NULL; sections = sections->next, i++) {
|
||||||
LpSection *section = (LpSection *)sections->data;
|
LpSection *section = (LpSection *)sections->data;
|
||||||
sections_names[i] = ms_strdup(section->name);
|
sections_names[i] = ms_strdup(section->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
sections_names[ndev] = NULL;
|
sections_names[ndev] = NULL;
|
||||||
return sections_names;
|
return sections_names;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* lp_config_dump_as_xml(const LpConfig *lpconfig) {
|
char* lp_config_dump_as_xml(const LpConfig *lpconfig) {
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
|
||||||
lpc2xml_context *ctx = lpc2xml_context_new(NULL, NULL);
|
lpc2xml_context *ctx = lpc2xml_context_new(NULL, NULL);
|
||||||
lpc2xml_set_lpc(ctx, lpconfig);
|
lpc2xml_set_lpc(ctx, lpconfig);
|
||||||
lpc2xml_convert_string(ctx, &buffer);
|
lpc2xml_convert_string(ctx, &buffer);
|
||||||
lpc2xml_context_destroy(ctx);
|
lpc2xml_context_destroy(ctx);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct _entry_data {
|
||||||
|
const LpConfig *conf;
|
||||||
|
const char *section;
|
||||||
|
char** buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
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, "");
|
||||||
|
*d->buffer = ms_strcat_printf(*d->buffer, "\t%s=%s\n", entry, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* lp_config_dump(const LpConfig *lpconfig) {
|
||||||
|
char* buffer = NULL;
|
||||||
|
struct _entry_data d = { lpconfig, NULL, &buffer };
|
||||||
|
lp_config_for_each_section(lpconfig, dump_section, &d);
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -306,11 +306,20 @@ LINPHONE_PUBLIC bool_t lp_config_relative_file_exists(const LpConfig *lpconfig,
|
||||||
* Dumps the LpConfig as XML into a buffer
|
* Dumps the LpConfig as XML into a buffer
|
||||||
* @param[in] lpconfig The LpConfig object
|
* @param[in] lpconfig The LpConfig object
|
||||||
* @return The buffer that contains the XML dump
|
* @return The buffer that contains the XML dump
|
||||||
*
|
*
|
||||||
* @ingroup misc
|
* @ingroup misc
|
||||||
**/
|
**/
|
||||||
LINPHONE_PUBLIC char* lp_config_dump_as_xml(const LpConfig *lpconfig);
|
LINPHONE_PUBLIC char* lp_config_dump_as_xml(const LpConfig *lpconfig);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps the LpConfig as INI into a buffer
|
||||||
|
* @param[in] lpconfig The LpConfig object
|
||||||
|
* @return The buffer that contains the config dump
|
||||||
|
*
|
||||||
|
* @ingroup misc
|
||||||
|
**/
|
||||||
|
LINPHONE_PUBLIC char* lp_config_dump(const LpConfig *lpconfig);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the overwrite flag for a config item
|
* Retrieves the overwrite flag for a config item
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue