diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2010-08-05 01:31:34 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2010-08-05 01:31:34 +0300 |
commit | 63edbec1418f493ff86a3e0615a50b0fb83ab6a5 (patch) | |
tree | 6ad5b2fe9b34d88c0b919e5d37681ebbe0d87027 | |
parent | 3be8db3edc326f02c9e345d7a8e6a9f2aa960864 (diff) |
new file: ../../api/db.h
modified: ../dbsqlite/main.cpp
modified: main.cpp
-rw-r--r-- | api/db.h | 11 | ||||
-rw-r--r-- | modules/dbsqlite/main.cpp | 17 | ||||
-rw-r--r-- | modules/example/main.cpp | 10 |
3 files changed, 31 insertions, 7 deletions
diff --git a/api/db.h b/api/db.h new file mode 100644 index 0000000..7e08814 --- /dev/null +++ b/api/db.h @@ -0,0 +1,11 @@ +#ifndef DB_H +#define DB_H +#define D_INT 0x0001 +#define D_STRING 0x0002 +struct DATA +{ + WORD wType; + void* pData; + char* szModule; +}; +#endif diff --git a/modules/dbsqlite/main.cpp b/modules/dbsqlite/main.cpp index c6462df..e1128f7 100644 --- a/modules/dbsqlite/main.cpp +++ b/modules/dbsqlite/main.cpp @@ -3,6 +3,7 @@ #include <pluginapi.h> #include <plugin_helper.h> +#include <db.h> #include "sqlite3.h" @@ -36,21 +37,29 @@ extern "C" __declspec(dllexport) PLUGININFO* SetPluginInfo() extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) { pluginLink = link; - sqlite3_open(".\\database.sql3", &db); - MessageBoxA(0, "dbsqlite plugin loaded", "INFO", MB_OK); + if(!sqlite3_open_v2(".\\database.sql3", &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL)) + MessageBoxA(0, "dbsqlite plugin loaded", "INFO", MB_OK); return 0; } extern "C" int __declspec(dllexport) OnModulesLoaded() { -// sqlite3_exec(db, "", 0, 0, &db_err); for(;;) Sleep(1000); return 0; } extern "C" int __declspec(dllexport) Unload() { - sqlite3_close(db); + while(sqlite3_close(db) == SQLITE_BUSY) + Sleep(1000); + MessageBoxA(0, "Database succesfuly unloaded", "INFO", MB_OK); return 0; } +SERVICE dbWriteSestting(WPARAM w, LPARAM l) +{ +} +SERVICE dbGetSetting(WPARAM w, LPARAM l) +{ +} + diff --git a/modules/example/main.cpp b/modules/example/main.cpp index 438e281..ecba903 100644 --- a/modules/example/main.cpp +++ b/modules/example/main.cpp @@ -28,12 +28,13 @@ PLUGININFO pluginInfo = extern "C" __declspec(dllexport) PLUGININFO* SetPluginInfo() { - return &pluginInfo; + return &pluginInfo; //necessary } extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) //basic initialisation, registering new functions, do other basic initialisation, you can create infinite loop, or other code which use many time here, only fast basic initialisation { pluginLink = link; //necessary + //some basic initialisation code MessageBoxA(0, "Simple plugin initialisation done", "INFO", MB_OK); TestService(); //only core servisec avaible in load return 0; //all ok, retrun 0 @@ -42,14 +43,17 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) //basic initialisat extern "C" int __declspec(dllexport) OnModulesLoaded() //load main code from here, all services from other plugins must be avaible here { MessageBoxA(0, "Advanced plugin features needed services from other plugins are working from now", "INFO", MB_OK); - CallService("Core/Test", 0, 0); //usage example of service registered in core - TestService(); //same as above, look in core_services.h + //some code +// TestService(); //same as CallService("Core/Test", 0, 0); Shutdown(); //same as CallService("Core/Shutdown", 0, 0); ,this will shutdown program return 0; } extern "C" int __declspec(dllexport) Unload() { + //close open files, databases, save settings in memory to db, e.t.c. here. + //some code + MessageBoxA(0, "Plugin Sucesfully unloaded", "INFO", MB_OK); return 0; } |