Remove snd_name_list() and snd_name_list_free() functions.

These functions were not used in applications anyway.
This commit is contained in:
Jaroslav Kysela 2006-10-12 14:52:07 +02:00
parent 10cca7c03b
commit b40a116b8e

View file

@ -35,156 +35,31 @@
#include <sys/stat.h> #include <sys/stat.h>
#include "local.h" #include "local.h"
#ifndef DOC_HIDDEN
#define ALSA_NAMES_ENV "ALSA_NAMES_FILE"
#define ALSA_NAMES_PATH1 "/etc/asound.names"
#define ALSA_NAMES_PATH2 "~/.asoundnm"
#endif
static int names_parse(snd_config_t *top, const char *iface, snd_devname_t **list)
{
snd_config_iterator_t i, next;
snd_config_iterator_t j, jnext;
char *name, *comment;
const char *id;
snd_devname_t *dn, *last = NULL;
int err;
err = snd_config_search(top, iface, &top);
if (err < 0)
return err;
snd_config_for_each(i, next, top) {
snd_config_t *n = snd_config_iterator_entry(i);
if (snd_config_get_id(n, &id) < 0)
continue;
name = comment = NULL;
snd_config_for_each(j, jnext, n) {
snd_config_t *m = snd_config_iterator_entry(j);
if (snd_config_get_id(m, &id) < 0)
continue;
if (strcmp(id, "name") == 0) {
err = snd_config_get_string(m, (const char **)&name);
if (err < 0)
continue;
name = strdup(name);
if (name == NULL) {
err = -ENOMEM;
goto _err;
}
continue;
}
if (strcmp(id, "comment") == 0) {
err = snd_config_get_string(m, (const char **)&comment);
if (err < 0)
continue;
comment = strdup(comment);
if (name == NULL) {
err = -ENOMEM;
goto _err;
}
continue;
}
}
if (name != NULL) {
dn = malloc(sizeof(*dn));
if (dn == NULL) {
err = -ENOMEM;
goto _err;
}
dn->name = name;
dn->comment = comment;
dn->next = NULL;
if (last == NULL) {
*list = dn;
} else {
last->next = dn;
}
last = dn;
} else {
free(comment);
}
}
return 0;
_err:
free(name);
free(comment);
return err;
}
/** /**
* \brief Give a list of device names and associated comments for selected interface * \brief Give a list of device names and associated comments for selected interface
* \param iface a string identifying interface ("pcm", "ctl", "seq", "rawmidi") * \param iface a string identifying interface ("pcm", "ctl", "seq", "rawmidi")
* \param list result - a pointer to list * \param list result - a pointer to list
* \return A non-negative value if successful, otherwise a negative error code. * \return A non-negative value if successful, otherwise a negative error code.
* \deprecated Since 1.0.14
* *
* The global configuration files are specified in the environment variable * The global configuration files are specified in the environment variable
* \c ALSA_NAMES_FILE. * \c ALSA_NAMES_FILE.
*/ */
int snd_names_list(const char *iface, snd_devname_t **list) int snd_names_list(const char *iface ATTRIBUTE_UNUSED,
snd_devname_t **list ATTRIBUTE_UNUSED)
{ {
char *file; return -ENXIO;
snd_config_t *top;
snd_input_t *in;
int err;
assert(iface);
assert(list);
*list = NULL;
file = getenv(ALSA_NAMES_ENV);
if (file) {
file = strdup(file);
if (file == NULL)
return -ENOMEM;
} else {
err = snd_user_file(ALSA_NAMES_PATH2, &file);
if (err < 0)
return err;
if (access(file, R_OK)) {
file = strdup(ALSA_NAMES_PATH1);
if (file == NULL)
return -ENOMEM;
}
}
top = NULL;
err = snd_config_top(&top);
if (err >= 0)
err = snd_input_stdio_open(&in, file, "r");
if (err >= 0) {
err = snd_config_load(top, in);
snd_input_close(in);
if (err < 0) {
SNDERR("%s may be old or corrupted: consider to remove or fix it", file);
} else {
err = names_parse(top, iface, list);
if (err < 0) {
snd_names_list_free(*list);
*list = NULL;
}
}
} else {
SNDERR("cannot access file %s", file);
}
if (top)
snd_config_delete(top);
return err >= 0 ? 0 : err;
} }
link_warning(snd_names_list, "Warning: snd_names_list is deprecated, use snd_device_name_hint");
/** /**
* \brief Release the list of device names * \brief Release the list of device names
* \param list the name list to release * \param list the name list to release
* \deprecated Since 1.0.14
* *
* Releases the list of device names allocated via #snd_names_list(). * Releases the list of device names allocated via #snd_names_list().
*/ */
void snd_names_list_free(snd_devname_t *list) void snd_names_list_free(snd_devname_t *list ATTRIBUTE_UNUSED)
{ {
snd_devname_t *next;
while (list != NULL) {
next = list->next;
free(list->name);
free(list->comment);
free(list);
list = next;
}
} }
link_warning(snd_names_list_free, "Warning: snd_names_list_free is deprecated, use snd_device_name_free_hint");