Lines Matching defs:config

590  * \brief Returns the default top-level config directory
591 * \return The top-level config directory path string
593 * This function returns the string of the top-level config directory path.
1126 static int _snd_config_make(snd_config_t **config, char **id, snd_config_type_t type)
1129 assert(config);
1145 *config = n;
1150 static int _snd_config_make_add(snd_config_t **config, char **id,
1161 *config = n;
1165 static int _snd_config_search(snd_config_t *config,
1169 snd_config_for_each(i, next, config) {
1625 static int _snd_config_save_children(snd_config_t *config, snd_output_t *out,
1673 static int _snd_config_save_children(snd_config_t *config, snd_output_t *out,
1679 assert(config && out);
1680 snd_config_for_each(i, next, config) {
1806 * \param config Handle to the configuration node.
1812 snd_config_type_t snd_config_get_type(const snd_config_t *config)
1814 return config->type;
1834 * \param config Handle to the configuration node.
1838 int snd_config_is_array(const snd_config_t *config)
1844 assert(config);
1845 if (config->type != SND_CONFIG_TYPE_COMPOUND)
1848 snd_config_for_each(i, next, config) {
1859 * \param config Handle to the configuration node.
1862 int snd_config_is_empty(const snd_config_t *config)
1864 assert(config);
1865 if (config->type != SND_CONFIG_TYPE_COMPOUND)
1867 return list_empty(&config->u.compound.fields);
1872 * \param[in] config Handle to the configuration node.
1886 int snd_config_get_id(const snd_config_t *config, const char **id)
1888 assert(config && id);
1889 *id = config->id;
1895 * \param config Handle to the configuration node.
1903 * <dt>-EEXIST<dd>One of \a config's siblings already has the id \a id.
1908 int snd_config_set_id(snd_config_t *config, const char *id)
1912 assert(config);
1914 if (config->parent) {
1915 snd_config_for_each(i, next, config->parent) {
1917 if (n != config && strcmp(id, n->id) == 0)
1925 if (config->parent)
1929 free(config->id);
1930 config->id = new_id;
1936 * \param[out] config Handle to the new node.
1950 int snd_config_top(snd_config_t **config)
1952 assert(config);
1953 return _snd_config_make(config, 0, SND_CONFIG_TYPE_COMPOUND);
1957 int _snd_config_load_with_include(snd_config_t *config, snd_input_t *in,
1964 assert(config && in);
1987 err = parse_defs(config, &input, 0, override);
2041 * \param config Handle to a top level configuration node.
2045 * The definitions loaded from the input are added to \a config, which
2055 int snd_config_load(snd_config_t *config, snd_input_t *in)
2057 return _snd_config_load_with_include(config, in, 0, NULL);
2062 * \param[out] config The function puts the handle to the configuration
2064 * by \a config.
2069 * The definitions loaded from the string are put to \a config, which
2076 int snd_config_load_string(snd_config_t **config, const char *s, size_t size)
2082 assert(config && s);
2099 *config = dst;
2105 * \param config Handle to a top level configuration node.
2109 * This function loads definitions from \a in into \a config like
2113 int snd_config_load_override(snd_config_t *config, snd_input_t *in)
2115 return _snd_config_load_with_include(config, in, 1, NULL);
2266 * \brief In-place merge of two config handles
2278 * from the \a src config handle.
2282 * Note: On error, config handles may be modified.
2327 /* move config from src to dst */
2339 * \param config Handle to the configuration node to be removed.
2342 * This function makes \a config a top-level node, i.e., if \a config
2343 * has a parent, then \a config is removed from the list of the parent's
2350 int snd_config_remove(snd_config_t *config)
2352 assert(config);
2353 if (config->parent)
2354 list_del(&config->list);
2355 config->parent = NULL;
2361 * \param config Handle to the configuration node to be deleted.
2372 * The function is supposed to be called only for locally copied config
2381 int snd_config_delete(snd_config_t *config)
2383 assert(config);
2384 if (config->refcount > 0) {
2385 config->refcount--;
2388 switch (config->type) {
2393 i = config->u.compound.fields.next;
2394 while (i != &config->u.compound.fields) {
2405 free(config->u.string);
2410 if (config->parent)
2411 list_del(&config->list);
2412 free(config->id);
2413 free(config);
2419 * \param config Handle to the compound configuration node.
2424 * Any compound nodes among the children of \a config are deleted
2427 * After a successful call to this function, \a config is an empty
2432 * <dt>-EINVAL<dd>\a config is not a compound node.
2435 int snd_config_delete_compound_members(const snd_config_t *config)
2440 assert(config);
2441 if (config->type != SND_CONFIG_TYPE_COMPOUND)
2443 i = config->u.compound.fields.next;
2444 while (i != &config->u.compound.fields) {
2457 * \param[out] config The function puts the handle to the new node at
2458 * the address specified by \a config.
2474 int snd_config_make(snd_config_t **config, const char *id,
2478 assert(config);
2485 return _snd_config_make(config, &id1, type);
2490 * \param[out] config The function puts the handle to the new node at
2491 * the address specified by \a config.
2508 int snd_config_make_integer(snd_config_t **config, const char *id)
2510 return snd_config_make(config, id, SND_CONFIG_TYPE_INTEGER);
2515 * \param[out] config The function puts the handle to the new node at
2516 * the address specified by \a config.
2533 int snd_config_make_integer64(snd_config_t **config, const char *id)
2535 return snd_config_make(config, id, SND_CONFIG_TYPE_INTEGER64);
2540 * \param[out] config The function puts the handle to the new node at
2541 * the address specified by \a config.
2555 int snd_config_make_real(snd_config_t **config, const char *id)
2557 return snd_config_make(config, id, SND_CONFIG_TYPE_REAL);
2562 * \param[out] config The function puts the handle to the new node at
2563 * the address specified by \a config.
2580 int snd_config_make_string(snd_config_t **config, const char *id)
2582 return snd_config_make(config, id, SND_CONFIG_TYPE_STRING);
2587 * \param[out] config The function puts the handle to the new node at
2588 * the address specified by \a config.
2602 int snd_config_make_pointer(snd_config_t **config, const char *id)
2604 return snd_config_make(config, id, SND_CONFIG_TYPE_POINTER);
2609 * \param[out] config The function puts the handle to the new node at
2610 * the address specified by \a config.
2645 int snd_config_make_compound(snd_config_t **config, const char *id,
2649 err = snd_config_make(config, id, SND_CONFIG_TYPE_COMPOUND);
2652 (*config)->u.compound.join = join;
2658 * \param[out] config The function puts the handle to the new or
2660 * by \a config.
2697 int snd_config_make_path(snd_config_t **config, snd_config_t *root,
2726 err = _snd_config_search(root, key, -1, config);
2728 if ((*config)->type != SND_CONFIG_TYPE_COMPOUND) {
2730 err = snd_config_delete(*config);
2747 *config = n;
2755 * \param[out] config The function puts the handle to the new node at
2756 * the address specified by \a config.
2772 int snd_config_imake_integer(snd_config_t **config, const char *id, const long value)
2776 err = snd_config_make(config, id, SND_CONFIG_TYPE_INTEGER);
2779 (*config)->u.integer = value;
2785 * \param[out] config The function puts the handle to the new node at
2786 * the address specified by \a config.
2802 int snd_config_imake_integer64(snd_config_t **config, const char *id, const long long value)
2806 err = snd_config_make(config, id, SND_CONFIG_TYPE_INTEGER64);
2809 (*config)->u.integer64 = value;
2815 * \param[out] config The function puts the handle to the new node at
2816 * the address specified by \a config.
2829 int snd_config_imake_real(snd_config_t **config, const char *id, const double value)
2833 err = snd_config_make(config, id, SND_CONFIG_TYPE_REAL);
2836 (*config)->u.real = value;
2842 * \param[out] config The function puts the handle to the new node at
2843 * the address specified by \a config.
2859 int snd_config_imake_string(snd_config_t **config, const char *id, const char *value)
2876 *config = tmp;
2882 * \param[out] config The function puts the handle to the new node at
2883 * the address specified by \a config.
2900 int snd_config_imake_safe_string(snd_config_t **config, const char *id, const char *value)
2927 *config = tmp;
2934 * \param[out] config The function puts the handle to the new node at
2935 * the address specified by \a config.
2948 int snd_config_imake_pointer(snd_config_t **config, const char *id, const void *value)
2952 err = snd_config_make(config, id, SND_CONFIG_TYPE_POINTER);
2955 (*config)->u.ptr = value;
2961 * \param config Handle to the configuration node.
2967 * <dt>-EINVAL<dd>\a config is not an integer node.
2973 int snd_config_set_integer(snd_config_t *config, long value)
2975 assert(config);
2976 if (config->type != SND_CONFIG_TYPE_INTEGER)
2978 config->u.integer = value;
2984 * \param config Handle to the configuration node.
2990 * <dt>-EINVAL<dd>\a config is not a 64-bit-integer node.
2996 int snd_config_set_integer64(snd_config_t *config, long long value)
2998 assert(config);
2999 if (config->type != SND_CONFIG_TYPE_INTEGER64)
3001 config->u.integer64 = value;
3007 * \param config Handle to the configuration node.
3013 * <dt>-EINVAL<dd>\a config is not a real-number node.
3016 int snd_config_set_real(snd_config_t *config, double value)
3018 assert(config);
3019 if (config->type != SND_CONFIG_TYPE_REAL)
3021 config->u.real = value;
3027 * \param config Handle to the configuration node.
3036 * <dt>-EINVAL<dd>\a config is not a string node.
3042 int snd_config_set_string(snd_config_t *config, const char *value)
3045 assert(config);
3046 if (config->type != SND_CONFIG_TYPE_STRING)
3055 free(config->u.string);
3056 config->u.string = new_string;
3062 * \param config Handle to the configuration node.
3070 * <dt>-EINVAL<dd>\a config is not a pointer node.
3073 int snd_config_set_pointer(snd_config_t *config, const void *value)
3075 assert(config);
3076 if (config->type != SND_CONFIG_TYPE_POINTER)
3078 config->u.ptr = value;
3084 * \param config Handle to the configuration node.
3098 * <dt>-EINVAL<dd>\a config is not a number or string node.
3107 int snd_config_set_ascii(snd_config_t *config, const char *ascii)
3109 assert(config && ascii);
3110 switch (config->type) {
3117 config->u.integer = i;
3126 config->u.integer64 = i;
3135 config->u.real = d;
3143 free(config->u.string);
3144 config->u.string = ptr;
3155 * \param[in] config Handle to the configuration node.
3161 * <dt>-EINVAL<dd>\a config is not an integer node.
3167 int snd_config_get_integer(const snd_config_t *config, long *ptr)
3169 assert(config && ptr);
3170 if (config->type != SND_CONFIG_TYPE_INTEGER)
3172 *ptr = config->u.integer;
3178 * \param[in] config Handle to the configuration node.
3184 * <dt>-EINVAL<dd>\a config is not a 64-bit-integer node.
3190 int snd_config_get_integer64(const snd_config_t *config, long long *ptr)
3192 assert(config && ptr);
3193 if (config->type != SND_CONFIG_TYPE_INTEGER64)
3195 *ptr = config->u.integer64;
3201 * \param[in] config Handle to the configuration node.
3207 * <dt>-EINVAL<dd>\a config is not a real-number node.
3210 int snd_config_get_real(const snd_config_t *config, double *ptr)
3212 assert(config && ptr);
3213 if (config->type != SND_CONFIG_TYPE_REAL)
3215 *ptr = config->u.real;
3221 * \param[in] config Handle to the configuration node.
3230 * <dt>-EINVAL<dd>\a config is not a number node.
3233 int snd_config_get_ireal(const snd_config_t *config, double *ptr)
3235 assert(config && ptr);
3236 if (config->type == SND_CONFIG_TYPE_REAL)
3237 *ptr = config->u.real;
3238 else if (config->type == SND_CONFIG_TYPE_INTEGER)
3239 *ptr = config->u.integer;
3240 else if (config->type == SND_CONFIG_TYPE_INTEGER64)
3241 *ptr = config->u.integer64;
3249 * \param[in] config Handle to the configuration node.
3262 * <dt>-EINVAL<dd>\a config is not a string node.
3268 int snd_config_get_string(const snd_config_t *config, const char **ptr)
3270 assert(config && ptr);
3271 if (config->type != SND_CONFIG_TYPE_STRING)
3273 *ptr = config->u.string;
3279 * \param[in] config Handle to the configuration node.
3286 * <dt>-EINVAL<dd>\a config is not a string node.
3289 int snd_config_get_pointer(const snd_config_t *config, const void **ptr)
3291 assert(config && ptr);
3292 if (config->type != SND_CONFIG_TYPE_POINTER)
3294 *ptr = config->u.ptr;
3300 * \param[in] config Handle to the configuration node.
3317 * <dt>-EINVAL<dd>\a config is not a (64-bit) integer or real number or
3325 int snd_config_get_ascii(const snd_config_t *config, char **ascii)
3327 assert(config && ascii);
3328 switch (config->type) {
3333 err = snprintf(res, sizeof(res), "%li", config->u.integer);
3345 err = snprintf(res, sizeof(res), "%lli", config->u.integer64);
3357 err = snprintf(res, sizeof(res), "%-16g", config->u.real);
3375 if (config->u.string)
3376 *ascii = strdup(config->u.string);
3392 * \param config Handle to the configuration node.
3395 * less than zero if \a config's id is lexicographically less
3396 * than \a id, zero if \a config's id is equal to id, greater
3399 int snd_config_test_id(const snd_config_t *config, const char *id)
3401 assert(config && id);
3402 if (config->id)
3403 return strcmp(config->id, id);
3410 * \param config Handle to the (root) configuration node.
3414 * This function writes a textual representation of \a config's value to
3426 int snd_config_save(snd_config_t *config, snd_output_t *out)
3428 assert(config && out);
3429 if (config->type == SND_CONFIG_TYPE_COMPOUND) {
3430 int array = snd_config_is_array(config);
3431 return _snd_config_save_children(config, out, 0, 0, array);
3433 return _snd_config_save_node_value(config, out, 0);
3443 #define SND_CONFIG_SEARCH(config, key, result, extra_code) \
3448 assert(config && key); \
3450 if (config->type != SND_CONFIG_TYPE_COMPOUND) \
3455 err = _snd_config_search(config, key, p - key, &n); \
3458 config = n; \
3461 return _snd_config_search(config, key, -1, result); \
3465 #define SND_CONFIG_SEARCHA(root, config, key, result, fcn, extra_code) \
3470 assert(config && key); \
3472 if (config->type != SND_CONFIG_TYPE_COMPOUND) { \
3473 if (snd_config_get_string(config, &p) < 0) \
3475 err = fcn(root, root, p, &config); \
3482 err = _snd_config_search(config, key, p - key, &n); \
3485 config = n; \
3488 return _snd_config_search(config, key, -1, result); \
3492 #define SND_CONFIG_SEARCHV(config, result, fcn) \
3496 assert(config); \
3503 err = fcn(config, k, &n); \
3508 config = n; \
3516 #define SND_CONFIG_SEARCHVA(root, config, result, fcn) \
3520 assert(config); \
3527 err = fcn(root, config, k, &n); \
3532 config = n; \
3540 #define SND_CONFIG_SEARCH_ALIAS(config, base, key, result, fcn1, fcn2) \
3545 assert(config && key); \
3553 err = first && base ? -EIO : fcn1(config, config, key, &res); \
3557 err = fcn2(config, config, &res, base, key, NULL); \
3589 * \param[in] config Handle to the root of the configuration (sub)tree to search.
3596 * This function searches for a child node of \a config that is
3598 * node of \a config, or a series of ids, separated with dots, where
3603 * search key to find that node, assuming that \a config is a handle to
3604 * the compound node with id \c config:
3606 * config {
3620 * <dt>-ENOENT<dd>\a config or one of its child nodes to be searched is
3627 int snd_config_search(snd_config_t *config, const char *key, snd_config_t **result)
3629 SND_CONFIG_SEARCH(config, key, result, );
3636 * \param[in] config Handle to the root of the configuration (sub)tree to search.
3643 * This functions searches for a child node of \a config like
3649 * \a root and \a config may be the same node.
3653 * snd_config_searcha(root, config, "a.b.c.d", &result);
3657 * config {
3678 * <dt>-ENOENT<dd>\a config or one of its child nodes to be searched is
3682 int snd_config_searcha(snd_config_t *root, snd_config_t *config, const char *key, snd_config_t **result)
3684 SND_CONFIG_SEARCHA(root, config, key, result, snd_config_searcha, );
3689 * \param[in] config Handle to the root of the configuration (sub)tree to search.
3697 * This functions searches for a child node of \a config like
3711 * <dt>-ENOENT<dd>\a config or one of its child nodes to be searched is
3718 int snd_config_searchv(snd_config_t *config, snd_config_t **result, ...)
3720 SND_CONFIG_SEARCHV(config, result, snd_config_search);
3727 * \param[in] config Handle to the root of the configuration (sub)tree to search.
3735 * This function searches for a child node of \a config, allowing
3743 * <dt>-ENOENT<dd>\a config or one of its child nodes to be searched is
3747 int snd_config_searchva(snd_config_t *root, snd_config_t *config, snd_config_t **result, ...)
3749 SND_CONFIG_SEARCHVA(root, config, result, snd_config_searcha);
3754 * \param[in] config Handle to the root of the configuration (sub)tree to search.
3762 * This functions searches for a child node of \a config, allowing
3764 * searched below \a config (there is no separate \a root parameter),
3767 * directly below \a config and that does not contain a period. In
3768 * other words, when \c "id" is not found in \a config, this function
3774 * <dt>-ENOENT<dd>\a config or one of its child nodes to be searched is
3778 int snd_config_search_alias(snd_config_t *config,
3782 SND_CONFIG_SEARCH_ALIAS(config, base, key, result,
3786 static int snd_config_hooks(snd_config_t *config, snd_config_t *private_data);
3790 * \param[in,out] config Handle to the root of the configuration
3797 * This functions searches for a child node of \a config like
3804 * <dt>-ENOENT<dd>\a config or one of its child nodes to be searched is
3810 int snd_config_search_hooks(snd_config_t *config, const char *key, snd_config_t **result)
3812 SND_CONFIG_SEARCH(config, key, result, \
3813 err = snd_config_hooks(config, NULL); \
3823 * \param[in,out] config Handle to the root of the configuration
3830 * This function searches for a child node of \a config, allowing
3837 * <dt>-ENOENT<dd>\a config or one of its child nodes to be searched is
3843 int snd_config_searcha_hooks(snd_config_t *root, snd_config_t *config, const char *key, snd_config_t **result)
3845 SND_CONFIG_SEARCHA(root, config, key, result,
3847 err = snd_config_hooks(config, NULL); \
3857 * \param[in,out] config Handle to the root of the configuration
3865 * This function searches for a child node of \a config, allowing
3873 * <dt>-ENOENT<dd>\a config or one of its child nodes to be searched is
3879 int snd_config_searchva_hooks(snd_config_t *root, snd_config_t *config,
3882 SND_CONFIG_SEARCHVA(root, config, result, snd_config_searcha_hooks);
3887 * \param[in] config Handle to the root of the configuration (sub)tree
3895 * This functions searches for a child node of \a config, allowing
3902 * <dt>-ENOENT<dd>\a config or one of its child nodes to be searched is
3908 int snd_config_search_alias_hooks(snd_config_t *config,
3912 SND_CONFIG_SEARCH_ALIAS(config, base, key, result,
3960 static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_config_t *private_data)
3967 int (*func)(snd_config_t *root, snd_config_t *config, snd_config_t **dst, snd_config_t *private_data) = NULL;
3970 err = snd_config_search(config, "func", &c);
4040 err = func(root, config, &nroot, private_data);
4053 static int snd_config_hooks(snd_config_t *config, snd_config_t *private_data)
4059 if ((err = snd_config_search(config, "@hooks", &n)) < 0)
4076 err = snd_config_hooks_call(config, n, private_data);
4251 * \param[in] config Handle to the configuration node for this hook.
4260 int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t **dst, snd_config_t *private_data)
4267 if ((err = snd_config_search(config, "errors", &n)) >= 0) {
4274 if ((err = snd_config_search(config, "files", &n)) < 0) {
4352 static int _snd_config_hook_table(snd_config_t *root, snd_config_t *config, snd_config_t *private_data)
4358 if (snd_config_search(config, "table", &n) < 0)
4394 * \param[in] config Handle to the configuration node for this hook.
4405 int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config, snd_config_t **dst, snd_config_t *private_data ATTRIBUTE_UNUSED)
4463 err = _snd_config_hook_table(root, config, private_data);
4467 err = snd_config_hook_load(root, config, &n, private_data);
4665 * For safer operations, use #snd_config_update_ref and release the config
4719 * \brief Take the reference of the config tree.
4721 * Increases a reference counter of the given config tree.
4734 * \brief Unreference the config tree.
4736 * Decreases a reference counter of the given config tree, and eventually
4740 * Also, the config taken via #snd_config_update_ref must be unreferenced
4798 * \param[in] config Handle to a configuration node.
4799 * \return An iterator pointing to \a config's first child.
4801 * \a config must be a compound node.
4804 * of #snd_config_iterator_end on \a config.
4812 snd_config_iterator_t snd_config_iterator_first(const snd_config_t *config)
4814 assert(config->type == SND_CONFIG_TYPE_COMPOUND);
4815 return config->u.compound.fields.next;
4839 * \param[in] config Handle to a configuration node.
4840 * \return An iterator that indicates the end of \a config's children list.
4842 * \a config must be a compound node.
4845 * \a config.
4850 snd_config_iterator_t snd_config_iterator_end(const snd_config_t *config)
4852 assert(config->type == SND_CONFIG_TYPE_COMPOUND);
4853 return (const snd_config_iterator_t)&config->u.compound.fields;
5220 * \param[in,out] config Handle to the source configuration node.
5226 * This function evaluates any functions (\c \@func) in \a config and
5229 int snd_config_evaluate(snd_config_t *config, snd_config_t *root,
5234 return snd_config_walk(config, root, result, _snd_config_evaluate, NULL, private_data);
5636 * \param[in] config Handle to the configuration node.
5645 * If \a config has arguments (defined by a child with id \c \@args),
5649 * The resulting copy of \a config is returned in \a result.
5653 int snd_config_expand_custom(snd_config_t *config, snd_config_t *root,
5660 err = snd_config_walk(config, root, &res, _snd_config_expand, fcn, private_data);
5671 * \param[in] config Handle to the configuration node.
5680 * If \a config has arguments (defined by a child with id \c \@args),
5684 * The resulting copy of \a config is returned in \a result.
5686 int snd_config_expand(snd_config_t *config, snd_config_t *root, const char *args,
5691 err = snd_config_search(config, "@args", &defs);
5697 err = snd_config_copy(&res, config);
5719 err = snd_config_walk(config, root, &res, _snd_config_expand, _snd_config_expand_vars, subs);
5742 * \param[in] config Handle to the configuration (sub)tree to search.
5749 * This functions searches for a child node of \a config, allowing
5762 * <dt>-ENOENT<dd>\a config or one of its child nodes to be searched is
5768 int snd_config_search_definition(snd_config_t *config,
5786 * and the key starts from root given by the 'config' parameter
5789 err = snd_config_search_alias_hooks(config, strchr(key, '.') ? NULL : base, key, &conf);
5794 err = snd_config_expand(conf, config, args, NULL, result);