00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
#ifndef __INCLUDE_PLUGIN_H__
00028
#define __INCLUDE_PLUGIN_H__
00029
00030
#include <cutk/dll.h>
00031
#include <cutk/strhmap.h>
00032
#include <limits.h>
00033
00034
#ifdef __cplusplus
00035
extern "C" {
00036
#endif
00037
00038
#ifdef _WIN32
00039
#define PATH_MAX MAX_PATH
00040
#endif
00041
00042
00043 typedef enum PluginResult
00044 {
00045
PLUGIN_NEXT,
00046
PLUGIN_STOP,
00047
PLUGIN_AGAIN
00048 }
PluginResult;
00049
00050 typedef PluginResult (*
PluginCallback)(size_t,
void*,
void*);
00051
00052 typedef struct CallbackEntry
00053 {
00054 PluginCallback callback;
00055 unsigned char priority;
00056 }
CallbackEntry;
00057
00058
struct PluginManager;
00059
00060 typedef struct Plugin
00061 {
00062 Dll dll_;
00063 char path_[PATH_MAX];
00064 int (*initialize)(
struct PluginManager*);
00065 int (*finalize)();
00066 }
Plugin;
00067
00068 typedef struct PluginManager
00069 {
00070 Plugin*
plugins_;
00071 StrHmap*
event_map_;
00072 CallbackEntry**
callbacks_;
00073
00074
00075 int (*AddPluginObj) (
struct PluginManager*,
Plugin*);
00076 int (*AddPlugin) (
struct PluginManager*,
const char*);
00077 int (*AddDir) (
struct PluginManager*,
const char* path,
char recursive);
00078 size_t (*AddEvent) (
struct PluginManager*,
const char*,
PluginCallback,
unsigned char);
00079 int (*RemoveEvent) (
struct PluginManager*, size_t,
PluginCallback,
unsigned char);
00080 int (*RemoveEventName)(
struct PluginManager*,
const char*,
PluginCallback,
unsigned char);
00081 size_t (*FindEvent) (
struct PluginManager*,
const char*);
00082 int (*DoEvent) (
struct PluginManager*, size_t event,
void*,
void*);
00083 int (*DoEventName) (
struct PluginManager*,
const char*,
void*,
void*);
00084 }
PluginManager;
00085
00086
00087
int PluginManagerAlloc(
PluginManager* mgr);
00088
void PluginManagerFree(
PluginManager* mgr);
00089
int PluginManagerAddPluginObj(
PluginManager* mgr,
Plugin* plugin);
00090
int PluginManagerAddPlugin(
PluginManager* mgr,
const char* path);
00091
int PluginManagerAddDir(
PluginManager* mgr,
const char* path,
char recursive);
00092 size_t
PluginManagerAddEvent(
PluginManager* mgr,
const char* event, PluginCallback cb,
unsigned char pri);
00093
int PluginManagerRemoveEvent(
PluginManager* mgr, size_t event, PluginCallback cb,
unsigned char pri);
00094
int PluginManagerRemoveEventName(
PluginManager* mgr,
const char* event, PluginCallback cb,
unsigned char pri);
00095 size_t
PluginManagerFindEvent(
PluginManager* mgr,
const char* event);
00096
int PluginManagerDoEvent(
PluginManager* mgr, size_t event,
void* param1,
void* param2);
00097
int PluginManagerDoEventName(
PluginManager* mgr,
const char* event,
void* param1,
void* param2);
00098
00099
#ifdef __cplusplus
00100
}
00101
#endif
00102
00103
#endif