The C Utility Toolkit
Main Page | Data Structures | File List | Data Fields | Globals

plugin.h File Reference

#include <cutk/dll.h>
#include <cutk/strhmap.h>
#include <limits.h>

Go to the source code of this file.

Data Structures

struct  CallbackEntry
struct  Plugin
struct  PluginManager

Typedefs

typedef enum PluginResult PluginResult
typedef PluginResult(* PluginCallback )(size_t, void *, void *)
typedef CallbackEntry CallbackEntry
typedef Plugin Plugin
typedef PluginManager PluginManager

Enumerations

enum  PluginResult { PLUGIN_NEXT, PLUGIN_STOP, PLUGIN_AGAIN }

Functions

int PluginManagerAlloc (PluginManager *mgr)
void PluginManagerFree (PluginManager *mgr)
int PluginManagerAddPluginObj (PluginManager *mgr, Plugin *plugin)
int PluginManagerAddPlugin (PluginManager *mgr, const char *path)
int PluginManagerAddDir (PluginManager *mgr, const char *path, char recursive)
size_t PluginManagerAddEvent (PluginManager *mgr, const char *event, PluginCallback cb, unsigned char pri)
int PluginManagerRemoveEvent (PluginManager *mgr, size_t event, PluginCallback cb, unsigned char pri)
int PluginManagerRemoveEventName (PluginManager *mgr, const char *event, PluginCallback cb, unsigned char pri)
size_t PluginManagerFindEvent (PluginManager *mgr, const char *event)
int PluginManagerDoEvent (PluginManager *mgr, size_t event, void *param1, void *param2)
int PluginManagerDoEventName (PluginManager *mgr, const char *event, void *param1, void *param2)


Typedef Documentation

typedef struct CallbackEntry CallbackEntry
 

typedef struct Plugin Plugin
 

typedef PluginResult(* PluginCallback)(size_t, void *, void *)
 

typedef struct PluginManager PluginManager
 

typedef enum PluginResult PluginResult
 


Enumeration Type Documentation

enum PluginResult
 

Enumeration values:
PLUGIN_NEXT 
PLUGIN_STOP 
PLUGIN_AGAIN 


Function Documentation

int PluginManagerAddDir PluginManager mgr,
const char *  path,
char  recursive
 

Adds an entire directory of plugins. This attempts to load all files in the specified directory. Some may fail if they are not plugins which is not a problem.

Parameters:
mgr Pointer to PluginManager structure
path Filesystem path directory
recursive Set to 0 to not traverse down sub-directories
Returns:
0 on success; non-zero on fail

size_t PluginManagerAddEvent PluginManager mgr,
const char *  event,
PluginCallback  cb,
unsigned char  pri
 

Adds a named event to the manager.

Parameters:
mgr Pointer to PluginManager structure
event Event name
cb Callback function to call when this event occurs
pri Priority of event
Returns:
The return value is the event ID number which can be used in future calls to PluginManagerDoEvent() or 0 if AddEvent fails.

int PluginManagerAddPlugin PluginManager mgr,
const char *  path
 

Adds a plugin DLL to the manager.

Parameters:
mgr Pointer to PluginManager structure
path Filesystem path to DLL that will be loaded
Returns:
0 on success; non-zero on fail

int PluginManagerAddPluginObj PluginManager mgr,
Plugin plugin
 

Destroys a PluginManager context, freeing all memory and resources

Parameters:
mgr Pointer to PluginManager structure

int PluginManagerAlloc PluginManager mgr  ) 
 

Initializes a new plugin manager

Parameters:
mgr Pointer to empty PluginManager structure to be filled in
Returns:
0 on success; non-zero on fail

int PluginManagerDoEvent PluginManager mgr,
size_t  event,
void *  param1,
void *  param2
 

Causes an event to run. This will call all functions registered for the specified event.

Parameters:
mgr Pointer to PluginManager structure
event Event ID number
param1 Parameter to pass to plugin
param2 Extra parameter to pass to plugin
Returns:
0 on success; non-zero on failure

int PluginManagerDoEventName PluginManager mgr,
const char *  event,
void *  param1,
void *  param2
 

Causes an event to run. This will call all functions registered for the specified event. This is slower than the plain DoEvent becuase it does a lookup of the event name.

Parameters:
mgr Pointer to PluginManager structure
event Event name
param1 Parameter to pass to plugin
param2 Extra parameter to pass to plugin
Returns:
0 on success; non-zero on failure

size_t PluginManagerFindEvent PluginManager mgr,
const char *  event
 

Finds a named event and returns the ID number.

Parameters:
mgr Pointer to PluginManager structure
event Event name
Returns:
The return value is the event ID number or 0 if find fails.

void PluginManagerFree PluginManager mgr  ) 
 

Destroys a PluginManager context, freeing all memory and resources. This also calls the finalize() function of all active plugins.

Parameters:
mgr Pointer to PluginManager structure

int PluginManagerRemoveEvent PluginManager mgr,
size_t  event,
PluginCallback  cb,
unsigned char  pri
 

Removes an event from the manager

Parameters:
mgr Pointer to PluginManager structure
event Event ID num
cb Callback function
pri Priority of event
Returns:
0 on sucess; non-zero on fail

int PluginManagerRemoveEventName PluginManager mgr,
const char *  event,
PluginCallback  cb,
unsigned char  pri
 

Removes a named event from the manager. Slower than RemoveEvent because this does a name lookup.

Parameters:
mgr Pointer to PluginManager structure
event Event name
cb Callback function
pri Priority of event
Returns:
0 on sucess; non-zero on fail


Generated on Wed Jan 12 13:13:42 2005 for CUTK by doxygen 1.3.7