summaryrefslogtreecommitdiff
path: root/src/common/HPM.h
blob: 10b1f0e793d22371682571aa8c23cf5d4e5757e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file

#ifndef	_HPM_H_
#define _HPM_H_

#include "../common/cbasetypes.h"
#include "../common/HPMi.h"

#ifdef WIN32
	#ifndef WIN32_LEAN_AND_MEAN
		#define WIN32_LEAN_AND_MEAN
	#endif
	#include <windows.h>
	#define plugin_open(x)		LoadLibraryA(x)
	#define plugin_import(x,y,z)	(z)GetProcAddress(x,y)
	#define plugin_close(x)	FreeLibrary(x)

	#define DLL_EXT			".dll"
	#define DLL				HINSTANCE
#else
	#include <dlfcn.h>
	#define plugin_open(x)		dlopen(x,RTLD_NOW)
	#define plugin_import(x,y,z)	(z)dlsym(x,y)
	#define plugin_close(x)	dlclose(x)

	#ifdef CYGWIN
		#define DLL_EXT		".dll"
	#else
		#define DLL_EXT		".so"
	#endif

	#define DLL				void *

	#include <string.h> // size_t

#endif

struct hplugin {
	DLL dll;
	unsigned int idx;
	char *filename;
	struct hplugin_info *info;
	struct HPMi_interface *hpi;
};

struct hpm_symbol {
	char *name;
	void *ptr;
};

/* Hercules Plugin Manager Interface */
struct HPM_interface {
	/* vars */
	unsigned int version[2];
	bool off;
	/* data */
	struct hplugin **plugins;
	unsigned int plugin_count;
	struct hpm_symbol **symbols;
	unsigned int symbol_count;
	/* funcs */
	void (*init) (void);
	void (*final) (void);
	struct hplugin * (*create) (void);
	void (*load) (const char* filename);
	void (*unload) (struct hplugin* plugin);
	bool (*exists) (const char *filename);
	bool (*iscompatible) (char* version);
	void (*event) (enum hp_event_types type);
	void *(*import_symbol) (char *);
	void (*share) (void *, char *);
	void (*symbol_defaults) (void);
	void (*config_read) (void);
	bool (*populate) (struct hplugin *plugin,const char *filename);
	void (*symbol_defaults_sub) (void);
} HPM_s;

struct HPM_interface *HPM;

void hpm_defaults(void);

#endif /* _HPM_H_ */