root/src/common/plugins.h @ 23

Revision 1, 1.6 kB (checked in by jinshiro, 17 years ago)
Line 
1// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
2// For more information, see LICENCE in the main folder
3
4#ifndef _PLUGINS_H_
5#define _PLUGINS_H_
6
7#ifndef _CBASETYPES_H_
8#include "../common/cbasetypes.h"
9#endif
10
11#include "../common/plugin.h"
12
13////// Dynamic Link Library functions ///////////////
14
15#ifdef WIN32
16
17        #define WIN32_LEAN_AND_MEAN
18        #include <windows.h>
19        #define DLL_OPEN(x)             LoadLibrary(x)
20        #define DLL_SYM(x,y)    GetProcAddress(x,y)
21        #define DLL_CLOSE(x)    FreeLibrary(x)
22        char *DLL_ERROR(void);
23
24        #define DLL_EXT                 ".dll"
25        #define DLL                             HINSTANCE
26
27#else
28
29        #include <dlfcn.h>
30        #define DLL_OPEN(x)             dlopen(x,RTLD_NOW)
31        #define DLL_SYM(x,y)    dlsym(x,y)
32        #define DLL_CLOSE(x)    dlclose(x)
33        #define DLL_ERROR               dlerror
34
35        #ifdef CYGWIN
36                #define DLL_EXT         ".dll"
37        #else
38                #define DLL_EXT         ".so"
39        #endif
40        #define DLL                             void *
41
42        #include <string.h> // size_t
43
44#endif
45
46////// Plugin Definitions ///////////////////
47
48typedef struct _Plugin {
49        DLL dll;
50        char state;
51        char* filename;
52        struct _Plugin_Info* info;
53        struct _Plugin* next;   
54} Plugin;
55
56/////////////////////////////////////////////
57
58int register_plugin_func(char* name);
59int register_plugin_event(Plugin_Event_Func* func, char* name);
60int plugin_event_trigger(char* name);
61
62int export_symbol(void* var, size_t offset);
63#define EXPORT_SYMBOL(s,o) export_symbol((void*)(s),(o));
64#define EXPORT_SYMBOL2(s) EXPORT_SYMBOL((s), -1);
65
66Plugin* plugin_open(const char* filename);
67void plugin_load(const char* filename);
68void plugin_unload(Plugin* plugin);
69void plugins_init(void);
70void plugins_final(void);
71
72#endif /* _PLUGINS_H_ */
Note: See TracBrowser for help on using the browser.