mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-02 09:01:48 -05:00
ucm: cfg-save - allow to save the sub-tree including root keys
The leading '+' in the keys specification add the key prefix (sub-tree root identification) to the saved configuration. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
225d3aecb6
commit
0ee4642a69
2 changed files with 20 additions and 6 deletions
|
|
@ -1607,8 +1607,8 @@ static int _snd_config_save_children(snd_config_t *config, snd_output_t *out,
|
||||||
unsigned int level, unsigned int joins,
|
unsigned int level, unsigned int joins,
|
||||||
int array);
|
int array);
|
||||||
|
|
||||||
static int _snd_config_save_node_value(snd_config_t *n, snd_output_t *out,
|
int _snd_config_save_node_value(snd_config_t *n, snd_output_t *out,
|
||||||
unsigned int level)
|
unsigned int level)
|
||||||
{
|
{
|
||||||
int err, array;
|
int err, array;
|
||||||
switch (n->type) {
|
switch (n->type) {
|
||||||
|
|
|
||||||
|
|
@ -573,20 +573,27 @@ static int execute_sysw(const char *sysw)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _snd_config_save_node_value(snd_config_t *n, snd_output_t *out, unsigned int level);
|
||||||
|
|
||||||
static int execute_cfgsave(snd_use_case_mgr_t *uc_mgr, const char *filename)
|
static int execute_cfgsave(snd_use_case_mgr_t *uc_mgr, const char *filename)
|
||||||
{
|
{
|
||||||
snd_config_t *config = uc_mgr->local_config;
|
snd_config_t *config = uc_mgr->local_config;
|
||||||
char *file, *root;
|
char *file, *root;
|
||||||
snd_output_t *out;
|
snd_output_t *out;
|
||||||
|
bool with_root = false;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
file = strdup(filename);
|
file = strdup(filename);
|
||||||
if (!file)
|
if (!file)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
root = strchr(file, ':');
|
root = strchr(file, ':');
|
||||||
if (root) {
|
if (config && root) {
|
||||||
*root = '\0';
|
*root++ = '\0';
|
||||||
err = snd_config_search(config, root + 1, &config);
|
if (*root == '+') {
|
||||||
|
with_root = true;
|
||||||
|
root++;
|
||||||
|
}
|
||||||
|
err = snd_config_search(config, root, &config);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
uc_error("Unable to find subtree '%s'", root);
|
uc_error("Unable to find subtree '%s'", root);
|
||||||
goto _err;
|
goto _err;
|
||||||
|
|
@ -598,7 +605,14 @@ static int execute_cfgsave(snd_use_case_mgr_t *uc_mgr, const char *filename)
|
||||||
uc_error("unable to open file '%s': %s", file, snd_strerror(err));
|
uc_error("unable to open file '%s': %s", file, snd_strerror(err));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
err = snd_config_save(config, out);
|
if (!config || snd_config_is_empty(config))
|
||||||
|
goto _err;
|
||||||
|
if (with_root) {
|
||||||
|
snd_output_printf(out, "%s ", root);
|
||||||
|
err = _snd_config_save_node_value(config, out, 0);
|
||||||
|
} else {
|
||||||
|
err = snd_config_save(config, out);
|
||||||
|
}
|
||||||
snd_output_close(out);
|
snd_output_close(out);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
uc_error("unable to save configuration: %s", snd_strerror(err));
|
uc_error("unable to save configuration: %s", snd_strerror(err));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue