OSDN Git Service

Updated GNU GPL license (address).
[android-x86/external-alsa-lib.git] / include / conf.h
1 /**
2  * \file <alsa/conf.h>
3  * \brief Application interface library for the ALSA driver
4  * \author Jaroslav Kysela <perex@suse.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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
25  *
26  */
27
28 #ifndef __ALSA_CONF_H
29 #define __ALSA_CONF_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /**
36  *  \defgroup Config Configuration Interface
37  *  Configuration Interface
38  *  \{
39  */
40
41 /** dlsym version for config evaluate callback */
42 #define SND_CONFIG_DLSYM_VERSION_EVALUATE       _dlsym_config_evaluate_001
43 /** dlsym version for config hook callback */
44 #define SND_CONFIG_DLSYM_VERSION_HOOK           _dlsym_config_hook_001
45
46 /** Config node type */
47 typedef enum _snd_config_type {
48         /** Integer number */
49         SND_CONFIG_TYPE_INTEGER,
50         /** Real number */
51         SND_CONFIG_TYPE_REAL,
52         /** Character string */
53         SND_CONFIG_TYPE_STRING,
54         /** Pointer - runtime only - cannot be saved */
55         SND_CONFIG_TYPE_POINTER,
56         /** Compound */
57         SND_CONFIG_TYPE_COMPOUND = 1024,
58 } snd_config_type_t;
59
60 /** Config node handle */
61 typedef struct _snd_config snd_config_t;
62 /** Config compound iterator */
63 typedef struct _snd_config_iterator *snd_config_iterator_t;
64 /** Config private update structure */
65 typedef struct _snd_config_update snd_config_update_t;
66
67 extern snd_config_t *snd_config;
68
69 int snd_config_top(snd_config_t **config);
70
71 int snd_config_load(snd_config_t *config, snd_input_t *in);
72 int snd_config_save(snd_config_t *config, snd_output_t *out);
73 int snd_config_update(void);
74 int snd_config_update_r(snd_config_t **top, snd_config_update_t **update, const char *path);
75 int snd_config_update_free(snd_config_update_t *update);
76 int snd_config_update_free_global(void);
77
78 int snd_config_search(snd_config_t *config, const char *key,
79                       snd_config_t **result);
80 int snd_config_searchv(snd_config_t *config, 
81                        snd_config_t **result, ...);
82 int snd_config_search_definition(snd_config_t *config,
83                                  const char *base, const char *key,
84                                  snd_config_t **result);
85
86 int snd_config_expand(snd_config_t *config, snd_config_t *root,
87                       const char *args, snd_config_t *private_data,
88                       snd_config_t **result);
89 int snd_config_evaluate(snd_config_t *config, snd_config_t *root,
90                         snd_config_t *private_data, snd_config_t **result);
91
92 int snd_config_add(snd_config_t *config, snd_config_t *leaf);
93 int snd_config_delete(snd_config_t *config);
94 int snd_config_delete_compound_members(const snd_config_t *config);
95 int snd_config_copy(snd_config_t **dst, snd_config_t *src);
96
97 int snd_config_make(snd_config_t **config, const char *key,
98                     snd_config_type_t type);
99 int snd_config_make_integer(snd_config_t **config, const char *key);
100 int snd_config_make_real(snd_config_t **config, const char *key);
101 int snd_config_make_string(snd_config_t **config, const char *key);
102 int snd_config_make_pointer(snd_config_t **config, const char *key);
103 int snd_config_make_compound(snd_config_t **config, const char *key, int join);
104
105 int snd_config_imake_integer(snd_config_t **config, const char *key, const long value);
106 int snd_config_imake_real(snd_config_t **config, const char *key, const double value);
107 int snd_config_imake_string(snd_config_t **config, const char *key, const char *ascii);
108 int snd_config_imake_pointer(snd_config_t **config, const char *key, const void *ptr);
109
110 snd_config_type_t snd_config_get_type(const snd_config_t *config);
111
112 int snd_config_set_id(snd_config_t *config, const char *id);
113 int snd_config_set_integer(snd_config_t *config, long value);
114 int snd_config_set_real(snd_config_t *config, double value);
115 int snd_config_set_string(snd_config_t *config, const char *value);
116 int snd_config_set_ascii(snd_config_t *config, const char *ascii);
117 int snd_config_set_pointer(snd_config_t *config, const void *ptr);
118 int snd_config_get_id(const snd_config_t *config, const char **value);
119 int snd_config_get_integer(const snd_config_t *config, long *value);
120 int snd_config_get_real(const snd_config_t *config, double *value);
121 int snd_config_get_ireal(const snd_config_t *config, double *value);
122 int snd_config_get_string(const snd_config_t *config, const char **value);
123 int snd_config_get_ascii(const snd_config_t *config, char **value);
124 int snd_config_get_pointer(const snd_config_t *config, const void **value);
125 int snd_config_test_id(const snd_config_t *config, const char *id);
126
127 const snd_config_iterator_t snd_config_iterator_first(const snd_config_t *node);
128 const snd_config_iterator_t snd_config_iterator_next(const snd_config_iterator_t iterator);
129 const snd_config_iterator_t snd_config_iterator_end(const snd_config_t *node);
130 snd_config_t *snd_config_iterator_entry(const snd_config_iterator_t iterator);
131
132 /** Helper for compound config node leaves traversal
133  * \param pos Current node iterator
134  * \param next Next node iterator
135  * \param node Compound config node
136  *
137  * This macro is designed to permit the removal of current node.
138  */
139 #define snd_config_for_each(pos, next, node) \
140         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))
141
142 /* Misc functions */
143
144 int snd_config_get_bool_ascii(const char *ascii);
145 int snd_config_get_bool(const snd_config_t *conf);
146 int snd_config_get_ctl_iface_ascii(const char *ascii);
147 int snd_config_get_ctl_iface(const snd_config_t *conf);
148
149 /** \} */
150
151 #ifdef __cplusplus
152 }
153 #endif
154
155 #endif /* __ALSA_CONF_H */
156