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

plugin.h

Go to the documentation of this file.
00001 /* 00002 ** This file is part of the C Utility Toolkit (CUTK) 00003 ** Copyright (C) 2002-2005 Chris Osgood 00004 ** http://www.cutk.org 00005 ** 00006 ** This library is free software; you can redistribute it and/or 00007 ** modify it under the terms of the GNU Lesser General Public 00008 ** License as published by the Free Software Foundation; either 00009 ** version 2.1 of the License, or (at your option) any later version. 00010 ** 00011 ** This library is distributed in the hope that it will be useful, 00012 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 ** Lesser General Public License for more details. 00015 ** 00016 ** You should have received a copy of the GNU Lesser General Public 00017 ** License along with this library; if not, write to the Free Software 00018 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 ** 00020 ** Please report all bugs and problems to "bugs at cutk.org". 00021 */ 00022 00023 /* 00024 ** $Id: plugin.h 29 2005-01-12 16:31:26Z chris $ 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 /* Callback funtions should return one of these */ 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_; /* Array of plugins */ 00071 StrHmap* event_map_; /* Hash-map of indexes into callbacks_ */ 00072 CallbackEntry** callbacks_; /* Array of pointers to PluginEntry arrays */ 00073 00074 /* Plugins should use this API to access the plugin manager */ 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 /* PluginManager API */ 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 /* __INCLUDE_PLUGIN_H__ */

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