参照元†
- snd_config_t *config
- const char *base
- const char *name
- snd_config_t **result
返り値†
/**
* \brief Searches for a definition in a configuration tree, using
* aliases and expanding hooks and arguments.
* \param[in] config Handle to the configuration (sub)tree to search.
* \param[in] base Implicit key base, or \c NULL for none.
* \param[in] name Key suffix, optionally with arguments.
* \param[out] result The function puts the handle to the expanded found
* node at the address specified by \a result.
* \return A non-negative value if successful, otherwise a negative error code.
*
* This functions searches for a child node of \a config, allowing
* aliases and expanding hooks, like #snd_config_search_alias_hooks.
*
* If \a name contains a colon (:), the rest of the string after the
* colon contains arguments that are expanded as with
* #snd_config_expand.
*
* In any case, \a result is a new node that must be freed by the
* caller.
*
* \par Errors:
* <dl>
* <dt>-ENOENT<dd>An id in \a key or an alias id does not exist.
* <dt>-ENOENT<dd>\a config or one of its child nodes to be searched is
* not a compound node.
* </dl>
* Additionally, any errors encountered when parsing the hook
* definitions or arguments, or returned by (hook) functions.
*/
int snd_config_search_definition(snd_config_t *config,
const char *base, const char *name,
snd_config_t **result)
{
snd_config_t *conf;
char *key;
const char *args = strchr(name, ':');
int err;
if (args) {
args++;
key = alloca(args - name);
memcpy(key, name, args - name - 1);
key[args - name - 1] = '\0';
} else {
key = (char *) name;
}
/*
* if key contains dot (.), the implicit base is ignored
* and the key starts from root given by the 'config' parameter
*/
snd_config_lock();
err = snd_config_search_alias_hooks(config, strchr(key, '.') ? NULL : base, key, &conf);
if (err < 0) {
snd_config_unlock();
return err;
}
err = snd_config_expand(conf, config, args, NULL, result);
snd_config_unlock();
return err;
}
コメント†