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