4 This file is part of PulseAudio.
6 Copyright 2004-2006 Lennart Poettering
7 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
9 PulseAudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published
11 by the Free Software Foundation; either version 2 of the License,
12 or (at your option) any later version.
14 PulseAudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with PulseAudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
35 #include <pulse/util.h>
37 #include <pulsecore/modinfo.h>
39 #include "dumpmodules.h"
41 #define PREFIX "module-"
43 static void short_info(const char *name, PA_GCC_UNUSED const char *path, pa_modinfo *i) {
45 printf("%-40s%s\n", name, i->description ? i->description : "n/a");
48 static void long_info(const char *name, const char *path, pa_modinfo *i) {
57 printf("Name: %s\n", name);
59 if (!i->description && !i->version && !i->author && !i->usage)
60 printf("No module information available\n");
63 printf("Version: %s\n", i->version);
65 printf("Description: %s\n", i->description);
67 printf("Author: %s\n", i->author);
69 printf("Usage: %s\n", i->usage);
73 printf("Path: %s\n", path);
76 static void show_info(const char *name, const char *path, void (*info)(const char *name, const char *path, pa_modinfo*i)) {
79 if ((i = pa_modinfo_get_by_name(path ? path : name))) {
85 extern const lt_dlsymlist lt_preloaded_symbols[];
87 static int is_preloaded(const char *name) {
88 const lt_dlsymlist *l;
90 for (l = lt_preloaded_symbols; l->name; l++) {
96 snprintf(buf, sizeof(buf), "%s", l->name);
97 if ((e = strrchr(buf, '.')))
100 if (!strcmp(name, buf))
107 static int callback(const char *path, lt_ptr data) {
109 pa_daemon_conf *c = (data);
111 e = pa_path_get_filename(path);
113 if (strlen(e) <= sizeof(PREFIX)-1 || strncmp(e, PREFIX, sizeof(PREFIX)-1))
119 show_info(e, path, c->log_level >= PA_LOG_INFO ? long_info : short_info);
123 void pa_dump_modules(pa_daemon_conf *c, int argc, char * const argv[]) {
126 for (i = 0; i < argc; i++)
127 show_info(argv[i], NULL, long_info);
129 const lt_dlsymlist *l;
131 for (l = lt_preloaded_symbols; l->name; l++) {
137 if (strlen(l->name) <= sizeof(PREFIX)-1 || strncmp(l->name, PREFIX, sizeof(PREFIX)-1))
140 snprintf(buf, sizeof(buf), "%s", l->name);
141 if ((e = strrchr(buf, '.')))
144 show_info(buf, NULL, c->log_level >= PA_LOG_INFO ? long_info : short_info);
147 lt_dlforeachfile(NULL, callback, c);