summaryrefslogtreecommitdiff
path: root/src/common/HPM.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2014-02-02 15:02:14 -0200
committershennetsind <ind@henn.et>2014-02-02 15:02:14 -0200
commitd33469689ea8e671fa0d525d54bce6932dfe9107 (patch)
treef6fc609df3a6d723f6390a69c8e8174e6a242b72 /src/common/HPM.c
parent8a05e611a71168cccac282777aa1719a46f574d0 (diff)
downloadhercules-d33469689ea8e671fa0d525d54bce6932dfe9107.tar.gz
hercules-d33469689ea8e671fa0d525d54bce6932dfe9107.tar.bz2
hercules-d33469689ea8e671fa0d525d54bce6932dfe9107.tar.xz
hercules-d33469689ea8e671fa0d525d54bce6932dfe9107.zip
Introducing HPM Datacheck
http://hercules.ws/board/topic/4283-introducing-hpm-datacheck/ Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/common/HPM.c')
-rw-r--r--src/common/HPM.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c
index 1edf24901..cf296e593 100644
--- a/src/common/HPM.c
+++ b/src/common/HPM.c
@@ -116,6 +116,8 @@ struct hplugin *hplugin_load(const char* filename) {
bool anyEvent = false;
void **import_symbol_ref;
Sql **sql_handle;
+ unsigned int *HPMDataCheckLen;
+ struct s_HPMDataCheck *HPMDataCheck;
if( HPM->exists(filename) ) {
ShowWarning("HPM:plugin_load: attempting to load duplicate '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename);
@@ -203,6 +205,24 @@ struct hplugin *hplugin_load(const char* filename) {
if( !HPM->populate(plugin,filename) )
return NULL;
+ if( !( HPMDataCheckLen = plugin_import(plugin->dll, "HPMDataCheckLen", unsigned int *) ) ) {
+ ShowWarning("HPM:plugin_load: failed to retrieve 'HPMDataCheckLen' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h, skipping...\n", filename);
+ HPM->unload(plugin);
+ return NULL;
+ }
+
+ if( !( HPMDataCheck = plugin_import(plugin->dll, "HPMDataCheck", struct s_HPMDataCheck *) ) ) {
+ ShowWarning("HPM:plugin_load: failed to retrieve 'HPMDataCheck' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h, skipping...\n", filename);
+ HPM->unload(plugin);
+ return NULL;
+ }
+
+ if( !HPM->DataCheck(HPMDataCheck,*HPMDataCheckLen,plugin->info->name) ) {
+ ShowWarning("HPM:plugin_load: '"CL_WHITE"%s"CL_RESET"' failed DataCheck, out of sync from the core (recompile plugin), skipping...\n", filename);
+ HPM->unload(plugin);
+ return NULL;
+ }
+
/* id */
plugin->hpi->pid = plugin->idx;
/* core */
@@ -255,6 +275,11 @@ void hplugins_config_read(void) {
const char *config_filename = "conf/plugins.conf"; // FIXME hardcoded name
FILE *fp;
+ if( !HPM->DataCheck ) {
+ ShowError("HPM:config_read: HPM->DataCheck not set! Failure\n");
+ return;
+ }
+
/* yes its ugly, its temporary and will be gone as soon as the new inter-server.conf is set */
if( (fp = fopen("conf/import/plugins.conf","r")) ) {
config_filename = "conf/import/plugins.conf";
@@ -829,4 +854,5 @@ void hpm_defaults(void) {
HPM->grabHPData = hplugins_grabHPData;
HPM->grabHPDataSub = NULL;
HPM->parseConf = hplugins_parse_conf;
+ HPM->DataCheck = NULL;
}