From 4bc88d46fa9859615521f436511d4f102f20eb67 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 18 Jul 2012 14:11:28 +0000 Subject: databases are still static, but are controlled via classes git-svn-id: http://svn.miranda-ng.org/main/trunk@1014 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dbx_tree/DatabaseLink.cpp | 44 +++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 25 deletions(-) (limited to 'plugins/Dbx_tree/DatabaseLink.cpp') diff --git a/plugins/Dbx_tree/DatabaseLink.cpp b/plugins/Dbx_tree/DatabaseLink.cpp index 3e75ce591e..850e798ef9 100644 --- a/plugins/Dbx_tree/DatabaseLink.cpp +++ b/plugins/Dbx_tree/DatabaseLink.cpp @@ -25,23 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "savestrings_gcc.h" #endif -static int getCapability(int); -static int getFriendlyName(char*, size_t, int); -static int makeDatabase(char*, int*); -static int grokHeader(char*, int*); -static int Load(char*); -static int Unload(int); - -DATABASELINK gDBLink = { - sizeof(DATABASELINK), - getCapability, - getFriendlyName, - makeDatabase, - grokHeader, - Load, - Unload, -}; - HANDLE hSystemModulesLoaded = 0; static int SystemModulesLoaded(WPARAM wParam, LPARAM lParam) @@ -70,12 +53,12 @@ static int getCapability(int flag) Returns: 0 on success, non zero on failure */ -static int getFriendlyName(char* buf, size_t cch, int shortName) +static int getFriendlyName(TCHAR *buf, size_t cch, int shortName) { if (shortName) - strncpy_s(buf, cch, gInternalName, strlen(gInternalName)); + _tcsncpy_s(buf, cch, _T(gInternalName), SIZEOF(gInternalName)); else - strncpy_s(buf, cch, gInternalNameLong, strlen(gInternalNameLong)); + _tcsncpy_s(buf, cch, _T(gInternalNameLong), SIZEOF(gInternalNameLong)); return 0; } @@ -87,10 +70,10 @@ static int getFriendlyName(char* buf, size_t cch, int shortName) Note: Do not initialise internal data structures at this point! Returns: 0 on success, non zero on failure - error contains extended error information, see EMKPRF_* */ -static int makeDatabase(char* profile, int* error) +static int makeDatabase(TCHAR *profile, int* error) { if (gDataBase) delete gDataBase; - gDataBase = new CDataBase(profile); + gDataBase = new CDataBase(profile); *error = gDataBase->CreateDB(); return *error; @@ -106,7 +89,7 @@ static int makeDatabase(char* profile, int* error) etc. Returns: 0 on success, non zero on failure */ -static int grokHeader(char* profile, int* error) +static int grokHeader(TCHAR *profile, int* error) { if (gDataBase) delete gDataBase; gDataBase = new CDataBase(profile); @@ -121,7 +104,7 @@ Affect: Tell the database to create all services/hooks that a 3.xx legecy databa Returns: 0 on success, nonzero on failure */ -static int Load(char* profile) +static MIDatabase* Load(TCHAR *profile) { if (gDataBase) delete gDataBase; gDataBase = new CDataBase(profile); @@ -131,7 +114,8 @@ static int Load(char* profile) hSystemModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, SystemModulesLoaded); - return gDataBase->OpenDB(); + gDataBase->OpenDB(); + return gDataBase; } /* @@ -147,3 +131,13 @@ static int Unload(int wasLoaded) gDataBase = NULL; return 0; } + +DATABASELINK gDBLink = { + sizeof(DATABASELINK), + getCapability, + getFriendlyName, + makeDatabase, + grokHeader, + Load, + Unload, +}; -- cgit v1.2.3