Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

addons.h

00001 /* $Id: addons.h 1 2006-01-13 22:47:50Z MagicalTux $
00002  *
00003  * Copied from UnrealIRCD and modified (a lot) because UnrealIRCd has
00004  * a really nice modules support :p
00005  * TODO: use APR DSO instead of dlopen/LoadLibrary
00006  */
00007 #ifndef OA_MODULES_H
00008 #define OA_MODULES_H
00009 
00010 #ifdef _WIN32
00011 #include <windows.h>
00012 #else
00013 #include <dlfcn.h>
00014 #endif
00015 
00016 #define MOD_VERSION     "1.0"
00017 
00018 #ifdef _WIN32
00019  #define DLLFUNC        _declspec(dllexport)
00020  #define mod_dlopen(x,y) LoadLibrary(x)
00021  #define mod_dlclose FreeLibrary
00022  #define mod_dlsym(x,y,z) z = (void *)GetProcAddress(x,y)
00023  #define mod_dlerror our_dlerror
00024 #else
00025  #define mod_dlopen dlopen
00026  #define mod_dlclose dlclose
00027  #define mod_dlsym(x,y,z) z = dlsym(x,y)
00028  #define mod_dlerror dlerror
00029  #define DLLFUNC
00030 #endif
00031 
00032 #ifndef RTLD_NOW
00033 #define RTLD_NOW 0
00034 #endif
00035 
00036 /* used for various temporary usages */
00037 void *addon_tmp_pointer;
00038 /* used to contain the common calls table */
00039 void *call_table;
00040 /* used to contain the local calls table */
00041 void *local_table;
00042 
00043 typedef struct _Module Module;
00044 
00045 /*
00046  * Module header that every module must include, with the name of
00047  * mod_header
00048 */
00049 
00050 typedef struct _ModuleHeader {
00051         char *name;
00052         char *version;
00053         char *description;
00054         char *modversion;
00055         char addon_target;
00056 } ModuleHeader;
00057 
00058 typedef struct {
00059         int size;
00060         int module_load;
00061         Module *handle;
00062 } ModuleInfo;
00063 
00064 
00065 struct _Module {
00066         struct _Module *prev, *next;
00067         ModuleHeader *header; /* The module's header */
00068         char *filename; /* filename of the module file */
00069 #ifdef _WIN32
00070         HMODULE dll;    /* Return value of LoadLibrary */
00071 #else
00072         void *dll;      /* Return value of dlopen */
00073 #endif
00074         int state; /* state of the addon (loaded or not, etc...) */
00075 };
00076 
00077 /* Module function return values */
00078 #define MOD_SUCCESS 0
00079 #define MOD_FAILED -1
00080 
00081 /* Addons states */
00082 #define MOD_STATE_EMPTY 0 /* No addon here, empty space */
00083 #define MOD_STATE_DISABLED 1 /* addon currently disabled */
00084 #define MOD_STATE_ENABLED 2 /* addon currently enabled */
00085 
00086 #define ADDONS_ALL 0
00087 #define ADDONS_LOGIN 1
00088 #define ADDONS_CHAR 2
00089 #define ADDONS_MAP 3
00090 
00091 #ifdef DYNAMIC_LINKING
00092  #define MOD_HEADER(name) Mod_Header
00093  #define MOD_TEST(name) Mod_Test
00094  #define MOD_INIT(name) Mod_Init
00095  #define MOD_LOAD(name) Mod_Load
00096  #define MOD_UNLOAD(name) Mod_Unload
00097 #else
00098  #define MOD_HEADER(name) name##_Header
00099  #define MOD_TEST(name) name##_Test
00100  #define MOD_INIT(name) name##_Init
00101  #define MOD_LOAD(name) name##_Load
00102  #define MOD_UNLOAD(name) name##_Unload
00103 #endif
00104 
00105 int addons_enable_all(void);
00106 int addons_load(char *, char);
00107 int addons_unload(struct _Module *, int);
00108 void addons_unload_all(void);
00109 
00110 #endif // MODULES_H
00111 

Generated on Fri Apr 28 10:20:04 2006 for OpenAthena by  doxygen 1.4.4