* Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com> * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <https://www.gnu.org/licenses/>. /****************************************************************************** *****************************************************************************/ static gint verbosity = 0; static gboolean show_internal = FALSE; static gboolean output_paths = FALSE; static gboolean exit_early = FALSE; /****************************************************************************** *****************************************************************************/ G_GNUC_UNUSED const gchar *n, G_GNUC_UNUSED const gchar *v, G_GNUC_UNUSED gpointer d, G_GNUC_UNUSED GError **e) G_GNUC_UNUSED const gchar *n, G_GNUC_UNUSED const gchar *v, G_GNUC_UNUSED gpointer d, G_GNUC_UNUSED GError **e) G_GNUC_UNUSED const gchar *n, G_GNUC_UNUSED const gchar *v, G_GNUC_UNUSED gpointer d, G_GNUC_UNUSED GError **e) G_GNUC_UNUSED const gchar *n, G_GNUC_UNUSED const gchar *v, G_GNUC_UNUSED gpointer d, G_GNUC_UNUSED GError **e) printf("gplugin-query %s\n", GPLUGIN_VERSION); G_GNUC_UNUSED const gchar *n, G_GNUC_UNUSED const gchar *v, G_GNUC_UNUSED gpointer d, G_GNUC_UNUSED GError **e) output_plugin(const gchar *id) GPluginManager *manager = gplugin_manager_get_default(); GSList *plugins = NULL, *l = NULL; gboolean first = TRUE, header_output = FALSE; #define MAIN_FORMAT_NEL " " FORMAT ": " #define MAIN_FORMAT MAIN_FORMAT_NEL "%s\n" #define STR_OR_EMPTY(str) ((str) ? (str) : "") plugins = gplugin_manager_find_plugins(manager, id); printf("%s not found\n", id); for(l = plugins; l; l = l->next) { GPluginPlugin *plugin = GPLUGIN_PLUGIN(l->data); GPluginPluginInfo *info = gplugin_plugin_get_info(plugin); gboolean internal, loq, bind_global, unloadable; gchar *license_id, *license_text, *license_url; gchar *icon_name, *summary, *description, *category, *website; gchar **authors, **dependencies; internal = gplugin_plugin_info_get_internal(info); if(!show_internal && internal) "abi-version", &abi_version, "license-id", &license_id, "license-text", &license_text, "license-url", &license_url, "description", &description, "dependencies", &dependencies, "bind-global", &bind_global, "unloadable", &unloadable, printf(MAIN_FORMAT, "name", STR_OR_EMPTY(name)); printf(MAIN_FORMAT, "category", STR_OR_EMPTY(category)); printf(MAIN_FORMAT, "version", STR_OR_EMPTY(version)); printf(MAIN_FORMAT, "license", STR_OR_EMPTY(license_id)); printf(MAIN_FORMAT, "license url", STR_OR_EMPTY(license_url)); printf(MAIN_FORMAT, "summary", STR_OR_EMPTY(summary)); printf(MAIN_FORMAT_NEL, "authors"); for(i = 0; authors[i]; i++) { printf("%s\n", STR_OR_EMPTY(authors[i])); printf(MAIN_FORMAT, "website", STR_OR_EMPTY(website)); STR_OR_EMPTY(gplugin_plugin_get_filename(plugin))); GPluginLoader *loader = gplugin_plugin_get_loader(plugin); printf(MAIN_FORMAT_NEL "%08x\n", "abi version", abi_version); printf(MAIN_FORMAT, "internal", (internal) ? "yes" : "no"); printf(MAIN_FORMAT, "load on query", (loq) ? "yes" : "no"); printf(MAIN_FORMAT, "bind globally", (bind_global) ? "yes" : "no"); printf(MAIN_FORMAT, "unloadable", (unloadable) ? "yes" : "no"); printf(MAIN_FORMAT, "loader", G_OBJECT_TYPE_NAME(loader)); g_object_unref(G_OBJECT(loader)); printf(MAIN_FORMAT, "description", STR_OR_EMPTY(description)); printf(MAIN_FORMAT_NEL, "dependencies"); for(i = 0; dependencies[i]; i++) { printf("%s\n", STR_OR_EMPTY(dependencies[i])); g_strfreev(dependencies); g_object_unref(G_OBJECT(info)); g_slist_free_full(plugins, g_object_unref); output_plugins(GList *plugins) gboolean ret = TRUE, first = TRUE; for(l = plugins; l; l = l->next) { if(!output_plugin(l->data)) /****************************************************************************** *****************************************************************************/ static GOptionEntry entries[] = { "internal", 'i', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, internal_cb, N_("Show internal plugins"), "verbose", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, verbosity_cb, N_("Increase verbosity"), "full-verbose", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, full_verbosity_cb, N_("Increase verbosity to eleven"), "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, version_cb, N_("Display the version and exit"), "list", 'L', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, list_cb, N_("Display all search paths and exit"), NULL, 0, 0, 0, NULL, NULL, NULL, main(gint argc, gchar **argv) GPluginManager *manager = NULL; GOptionContext *ctx = NULL; GOptionGroup *group = NULL; ctx = g_option_context_new("PLUGIN-ID..."); g_option_context_set_summary(ctx, _("Query installed plugins")); g_option_context_set_translation_domain(ctx, GETTEXT_PACKAGE); g_option_context_add_main_entries(ctx, entries, NULL); group = gplugin_get_option_group(); g_option_context_add_group(ctx, group); g_option_context_parse(ctx, &argc, &argv, &error); g_option_context_free(ctx); fprintf(stderr, "%s\n", error->message); /* This is just for consistency, but the gplugins-option will init the gplugin_init(GPLUGIN_CORE_FLAGS_NONE); manager = gplugin_manager_get_default(); gplugin_manager_prepend_paths_from_environment( for(path = gplugin_manager_get_paths(manager); path; printf("%s\n", (gchar *)path->data); gplugin_manager_refresh(manager); /* check if the user gave us at least one plugin, and output them */ GQueue *plugins = g_queue_new(); for(i = 1; i < argc; i++) { g_queue_push_tail(plugins, argv[i]); if(!output_plugins(plugins->head)) GList *plugins = gplugin_manager_list_plugins(manager); if(!output_plugins(plugins))