mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-10 18:23:46 +01:00
Display plugin version in debug mode.
This commit is contained in:
parent
eec5f61926
commit
1e1b55de57
10
plugin-api.h
10
plugin-api.h
@ -45,11 +45,11 @@ void zathura_plugin_add_mimetype(zathura_plugin_t* plugin, const char* mime_type
|
|||||||
* @param mimetypes a char array of mime types supported by the plugin
|
* @param mimetypes a char array of mime types supported by the plugin
|
||||||
*/
|
*/
|
||||||
#define ZATHURA_PLUGIN_REGISTER(plugin_name, major, minor, rev, register_functions, mimetypes) \
|
#define ZATHURA_PLUGIN_REGISTER(plugin_name, major, minor, rev, register_functions, mimetypes) \
|
||||||
unsigned int zathura_plugin_version_major() { return major; } \
|
unsigned int zathura_plugin_version_major(void) { return major; } \
|
||||||
unsigned int zathura_plugin_version_minor() { return minor; } \
|
unsigned int zathura_plugin_version_minor(void) { return minor; } \
|
||||||
unsigned int zathura_plugin_version_revision() { return rev; } \
|
unsigned int zathura_plugin_version_revision(void) { return rev; } \
|
||||||
unsigned int zathura_plugin_api_version() { return ZATHURA_API_VERSION; } \
|
unsigned int zathura_plugin_api_version(void) { return ZATHURA_API_VERSION; } \
|
||||||
unsigned int zathura_plugin_abi_version() { return ZATHURA_ABI_VERSION; } \
|
unsigned int zathura_plugin_abi_version(void) { return ZATHURA_ABI_VERSION; } \
|
||||||
\
|
\
|
||||||
void zathura_plugin_register(zathura_plugin_t* plugin) \
|
void zathura_plugin_register(zathura_plugin_t* plugin) \
|
||||||
{ \
|
{ \
|
||||||
|
19
plugin.c
19
plugin.c
@ -11,6 +11,8 @@
|
|||||||
#include <girara/session.h>
|
#include <girara/session.h>
|
||||||
#include <girara/settings.h>
|
#include <girara/settings.h>
|
||||||
|
|
||||||
|
typedef unsigned int (*zathura_plugin_version_t)(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin manager
|
* Plugin manager
|
||||||
*/
|
*/
|
||||||
@ -92,7 +94,8 @@ zathura_plugin_manager_load(zathura_plugin_manager_t* plugin_manager)
|
|||||||
|
|
||||||
/* resolve symbols and check API and ABI version*/
|
/* resolve symbols and check API and ABI version*/
|
||||||
zathura_plugin_api_version_t api_version = NULL;
|
zathura_plugin_api_version_t api_version = NULL;
|
||||||
if (g_module_symbol(handle, PLUGIN_API_VERSION_FUNCTION, (gpointer*) &api_version) == FALSE || !api_version)
|
if (g_module_symbol(handle, PLUGIN_API_VERSION_FUNCTION, (gpointer*) &api_version) == FALSE ||
|
||||||
|
api_version == NULL)
|
||||||
{
|
{
|
||||||
girara_error("could not find '%s' function in plugin %s", PLUGIN_API_VERSION_FUNCTION, path);
|
girara_error("could not find '%s' function in plugin %s", PLUGIN_API_VERSION_FUNCTION, path);
|
||||||
g_free(path);
|
g_free(path);
|
||||||
@ -109,7 +112,8 @@ zathura_plugin_manager_load(zathura_plugin_manager_t* plugin_manager)
|
|||||||
}
|
}
|
||||||
|
|
||||||
zathura_plugin_abi_version_t abi_version = NULL;
|
zathura_plugin_abi_version_t abi_version = NULL;
|
||||||
if (g_module_symbol(handle, PLUGIN_ABI_VERSION_FUNCTION, (gpointer*) &abi_version) == FALSE || !abi_version)
|
if (g_module_symbol(handle, PLUGIN_ABI_VERSION_FUNCTION, (gpointer*) &abi_version) == FALSE ||
|
||||||
|
abi_version == NULL)
|
||||||
{
|
{
|
||||||
girara_error("could not find '%s' function in plugin %s", PLUGIN_ABI_VERSION_FUNCTION, path);
|
girara_error("could not find '%s' function in plugin %s", PLUGIN_ABI_VERSION_FUNCTION, path);
|
||||||
g_free(path);
|
g_free(path);
|
||||||
@ -126,7 +130,8 @@ zathura_plugin_manager_load(zathura_plugin_manager_t* plugin_manager)
|
|||||||
}
|
}
|
||||||
|
|
||||||
zathura_plugin_register_service_t register_service = NULL;
|
zathura_plugin_register_service_t register_service = NULL;
|
||||||
if (g_module_symbol(handle, PLUGIN_REGISTER_FUNCTION, (gpointer*) ®ister_service) == FALSE || !register_service)
|
if (g_module_symbol(handle, PLUGIN_REGISTER_FUNCTION, (gpointer*) ®ister_service) == FALSE ||
|
||||||
|
register_service == NULL)
|
||||||
{
|
{
|
||||||
girara_error("could not find '%s' function in plugin %s", PLUGIN_REGISTER_FUNCTION, path);
|
girara_error("could not find '%s' function in plugin %s", PLUGIN_REGISTER_FUNCTION, path);
|
||||||
g_free(path);
|
g_free(path);
|
||||||
@ -156,6 +161,14 @@ zathura_plugin_manager_load(zathura_plugin_manager_t* plugin_manager)
|
|||||||
zathura_plugin_free(plugin);
|
zathura_plugin_free(plugin);
|
||||||
} else {
|
} else {
|
||||||
girara_info("successfully loaded plugin %s", path);
|
girara_info("successfully loaded plugin %s", path);
|
||||||
|
|
||||||
|
zathura_plugin_version_t major = NULL, minor = NULL, rev = NULL;
|
||||||
|
g_module_symbol(handle, PLUGIN_VERSION_MAJOR_FUNCTION, (gpointer*) &major);
|
||||||
|
g_module_symbol(handle, PLUGIN_VERSION_MINOR_FUNCTION, (gpointer*) &minor);
|
||||||
|
g_module_symbol(handle, PLUGIN_VERSION_REVISION_FUNCTION, (gpointer*) &rev);
|
||||||
|
if (major != NULL && minor != NULL && rev != NULL) {
|
||||||
|
girara_debug("plugin '%s': version %u.%u.%u", path, major(), minor(), rev());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(path);
|
g_free(path);
|
||||||
|
3
plugin.h
3
plugin.h
@ -14,6 +14,9 @@
|
|||||||
#define PLUGIN_REGISTER_FUNCTION "zathura_plugin_register"
|
#define PLUGIN_REGISTER_FUNCTION "zathura_plugin_register"
|
||||||
#define PLUGIN_API_VERSION_FUNCTION "zathura_plugin_api_version"
|
#define PLUGIN_API_VERSION_FUNCTION "zathura_plugin_api_version"
|
||||||
#define PLUGIN_ABI_VERSION_FUNCTION "zathura_plugin_abi_version"
|
#define PLUGIN_ABI_VERSION_FUNCTION "zathura_plugin_abi_version"
|
||||||
|
#define PLUGIN_VERSION_MAJOR_FUNCTION "zathura_plugin_version_major"
|
||||||
|
#define PLUGIN_VERSION_MINOR_FUNCTION "zathura_plugin_version_minor"
|
||||||
|
#define PLUGIN_VERSION_REVISION_FUNCTION "zathura_plugin_version_revision"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document plugin structure
|
* Document plugin structure
|
||||||
|
Loading…
Reference in New Issue
Block a user