2004-09-11 23:17:38 +00:00
|
|
|
/***
|
2006-06-19 21:53:48 +00:00
|
|
|
This file is part of PulseAudio.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-02-13 15:35:19 +00:00
|
|
|
Copyright 2004-2006 Lennart Poettering
|
|
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is free software; you can redistribute it and/or modify
|
2004-11-21 21:31:28 +00:00
|
|
|
it under the terms of the GNU Lesser General Public License as
|
2009-03-03 20:23:02 +00:00
|
|
|
published by the Free Software Foundation; either version 2.1 of the
|
2004-11-21 21:31:28 +00:00
|
|
|
License, or (at your option) any later version.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is distributed in the hope that it will be useful, but
|
2004-09-11 23:17:38 +00:00
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2004-11-21 21:31:28 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2014-11-26 14:14:51 +01:00
|
|
|
License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
|
2004-09-11 23:17:38 +00:00
|
|
|
***/
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <ltdl.h>
|
|
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulse/xmalloc.h>
|
2006-05-17 16:34:18 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulsecore/log.h>
|
2007-10-28 19:13:50 +00:00
|
|
|
#include <pulsecore/macro.h>
|
|
|
|
|
#include <pulsecore/ltdl-helper.h>
|
2006-02-17 12:10:58 +00:00
|
|
|
|
2004-09-11 23:17:38 +00:00
|
|
|
#include "modinfo.h"
|
|
|
|
|
|
|
|
|
|
#define PA_SYMBOL_AUTHOR "pa__get_author"
|
|
|
|
|
#define PA_SYMBOL_DESCRIPTION "pa__get_description"
|
|
|
|
|
#define PA_SYMBOL_USAGE "pa__get_usage"
|
|
|
|
|
#define PA_SYMBOL_VERSION "pa__get_version"
|
2009-05-28 02:47:36 +02:00
|
|
|
#define PA_SYMBOL_DEPRECATED "pa__get_deprecated"
|
2007-11-09 18:25:40 +00:00
|
|
|
#define PA_SYMBOL_LOAD_ONCE "pa__load_once"
|
2004-09-11 23:17:38 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_modinfo *pa_modinfo_get_by_handle(lt_dlhandle dl, const char *module_name) {
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_modinfo *i;
|
2004-09-11 23:17:38 +00:00
|
|
|
const char* (*func)(void);
|
2013-06-27 19:28:09 +02:00
|
|
|
bool (*func2) (void);
|
2007-10-28 19:13:50 +00:00
|
|
|
|
|
|
|
|
pa_assert(dl);
|
2004-09-11 23:17:38 +00:00
|
|
|
|
2006-04-13 17:53:43 +00:00
|
|
|
i = pa_xnew0(pa_modinfo, 1);
|
2004-09-11 23:17:38 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
if ((func = (const char* (*)(void)) pa_load_sym(dl, module_name, PA_SYMBOL_AUTHOR)))
|
2004-09-11 23:17:38 +00:00
|
|
|
i->author = pa_xstrdup(func());
|
|
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
if ((func = (const char* (*)(void)) pa_load_sym(dl, module_name, PA_SYMBOL_DESCRIPTION)))
|
2004-09-11 23:17:38 +00:00
|
|
|
i->description = pa_xstrdup(func());
|
|
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
if ((func = (const char* (*)(void)) pa_load_sym(dl, module_name, PA_SYMBOL_USAGE)))
|
2004-09-11 23:17:38 +00:00
|
|
|
i->usage = pa_xstrdup(func());
|
|
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
if ((func = (const char* (*)(void)) pa_load_sym(dl, module_name, PA_SYMBOL_VERSION)))
|
2004-09-11 23:17:38 +00:00
|
|
|
i->version = pa_xstrdup(func());
|
|
|
|
|
|
2009-05-28 02:47:36 +02:00
|
|
|
if ((func = (const char* (*)(void)) pa_load_sym(dl, module_name, PA_SYMBOL_DEPRECATED)))
|
|
|
|
|
i->deprecated = pa_xstrdup(func());
|
|
|
|
|
|
2013-06-27 19:28:09 +02:00
|
|
|
if ((func2 = (bool (*)(void)) pa_load_sym(dl, module_name, PA_SYMBOL_LOAD_ONCE)))
|
2007-11-09 18:25:40 +00:00
|
|
|
i->load_once = func2();
|
|
|
|
|
|
2004-09-11 23:17:38 +00:00
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_modinfo *pa_modinfo_get_by_name(const char *name) {
|
2004-09-11 23:17:38 +00:00
|
|
|
lt_dlhandle dl;
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_modinfo *i;
|
2007-10-28 19:13:50 +00:00
|
|
|
|
|
|
|
|
pa_assert(name);
|
2004-09-11 23:17:38 +00:00
|
|
|
|
|
|
|
|
if (!(dl = lt_dlopenext(name))) {
|
2006-08-18 21:38:40 +00:00
|
|
|
pa_log("Failed to open module \"%s\": %s", name, lt_dlerror());
|
2004-09-11 23:17:38 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
i = pa_modinfo_get_by_handle(dl, name);
|
2004-09-11 23:17:38 +00:00
|
|
|
lt_dlclose(dl);
|
|
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_modinfo_free(pa_modinfo *i) {
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_assert(i);
|
|
|
|
|
|
2004-09-11 23:17:38 +00:00
|
|
|
pa_xfree(i->author);
|
|
|
|
|
pa_xfree(i->description);
|
|
|
|
|
pa_xfree(i->usage);
|
|
|
|
|
pa_xfree(i->version);
|
2009-05-28 02:47:36 +02:00
|
|
|
pa_xfree(i->deprecated);
|
2004-09-11 23:17:38 +00:00
|
|
|
pa_xfree(i);
|
|
|
|
|
}
|