int snd_config_get_integer64(const snd_config_t *config, long long *value);
int snd_config_get_real(const snd_config_t *config, double *value);
int snd_config_get_ireal(const snd_config_t *config, double *value);
+int snd_config_get_llong(const snd_config_t *config, long long *value, int base);
int snd_config_get_string(const snd_config_t *config, const char **value);
int snd_config_get_ascii(const snd_config_t *config, char **value);
int snd_config_get_pointer(const snd_config_t *config, const void **value);
@SYMBOL_PREFIX@snd_lib_log_filter;
@SYMBOL_PREFIX@snd_lib_check;
} ALSA_1.2.13;
+
+ALSA_1.2.17 {
+ global:
+
+ @SYMBOL_PREFIX@snd_config_get_llong;
+} ALSA_1.2.15;
return 0;
}
+/**
+ * \brief Returns the value of an integer or string configuration node as a long long.
+ * \param[in] config Handle to the configuration node.
+ * \param[out] ptr The node's value.
+ * \param[in] base The numeric base used to parse a string node (see \c strtoll()).
+ * \return Zero if successful, otherwise a negative error code.
+ *
+ * If the node's type is integer or integer64, the value is converted
+ * to the \c long \c long type on the fly. If the node's type is string,
+ * the string is parsed as a number using \a base.
+ *
+ * \par Errors:
+ * <dl>
+ * <dt>-EINVAL<dd>\a config is not an integer, integer64 or a parseable string node.
+ * </dl>
+ */
+int snd_config_get_llong(const snd_config_t *config, long long *ptr, int base)
+{
+ const char *str;
+
+ assert(config && ptr);
+ if (config->type == SND_CONFIG_TYPE_INTEGER)
+ *ptr = config->u.integer;
+ else if (config->type == SND_CONFIG_TYPE_INTEGER64)
+ *ptr = config->u.integer64;
+ else if (config->type == SND_CONFIG_TYPE_STRING) {
+ str = config->u.string;
+ if (str == NULL || safe_strtoll_base(str, ptr, base) < 0)
+ return -EINVAL;
+ } else
+ return -EINVAL;
+ return 0;
+}
+
/**
* \brief Returns the value of a string configuration node.
* \param[in] config Handle to the configuration node.
*/
static int get_integer(snd_config_t *compound, const char *key, long long *val)
{
- snd_config_type_t t;
snd_config_t *node;
- const char *str;
int err;
err = snd_config_search(compound, key, &node);
if (err < 0)
return err;
- t = snd_config_get_type(node);
- if (t == SND_CONFIG_TYPE_INTEGER) {
- long i;
- err = snd_config_get_integer(node, &i);
- if (err >= 0)
- *val = i;
- } else if (t == SND_CONFIG_TYPE_INTEGER64) {
- err = snd_config_get_integer64(node, val);
- } else {
- err = snd_config_get_string(node, &str);
- if (err < 0)
- return err;
- err = safe_strtoll(str, val);
- }
+ err = snd_config_get_llong(node, val, 0);
if (err < 0)
return -EINVAL;