ncmpc  0.31
Data Structures | Typedefs | Functions
plugin.hxx File Reference
#include <vector>
#include <string>

Go to the source code of this file.

Data Structures

struct  PluginList
 

Typedefs

typedef void(* plugin_callback_t) (std::string &&result, const bool success, const char *plugin_name, void *data)
 

Functions

bool plugin_list_load_directory (PluginList *list, const char *path)
 
PluginCycle * plugin_run (PluginList *list, const char *const *args, plugin_callback_t callback, void *callback_data)
 
void plugin_stop (PluginCycle *invocation)
 

Typedef Documentation

◆ plugin_callback_t

typedef void(* plugin_callback_t) (std::string &&result, const bool success, const char *plugin_name, void *data)

When a plugin cycle is finished, this function is called. In any case, plugin_stop() has to be called to free all memory.

Parameters
resultthe plugin's output (stdout) on success; summary of all error messages on failure as determined by success
successresult of the plugin cycle; true if result is meaningful output, false if result contains error messages
plugin_namethe name of the plugin which succeeded; becomes invalid when plugin_stop is called (i.e. strdup it if you need it afterwards).
datathe caller defined pointer passed to plugin_run()

Function Documentation

◆ plugin_list_load_directory()

bool plugin_list_load_directory ( PluginList list,
const char *  path 
)

Load all plugins (executables) in a directory.

◆ plugin_run()

PluginCycle* plugin_run ( PluginList list,
const char *const *  args,
plugin_callback_t  callback,
void *  callback_data 
)

Run plugins in this list, until one returns success (or until the plugin list is exhausted).

Parameters
listthe plugin list
argsnullptr terminated command line arguments passed to the plugin programs; they must remain valid while the plugin runs
callbackthe callback function which will be called when a result is available
callback_datacaller defined pointer which is passed to the callback function

◆ plugin_stop()

void plugin_stop ( PluginCycle *  invocation)

Stops the plugin cycle and frees resources. This can be called to abort the current cycle, or after the plugin_callback_t has been invoked.