summaryrefslogtreecommitdiff
path: root/plugins/YAMN/src/main.cpp
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2013-08-23 12:05:26 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2013-08-23 12:05:26 +0000
commitd3f0f130d7c6eab9c723dcb06d64853bcedd7035 (patch)
treef7f40fcb7aca760da94251ed46653caf0c180559 /plugins/YAMN/src/main.cpp
parent264e076f02faca0cfd59e5b0929d74ca621119cb (diff)
use mir_sntprintf
git-svn-id: http://svn.miranda-ng.org/main/trunk@5791 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/YAMN/src/main.cpp')
-rw-r--r--plugins/YAMN/src/main.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/plugins/YAMN/src/main.cpp b/plugins/YAMN/src/main.cpp
index ed0ea35794..65aee18a87 100644
--- a/plugins/YAMN/src/main.cpp
+++ b/plugins/YAMN/src/main.cpp
@@ -258,17 +258,14 @@ void WINAPI g_ReleaseIcon( HICON hIcon )
static void LoadPlugins()
{
- HANDLE hFind;
- WIN32_FIND_DATA fd;
TCHAR szSearchPath[MAX_PATH];
- TCHAR szPluginPath[MAX_PATH];
- lstrcpy(szSearchPath, szMirandaDir);
- lstrcat(szSearchPath, _T("\\Plugins\\YAMN\\*.dll"));
- typedef INT_PTR (*LOADFILTERFCN)(MIRANDASERVICE GetYAMNFcn);
+ mir_sntprintf(szSearchPath, MAX_PATH, _T("%s\\Plugins\\YAMN\\*.dll"), szMirandaDir);
hDllPlugins = NULL;
- if (INVALID_HANDLE_VALUE != (hFind = FindFirstFile(szSearchPath, &fd))) {
+ WIN32_FIND_DATA fd;
+ HANDLE hFind = FindFirstFile(szSearchPath, &fd);
+ if (hFind != INVALID_HANDLE_VALUE) {
do {
//rewritten from Miranda sources... Needed because Win32 API has a bug in FindFirstFile, search is done for *.dlllllll... too
TCHAR *dot = _tcsrchr(fd.cFileName, '.');
@@ -276,21 +273,20 @@ static void LoadPlugins()
continue;
// we have a dot
- int len = (int)lstrlen(fd.cFileName); // find the length of the string
+ int len = lstrlen(fd.cFileName); // find the length of the string
TCHAR* end = fd.cFileName+len; // get a pointer to the NULL
int safe = (end-dot)-1; // figure out how many chars after the dot are "safe", not including NULL
if ((safe != 3) || (lstrcmpi(dot+1, _T("dll")) != 0)) //not bound, however the "dll" string should mean only 3 chars are compared
continue;
- HINSTANCE hDll;
- LOADFILTERFCN LoadFilter;
+ TCHAR szPluginPath[MAX_PATH];
+ mir_sntprintf(szPluginPath, MAX_PATH,_T("%s\\Plugins\\YAMN\\%s"), szMirandaDir, fd.cFileName);
+ HINSTANCE hDll = LoadLibrary(szPluginPath);
+ if (hDll == NULL)
+ continue;
- lstrcpy(szPluginPath, szMirandaDir);
- lstrcat(szPluginPath, _T("\\Plugins\\YAMN\\"));
- lstrcat(szPluginPath, fd.cFileName);
- if ((hDll = LoadLibrary(szPluginPath)) == NULL) continue;
- LoadFilter = (LOADFILTERFCN)GetProcAddress(hDll, "LoadFilter");
+ LOADFILTERFCN LoadFilter = (LOADFILTERFCN) GetProcAddress(hDll, "LoadFilter");
if (NULL == LoadFilter) {
FreeLibrary(hDll);
hDll = NULL;