From bfe1bd0fc087be44c70904aee0fe4276643d206d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 20 Jul 2012 15:56:25 +0000 Subject: - db3x_mmap is completely moved to a class; - the old nightmare in the core "How to detect a db plugin and load it" is eliminated forever; - databases are the usual plugins now (loadable via Load) - dynamic DATABASELINK registration git-svn-id: http://svn.miranda-ng.org/main/trunk@1082 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dbx_mmap_SA/init.cpp | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to 'plugins/Dbx_mmap_SA') diff --git a/plugins/Dbx_mmap_SA/init.cpp b/plugins/Dbx_mmap_SA/init.cpp index 97c6353d69..cf06474dde 100644 --- a/plugins/Dbx_mmap_SA/init.cpp +++ b/plugins/Dbx_mmap_SA/init.cpp @@ -45,13 +45,10 @@ PLUGININFOEX pluginInfo = { { 0x28ff9b91, 0x3e4d, 0x4f1c, { 0xb4, 0x7c, 0xc6, 0x41, 0xb0, 0x37, 0xff, 0x40 } } }; -static int getCapability( int flag ) -{ - return 0; -} +///////////////////////////////////////////////////////////////////////////////////////// // returns 0 if the profile is created, EMKPRF* -static int makeDatabase(TCHAR *profile, int *error) +static int makeDatabase(const TCHAR *profile, int *error) { HANDLE hFile = CreateFile(profile, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); if ( hFile != INVALID_HANDLE_VALUE ) { @@ -64,7 +61,7 @@ static int makeDatabase(TCHAR *profile, int *error) } // returns 0 if the given profile has a valid header -static int grokHeader(TCHAR *profile, int *error ) +static int grokHeader(const TCHAR *profile, int *error ) { int rc = 1; int chk = 0; @@ -116,7 +113,7 @@ static int grokHeader(TCHAR *profile, int *error ) } // returns 0 if all the APIs are injected otherwise, 1 -static MIDatabase* LoadDatabase(TCHAR *profile) +static MIDatabase* LoadDatabase(const TCHAR *profile) { if (g_Db) delete g_Db; g_Db = new CDdxMmap(profile); @@ -152,23 +149,17 @@ static MIDatabase* LoadDatabase(TCHAR *profile) return g_Db; } -static int UnloadDatabase(int wasLoaded) +static int UnloadDatabase(MIDatabase* db) { - if ( !wasLoaded) return 0; UnloadDatabaseModule(); - return 0; -} - -static int getFriendlyName( TCHAR* buf, size_t cch, int shortName ) -{ - _tcsncpy(buf,shortName ? _T("db3x secured_mmap driver") : _T("db3x mmap database support"), cch); + delete g_Db; g_Db = 0; return 0; } static DATABASELINK dblink = { sizeof(DATABASELINK), - getCapability, - getFriendlyName, + "db3x secured_mmap driver", + _T("db3x mmap database support"), makeDatabase, grokHeader, LoadDatabase, @@ -181,11 +172,6 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID reserved) return TRUE; } -extern "C" __declspec(dllexport) DATABASELINK* DatabasePluginInfo(void * reserved) -{ - return &dblink; -} - extern "C" __declspec(dllexport) PLUGININFOEX * MirandaPluginInfoEx(DWORD mirandaVersion) { return &pluginInfo; @@ -195,7 +181,7 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_DATABAS extern "C" __declspec(dllexport) int Load(void) { - return 1; + return 0; } extern "C" __declspec(dllexport) int Unload(void) -- cgit v1.2.3