From d04454be20272e2d9db3a6546a4ad7d373ca4571 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 10 Mar 2018 22:01:06 +0300 Subject: GetDatabasePlugin(pszDriverName) - new function to retrieve a database link by its short name --- src/mir_app/src/db_intf.cpp | 15 ++++++++++++--- src/mir_app/src/mir_app.def | 1 + src/mir_app/src/mir_app64.def | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src') 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 -- cgit v1.2.3