1/** 2 * \file include/conf.h 3 * \brief Application interface library for the ALSA driver 4 * \author Jaroslav Kysela <perex@perex.cz> 5 * \author Abramo Bagnara <abramo@alsa-project.org> 6 * \author Takashi Iwai <tiwai@suse.de> 7 * \date 1998-2001 8 * 9 * Application interface library for the ALSA driver 10 */ 11/* 12 * This library is free software; you can redistribute it and/or modify 13 * it under the terms of the GNU Lesser General Public License as 14 * published by the Free Software Foundation; either version 2.1 of 15 * the License, or (at your option) any later version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU Lesser General Public License for more details. 21 * 22 * You should have received a copy of the GNU Lesser General Public 23 * License along with this library; if not, write to the Free Software 24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25 * 26 */ 27 28#ifndef __ALSA_CONF_H 29#define __ALSA_CONF_H 30 31#ifdef __cplusplus 32extern "C" { 33#endif 34 35/** 36 * \defgroup Configuration Configuration Interface 37 * The configuration functions and types allow you to read, enumerate, 38 * modify and write the contents of ALSA configuration files. 39 * \{ 40 */ 41 42/** \brief \c dlsym version for the config evaluate callback. */ 43#define SND_CONFIG_DLSYM_VERSION_EVALUATE _dlsym_config_evaluate_001 44/** \brief \c dlsym version for the config hook callback. */ 45#define SND_CONFIG_DLSYM_VERSION_HOOK _dlsym_config_hook_001 46 47/** \brief Configuration node type. */ 48typedef enum _snd_config_type { 49 /** Integer number. */ 50 SND_CONFIG_TYPE_INTEGER, 51 /** 64-bit integer number. */ 52 SND_CONFIG_TYPE_INTEGER64, 53 /** Real number. */ 54 SND_CONFIG_TYPE_REAL, 55 /** Character string. */ 56 SND_CONFIG_TYPE_STRING, 57 /** Pointer (runtime only, cannot be saved). */ 58 SND_CONFIG_TYPE_POINTER, 59 /** Compound node. */ 60 SND_CONFIG_TYPE_COMPOUND = 1024 61} snd_config_type_t; 62 63/** 64 * \brief Internal structure for a configuration node object. 65 * 66 * The ALSA library uses a pointer to this structure as a handle to a 67 * configuration node. Applications don't access its contents directly. 68 */ 69typedef struct _snd_config snd_config_t; 70/** 71 * \brief Type for a configuration compound iterator. 72 * 73 * The ALSA library uses this pointer type as a handle to a configuration 74 * compound iterator. Applications don't directly access the contents of 75 * the structure pointed to by this type. 76 */ 77typedef struct _snd_config_iterator *snd_config_iterator_t; 78/** 79 * \brief Internal structure for a configuration private update object. 80 * 81 * The ALSA library uses this structure to save private update information. 82 */ 83typedef struct _snd_config_update snd_config_update_t; 84 85extern snd_config_t *snd_config; 86 87const char *snd_config_topdir(void); 88 89int snd_config_top(snd_config_t **config); 90 91int snd_config_load(snd_config_t *config, snd_input_t *in); 92int snd_config_load_string(snd_config_t **config, const char *s, size_t size); 93int snd_config_load_override(snd_config_t *config, snd_input_t *in); 94int snd_config_save(snd_config_t *config, snd_output_t *out); 95int snd_config_update(void); 96int snd_config_update_r(snd_config_t **top, snd_config_update_t **update, const char *path); 97int snd_config_update_free(snd_config_update_t *update); 98int snd_config_update_free_global(void); 99 100int snd_config_update_ref(snd_config_t **top); 101void snd_config_ref(snd_config_t *top); 102void snd_config_unref(snd_config_t *top); 103 104int snd_config_search(snd_config_t *config, const char *key, 105 snd_config_t **result); 106int snd_config_searchv(snd_config_t *config, 107 snd_config_t **result, ...); 108int snd_config_search_definition(snd_config_t *config, 109 const char *base, const char *key, 110 snd_config_t **result); 111 112/** 113 * \brief custom expansion callback 114 * \param[out] dst The function puts the handle to the new configuration 115 * node at the address specified by \a dst. 116 * \param[in] s string the string to be expanded 117 * \param[in] private_data Handle to the \c private_data node. 118 * \return A non-negative value if successful, otherwise a negative error code. 119 * 120 * Use a function of this type to define a custom expansion 121 */ 122typedef int (*snd_config_expand_fcn_t)(snd_config_t **dst, const char *s, void *private_data); 123 124int snd_config_expand_custom(snd_config_t *config, snd_config_t *root, 125 snd_config_expand_fcn_t fcn, void *private_data, 126 snd_config_t **result); 127int snd_config_expand(snd_config_t *config, snd_config_t *root, 128 const char *args, snd_config_t *private_data, 129 snd_config_t **result); 130int snd_config_evaluate(snd_config_t *config, snd_config_t *root, 131 snd_config_t *private_data, snd_config_t **result); 132int snd_config_evaluate_string(snd_config_t **dst, const char *s, 133 snd_config_expand_fcn_t fcn, void *private_data); 134 135int snd_config_add(snd_config_t *config, snd_config_t *child); 136int snd_config_add_before(snd_config_t *before, snd_config_t *child); 137int snd_config_add_after(snd_config_t *after, snd_config_t *child); 138int snd_config_remove(snd_config_t *config); 139int snd_config_delete(snd_config_t *config); 140int snd_config_delete_compound_members(const snd_config_t *config); 141int snd_config_copy(snd_config_t **dst, snd_config_t *src); 142int snd_config_substitute(snd_config_t *dst, snd_config_t *src); 143int snd_config_merge(snd_config_t *dst, snd_config_t *src, int override); 144 145int snd_config_make(snd_config_t **config, const char *key, 146 snd_config_type_t type); 147int snd_config_make_integer(snd_config_t **config, const char *key); 148int snd_config_make_integer64(snd_config_t **config, const char *key); 149int snd_config_make_real(snd_config_t **config, const char *key); 150int snd_config_make_string(snd_config_t **config, const char *key); 151int snd_config_make_pointer(snd_config_t **config, const char *key); 152int snd_config_make_compound(snd_config_t **config, const char *key, int join); 153int snd_config_make_path(snd_config_t **config, snd_config_t *root, const char *key, 154 int join, int override); 155 156int snd_config_imake_integer(snd_config_t **config, const char *key, const long value); 157int snd_config_imake_integer64(snd_config_t **config, const char *key, const long long value); 158int snd_config_imake_real(snd_config_t **config, const char *key, const double value); 159int snd_config_imake_string(snd_config_t **config, const char *key, const char *ascii); 160int snd_config_imake_safe_string(snd_config_t **config, const char *key, const char *ascii); 161int snd_config_imake_pointer(snd_config_t **config, const char *key, const void *ptr); 162 163snd_config_type_t snd_config_get_type(const snd_config_t *config); 164int snd_config_is_array(const snd_config_t *config); 165int snd_config_is_empty(const snd_config_t *config); 166 167int snd_config_set_id(snd_config_t *config, const char *id); 168int snd_config_set_integer(snd_config_t *config, long value); 169int snd_config_set_integer64(snd_config_t *config, long long value); 170int snd_config_set_real(snd_config_t *config, double value); 171int snd_config_set_string(snd_config_t *config, const char *value); 172int snd_config_set_ascii(snd_config_t *config, const char *ascii); 173int snd_config_set_pointer(snd_config_t *config, const void *ptr); 174int snd_config_get_id(const snd_config_t *config, const char **value); 175int snd_config_get_integer(const snd_config_t *config, long *value); 176int snd_config_get_integer64(const snd_config_t *config, long long *value); 177int snd_config_get_real(const snd_config_t *config, double *value); 178int snd_config_get_ireal(const snd_config_t *config, double *value); 179int snd_config_get_string(const snd_config_t *config, const char **value); 180int snd_config_get_ascii(const snd_config_t *config, char **value); 181int snd_config_get_pointer(const snd_config_t *config, const void **value); 182int snd_config_test_id(const snd_config_t *config, const char *id); 183 184snd_config_iterator_t snd_config_iterator_first(const snd_config_t *node); 185snd_config_iterator_t snd_config_iterator_next(const snd_config_iterator_t iterator); 186snd_config_iterator_t snd_config_iterator_end(const snd_config_t *node); 187snd_config_t *snd_config_iterator_entry(const snd_config_iterator_t iterator); 188 189/** 190 * \brief Helper macro to iterate over the children of a compound node. 191 * \param[in,out] pos Iterator variable for the current node. 192 * \param[in,out] next Temporary iterator variable for the next node. 193 * \param[in] node Handle to the compound configuration node to iterate over. 194 * 195 * Use this macro like a \c for statement, e.g.: 196 * \code 197 * snd_config_iterator_t pos, next; 198 * snd_config_for_each(pos, next, node) { 199 * snd_config_t *entry = snd_config_iterator_entry(pos); 200 * ... 201 * } 202 * \endcode 203 * 204 * This macro allows deleting or removing the current node. 205 */ 206#define snd_config_for_each(pos, next, node) \ 207 for (pos = snd_config_iterator_first(node), next = snd_config_iterator_next(pos); pos != snd_config_iterator_end(node); pos = next, next = snd_config_iterator_next(pos)) 208 209/* Misc functions */ 210 211int snd_config_get_bool_ascii(const char *ascii); 212int snd_config_get_bool(const snd_config_t *conf); 213int snd_config_get_card(const snd_config_t *conf); 214int snd_config_get_ctl_iface_ascii(const char *ascii); 215int snd_config_get_ctl_iface(const snd_config_t *conf); 216 217/* Names functions */ 218 219/** 220 * Device-name list element 221 */ 222typedef struct snd_devname snd_devname_t; 223 224/** 225 * Device-name list element (definition) 226 */ 227struct snd_devname { 228 char *name; /**< Device name string */ 229 char *comment; /**< Comments */ 230 snd_devname_t *next; /**< Next pointer */ 231}; 232 233int snd_names_list(const char *iface, snd_devname_t **list); 234void snd_names_list_free(snd_devname_t *list); 235 236/** \} */ 237 238#ifdef __cplusplus 239} 240#endif 241 242#endif /* __ALSA_CONF_H */ 243