diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-10 22:01:06 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-10 22:01:06 +0300 |
commit | d04454be20272e2d9db3a6546a4ad7d373ca4571 (patch) | |
tree | 8e7165c1ec0233bd30f13b83a3c75e49f51ef115 | |
parent | 622e8f22fad1f323c6b7797a3e9f9ac34d50ae3e (diff) |
GetDatabasePlugin(pszDriverName) - new function to retrieve a database link by its short name
-rw-r--r-- | include/m_db_int.h | 8 | ||||
-rw-r--r-- | libs/win32/mir_app.lib | bin | 130394 -> 130624 bytes | |||
-rw-r--r-- | libs/win64/mir_app.lib | bin | 125918 -> 126128 bytes | |||
-rw-r--r-- | src/mir_app/src/db_intf.cpp | 15 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 1 |
6 files changed, 19 insertions, 6 deletions
diff --git a/include/m_db_int.h b/include/m_db_int.h index 19d5377039..0a6aa6ddb5 100644 --- a/include/m_db_int.h +++ b/include/m_db_int.h @@ -267,12 +267,14 @@ EXTERN_C MIR_CORE_DLL(DBCachedContact*) db_get_contact(MCONTACT); EXTERN_C MIR_CORE_DLL(MIDatabase*) db_get_current(void);
// registers a database plugin
-
EXTERN_C MIR_APP_DLL(void) RegisterDatabasePlugin(DATABASELINK *pDescr);
-// looks for a database plugin suitable to open this file
-// returns DATABASELINK* of the required plugin or NULL on error
+// looks for a database plugin by its short name
+// returns DATABASELINK* of the required plugin or nullptr on error
+EXTERN_C MIR_APP_DLL(DATABASELINK*) GetDatabasePlugin(const char *pszDriverName);
+// looks for a database plugin suitable to open this file
+// returns DATABASELINK* of the required plugin or nullptr on error
EXTERN_C MIR_APP_DLL(DATABASELINK*) FindDatabasePlugin(const wchar_t *ptszFileName);
#endif // M_DB_INT_H__
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 952858edd8..e98e8153b9 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 993d1bf4ab..bb0b07d244 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/src/mir_app/src/db_intf.cpp b/src/mir_app/src/db_intf.cpp index 1a20ef4263..a4d271c367 100644 --- a/src/mir_app/src/db_intf.cpp +++ b/src/mir_app/src/db_intf.cpp @@ -35,12 +35,21 @@ MIR_APP_DLL(void) RegisterDatabasePlugin(DATABASELINK *pDescr) arDbPlugins.insert(pDescr);
}
+MIR_APP_DLL(DATABASELINK*) GetDatabasePlugin(const char *pszDriverName)
+{
+ for (auto &it : arDbPlugins)
+ if (!mir_strcmp(pszDriverName, it->szShortName))
+ return it;
+
+ return nullptr;
+}
+
MIR_APP_DLL(DATABASELINK*) FindDatabasePlugin(const wchar_t *ptszFileName)
{
- for (int i = arDbPlugins.getCount() - 1; i >= 0; i--) {
- int error = arDbPlugins[i]->grokHeader(ptszFileName);
+ for (auto &it : arDbPlugins) {
+ int error = it->grokHeader(ptszFileName);
if (error == ERROR_SUCCESS || error == EGROKPRF_OBSOLETE)
- return arDbPlugins[i];
+ return it;
}
return nullptr;
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 11289c7a7e..a65d30b6a8 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -487,3 +487,4 @@ Image_Load @504 Image_LoadFromMem @505
Image_Resize @506
Image_Save @507
+GetDatabasePlugin @508
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index d6c4787c57..2a29d7d486 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -487,3 +487,4 @@ Image_Load @504 Image_LoadFromMem @505
Image_Resize @506
Image_Save @507
+GetDatabasePlugin @508
|