Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
1537a522
Commit
1537a522
authored
Apr 05, 2016
by
Gautier Pelloux-Prayer
Browse files
lpconfig: add lp_config_dump
parent
2d3d9754
Changes
2
Hide whitespace changes
Inline
Side-by-side
coreapi/lpconfig.c
View file @
1537a522
...
...
@@ -923,26 +923,53 @@ const char** lp_config_get_sections_names(LpConfig *lpconfig) {
const
MSList
*
sections
=
lpconfig
->
sections
;
int
ndev
;
int
i
;
ndev
=
ms_list_size
(
sections
);
sections_names
=
ms_malloc
((
ndev
+
1
)
*
sizeof
(
const
char
*
));
for
(
i
=
0
;
sections
!=
NULL
;
sections
=
sections
->
next
,
i
++
)
{
LpSection
*
section
=
(
LpSection
*
)
sections
->
data
;
sections_names
[
i
]
=
ms_strdup
(
section
->
name
);
}
sections_names
[
ndev
]
=
NULL
;
return
sections_names
;
}
char
*
lp_config_dump_as_xml
(
const
LpConfig
*
lpconfig
)
{
char
*
buffer
;
lpc2xml_context
*
ctx
=
lpc2xml_context_new
(
NULL
,
NULL
);
lpc2xml_set_lpc
(
ctx
,
lpconfig
);
lpc2xml_convert_string
(
ctx
,
&
buffer
);
lpc2xml_context_destroy
(
ctx
);
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
;
}
\ No newline at end of file
}
coreapi/lpconfig.h
View file @
1537a522
...
...
@@ -306,11 +306,20 @@ LINPHONE_PUBLIC bool_t lp_config_relative_file_exists(const LpConfig *lpconfig,
* Dumps the LpConfig as XML into a buffer
* @param[in] lpconfig The LpConfig object
* @return The buffer that contains the XML dump
*
*
* @ingroup misc
**/
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
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment