zathura/plugin.h

98 lines
2.5 KiB
C
Raw Normal View History

2012-03-27 13:30:04 +02:00
/* See LICENSE file for license and copyright information */
#ifndef PLUGIN_H
#define PLUGIN_H
#include <girara/types.h>
#include "types.h"
#include "plugin-api.h"
#include "version.h"
#include "zathura.h"
#define PLUGIN_REGISTER_FUNCTION "zathura_plugin_register"
#define PLUGIN_API_VERSION_FUNCTION "zathura_plugin_api_version"
#define PLUGIN_ABI_VERSION_FUNCTION "zathura_plugin_abi_version"
2012-03-27 13:30:04 +02:00
/**
* Document plugin structure
*/
struct zathura_plugin_s
{
girara_list_t* content_types; /**< List of supported content types */
zathura_plugin_register_function_t register_function; /**< Document open function */
zathura_plugin_functions_t functions; /**< Document functions */
2012-03-27 13:30:04 +02:00
void* handle; /**< DLL handle */
};
/**
2012-04-01 18:32:16 +02:00
* Creates a new instance of the plugin manager
2012-03-27 13:30:04 +02:00
*
2012-04-01 18:32:16 +02:00
* @return A plugin manager object or NULL if an error occured
2012-03-27 13:30:04 +02:00
*/
2012-04-01 18:32:16 +02:00
zathura_plugin_manager_t* zathura_plugin_manager_new();
2012-03-27 13:30:04 +02:00
/**
2012-04-01 18:32:16 +02:00
* Adds a plugin directory to the plugin manager
2012-03-27 13:30:04 +02:00
*
2012-04-01 18:32:16 +02:00
* @param plugin_manager The plugin manager
* @param dir Path to a directory with plugins
2012-03-27 13:30:04 +02:00
*/
2012-04-01 18:32:16 +02:00
void zathura_plugin_manager_add_dir(zathura_plugin_manager_t* plugin_manager, const char* dir);
2012-03-27 13:30:04 +02:00
/**
2012-04-01 18:32:16 +02:00
* Loads all plugins available in the previously given directories
2012-03-27 13:30:04 +02:00
*
2012-04-01 18:32:16 +02:00
* @param plugin_manager The plugin manager
2012-03-27 13:30:04 +02:00
*/
2012-04-01 18:32:16 +02:00
void zathura_plugin_manager_load(zathura_plugin_manager_t* plugin_manager);
2012-03-27 13:30:04 +02:00
/**
2012-04-01 18:32:16 +02:00
* Returns the (if available) associated plugin
2012-03-27 13:30:04 +02:00
*
2012-04-01 18:32:16 +02:00
* @param plugin_manager The plugin manager
* @param type The document type
* @return The plugin or NULL if no matching plugin is available
2012-03-27 13:30:04 +02:00
*/
2012-04-01 18:32:16 +02:00
zathura_plugin_t* zathura_plugin_manager_get_plugin(zathura_plugin_manager_t* plugin_manager, const char* type);
2012-03-27 13:30:04 +02:00
/**
2012-04-01 18:32:16 +02:00
* Frees the plugin manager
2012-03-27 13:30:04 +02:00
*
2012-04-01 18:32:16 +02:00
* @param plugin_manager
2012-03-27 13:30:04 +02:00
*/
2012-04-01 18:32:16 +02:00
void zathura_plugin_manager_free(zathura_plugin_manager_t* plugin_manager);
2012-03-27 13:30:04 +02:00
/**
2012-04-01 18:32:16 +02:00
* Plugin mapping
2012-03-27 13:30:04 +02:00
*/
2012-04-01 18:32:16 +02:00
typedef struct zathura_type_plugin_mapping_s
{
const gchar* type; /**< Plugin type */
zathura_plugin_t* plugin; /**< Mapped plugin */
} zathura_type_plugin_mapping_t;
/**
* Function prototype that is called to register a document plugin
*
* @param The document plugin
*/
typedef void (*zathura_plugin_register_service_t)(zathura_plugin_t*);
/**
* Function prototype that is called to get the plugin's API version.
*
* @return plugin's API version
*/
typedef unsigned int (*zathura_plugin_api_version_t)();
2012-03-27 13:30:04 +02:00
/**
2012-04-01 18:32:16 +02:00
* Function prototype that is called to get the ABI version the plugin is built
* against.
*
* @return plugin's ABI version
2012-03-27 13:30:04 +02:00
*/
2012-04-01 18:32:16 +02:00
typedef unsigned int (*zathura_plugin_abi_version_t)();
2012-03-27 13:30:04 +02:00
#endif // PLUGIN_H