conf.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25. *
  26. */
  27. #ifndef __ALSA_CONF_H
  28. #define __ALSA_CONF_H
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /**
  33. * \defgroup Config Configuration Interface
  34. * The configuration functions and types allow you to read, enumerate,
  35. * modify and write the contents of ALSA configuration files.
  36. * \{
  37. */
  38. /** \brief \c dlsym version for the config evaluate callback. */
  39. #define SND_CONFIG_DLSYM_VERSION_EVALUATE _dlsym_config_evaluate_001
  40. /** \brief \c dlsym version for the config hook callback. */
  41. #define SND_CONFIG_DLSYM_VERSION_HOOK _dlsym_config_hook_001
  42. /** \brief Configuration node type. */
  43. typedef enum _snd_config_type {
  44. /** Integer number. */
  45. SND_CONFIG_TYPE_INTEGER,
  46. /** 64-bit integer number. */
  47. SND_CONFIG_TYPE_INTEGER64,
  48. /** Real number. */
  49. SND_CONFIG_TYPE_REAL,
  50. /** Character string. */
  51. SND_CONFIG_TYPE_STRING,
  52. /** Pointer (runtime only, cannot be saved). */
  53. SND_CONFIG_TYPE_POINTER,
  54. /** Compound node. */
  55. SND_CONFIG_TYPE_COMPOUND = 1024
  56. } snd_config_type_t;
  57. /**
  58. * \brief Internal structure for a configuration node object.
  59. *
  60. * The ALSA library uses a pointer to this structure as a handle to a
  61. * configuration node. Applications don't access its contents directly.
  62. */
  63. typedef struct _snd_config snd_config_t;
  64. /**
  65. * \brief Type for a configuration compound iterator.
  66. *
  67. * The ALSA library uses this pointer type as a handle to a configuration
  68. * compound iterator. Applications don't directly access the contents of
  69. * the structure pointed to by this type.
  70. */
  71. typedef struct _snd_config_iterator *snd_config_iterator_t;
  72. /**
  73. * \brief Internal structure for a configuration private update object.
  74. *
  75. * The ALSA library uses this structure to save private update information.
  76. */
  77. typedef struct _snd_config_update snd_config_update_t;
  78. extern snd_config_t *snd_config;
  79. int snd_config_top(snd_config_t **config);
  80. int snd_config_load(snd_config_t *config, snd_input_t *in);
  81. int snd_config_load_override(snd_config_t *config, snd_input_t *in);
  82. int snd_config_save(snd_config_t *config, snd_output_t *out);
  83. int snd_config_update(void);
  84. int snd_config_update_r(snd_config_t **top, snd_config_update_t **update, const char *path);
  85. int snd_config_update_free(snd_config_update_t *update);
  86. int snd_config_update_free_global(void);
  87. int snd_config_update_ref(snd_config_t **top);
  88. void snd_config_ref(snd_config_t *top);
  89. void snd_config_unref(snd_config_t *top);
  90. int snd_config_search(snd_config_t *config, const char *key,
  91. snd_config_t **result);
  92. int snd_config_searchv(snd_config_t *config,
  93. snd_config_t **result, ...);
  94. int snd_config_search_definition(snd_config_t *config,
  95. const char *base, const char *key,
  96. snd_config_t **result);
  97. int snd_config_expand(snd_config_t *config, snd_config_t *root,
  98. const char *args, snd_config_t *private_data,
  99. snd_config_t **result);
  100. int snd_config_evaluate(snd_config_t *config, snd_config_t *root,
  101. snd_config_t *private_data, snd_config_t **result);
  102. int snd_config_add(snd_config_t *config, snd_config_t *leaf);
  103. int snd_config_delete(snd_config_t *config);
  104. int snd_config_delete_compound_members(const snd_config_t *config);
  105. int snd_config_copy(snd_config_t **dst, snd_config_t *src);
  106. int snd_config_make(snd_config_t **config, const char *key,
  107. snd_config_type_t type);
  108. int snd_config_make_integer(snd_config_t **config, const char *key);
  109. int snd_config_make_integer64(snd_config_t **config, const char *key);
  110. int snd_config_make_real(snd_config_t **config, const char *key);
  111. int snd_config_make_string(snd_config_t **config, const char *key);
  112. int snd_config_make_pointer(snd_config_t **config, const char *key);
  113. int snd_config_make_compound(snd_config_t **config, const char *key, int join);
  114. int snd_config_imake_integer(snd_config_t **config, const char *key, const long value);
  115. int snd_config_imake_integer64(snd_config_t **config, const char *key, const long long value);
  116. int snd_config_imake_real(snd_config_t **config, const char *key, const double value);
  117. int snd_config_imake_string(snd_config_t **config, const char *key, const char *ascii);
  118. int snd_config_imake_safe_string(snd_config_t **config, const char *key, const char *ascii);
  119. int snd_config_imake_pointer(snd_config_t **config, const char *key, const void *ptr);
  120. snd_config_type_t snd_config_get_type(const snd_config_t *config);
  121. int snd_config_set_id(snd_config_t *config, const char *id);
  122. int snd_config_set_integer(snd_config_t *config, long value);
  123. int snd_config_set_integer64(snd_config_t *config, long long value);
  124. int snd_config_set_real(snd_config_t *config, double value);
  125. int snd_config_set_string(snd_config_t *config, const char *value);
  126. int snd_config_set_ascii(snd_config_t *config, const char *ascii);
  127. int snd_config_set_pointer(snd_config_t *config, const void *ptr);
  128. int snd_config_get_id(const snd_config_t *config, const char **value);
  129. int snd_config_get_integer(const snd_config_t *config, long *value);
  130. int snd_config_get_integer64(const snd_config_t *config, long long *value);
  131. int snd_config_get_real(const snd_config_t *config, double *value);
  132. int snd_config_get_ireal(const snd_config_t *config, double *value);
  133. int snd_config_get_string(const snd_config_t *config, const char **value);
  134. int snd_config_get_ascii(const snd_config_t *config, char **value);
  135. int snd_config_get_pointer(const snd_config_t *config, const void **value);
  136. int snd_config_test_id(const snd_config_t *config, const char *id);
  137. snd_config_iterator_t snd_config_iterator_first(const snd_config_t *node);
  138. snd_config_iterator_t snd_config_iterator_next(const snd_config_iterator_t iterator);
  139. snd_config_iterator_t snd_config_iterator_end(const snd_config_t *node);
  140. snd_config_t *snd_config_iterator_entry(const snd_config_iterator_t iterator);
  141. /**
  142. * \brief Helper macro to iterate over the children of a compound node.
  143. * \param[in,out] pos Iterator variable for the current node.
  144. * \param[in,out] next Temporary iterator variable for the next node.
  145. * \param[in] node Handle to the compound configuration node to iterate over.
  146. *
  147. * Use this macro like a \c for statement, e.g.:
  148. * \code
  149. * snd_config_iterator_t pos, next;
  150. * snd_config_for_each(pos, next, node) {
  151. * snd_config_t *entry = snd_config_iterator_entry(pos);
  152. * ...
  153. * }
  154. * \endcode
  155. *
  156. * This macro allows deleting or removing the current node.
  157. */
  158. #define snd_config_for_each(pos, next, node) \
  159. 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))
  160. /* Misc functions */
  161. int snd_config_get_bool_ascii(const char *ascii);
  162. int snd_config_get_bool(const snd_config_t *conf);
  163. int snd_config_get_ctl_iface_ascii(const char *ascii);
  164. int snd_config_get_ctl_iface(const snd_config_t *conf);
  165. /* Names functions */
  166. /**
  167. * Device-name list element
  168. */
  169. typedef struct snd_devname snd_devname_t;
  170. /**
  171. * Device-name list element (definition)
  172. */
  173. struct snd_devname {
  174. char *name; /**< Device name string */
  175. char *comment; /**< Comments */
  176. snd_devname_t *next; /**< Next pointer */
  177. };
  178. int snd_names_list(const char *iface, snd_devname_t **list);
  179. void snd_names_list_free(snd_devname_t *list);
  180. /** \} */
  181. #ifdef __cplusplus
  182. }
  183. #endif
  184. #endif /* __ALSA_CONF_H */