summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2013-07-26 08:46:45 +0000
committerKirill Volinsky <mataes2007@gmail.com>2013-07-26 08:46:45 +0000
commit12718514fb673dbb72f7d93ea3bb34c9574bd69a (patch)
tree91569255bd22163c21eb9f22ceb388db16f53e19
parent3856c86d711275b80e09371cad10b8b828a5879a (diff)
replace sprintf to mir_snprintf (part 7)
removed not used files git-svn-id: http://svn.miranda-ng.org/main/trunk@5490 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/BasicHistory/src/ExportManager.cpp4
-rw-r--r--plugins/BasicHistory/src/PlainHtmlExport.cpp2
-rw-r--r--plugins/CmdLine/MimCmd/src/MimCmd.cpp2
-rw-r--r--plugins/CmdLine/MimCmd/src/commands.cpp2
-rw-r--r--plugins/CmdLine/src/commonheaders.h38
-rw-r--r--plugins/CountryFlags/src/ip2country.cpp2
-rw-r--r--plugins/CrashDumper/src/bkstring.cpp2
-rw-r--r--plugins/DbChecker/src/progress.cpp2
-rw-r--r--plugins/Dbx_tree/src/Events.cpp8
-rw-r--r--plugins/Dbx_tree/src/Logger.cpp6
-rw-r--r--plugins/Dbx_tree/src/Settings.cpp12
-rw-r--r--plugins/Dbx_tree/src/savestrings_gcc.h31
-rw-r--r--plugins/FingerprintNG/src/utilities.cpp12
-rw-r--r--plugins/IEView/ieview_11.vcxproj1
-rw-r--r--plugins/IEView/ieview_11.vcxproj.filters3
-rw-r--r--plugins/IEView/src/SRMMHTMLBuilder.cpp275
-rw-r--r--plugins/IEView/src/SRMMHTMLBuilder.h40
-rw-r--r--plugins/KeyboardNotify/src/keyboard.cpp8
-rw-r--r--plugins/LangMan/src/options.cpp2
-rw-r--r--plugins/PasteIt/src/PasteToWeb.cpp8
-rw-r--r--plugins/PasteIt/src/PasteToWeb1.cpp4
-rw-r--r--plugins/SmileyAdd/src/bkstring.cpp2
-rw-r--r--plugins/SpellChecker/src/commons.h4
-rw-r--r--plugins/StatusPlugins/dbhelpers.h100
-rw-r--r--plugins/Utils/ContactAsyncQueue.cpp234
-rw-r--r--plugins/Utils/ContactAsyncQueue.h95
-rw-r--r--plugins/Utils/MemoryModule.c540
-rw-r--r--plugins/Utils/MemoryModule.h48
-rw-r--r--plugins/Utils/mir_dbutils.h70
-rw-r--r--plugins/Utils/mir_log.cpp220
-rw-r--r--plugins/Utils/mir_log.h63
-rw-r--r--plugins/Utils/mir_options_notify.cpp199
-rw-r--r--plugins/Utils/mir_options_notify.h69
-rw-r--r--plugins/Utils/mir_profiler.cpp178
-rw-r--r--plugins/Utils/mir_profiler.h77
-rw-r--r--plugins/Utils/mir_scope.h35
-rw-r--r--plugins/Utils/templates.cpp473
-rw-r--r--plugins/Utils/templates.h102
-rw-r--r--plugins/Utils/tstring.h14
-rw-r--r--plugins/Variables/src/parse_inet.cpp2
-rw-r--r--plugins/Weather/src/weather_ini.cpp2
-rw-r--r--plugins/mTextControl/src/richeditutils.cpp8
42 files changed, 46 insertions, 2953 deletions
diff --git a/plugins/BasicHistory/src/ExportManager.cpp b/plugins/BasicHistory/src/ExportManager.cpp
index 83c4a2ba7e..c5c01b4ac2 100644
--- a/plugins/BasicHistory/src/ExportManager.cpp
+++ b/plugins/BasicHistory/src/ExportManager.cpp
@@ -40,9 +40,9 @@ std::wstring GetFile(const TCHAR* ext, HWND hwnd, bool open)
TCHAR extUpper[32];
_tcscpy_s(extUpper, ext);
extUpper[0] = std::toupper(ext[0], loc);
- _stprintf_s(filter, TranslateT("%s Files (*.%s)"), extUpper, ext);
+ mir_sntprintf(filter, SIZEOF(filter), TranslateT("%s Files (*.%s)"), extUpper, ext);
size_t len = _tcslen(filter) + 1;
- _stprintf_s(filter + len, 512 - len, TranslateT("*.%s"), ext);
+ mir_sntprintf(filter + len, 512 - len, TranslateT("*.%s"), ext);
len += _tcslen(filter + len);
filter[++len] = 0;
TCHAR stzFilePath[1024];
diff --git a/plugins/BasicHistory/src/PlainHtmlExport.cpp b/plugins/BasicHistory/src/PlainHtmlExport.cpp
index 050b4e457e..ca0e110822 100644
--- a/plugins/BasicHistory/src/PlainHtmlExport.cpp
+++ b/plugins/BasicHistory/src/PlainHtmlExport.cpp
@@ -83,7 +83,7 @@ void PlainHtmlExport::WriteGroup(bool isMe, const std::wstring &time, const std:
{
TCHAR buf[256];
EXP_FILE << _T("<div class=mes id=session>\n");
- _stprintf_s(buf, TranslateT("Conversation started at %s"), time.c_str());
+ mir_sntprintf(buf, SIZEOF(buf), TranslateT("Conversation started at %s"), time.c_str());
EXP_FILE << _T("<div class=text>") << buf << _T("</div>\n");
EXP_FILE << _T("</div>\n");
}
diff --git a/plugins/CmdLine/MimCmd/src/MimCmd.cpp b/plugins/CmdLine/MimCmd/src/MimCmd.cpp
index 94f614a20c..8ae4e6909d 100644
--- a/plugins/CmdLine/MimCmd/src/MimCmd.cpp
+++ b/plugins/CmdLine/MimCmd/src/MimCmd.cpp
@@ -28,7 +28,7 @@ int lpprintf(const char *format, ...)
va_start(va, format);
const int MAX_SIZE = 16192;
char buffer[MAX_SIZE] = {0};
- int len = _vsnprintf(buffer, MAX_SIZE - 1, format, va);
+ int len = mir_vsnprintf(buffer, MAX_SIZE - 1, format, va);
buffer[MAX_SIZE - 1] = 0;
va_end(va);
CharToOemBuff(buffer, buffer, len);
diff --git a/plugins/CmdLine/MimCmd/src/commands.cpp b/plugins/CmdLine/MimCmd/src/commands.cpp
index bae47b089c..8b2f70259f 100644
--- a/plugins/CmdLine/MimCmd/src/commands.cpp
+++ b/plugins/CmdLine/MimCmd/src/commands.cpp
@@ -131,7 +131,7 @@ void HandleHelpCommand(PCommand helpCommand, char *argv[], int argc, PReply repl
}
else{
reply->code = MIMRES_NOTFOUND;
- _snprintf(reply->message, size, Translate("No help for '%s'."), argv[2]);
+ mir_snprintf(reply->message, size, Translate("No help for '%s'."), argv[2]);
reply->message[size -1 ] = 0;
}
}
diff --git a/plugins/CmdLine/src/commonheaders.h b/plugins/CmdLine/src/commonheaders.h
index 9cd110bc24..eb64fbed2a 100644
--- a/plugins/CmdLine/src/commonheaders.h
+++ b/plugins/CmdLine/src/commonheaders.h
@@ -59,42 +59,4 @@ extern int bWaitForUnload;
#define ID_ICQ_EXIT 40001
-static __inline int mir_old_snprintf(char *buffer, size_t count, const char* fmt, ...) {
- va_list va;
- int len;
-
- va_start(va, fmt);
- len = _vsnprintf(buffer, count-1, fmt, va);
- va_end(va);
- buffer[count-1] = 0;
- return len;
-}
-
-static __inline int mir_old_sntprintf(TCHAR *buffer, size_t count, const TCHAR* fmt, ...) {
- va_list va;
- int len;
-
- va_start(va, fmt);
- len = _vsntprintf(buffer, count-1, fmt, va);
- va_end(va);
- buffer[count-1] = 0;
- return len;
-}
-
-static __inline int mir_old_vsnprintf(char *buffer, size_t count, const char* fmt, va_list va) {
- int len;
-
- len = _vsnprintf(buffer, count-1, fmt, va);
- buffer[count-1] = 0;
- return len;
-}
-
-static __inline int mir_old_vsntprintf(TCHAR *buffer, size_t count, const TCHAR* fmt, va_list va) {
- int len;
-
- len = _vsntprintf(buffer, count-1, fmt, va);
- buffer[count-1] = 0;
- return len;
-}
-
#endif //M_CMDLINE_COMMONHEADERS_H \ No newline at end of file
diff --git a/plugins/CountryFlags/src/ip2country.cpp b/plugins/CountryFlags/src/ip2country.cpp
index e11195c521..ceaaefbb3b 100644
--- a/plugins/CountryFlags/src/ip2country.cpp
+++ b/plugins/CountryFlags/src/ip2country.cpp
@@ -248,7 +248,7 @@ static int EnumIpDataLines(const char *pszFileCSV,const char *pszFileOut)
}
/* not in list */
if (i == nCountriesCount) {
- wsprintfA(out,"Unknown: %s-%s [%s, %s]\n",pszFrom,pszTo,pszTwo,pszCountry);
+ mir_snprintf(out, SIZEOF(out), "Unknown: %s-%s [%s, %s]\n", pszFrom, pszTo, pszTwo, pszCountry);
OutputDebugStringA(out); /* all ascii */
}
}
diff --git a/plugins/CrashDumper/src/bkstring.cpp b/plugins/CrashDumper/src/bkstring.cpp
index e5e0eb9e7b..b79301a036 100644
--- a/plugins/CrashDumper/src/bkstring.cpp
+++ b/plugins/CrashDumper/src/bkstring.cpp
@@ -40,7 +40,7 @@ void bkstring::appendfmt(const value_type *fmt, ...)
va_start(vararg, fmt);
for (;;)
{
- int len = _vsntprintf(buf + lenBuf, sizeAlloced - lenBuf - 1, fmt, vararg);
+ int len = mir_vsntprintf(buf + lenBuf, sizeAlloced - lenBuf - 1, fmt, vararg);
if (len < 0)
reserve(sizeAlloced + 256);
else
diff --git a/plugins/DbChecker/src/progress.cpp b/plugins/DbChecker/src/progress.cpp
index f223066b1d..3ba8b45bb5 100644
--- a/plugins/DbChecker/src/progress.cpp
+++ b/plugins/DbChecker/src/progress.cpp
@@ -32,7 +32,7 @@ void AddToStatus(int flags, const TCHAR* fmt, ...)
va_start(vararg, fmt);
TCHAR str[256];
- _vsntprintf(str, SIZEOF(str), fmt, vararg);
+ mir_vsntprintf(str, SIZEOF(str), fmt, vararg);
va_end(vararg);
int i = SendMessage(hwndStatus, LB_ADDSTRING, 0, (LPARAM)str);
diff --git a/plugins/Dbx_tree/src/Events.cpp b/plugins/Dbx_tree/src/Events.cpp
index 41228b69ce..ee3254ad44 100644
--- a/plugins/Dbx_tree/src/Events.cpp
+++ b/plugins/Dbx_tree/src/Events.cpp
@@ -89,12 +89,12 @@ bool CEventsTypeManager::GetType(uint32_t GlobalID, char * & Module, uint32_t &
sname.Descriptor = &d;
sname.Type = DBT_ST_ANSI;
- sprintf_s(n, "$EventTypes/%08x/ModuleID", GlobalID);
+ mir_snprintf(n, SIZEOF(n), "$EventTypes/%08x/ModuleID", GlobalID);
TDBTSettingHandle h = m_Settings.ReadSetting(sid);
if ((h != DBT_INVALIDPARAM) && (h != 0))
{
- sprintf_s(n, "$EventTypes/%08x/ModuleName", GlobalID);
+ mir_snprintf(n, SIZEOF(n), "$EventTypes/%08x/ModuleName", GlobalID);
d.Flags = 0;
h = m_Settings.ReadSetting(sname);
@@ -145,12 +145,12 @@ uint32_t CEventsTypeManager::EnsureIDExists(char* Module, uint32_t EventType)
s.cbSize = sizeof(s);
s.Descriptor = &d;
- sprintf_s(n, "$EventTypes/%08x/ModuleID", res);
+ mir_snprintf(n, SIZEOF(n), "$EventTypes/%08x/ModuleID", res);
s.Type = DBT_ST_INT;
s.Value.Int = EventType;
m_Settings.WriteSetting(s);
- sprintf_s(n, "$EventTypes/%08x/ModuleName", res);
+ mir_snprintf(n, SIZEOF(n), "$EventTypes/%08x/ModuleName", res);
d.Flags = 0;
s.Type = DBT_ST_ANSI;
s.Value.Length = static_cast<uint32_t>(strlen(Module) + 1);
diff --git a/plugins/Dbx_tree/src/Logger.cpp b/plugins/Dbx_tree/src/Logger.cpp
index 7ca9452460..7b732b6cfd 100644
--- a/plugins/Dbx_tree/src/Logger.cpp
+++ b/plugins/Dbx_tree/src/Logger.cpp
@@ -53,7 +53,7 @@ void CLogger::Append(const TCHAR * File, const TCHAR * Function, const int Line,
TCHAR msgbuf[4096];
va_list va;
va_start(va, Message);
- len += _vstprintf_s(msgbuf, Message, va);
+ len += mir_vsntprintf(msgbuf, SIZEOF(msgbuf), Message, va);
va_end(va);
TCHAR * message;
@@ -65,12 +65,12 @@ void CLogger::Append(const TCHAR * File, const TCHAR * Function, const int Line,
len += /*_tcslen(File) + 10 +*/ _tcslen(Function) + 32 + 12 + 1;
message = new TCHAR[len];
- m_Length += _stprintf_s(message, len, _T("[%s - %s]\n%s\n\nSystem Error Code: %d\n%s\n\n"), timebuf, /*File, Line, */ Function, msgbuf, SysState, syserror) + 1;
+ m_Length += mir_sntprintf(message, len, _T("[%s - %s]\n%s\n\nSystem Error Code: %d\n%s\n\n"), timebuf, /*File, Line, */ Function, msgbuf, SysState, syserror) + 1;
} else {
len += /*_tcslen(File) + 10 +*/ _tcslen(Function) + 12 + 1;
message = new TCHAR[len];
- m_Length += _stprintf_s(message, len, _T("[%s - %s]\n%s\n\n"), timebuf, /*File, Line, */Function, msgbuf) + 1;
+ m_Length += mir_sntprintf(message, len, _T("[%s - %s]\n%s\n\n"), timebuf, /*File, Line, */Function, msgbuf) + 1;
}
m_Messages.push_back(message);
}
diff --git a/plugins/Dbx_tree/src/Settings.cpp b/plugins/Dbx_tree/src/Settings.cpp
index 54c0f03b6b..814086a432 100644
--- a/plugins/Dbx_tree/src/Settings.cpp
+++ b/plugins/Dbx_tree/src/Settings.cpp
@@ -808,7 +808,7 @@ unsigned int CSettings::ReadSetting(TDBTSetting & Setting, TDBTSettingHandle hSe
{
char buffer[24];
buffer[0] = 0;
- Setting.Value.Length = 1 + sprintf_s(buffer, "%llu", setting->Value.QWord);
+ Setting.Value.Length = 1 + mir_snprintf(buffer, SIZEOF(buffer), "%llu", setting->Value.QWord);
Setting.Value.pAnsi = (char *) mir_realloc(Setting.Value.pAnsi, Setting.Value.Length);
memcpy(Setting.Value.pAnsi, buffer, Setting.Value.Length);
@@ -817,7 +817,7 @@ unsigned int CSettings::ReadSetting(TDBTSetting & Setting, TDBTSettingHandle hSe
{
wchar_t buffer[24];
buffer[0] = 0;
- Setting.Value.Length = 1 + swprintf_s(buffer, L"%llu", setting->Value.QWord);
+ Setting.Value.Length = 1 + mir_snwprintf(buffer, SIZEOF(buffer), L"%llu", setting->Value.QWord);
Setting.Value.pWide = (wchar_t *) mir_realloc(Setting.Value.pWide, Setting.Value.Length * sizeof(wchar_t));
memcpy(Setting.Value.pWide, buffer, Setting.Value.Length * sizeof(wchar_t));
@@ -867,7 +867,7 @@ unsigned int CSettings::ReadSetting(TDBTSetting & Setting, TDBTSettingHandle hSe
{
char buffer[24];
buffer[0] = 0;
- Setting.Value.Length = 1 + sprintf_s(buffer, "%lli", val);
+ Setting.Value.Length = 1 + mir_snprintf(buffer, SIZEOF(buffer), "%lli", val);
Setting.Value.pAnsi = (char *) mir_realloc(Setting.Value.pAnsi, Setting.Value.Length);
memcpy(Setting.Value.pAnsi, buffer, Setting.Value.Length);
@@ -876,7 +876,7 @@ unsigned int CSettings::ReadSetting(TDBTSetting & Setting, TDBTSettingHandle hSe
{
wchar_t buffer[24];
buffer[0] = 0;
- Setting.Value.Length = 1 + swprintf_s(buffer, L"%lli", val);
+ Setting.Value.Length = 1 + mir_snwprintf(buffer, SIZEOF(buffer), L"%lli", val);
Setting.Value.pWide = (wchar_t *) mir_realloc(Setting.Value.pWide, Setting.Value.Length * sizeof(wchar_t));
memcpy(Setting.Value.pWide, buffer, Setting.Value.Length * sizeof(wchar_t));
@@ -923,7 +923,7 @@ unsigned int CSettings::ReadSetting(TDBTSetting & Setting, TDBTSettingHandle hSe
{
char buffer[128];
buffer[0] = 0;
- Setting.Value.Length = 1 + sprintf_s(buffer, "%lf", setting->Value.QWord);
+ Setting.Value.Length = 1 + mir_snprintf(buffer, SIZEOF(buffer), "%lf", setting->Value.QWord);
Setting.Value.pAnsi = (char *) mir_realloc(Setting.Value.pAnsi, Setting.Value.Length);
memcpy(Setting.Value.pAnsi, buffer, Setting.Value.Length);
} break;
@@ -931,7 +931,7 @@ unsigned int CSettings::ReadSetting(TDBTSetting & Setting, TDBTSettingHandle hSe
{
wchar_t buffer[128];
buffer[0] = 0;
- Setting.Value.Length = 1 + swprintf_s(buffer, L"%lf", setting->Value.QWord);
+ Setting.Value.Length = 1 + mir_snwprintf(buffer, SIZEOF(buffer), L"%lf", setting->Value.QWord);
Setting.Value.pWide = (wchar_t *) mir_realloc(Setting.Value.pWide, Setting.Value.Length * sizeof(wchar_t));
memcpy(Setting.Value.pWide, buffer, Setting.Value.Length * sizeof(wchar_t));
} break;
diff --git a/plugins/Dbx_tree/src/savestrings_gcc.h b/plugins/Dbx_tree/src/savestrings_gcc.h
index 9da680874d..2fa60f071a 100644
--- a/plugins/Dbx_tree/src/savestrings_gcc.h
+++ b/plugins/Dbx_tree/src/savestrings_gcc.h
@@ -95,33 +95,4 @@ inline int strncpy_s(
return strcpy_s(strDest, numberOfElements, strSource);
else
return strcpy_s(strDest, count + 1, strSource);
-}
-
-
-template <size_t size>
-inline int sprintf_s(
- char (&buffer)[size],
- const char *format,
- ...
-)
-{
- va_list va;
- va_start(va, format);
- vsnprintf(buffer, size, format, va);
- va_end(va);
-}
-
-template <size_t size>
-inline int swprintf_s(
- wchar_t (&buffer)[size],
- const wchar_t *format,
- ...
-)
-{
- va_list va;
- va_start(va, format);
- vsnwprintf(buffer, size, format, va);
- va_end(va);
-}
-
-#define vsprintf_s vsnprintf
+} \ No newline at end of file
diff --git a/plugins/FingerprintNG/src/utilities.cpp b/plugins/FingerprintNG/src/utilities.cpp
index bea14c0d6a..9ddfc7c014 100644
--- a/plugins/FingerprintNG/src/utilities.cpp
+++ b/plugins/FingerprintNG/src/utilities.cpp
@@ -47,18 +47,6 @@ size_t __fastcall strlennull(LPCSTR string)
return 0;
}
-int null_snprintf(LPSTR buffer, size_t count, LPCSTR fmt, ...)
-{
- va_list va;
- int len;
-
- ZeroMemory(buffer, count);
- va_start(va, fmt);
- len = _vsnprintf(buffer, count-1, fmt, va);
- va_end(va);
- return len;
-}
-
LPSTR __fastcall TranslateUtfStatic(LPCSTR src, LPSTR buf, size_t bufsize)
{ // this takes UTF-8 strings only!!!
if (strlennull(src))
diff --git a/plugins/IEView/ieview_11.vcxproj b/plugins/IEView/ieview_11.vcxproj
index a6ba0c4c53..40781d6ed7 100644
--- a/plugins/IEView/ieview_11.vcxproj
+++ b/plugins/IEView/ieview_11.vcxproj
@@ -194,6 +194,7 @@
<ClInclude Include="src\TemplateHTMLBuilder.h" />
<ClInclude Include="src\TextToken.h" />
<ClInclude Include="src\Utils.h" />
+ <ClInclude Include="src\Version.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\ieview.rc" />
diff --git a/plugins/IEView/ieview_11.vcxproj.filters b/plugins/IEView/ieview_11.vcxproj.filters
index 4bbed46c39..af060df0f9 100644
--- a/plugins/IEView/ieview_11.vcxproj.filters
+++ b/plugins/IEView/ieview_11.vcxproj.filters
@@ -93,6 +93,9 @@
<ClInclude Include="src\Utils.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="src\Version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\ieview.rc">
diff --git a/plugins/IEView/src/SRMMHTMLBuilder.cpp b/plugins/IEView/src/SRMMHTMLBuilder.cpp
deleted file mode 100644
index fd3ca560de..0000000000
--- a/plugins/IEView/src/SRMMHTMLBuilder.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
-
-IEView Plugin for Miranda IM
-Copyright (C) 2005-2008 Piotr Piastucki
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-#include "SRMMHTMLBuilder.h"
-
-#include "Options.h"
-#include "Utils.h"
-
-// srmm stuff
-#define SMF_LOG_SHOWNICK 1
-#define SMF_LOG_SHOWTIME 2
-#define SMF_LOG_SHOWDATES 4
-#define SMF_LOG_SHOWICONS 8
-#define SMF_LOG_SHOWSTATUSCHANGES 16
-#define SRMMMOD "SRMM"
-
-#define SRMSGSET_SHOWLOGICONS "ShowLogIcon"
-#define SRMSGSET_HIDENAMES "HideNames"
-#define SRMSGSET_SHOWTIME "ShowTime"
-#define SRMSGSET_SHOWDATE "ShowDate"
-#define SRMSGSET_SHOWSTATUSCHANGES "ShowStatusChanges"
-
-#define FONTF_BOLD 1
-#define FONTF_ITALIC 2
-#define FONTF_UNDERLINE 4
-
-#define FONT_NUM 10
-
-static const char *classNames[] = {
- ".messageOut", ".messageIn", ".nameOut", ".timeOut", ".colonOut", ".nameIn", ".timeIn", ".colonIn",
- ".inputArea", ".notices"
-};
-
-bool SRMMHTMLBuilder::isDbEventShown(DBEVENTINFO * dbei)
-{
- switch (dbei->eventType) {
- case EVENTTYPE_MESSAGE:
- return 1;
- case EVENTTYPE_STATUSCHANGE:
- if (dbei->flags & DBEF_READ) return 0;
- return 1;
- }
- return 0;
-}
-
-void SRMMHTMLBuilder::loadMsgDlgFont(int i, LOGFONTA * lf, COLORREF * colour) {
- char str[32];
- int style;
- DBVARIANT dbv;
- if (colour) {
- wsprintfA(str, "SRMFont%dCol", i);
- *colour = DBGetContactSettingDword(NULL, SRMMMOD, str, 0x000000);
- }
- if (lf) {
- wsprintfA(str, "SRMFont%dSize", i);
- lf->lfHeight = (char) DBGetContactSettingByte(NULL, SRMMMOD, str, 10);
- lf->lfHeight = abs(lf->lfHeight);
- lf->lfWidth = 0;
- lf->lfEscapement = 0;
- lf->lfOrientation = 0;
- wsprintfA(str, "SRMFont%dSty", i);
- style = DBGetContactSettingByte(NULL, SRMMMOD, str, 0);
- lf->lfWeight = style & FONTF_BOLD ? FW_BOLD : FW_NORMAL;
- lf->lfItalic = style & FONTF_ITALIC ? 1 : 0;
- lf->lfUnderline = style & FONTF_UNDERLINE ? 1 : 0;
- lf->lfStrikeOut = 0;
- wsprintfA(str, "SRMFont%dSet", i);
- lf->lfCharSet = DBGetContactSettingByte(NULL, SRMMMOD, str, DEFAULT_CHARSET);
- lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
- lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
- lf->lfQuality = DEFAULT_QUALITY;
- lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
- wsprintfA(str, "SRMFont%d", i);
- if (DBGetContactSetting(NULL, SRMMMOD, str, &dbv))
- lstrcpyA(lf->lfFaceName, "Verdana");
- else {
- lstrcpynA(lf->lfFaceName, dbv.pszVal, sizeof(lf->lfFaceName));
- DBFreeVariant(&dbv);
- }
- }
-}
-
-char *SRMMHTMLBuilder::timestampToString(DWORD dwFlags, time_t check) {
- static char szResult[512];
- char str[80];
- DBTIMETOSTRING dbtts;
- dbtts.cbDest = 70;;
- dbtts.szDest = str;
- szResult[0] = '\0';
- if (!(dwFlags & SMF_LOG_SHOWDATES)) {
- dbtts.szFormat = (char *)"s";
- }
- else {
- dbtts.szFormat = (char *)"d t";
- }
- CallService(MS_DB_TIME_TIMESTAMPTOSTRING, check, (LPARAM) & dbtts);
- strncat(szResult, str, 500);
- Utils::UTF8Encode(szResult, szResult, 500);
- return szResult;
-}
-
-
-void SRMMHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) {
- LOGFONTA lf;
- COLORREF color;
- char *output = NULL;
- int outputSize;
- ProtocolSettings *protoSettings = getSRMMProtocolSettings(event->hContact);
- if (protoSettings == NULL) {
- return;
- }
- if (protoSettings->getSRMMMode() == Options::MODE_TEMPLATE) {
- buildHeadTemplate(view, event);
- return;
- }
- if (protoSettings->getSRMMMode() == Options::MODE_CSS) {
- const char *externalCSS = (event->dwFlags & IEEF_RTL) ? protoSettings->getSRMMCssFilenameRtl() : protoSettings->getSRMMCssFilename();
- Utils::appendText(&output, &outputSize, "<html><head><link rel=\"stylesheet\" href=\"%s\"/></head><body class=\"body\">\n",externalCSS);
- } else {
- HDC hdc = GetDC(NULL);
- int logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
- ReleaseDC(NULL, hdc);
- Utils::appendText(&output, &outputSize, "<html><head><style type=\"text/css\">\n");
- COLORREF bkgColor = DBGetContactSettingDword(NULL, SRMMMOD, "BkgColour", 0xFFFFFF);
- COLORREF inColor, outColor;
- bkgColor= (((bkgColor & 0xFF) << 16) | (bkgColor & 0xFF00) | ((bkgColor & 0xFF0000) >> 16));
- inColor = outColor = bkgColor;
- if (protoSettings->getSRMMFlags() & Options::LOG_IMAGE_ENABLED) {
- Utils::appendText(&output, &outputSize, ".body {margin: 0px; text-align: left; background-attachment: %s; background-color: #%06X; background-image: url('%s'); overflow: auto;}\n",
- protoSettings->getSRMMFlags() & Options::LOG_IMAGE_SCROLL ? "scroll" : "fixed", (int) bkgColor, protoSettings->getSRMMBackgroundFilename());
- } else {
- Utils::appendText(&output, &outputSize, ".body {margin: 0px; text-align: left; background-color: #%06X; overflow: auto;}\n",
- (int) bkgColor);
- }
- Utils::appendText(&output, &outputSize, ".link {color: #0000FF; text-decoration: underline;}\n");
- Utils::appendText(&output, &outputSize, ".img {vertical-align: middle;}\n");
- if (protoSettings->getSRMMFlags() & Options::LOG_IMAGE_ENABLED) {
- Utils::appendText(&output, &outputSize, ".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- } else {
- Utils::appendText(&output, &outputSize, ".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int) inColor);
- Utils::appendText(&output, &outputSize, ".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int) outColor);
- }
- for(int i = 0; i < FONT_NUM; i++) {
- loadMsgDlgFont(i, &lf, &color);
- Utils::appendText(&output, &outputSize, "%s {font-family: %s; font-size: %dpt; font-weight: %s; color: #%06X; %s }\n",
- classNames[i],
- lf.lfFaceName,
- abs((signed char)lf.lfHeight) * 74 /logPixelSY ,
- lf.lfWeight >= FW_BOLD ? "bold" : "normal",
- (int)(((color & 0xFF) << 16) | (color & 0xFF00) | ((color & 0xFF0000) >> 16)),
- lf.lfItalic ? "font-style: italic;" : "");
- }
- Utils::appendText(&output, &outputSize, "</style></head><body class=\"body\">\n");
- }
- if (output != NULL) {
- view->write(output);
- free(output);
- }
-
-}
-
-void SRMMHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) {
-
- DWORD dwFlags = DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_SHOWTIME, 0) ? SMF_LOG_SHOWTIME : 0;
- dwFlags |= !DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_HIDENAMES, 0) ? SMF_LOG_SHOWNICK : 0;
- dwFlags |= DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_SHOWDATE, 0) ? SMF_LOG_SHOWDATES : 0;
- dwFlags |= DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_SHOWLOGICONS, 0) ? SMF_LOG_SHOWICONS : 0;
- dwFlags |= DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_SHOWSTATUSCHANGES, 0) ? SMF_LOG_SHOWSTATUSCHANGES : 0;
-
- char *szRealProto = getRealProto(event->hContact);
- IEVIEWEVENTDATA* eventData = event->eventData;
- for (int eventIdx = 0; eventData!=NULL && (eventIdx < event->count || event->count==-1); eventData = eventData->next, eventIdx++) {
- int outputSize;
- char *output;
- output = NULL;
- int isSent = eventData->dwFlags & IEEDF_SENT;
- int isRTL = eventData->dwFlags & IEEDF_RTL;
- showColon = false;
-
- if (eventData->iType == IEED_EVENT_MESSAGE || eventData->iType == IEED_EVENT_STATUSCHANGE) {
- char *szName = NULL;
- char *szText = NULL;
- if (eventData->dwFlags & IEEDF_UNICODE_NICK) {
- szName = encodeUTF8(eventData->pszNickW, szRealProto, ENF_NAMESMILEYS);
- } else {
- szName = encodeUTF8(eventData->pszNick, szRealProto, ENF_NAMESMILEYS);
- }
- if (eventData->dwFlags & IEEDF_UNICODE_TEXT) {
- szText = encodeUTF8(eventData->pszTextW, szRealProto, ENF_ALL);
- } else {
- szText = encodeUTF8(eventData->pszText, event->codepage, szRealProto, ENF_ALL);
- }
-
- /* SRMM-specific formatting */
- Utils::appendText(&output, &outputSize, "<div class=\"%s\">", isSent ? "divOut" : "divIn");
- if (dwFlags & SMF_LOG_SHOWICONS) {
- const char *iconFile = "";
- if (dbei.eventType == EVENTTYPE_MESSAGE) {
- iconFile = isSent ? "message_out.gif" : "message_in.gif";
- } else if (dbei.eventType == EVENTTYPE_STATUSCHANGE) {
- iconFile = "status.gif";
- }
- Utils::appendText(&output, &outputSize, "<img class=\"img\" src=\"%s/plugins/ieview/%s\"/>",
- workingDir, iconFile);
- }
- if (dwFlags & SMF_LOG_SHOWTIME) {
- const char *className = "";
- className = isSent ? "timeOut" : "timeIn";
- if (!(dwFlags & SMF_LOG_SHOWNICK) || (dbei.eventType == EVENTTYPE_STATUSCHANGE)) {
- const char *className2 = "";
- className2 = isSent ? "colonOut" : "colonIn";
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s</span><span class=\"%s\">: </span>",
- className, timestampToString(dwFlags, dbei.timestamp), className2);
- } else {
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s </span>",
- className, timestampToString(dwFlags, dbei.timestamp));
- }
- }
- if (dwFlags & SMF_LOG_SHOWNICK) {
- if (dbei.eventType == EVENTTYPE_STATUSCHANGE) {
- Utils::appendText(&output, &outputSize, "<span class=\"notices\">%s </span>", szName);
- } else {
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s</span><span class=\"%s\">: </span>",
- isSent ? "nameOut" : "nameIn", szName, isSent ? "colonOut" : "colonIn");
- }
- }
- const char *className = "";
- if (dbei.eventType == EVENTTYPE_MESSAGE) {
- className = isSent ? "messageOut" : "messageIn";
- } else if (dbei.eventType == EVENTTYPE_STATUSCHANGE) {
- className = "notices";
- }
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s</span>", className, szText);
- Utils::appendText(&output, &outputSize, "</div>\n");
- event->hDbEventFirst = hCurDbEvent;
- if (szName!=NULL) delete szName;
- if (szText!=NULL) delete szText;
- }
- if (output != NULL) {
- view->write(output);
- free(output);
- }
- }
- if (szRealProto!=NULL) delete szRealProto;
-}
-
-void SRMMHTMLBuilder::appendEvent(IEView *view, IEVIEWEVENT *event) {
- ProtocolSettings *protoSettings = getSRMMProtocolSettings(event->hContact);
- if (protoSettings == NULL) {
- return;
- }
- if (protoSettings->getSRMMMode() == Options::MODE_TEMPLATE) {
- appendEventTemplate(view, event, protoSettings);
- } else {
- appendEventNonTemplate(view, event);
- }
-}
diff --git a/plugins/IEView/src/SRMMHTMLBuilder.h b/plugins/IEView/src/SRMMHTMLBuilder.h
deleted file mode 100644
index 801f1a6359..0000000000
--- a/plugins/IEView/src/SRMMHTMLBuilder.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-
-IEView Plugin for Miranda IM
-Copyright (C) 2005-2008 Piotr Piastucki
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-class SRMMHTMLBuilder;
-
-#ifndef SRMMHTMLBUILDER_INCLUDED
-#define SRMMHTMLBUILDER_INCLUDED
-
-#include "HTMLBuilder.h"
-
-class SRMMHTMLBuilder:public TemplateHTMLBuilder
-{
-protected:
- virtual void loadMsgDlgFont(int i, LOGFONTA * lf, COLORREF * colour);
- char *timestampToString(DWORD dwFlags, time_t check);
- bool isDbEventShown(DBEVENTINFO * dbei);
- void appendEventNonTemplate(IEView *, IEVIEWEVENT *event);
-public:
- void buildHead(IEView *, IEVIEWEVENT *event);
- void appendEvent(IEView *, IEVIEWEVENT *event);
-};
-
-#endif
diff --git a/plugins/KeyboardNotify/src/keyboard.cpp b/plugins/KeyboardNotify/src/keyboard.cpp
index 7379181fd9..b0a6761738 100644
--- a/plugins/KeyboardNotify/src/keyboard.cpp
+++ b/plugins/KeyboardNotify/src/keyboard.cpp
@@ -55,11 +55,11 @@ BOOL OpenKeyboardDevice()
return TRUE;
do {
- _snwprintf(aux1, sizeof(aux1), _T("Kbd%d"), i);
- _snwprintf(aux2, sizeof(aux2), _T("\\Device\\KeyboardClass%d"), i);
+ mir_sntprintf(aux1, SIZEOF(aux1), _T("Kbd%d"), i);
+ mir_sntprintf(aux2, SIZEOF(aux2), _T("\\Device\\KeyboardClass%d"), i);
DefineDosDevice(DDD_RAW_TARGET_PATH, aux1, aux2);
- _snwprintf(aux1, sizeof(aux1), _T("\\\\.\\Kbd%d"), i);
+ mir_sntprintf(aux1, SIZEOF(aux1), _T("\\\\.\\Kbd%d"), i);
hKbdDev[i] = CreateFile(aux1, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
} while (hKbdDev[i] != INVALID_HANDLE_VALUE && ++i < MAX_KBDHANDLES);
@@ -105,7 +105,7 @@ void CloseKeyboardDevice()
if (hKbdDev[i] != INVALID_HANDLE_VALUE)
CloseHandle(hKbdDev[i]);
- _snwprintf(aux, sizeof(aux), _T("Kbd%d"), i);
+ mir_sntprintf(aux, SIZEOF(aux), _T("Kbd%d"), i);
DefineDosDevice(DDD_REMOVE_DEFINITION, aux, NULL);
} while (hKbdDev[i] != INVALID_HANDLE_VALUE && ++i < MAX_KBDHANDLES);
diff --git a/plugins/LangMan/src/options.cpp b/plugins/LangMan/src/options.cpp
index 6511d979af..2420509699 100644
--- a/plugins/LangMan/src/options.cpp
+++ b/plugins/LangMan/src/options.cpp
@@ -27,7 +27,7 @@ static HANDLE hHookOptInit;
/************************* Utils **************************************/
#define BOX(str) BOX2("%s (err:%i)", str, GetLastError())
-#define BOX2(fmt, p1, p2) { char str[256]; wsprintfA(str, fmt, p1, p2); MessageBoxA(NULL, str, "dbg", 0); }
+#define BOX2(fmt, p1, p2) { char str[256]; mir_snprintf(str, SIZEOF(str), fmt, p1, p2); MessageBoxA(NULL, str, "dbg", 0); }
// ImageList_Destroy() the return value
// refresh on WM_THEMECHANGED
diff --git a/plugins/PasteIt/src/PasteToWeb.cpp b/plugins/PasteIt/src/PasteToWeb.cpp
index fa251a22f0..308f4d4930 100644
--- a/plugins/PasteIt/src/PasteToWeb.cpp
+++ b/plugins/PasteIt/src/PasteToWeb.cpp
@@ -386,7 +386,7 @@ void PasteToWeb::FromFile(std::wstring file)
{
if(fileSize.QuadPart > 512000LL)
{
- _stprintf_s(bufErr, 1024, TranslateT("File size is %dKB, do you realy want to paste such large file?"), fileSize.LowPart / 1024);
+ mir_sntprintf(bufErr, 1024, TranslateT("File size is %dKB, do you realy want to paste such large file?"), fileSize.LowPart / 1024);
if(MessageBox(NULL, bufErr, TranslateT("Are You sure?"), MB_YESNO | MB_ICONQUESTION) != IDYES)
{
CloseHandle(hFile);
@@ -401,7 +401,7 @@ void PasteToWeb::FromFile(std::wstring file)
mir_free(fromFileData.content);
fromFileData.content = NULL;
fromFileData.contentLen = 0;
- _stprintf_s(bufErr, 1024, TranslateT("Cannot read file '%s'"), file.c_str());
+ mir_sntprintf(bufErr, 1024, TranslateT("Cannot read file '%s'"), file.c_str());
error = bufErr;
}
}
@@ -415,7 +415,7 @@ void PasteToWeb::FromFile(std::wstring file)
}
else
{
- _stprintf_s(bufErr, 1024, TranslateT("Cannot open file '%s'"), file.c_str());
+ mir_sntprintf(bufErr, 1024, TranslateT("Cannot open file '%s'"), file.c_str());
error = bufErr;
}
@@ -493,7 +493,7 @@ void PasteToWeb::FromFile(std::wstring file)
}
else
{
- _stprintf_s(bufErr, 1024, TranslateT("File '%s' is empty"), file.c_str());
+ mir_sntprintf(bufErr, 1024, TranslateT("File '%s' is empty"), file.c_str());
error = bufErr;
}
mir_free(fromFileData.content);
diff --git a/plugins/PasteIt/src/PasteToWeb1.cpp b/plugins/PasteIt/src/PasteToWeb1.cpp
index b768a15b25..f1a669c040 100644
--- a/plugins/PasteIt/src/PasteToWeb1.cpp
+++ b/plugins/PasteIt/src/PasteToWeb1.cpp
@@ -304,7 +304,7 @@ void PasteToWeb1::SendToServer(std::wstring str, std::wstring fileName, std::wst
{
if(memcmp(L"Bad API request, ", resCont, 17 * sizeof(wchar_t)) == 0)
{
- _stprintf_s(bufErr, 1024, TranslateT("Error during sending text to web page: %s"), resCont + 17);
+ mir_sntprintf(bufErr, 1024, TranslateT("Error during sending text to web page: %s"), resCont + 17);
error = bufErr;
}
else
@@ -336,7 +336,7 @@ std::wstring PasteToWeb1::GetUserKey(std::wstring& user, std::wstring& password)
{
if(memcmp(L"Bad API request, ", resCont, 17 * sizeof(wchar_t)) == 0)
{
- _stprintf_s(bufErr, 1024, TranslateT("Error during getting user key from web page: %s"), resCont + 17);
+ mir_sntprintf(bufErr, 1024, TranslateT("Error during getting user key from web page: %s"), resCont + 17);
MessageBox(NULL, bufErr, TranslateT("Error"), MB_OK | MB_ICONERROR);
}
else
diff --git a/plugins/SmileyAdd/src/bkstring.cpp b/plugins/SmileyAdd/src/bkstring.cpp
index f6d3270fef..dc8d653e84 100644
--- a/plugins/SmileyAdd/src/bkstring.cpp
+++ b/plugins/SmileyAdd/src/bkstring.cpp
@@ -39,7 +39,7 @@ void bkstring::appendfmt(const value_type *fmt, ...)
va_start(vararg, fmt);
for (;;)
{
- int len = _vsntprintf(buf + lenBuf, sizeAlloced - lenBuf - 1, fmt, vararg);
+ int len = mir_vsntprintf(buf + lenBuf, sizeAlloced - lenBuf - 1, fmt, vararg);
if (len < 0)
reserve(sizeAlloced + 256);
else
diff --git a/plugins/SpellChecker/src/commons.h b/plugins/SpellChecker/src/commons.h
index a71d850bc9..fa435a0a42 100644
--- a/plugins/SpellChecker/src/commons.h
+++ b/plugins/SpellChecker/src/commons.h
@@ -30,6 +30,7 @@ Boston, MA 02111-1307, USA.
#include <commctrl.h>
#include <map>
#include <vector>
+#include <string>
using namespace std;
#include <newpluginapi.h>
@@ -42,6 +43,7 @@ using namespace std;
#include <m_icolib.h>
#include <m_hotkeys.h>
#include <win2k.h>
+#include <m_system_cpp.h>
//own includes
#include <m_folders.h>
@@ -51,7 +53,7 @@ using namespace std;
#include <m_spellchecker.h>
#include <../utils/mir_options.h>
-#include <../utils/tstring.h>
+//#include <../utils/tstring.h>
#include <../utils/utf8_helpers.h>
#include <../utils/scope.h>
diff --git a/plugins/StatusPlugins/dbhelpers.h b/plugins/StatusPlugins/dbhelpers.h
deleted file mode 100644
index cf91748fe6..0000000000
--- a/plugins/StatusPlugins/dbhelpers.h
+++ /dev/null
@@ -1,100 +0,0 @@
-#ifndef PREFIX_ITH
-#define PREFIX_ITH ""
-#endif
-
-// database helpers
-static int __inline DBWriteIthSettingByte(DWORD i, HANDLE hContact,const char *szModule,const char *szSetting,BYTE val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBWriteContactSettingByte(hContact, szModule, dbSetting, val);
-}
-
-static int __inline DBWriteIthSettingWord(DWORD i, HANDLE hContact,const char *szModule,const char *szSetting,WORD val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBWriteContactSettingWord(hContact, szModule, dbSetting, val);
-}
-
-static int __inline DBWriteIthSettingDword(DWORD i, HANDLE hContact,const char *szModule,const char *szSetting,DWORD val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBWriteContactSettingDword(hContact, szModule, dbSetting, val);
-}
-
-static int __inline DBWriteIthSettingString(DWORD i, HANDLE hContact,const char *szModule,const char *szSetting,const char *val) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBWriteContactSettingString(hContact, szModule, dbSetting, val);
-}
-
-static int __inline DBGetIthSettingByte(DWORD i, HANDLE hContact, const char *szModule, const char *szSetting, int errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBGetContactSettingByte(hContact, szModule, dbSetting, errorValue);
-}
-
-static WORD __inline DBGetIthSettingWord(DWORD i, HANDLE hContact, const char *szModule, const char *szSetting, int errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBGetContactSettingWord(hContact, szModule, dbSetting, errorValue);
-}
-
-static DWORD __inline DBGetIthSettingDword(DWORD i, HANDLE hContact, const char *szModule, const char *szSetting, int errorValue) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBGetContactSettingDword(hContact, szModule, dbSetting, errorValue);
-}
-
-static int __inline DBGetIthSetting(DWORD i, HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) {
-
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBGetContactSetting(hContact, szModule, dbSetting, dbv);
-}
-
-static int __inline DBDeleteIthSetting(DWORD i, HANDLE hContact,const char *szModule,const char *szSetting) {
-
- char dbSetting[128];
-
- _snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ITH, i, szSetting);
- return DBDeleteContactSetting(hContact, szModule, dbSetting);
-}
-
-#define db_getb(a,b) DBGetContactSettingByte(NULL, MODULENAME, a, b)
-#define db_getw(a,b) DBGetContactSettingWord(NULL, MODULENAME, a, b)
-#define db_getd(a,b) DBGetContactSettingDword(NULL, MODULENAME, a, b)
-#define db_gets(a,b) DBGetContactSetting(NULL, MODULENAME, a, b)
-#define db_setb(a,b) DBWriteContactSettingByte(NULL, MODULENAME, a, (BYTE)b)
-#define db_sets(a,b) DBWriteContactSettingString(NULL, MODULENAME, a, b)
-#define db_setw(a,b) DBWriteContactSettingWord(NULL, MODULENAME, a, (WORD)b)
-#define db_setd(a,b) DBWriteContactSettingDword(NULL, MODULENAME, a, (DWORD)b)
-#define db_del(a) DBDeleteContactSetting(NULL, MODULENAME, a);
-
-#define dbi_getb(a,b,c) DBGetIthSettingByte(a, NULL, MODULENAME, b, c)
-#define dbi_getw(a,b,c) DBGetIthSettingWord(a, NULL, MODULENAME, b, c)
-#define dbi_getd(a,b,c) DBGetIthSettingDword(a, NULL, MODULENAME, b, c)
-#define dbi_gets(a,b,c) DBGetIthSetting(a, NULL, MODULENAME, b, c)
-#define dbi_setb(a,b,c) DBWriteIthSettingByte(a, NULL, MODULENAME, b, (BYTE)c)
-#define dbi_sets(a,b,c) DBWriteIthSettingString(a, NULL, MODULENAME, b, c)
-#define dbi_setw(a,b,c) DBWriteIthSettingWord(a, NULL, MODULENAME, b, (WORD)c)
-#define dbi_setd(a,b,c) DBWriteIthSettingDword(a, NULL, MODULENAME, b, (DWORD)c)
-#define dbi_del(a,b) DBDeleteIthSetting(a, NULL, MODULENAME, b); \ No newline at end of file
diff --git a/plugins/Utils/ContactAsyncQueue.cpp b/plugins/Utils/ContactAsyncQueue.cpp
deleted file mode 100644
index 2d5d1f104d..0000000000
--- a/plugins/Utils/ContactAsyncQueue.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
-Copyright (C) 2006-2009 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "ContactAsyncQueue.h"
-#include <process.h>
-
-
-// Itens with higher time at end
-static int QueueSortItems(const QueueItem *oldItem, const QueueItem *newItem)
-{
- if (oldItem->check_time == newItem->check_time)
- return -1;
-
- return oldItem->check_time - newItem->check_time;
-}
-
-// Itens with higher time at end
-static void ContactAsyncQueueThread(void *obj)
-{
- ((ContactAsyncQueue *)obj)->Thread();
-}
-
-ContactAsyncQueue::ContactAsyncQueue(pfContactAsyncQueueCallback fContactAsyncQueueCallback, int initialSize)
- : queue(30, QueueSortItems)
-{
- hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- finished = 0;
- callback = fContactAsyncQueueCallback;
-
- InitializeCriticalSection(&cs);
-
- _beginthread(ContactAsyncQueueThread, 0, this);
- //mir_forkthread(ContactAsyncQueueThread, this);
-}
-
-ContactAsyncQueue::~ContactAsyncQueue()
-{
- Finish();
-
- int count = 0;
- while(finished != 2 && ++count < 50)
- Sleep(30);
-
- for (int i = 0; i < queue.getCount(); i++)
- if (queue[i] != NULL)
- mir_free(queue[i]);
-
- DeleteCriticalSection(&cs);
-}
-
-void ContactAsyncQueue::Finish()
-{
- if (finished == 0)
- finished = 1;
- SetEvent(hEvent);
-}
-
-void ContactAsyncQueue::Lock()
-{
- EnterCriticalSection(&cs);
-}
-
-void ContactAsyncQueue::Release()
-{
- LeaveCriticalSection(&cs);
-}
-
-void ContactAsyncQueue::RemoveAll(HANDLE hContact)
-{
- Lock();
-
- for (int i = queue.getCount() - 1; i >= 0; --i)
- {
- QueueItem *item = queue[i];
-
- if (item->hContact == hContact)
- {
- queue.remove(i);
- mir_free(item);
- }
- }
-
- Release();
-}
-
-void ContactAsyncQueue::RemoveAllConsiderParam(HANDLE hContact, void *param)
-{
- Lock();
-
- for (int i = queue.getCount() - 1; i >= 0; --i)
- {
- QueueItem *item = queue[i];
-
- if (item->hContact == hContact && item->param == param)
- {
- queue.remove(i);
- mir_free(item);
- }
- }
-
- Release();
-}
-
-void ContactAsyncQueue::Add(int waitTime, HANDLE hContact, void *param)
-{
- Lock();
-
- InternalAdd(waitTime, hContact, param);
-
- Release();
-}
-
-void ContactAsyncQueue::AddIfDontHave(int waitTime, HANDLE hContact, void *param)
-{
- Lock();
-
- int i;
- for (i = queue.getCount() - 1; i >= 0; --i)
- if (queue[i]->hContact == hContact)
- break;
-
- if (i < 0)
- InternalAdd(waitTime, hContact, param);
-
- Release();
-}
-
-void ContactAsyncQueue::AddAndRemovePrevious(int waitTime, HANDLE hContact, void *param)
-{
- Lock();
-
- RemoveAll(hContact);
- InternalAdd(waitTime, hContact, param);
-
- Release();
-}
-
-void ContactAsyncQueue::AddAndRemovePreviousConsiderParam(int waitTime, HANDLE hContact, void *param)
-{
- Lock();
-
- RemoveAllConsiderParam(hContact, param);
- InternalAdd(waitTime, hContact, param);
-
- Release();
-}
-
-void ContactAsyncQueue::InternalAdd(int waitTime, HANDLE hContact, void *param)
-{
- QueueItem *item = (QueueItem *) mir_alloc(sizeof(QueueItem));
- item->hContact = hContact;
- item->check_time = GetTickCount() + waitTime;
- item->param = param;
-
- queue.insert(item);
-
- SetEvent(hEvent);
-}
-
-void ContactAsyncQueue::Thread()
-{
- while (!finished)
- {
- ResetEvent(hEvent);
-
- if (finished)
- break;
-
- Lock();
-
- if (queue.getCount() <= 0)
- {
- // No items, so supend thread
- Release();
-
- wait(/*INFINITE*/ 2 * 60 * 1000);
- }
- else
- {
- // Take a look at first item
- QueueItem *qi = queue[0];
-
- int dt = qi->check_time - GetTickCount();
- if (dt > 0)
- {
- // Not time to request yet, wait...
- Release();
-
- wait(dt);
- }
- else
- {
- // Will request this item
- queue.remove(0);
-
- Release();
-
- callback(qi->hContact, qi->param);
-
- mir_free(qi);
- }
- }
- }
-
- finished = 2;
-}
-
-void ContactAsyncQueue::wait(int time)
-{
- if (!finished)
- WaitForSingleObject(hEvent, time);
-}
-
-
-
-
-
-
diff --git a/plugins/Utils/ContactAsyncQueue.h b/plugins/Utils/ContactAsyncQueue.h
deleted file mode 100644
index b38509869d..0000000000
--- a/plugins/Utils/ContactAsyncQueue.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
-Copyright (C) 2006-2009 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-
-#ifndef __CONTACTASYNCQUEUE_H__
-# define __CONTACTASYNCQUEUE_H__
-
-#ifndef MIRANDA_VER
-#define MIRANDA_VER 0x0A00
-#endif
-
-#include <windows.h>
-#include <newpluginapi.h>
-#include <m_system_cpp.h>
-
-
-typedef void (*pfContactAsyncQueueCallback) (HANDLE hContact, void *param);
-
-
-struct QueueItem
-{
- DWORD check_time;
- HANDLE hContact;
- void *param;
-};
-
-
-class ContactAsyncQueue
-{
-public:
-
- ContactAsyncQueue(pfContactAsyncQueueCallback fContactAsyncQueueCallback, int initialSize = 10);
- ~ContactAsyncQueue();
-
- void Finish();
-
- inline int Size() const { return queue.getCount(); }
- inline int Remove(int idx) { mir_free(queue[idx]); return queue.remove(idx); }
- inline QueueItem* Get(int idx) const { return queue[idx]; }
-
-
- void RemoveAll(HANDLE hContact);
- void RemoveAllConsiderParam(HANDLE hContact, void *param);
- void Add(int waitTime, HANDLE hContact, void *param = NULL);
- void AddIfDontHave(int waitTime, HANDLE hContact, void *param = NULL);
- void AddAndRemovePrevious(int waitTime, HANDLE hContact, void *param = NULL);
- void AddAndRemovePreviousConsiderParam(int waitTime, HANDLE hContact, void *param = NULL);
-
- void Lock();
- void Release();
-
-
- void Thread();
-
-private:
-
- LIST<QueueItem> queue;
-
- CRITICAL_SECTION cs;
- pfContactAsyncQueueCallback callback;
- HANDLE hEvent;
- int finished;
-
-
- void InternalAdd(int waitTime, HANDLE hContact, void *param);
- void wait(int time);
-};
-
-
-
-
-
-
-
-
-
-
-
-#endif // __CONTACTASYNCQUEUE_H__
diff --git a/plugins/Utils/MemoryModule.c b/plugins/Utils/MemoryModule.c
deleted file mode 100644
index 1e7ac0ac01..0000000000
--- a/plugins/Utils/MemoryModule.c
+++ /dev/null
@@ -1,540 +0,0 @@
-/*
- * Memory DLL loading code
- * Version 0.0.2 with additions from Thomas Heller
- *
- * Copyright (c) 2004-2005 by Joachim Bauch / mail@joachim-bauch.de
- * http://www.joachim-bauch.de
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is MemoryModule.c
- *
- * The Initial Developer of the Original Code is Joachim Bauch.
- *
- * Portions created by Joachim Bauch are Copyright (C) 2004-2005
- * Joachim Bauch. All Rights Reserved.
- *
- * Portions Copyright (C) 2005 Thomas Heller.
- *
- */
-
-// disable warnings about pointer <-> DWORD conversions
-#pragma warning( disable : 4311 4312 )
-
-#include <Windows.h>
-#include <winnt.h>
-#ifdef DEBUG_OUTPUT
-#include <stdio.h>
-#endif
-
-#ifndef IMAGE_SIZEOF_BASE_RELOCATION
-// Vista SDKs no longer define IMAGE_SIZEOF_BASE_RELOCATION!?
-# define IMAGE_SIZEOF_BASE_RELOCATION (sizeof(IMAGE_BASE_RELOCATION))
-#endif
-#include "MemoryModule.h"
-
-
-struct NAME_TABLE {
- char *name;
- DWORD ordinal;
-};
-
-typedef struct tagMEMORYMODULE {
- PIMAGE_NT_HEADERS headers;
- unsigned char *codeBase;
- HMODULE *modules;
- int numModules;
- int initialized;
-
- struct NAME_TABLE *name_table;
-} MEMORYMODULE, *PMEMORYMODULE;
-
-typedef BOOL (WINAPI *DllEntryProc)(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved);
-
-#define GET_HEADER_DICTIONARY(module, idx) &(module)->headers->OptionalHeader.DataDirectory[idx]
-
-#ifdef DEBUG_OUTPUT
-static void
-OutputLastError(const char *msg)
-{
- LPVOID tmp;
- char *tmpmsg;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&tmp, 0, NULL);
- tmpmsg = (char *)LocalAlloc(LPTR, strlen(msg) + strlen(tmp) + 3);
- sprintf(tmpmsg, "%s: %s", msg, tmp);
- OutputDebugString(tmpmsg);
- LocalFree(tmpmsg);
- LocalFree(tmp);
-}
-#endif
-
-static void
-CopySections(const unsigned char *data, PIMAGE_NT_HEADERS old_headers, PMEMORYMODULE module)
-{
- int i, size;
- unsigned char *codeBase = module->codeBase;
- unsigned char *dest;
- PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(module->headers);
- for (i=0; i<module->headers->FileHeader.NumberOfSections; i++, section++)
- {
- if (section->SizeOfRawData == 0)
- {
- // section doesn't contain data in the dll itself, but may define
- // uninitialized data
- size = old_headers->OptionalHeader.SectionAlignment;
- if (size > 0)
- {
- dest = (unsigned char *)VirtualAlloc(codeBase + section->VirtualAddress,
- size,
- MEM_COMMIT,
- PAGE_READWRITE);
-
- section->Misc.PhysicalAddress = (DWORD)dest;
- memset(dest, 0, size);
- }
-
- // section is empty
- continue;
- }
-
- // commit memory block and copy data from dll
- dest = (unsigned char *)VirtualAlloc(codeBase + section->VirtualAddress,
- section->SizeOfRawData,
- MEM_COMMIT,
- PAGE_READWRITE);
- memcpy(dest, data + section->PointerToRawData, section->SizeOfRawData);
- section->Misc.PhysicalAddress = (DWORD)dest;
- }
-}
-
-// Protection flags for memory pages (Executable, Readable, Writeable)
-static int ProtectionFlags[2][2][2] = {
- {
- // not executable
- {PAGE_NOACCESS, PAGE_WRITECOPY},
- {PAGE_READONLY, PAGE_READWRITE},
- }, {
- // executable
- {PAGE_EXECUTE, PAGE_EXECUTE_WRITECOPY},
- {PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE},
- },
-};
-
-static void
-FinalizeSections(PMEMORYMODULE module)
-{
- int i;
- PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(module->headers);
-
- // loop through all sections and change access flags
- for (i=0; i<module->headers->FileHeader.NumberOfSections; i++, section++)
- {
- DWORD protect, oldProtect, size;
- int executable = (section->Characteristics & IMAGE_SCN_MEM_EXECUTE) != 0;
- int readable = (section->Characteristics & IMAGE_SCN_MEM_READ) != 0;
- int writeable = (section->Characteristics & IMAGE_SCN_MEM_WRITE) != 0;
-
- if (section->Characteristics & IMAGE_SCN_MEM_DISCARDABLE)
- {
- // section is not needed any more and can safely be freed
- VirtualFree((LPVOID)section->Misc.PhysicalAddress, section->SizeOfRawData, MEM_DECOMMIT);
- continue;
- }
-
- // determine protection flags based on characteristics
- protect = ProtectionFlags[executable][readable][writeable];
- if (section->Characteristics & IMAGE_SCN_MEM_NOT_CACHED)
- protect |= PAGE_NOCACHE;
-
- // determine size of region
- size = section->SizeOfRawData;
- if (size == 0)
- {
- if (section->Characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA)
- size = module->headers->OptionalHeader.SizeOfInitializedData;
- else if (section->Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
- size = module->headers->OptionalHeader.SizeOfUninitializedData;
- }
-
- if (size > 0)
- {
- // change memory access flags
- if (VirtualProtect((LPVOID)section->Misc.PhysicalAddress, size, protect, &oldProtect) == 0)
-#ifdef DEBUG_OUTPUT
- OutputLastError("Error protecting memory page")
-#endif
- ;
- }
- }
-}
-
-static void
-PerformBaseRelocation(PMEMORYMODULE module, DWORD delta)
-{
- DWORD i;
- unsigned char *codeBase = module->codeBase;
-
- PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY(module, IMAGE_DIRECTORY_ENTRY_BASERELOC);
- if (directory->Size > 0)
- {
- PIMAGE_BASE_RELOCATION relocation = (PIMAGE_BASE_RELOCATION)(codeBase + directory->VirtualAddress);
- for (; relocation->VirtualAddress > 0; )
- {
- unsigned char *dest = (unsigned char *)(codeBase + relocation->VirtualAddress);
- unsigned short *relInfo = (unsigned short *)((unsigned char *)relocation + IMAGE_SIZEOF_BASE_RELOCATION);
- for (i=0; i<((relocation->SizeOfBlock-IMAGE_SIZEOF_BASE_RELOCATION) / 2); i++, relInfo++)
- {
- DWORD *patchAddrHL;
- int type, offset;
-
- // the upper 4 bits define the type of relocation
- type = *relInfo >> 12;
- // the lower 12 bits define the offset
- offset = *relInfo & 0xfff;
-
- switch (type)
- {
- case IMAGE_REL_BASED_ABSOLUTE:
- // skip relocation
- break;
-
- case IMAGE_REL_BASED_HIGHLOW:
- // change complete 32 bit address
- patchAddrHL = (DWORD *)(dest + offset);
- *patchAddrHL += delta;
- break;
-
- default:
- //printf("Unknown relocation: %d\n", type);
- break;
- }
- }
-
- // advance to next relocation block
- relocation = (PIMAGE_BASE_RELOCATION)(((DWORD)relocation) + relocation->SizeOfBlock);
- }
- }
-}
-
-static int
-BuildImportTable(PMEMORYMODULE module)
-{
- int result=1;
- unsigned char *codeBase = module->codeBase;
-
- PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY(module, IMAGE_DIRECTORY_ENTRY_IMPORT);
- if (directory->Size > 0)
- {
- PIMAGE_IMPORT_DESCRIPTOR importDesc = (PIMAGE_IMPORT_DESCRIPTOR)(codeBase + directory->VirtualAddress);
- for (; !IsBadReadPtr(importDesc, sizeof(IMAGE_IMPORT_DESCRIPTOR)) && importDesc->Name; importDesc++)
- {
- DWORD *thunkRef, *funcRef;
- HMODULE handle = LoadLibraryA((LPCSTR)(codeBase + importDesc->Name));
- if (handle == INVALID_HANDLE_VALUE || handle == NULL)
- {
- //LastError should already be set
-#if DEBUG_OUTPUT
- OutputLastError("Can't load library");
-#endif
- result = 0;
- break;
- }
-
- module->modules = (HMODULE *)realloc(module->modules, (module->numModules+1)*(sizeof(HMODULE)));
- if (module->modules == NULL)
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- result = 0;
- break;
- }
-
- module->modules[module->numModules++] = handle;
- if (importDesc->OriginalFirstThunk)
- {
- thunkRef = (DWORD *)(codeBase + importDesc->OriginalFirstThunk);
- funcRef = (DWORD *)(codeBase + importDesc->FirstThunk);
- } else {
- // no hint table
- thunkRef = (DWORD *)(codeBase + importDesc->FirstThunk);
- funcRef = (DWORD *)(codeBase + importDesc->FirstThunk);
- }
- for (; *thunkRef; thunkRef++, funcRef++)
- {
- if IMAGE_SNAP_BY_ORDINAL(*thunkRef)
- *funcRef = (DWORD)GetProcAddress(handle, (LPCSTR)IMAGE_ORDINAL(*thunkRef));
- else {
- PIMAGE_IMPORT_BY_NAME thunkData = (PIMAGE_IMPORT_BY_NAME)(codeBase + *thunkRef);
- *funcRef = (DWORD)GetProcAddress(handle, (LPCSTR)&thunkData->Name);
- }
- if (*funcRef == 0)
- {
- SetLastError(ERROR_PROC_NOT_FOUND);
- result = 0;
- break;
- }
- }
-
- if (!result)
- break;
- }
- }
-
- return result;
-}
-
-HMEMORYMODULE MemoryLoadLibrary(const void *data)
-{
- PMEMORYMODULE result;
- PIMAGE_DOS_HEADER dos_header;
- PIMAGE_NT_HEADERS old_header;
- unsigned char *code, *headers;
- DWORD locationDelta;
- DllEntryProc DllEntry;
- BOOL successfull;
-
- dos_header = (PIMAGE_DOS_HEADER)data;
- if (dos_header->e_magic != IMAGE_DOS_SIGNATURE)
- {
- SetLastError(ERROR_BAD_FORMAT);
-#if DEBUG_OUTPUT
- OutputDebugString("Not a valid executable file.\n");
-#endif
- return NULL;
- }
-
- old_header = (PIMAGE_NT_HEADERS)&((const unsigned char *)(data))[dos_header->e_lfanew];
- if (old_header->Signature != IMAGE_NT_SIGNATURE)
- {
- SetLastError(ERROR_BAD_FORMAT);
-#if DEBUG_OUTPUT
- OutputDebugString("No PE header found.\n");
-#endif
- return NULL;
- }
-
- // reserve memory for image of library
- code = (unsigned char *)VirtualAlloc((LPVOID)(old_header->OptionalHeader.ImageBase),
- old_header->OptionalHeader.SizeOfImage,
- MEM_RESERVE,
- PAGE_READWRITE);
-
- if (code == NULL)
- // try to allocate memory at arbitrary position
- code = (unsigned char *)VirtualAlloc(NULL,
- old_header->OptionalHeader.SizeOfImage,
- MEM_RESERVE,
- PAGE_READWRITE);
-
- if (code == NULL)
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
-#if DEBUG_OUTPUT
- OutputLastError("Can't reserve memory");
-#endif
- return NULL;
- }
-
- result = (PMEMORYMODULE)HeapAlloc(GetProcessHeap(), 0, sizeof(MEMORYMODULE));
- result->codeBase = code;
- result->numModules = 0;
- result->modules = NULL;
- result->initialized = 0;
- result->name_table = NULL;
-
- // XXX: is it correct to commit the complete memory region at once?
- // calling DllEntry raises an exception if we don't...
- VirtualAlloc(code,
- old_header->OptionalHeader.SizeOfImage,
- MEM_COMMIT,
- PAGE_READWRITE);
-
- // commit memory for headers
- headers = (unsigned char *)VirtualAlloc(code,
- old_header->OptionalHeader.SizeOfHeaders,
- MEM_COMMIT,
- PAGE_READWRITE);
-
- // copy PE header to code
- memcpy(headers, dos_header, dos_header->e_lfanew + old_header->OptionalHeader.SizeOfHeaders);
- result->headers = (PIMAGE_NT_HEADERS)&((const unsigned char *)(headers))[dos_header->e_lfanew];
-
- // update position
- result->headers->OptionalHeader.ImageBase = (DWORD)code;
-
- // copy sections from DLL file block to new memory location
- CopySections(data, old_header, result);
-
- // adjust base address of imported data
- locationDelta = (DWORD)(code - old_header->OptionalHeader.ImageBase);
- if (locationDelta != 0)
- PerformBaseRelocation(result, locationDelta);
-
- // load required dlls and adjust function table of imports
- if (!BuildImportTable(result))
- goto error;
-
- // mark memory pages depending on section headers and release
- // sections that are marked as "discardable"
- FinalizeSections(result);
-
- // get entry point of loaded library
- if (result->headers->OptionalHeader.AddressOfEntryPoint != 0)
- {
- DllEntry = (DllEntryProc)(code + result->headers->OptionalHeader.AddressOfEntryPoint);
- if (DllEntry == 0)
- {
- SetLastError(ERROR_BAD_FORMAT); /* XXX ? */
-#if DEBUG_OUTPUT
- OutputDebugString("Library has no entry point.\n");
-#endif
- goto error;
- }
-
- // notify library about attaching to process
- successfull = (*DllEntry)((HINSTANCE)code, DLL_PROCESS_ATTACH, 0);
- if (!successfull)
- {
-#if DEBUG_OUTPUT
- OutputDebugString("Can't attach library.\n");
-#endif
- goto error;
- }
- result->initialized = 1;
- }
-
- return (HMEMORYMODULE)result;
-
-error:
- // cleanup
- MemoryFreeLibrary(result);
- return NULL;
-}
-
-int _compare(const struct NAME_TABLE *p1, const struct NAME_TABLE *p2)
-{
- return stricmp(p1->name, p2->name);
-}
-
-int _find(const char **name, const struct NAME_TABLE *p)
-{
- return stricmp(*name, p->name);
-}
-
-struct NAME_TABLE *GetNameTable(PMEMORYMODULE module)
-{
- unsigned char *codeBase;
- PIMAGE_EXPORT_DIRECTORY exports;
- PIMAGE_DATA_DIRECTORY directory;
- DWORD i, *nameRef;
- WORD *ordinal;
- struct NAME_TABLE *p, *ptab;
-
- if (module->name_table)
- return module->name_table;
-
- codeBase = module->codeBase;
- directory = GET_HEADER_DICTIONARY(module, IMAGE_DIRECTORY_ENTRY_EXPORT);
- exports = (PIMAGE_EXPORT_DIRECTORY)(codeBase + directory->VirtualAddress);
-
- nameRef = (DWORD *)(codeBase + exports->AddressOfNames);
- ordinal = (WORD *)(codeBase + exports->AddressOfNameOrdinals);
-
- p = ((PMEMORYMODULE)module)->name_table = (struct NAME_TABLE *)malloc(sizeof(struct NAME_TABLE)
- * exports->NumberOfNames);
- if (p == NULL)
- return NULL;
- ptab = p;
- for (i=0; i<exports->NumberOfNames; ++i) {
- p->name = (char *)(codeBase + *nameRef++);
- p->ordinal = *ordinal++;
- ++p;
- }
- qsort(ptab, exports->NumberOfNames, sizeof(struct NAME_TABLE), _compare);
- return ptab;
-}
-
-FARPROC MemoryGetProcAddress(HMEMORYMODULE module, const char *name)
-{
- unsigned char *codeBase = ((PMEMORYMODULE)module)->codeBase;
- int idx=-1;
- PIMAGE_EXPORT_DIRECTORY exports;
- PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY((PMEMORYMODULE)module, IMAGE_DIRECTORY_ENTRY_EXPORT);
-
- if (directory->Size == 0)
- // no export table found
- return NULL;
-
- exports = (PIMAGE_EXPORT_DIRECTORY)(codeBase + directory->VirtualAddress);
- if (exports->NumberOfNames == 0 || exports->NumberOfFunctions == 0)
- // DLL doesn't export anything
- return NULL;
-
- if (HIWORD(name)) {
- struct NAME_TABLE *ptab;
- struct NAME_TABLE *found;
- ptab = GetNameTable((PMEMORYMODULE)module);
- if (ptab == NULL)
- // some failure
- return NULL;
- found = bsearch(&name, ptab, exports->NumberOfNames, sizeof(struct NAME_TABLE), _find);
- if (found == NULL)
- // exported symbol not found
- return NULL;
-
- idx = found->ordinal;
- }
- else
- idx = LOWORD(name) - exports->Base;
-
- if ((DWORD)idx > exports->NumberOfFunctions)
- // name <-> ordinal number don't match
- return NULL;
-
- // AddressOfFunctions contains the RVAs to the "real" functions
- return (FARPROC)(codeBase + *(DWORD *)(codeBase + exports->AddressOfFunctions + (idx*4)));
-}
-
-void MemoryFreeLibrary(HMEMORYMODULE mod)
-{
- int i;
- PMEMORYMODULE module = (PMEMORYMODULE)mod;
-
- if (module != NULL)
- {
- if (module->initialized != 0)
- {
- // notify library about detaching from process
- DllEntryProc DllEntry = (DllEntryProc)(module->codeBase + module->headers->OptionalHeader.AddressOfEntryPoint);
- (*DllEntry)((HINSTANCE)module->codeBase, DLL_PROCESS_DETACH, 0);
- module->initialized = 0;
- }
-
- if (module->modules != NULL)
- {
- // free previously opened libraries
- for (i=0; i<module->numModules; i++)
- if (module->modules[i] != INVALID_HANDLE_VALUE)
- FreeLibrary(module->modules[i]);
-
- free(module->modules);
- }
-
- if (module->codeBase != NULL)
- // release memory of library
- VirtualFree(module->codeBase, 0, MEM_RELEASE);
-
- if (module->name_table != NULL)
- free(module->name_table);
-
- HeapFree(GetProcessHeap(), 0, module);
- }
-}
diff --git a/plugins/Utils/MemoryModule.h b/plugins/Utils/MemoryModule.h
deleted file mode 100644
index f314e5d1fb..0000000000
--- a/plugins/Utils/MemoryModule.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Memory DLL loading code
- * Version 0.0.2
- *
- * Copyright (c) 2004-2005 by Joachim Bauch / mail@joachim-bauch.de
- * http://www.joachim-bauch.de
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is MemoryModule.h
- *
- * The Initial Developer of the Original Code is Joachim Bauch.
- *
- * Portions created by Joachim Bauch are Copyright (C) 2004-2005
- * Joachim Bauch. All Rights Reserved.
- *
- */
-
-#ifndef __MEMORY_MODULE_HEADER
-#define __MEMORY_MODULE_HEADER
-
-#include <Windows.h>
-
-typedef void *HMEMORYMODULE;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-HMEMORYMODULE MemoryLoadLibrary(const void *);
-
-FARPROC MemoryGetProcAddress(HMEMORYMODULE, const char *);
-
-void MemoryFreeLibrary(HMEMORYMODULE);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __MEMORY_MODULE_HEADER
diff --git a/plugins/Utils/mir_dbutils.h b/plugins/Utils/mir_dbutils.h
deleted file mode 100644
index cb7400a5ff..0000000000
--- a/plugins/Utils/mir_dbutils.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-Copyright (C) 2009 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-#ifndef __DBUTILS_H__
-# define __DBUTILS_H__
-
-
-class DBTString
-{
- DBVARIANT dbv;
- bool exists;
-
-public:
- DBTString(HANDLE hContact, char *module, char *setting)
- {
- ZeroMemory(&dbv, sizeof(dbv));
- exists = (DBGetContactSettingTString(hContact, module, setting, &dbv) == 0);
- }
-
- ~DBTString()
- {
- if (exists)
- DBFreeVariant(&dbv);
- }
-
- const TCHAR * get() const
- {
- if (!exists)
- return NULL;
- else
- return dbv.ptszVal;
- }
-
- const bool operator==(const TCHAR *other)
- {
- return get() == other;
- }
-
- const bool operator!=(const TCHAR *other)
- {
- return get() != other;
- }
-
- operator const TCHAR *() const
- {
- return get();
- }
-};
-
-
-
-
-
-
-#endif // __DBUTILS_H__
diff --git a/plugins/Utils/mir_log.cpp b/plugins/Utils/mir_log.cpp
deleted file mode 100644
index 5a5a18060f..0000000000
--- a/plugins/Utils/mir_log.cpp
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
-Copyright (C) 2005-2009 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-
-#include "mir_log.h"
-
-#include <stdio.h>
-
-#include <newpluginapi.h>
-#include <m_netlib.h>
-#include <m_protocols.h>
-#include <m_clist.h>
-
-#define ENABLE_LOG
-
-
-int MLog::deep = 0;
-
-MLog::MLog(const char *aModule, const char *aFunction)
- : module(aModule)
-{
- memset(&total, 0, sizeof(total));
-
- function = "";
- for(int i = 0; i < deep; i++)
- function += " ";
- function += aFunction;
-
- deep ++;
-
- mlog(module.c_str(), function.c_str(), "BEGIN");
-
- StartTimer();
-}
-
-MLog::~MLog()
-{
- StopTimer();
-
- mlog(module.c_str(), function.c_str(), "END in %2.1lf ms", GetTotalTimeMS());
- deep --;
-}
-
-int MLog::log(const char *fmt, ...)
-{
- StopTimer();
-
- double elapsed = GetElapsedTimeMS();
-
- va_list va;
- va_start(va, fmt);
-
- char text[1024];
- mir_snprintf(text, sizeof(text) - 10, "%s [in %2.1lf ms | total %2.1lf ms]",
- fmt, GetElapsedTimeMS(), GetTotalTimeMS());
-
- int ret = mlog(module.c_str(), function.c_str(), text, va);
-
- va_end(va);
-
- StartTimer();
-
- return ret;
-}
-
-void MLog::StartTimer()
-{
- QueryPerformanceCounter(&start);
-}
-
-void MLog::StopTimer()
-{
- QueryPerformanceCounter(&end);
-
- total.QuadPart += end.QuadPart - start.QuadPart;
-}
-
-double MLog::GetElapsedTimeMS()
-{
- LARGE_INTEGER frequency;
- QueryPerformanceFrequency(&frequency);
-
- return (end.QuadPart - start.QuadPart) * 1000. / frequency.QuadPart;
-}
-
-double MLog::GetTotalTimeMS()
-{
- LARGE_INTEGER frequency;
- QueryPerformanceFrequency(&frequency);
-
- return total.QuadPart * 1000. / frequency.QuadPart;
-}
-
-
-int mlog(const char *module, const char *function, const char *fmt, va_list va)
-{
-#ifdef ENABLE_LOG
-
- char text[1024];
- size_t len;
-
- mir_snprintf(text, sizeof(text) - 10, "[%08u - %08u] [%s] [%s] ",
- GetCurrentThreadId(), GetTickCount(), module, function);
- len = strlen(text);
-
- mir_vsnprintf(&text[len], sizeof(text) - len, fmt, va);
-
-#ifdef LOG_TO_NETLIB
-
- return CallService(MS_NETLIB_LOG, NULL, (LPARAM) text);
-
-#else
- char file[256];
- _snprintf(file, sizeof(file), "c:\\miranda_%s.log.txt", module);
-
- FILE *fp = fopen(file,"at");
-
- if (fp != NULL)
- {
- fprintf(fp, "%s\n", text);
- fclose(fp);
- return 0;
- }
- else
- {
- return -1;
- }
-
-#endif
-
-#else
-
- return 0;
-
-#endif
-}
-
-
-int mlog(const char *module, const char *function, const char *fmt, ...)
-{
- va_list va;
- va_start(va, fmt);
-
- int ret = mlog(module, function, fmt, va);
-
- va_end(va);
-
- return ret;
-}
-
-int mlogC(const char *module, const char *function, HANDLE hContact, const char *fmt, ...)
-{
-#ifdef ENABLE_LOG
-
- va_list va;
- char text[1024];
- size_t len;
-
- char *name = NULL;
- char *proto = NULL;
- if (hContact != NULL)
- {
- name = (char*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0);
- proto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
- }
-
- mir_snprintf(text, sizeof(text) - 10, "[%08u - %08u] [%s] [%s] [%08d - %s - %s] ",
- GetCurrentThreadId(), GetTickCount(), module, function,
- hContact, proto == NULL ? "" : proto, name == NULL ? "" : name);
- len = strlen(text);
-
- va_start(va, fmt);
- mir_vsnprintf(&text[len], sizeof(text) - len, fmt, va);
- va_end(va);
-
-#ifdef LOG_TO_NETLIB
-
- return CallService(MS_NETLIB_LOG, NULL, (LPARAM) text);
-
-#else
- char file[256];
- _snprintf(file, sizeof(file), "c:\\miranda_%s.log.txt", module);
-
- FILE *fp = fopen(file,"at");
-
- if (fp != NULL)
- {
- fprintf(fp, "%s\n", text);
- fclose(fp);
- return 0;
- }
- else
- {
- return -1;
- }
-
-#endif
-
-#else
-
- return 0;
-
-#endif
-}
diff --git a/plugins/Utils/mir_log.h b/plugins/Utils/mir_log.h
deleted file mode 100644
index 5785e191ff..0000000000
--- a/plugins/Utils/mir_log.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-Copyright (C) 2005-2009 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-
-#ifndef __LOG_H__
-# define __LOG_H__
-
-#include <windows.h>
-#include <string>
-
-
-int mlog(const char *module, const char *function, const char *fmt, ...);
-int mlog(const char *module, const char *function, const char *fmt, va_list va);
-int mlogC(const char *module, const char *function, HANDLE hContact, const char *fmt, ...);
-
-
-#ifdef __cplusplus
-
-class MLog
-{
-private:
- std::string module;
- std::string function;
- LARGE_INTEGER start;
- LARGE_INTEGER end;
- LARGE_INTEGER total;
-
- static int deep;
-
- void StartTimer();
- void StopTimer();
- double GetElapsedTimeMS();
- double GetTotalTimeMS();
-
-public:
- MLog(const char *aModule, const char *aFunction);
- ~MLog();
-
- int log(const char *fmt, ...);
-};
-
-
-#endif __cplusplus
-
-
-
-#endif // __LOG_H__
diff --git a/plugins/Utils/mir_options_notify.cpp b/plugins/Utils/mir_options_notify.cpp
deleted file mode 100644
index b2ee76a512..0000000000
--- a/plugins/Utils/mir_options_notify.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
-Copyright (C) 2005 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-
-#include "mir_options_notify.h"
-
-#include <stdio.h>
-#include <commctrl.h>
-#include <tchar.h>
-
-extern "C"
-{
-#include <newpluginapi.h>
-#include <m_database.h>
-#include <m_utils.h>
-#include <m_langpack.h>
-#include <m_notify.h>
-#include "templates.h"
-}
-
-
-#define MAX_REGS(_A_) ( sizeof(_A_) / sizeof(_A_[0]) )
-
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Dialog to save options
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-BOOL CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg)
- {
- case WM_USER+100:
- {
- HANDLE hNotify = (HANDLE)lParam;
- SetWindowLongPtr(hwndDlg, GWL_USERDATA, lParam);
-
- TranslateDialogDefault(hwndDlg);
-
- for (int i = 0 ; i < controlsSize ; i++)
- {
- OptPageControl *ctrl = &controls[i];
-
- switch(ctrl->type)
- {
- case CONTROL_CHECKBOX:
- {
- CheckDlgButton(hwndDlg, ctrl->nID, MNotifyGetByte(hNotify, ctrl->setting, (BYTE)ctrl->dwDefValue) == 1 ? BST_CHECKED : BST_UNCHECKED);
- break;
- }
- case CONTROL_SPIN:
- {
- SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, ctrl->nID),0);
- SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETRANGE, 0, MAKELONG(ctrl->max, ctrl->min));
- SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETPOS,0, MAKELONG(MNotifyGetWord(hNotify, ctrl->setting, (WORD)ctrl->dwDefValue), 0));
-
- break;
- }
- case CONTROL_COLOR:
- {
- SendDlgItemMessage(hwndDlg, ctrl->nID, CPM_SETCOLOUR, 0, (COLORREF) MNotifyGetDWord(hNotify, ctrl->setting, (DWORD)ctrl->dwDefValue));
-
- break;
- }
- case CONTROL_RADIO:
- {
- CheckDlgButton(hwndDlg, ctrl->nID, MNotifyGetWord(hNotify, ctrl->setting, (WORD)ctrl->dwDefValue) == ctrl->value ? BST_CHECKED : BST_UNCHECKED);
- break;
- }
- case CONTROL_TEXT:
- {
- SetDlgItemText(hwndDlg, ctrl->nID, MNotifyGetTString(hNotify, ctrl->setting, ctrl->szDefVale));
-
- if (ctrl->max > 0)
- SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, min(ctrl->max, 1024), 0);
- else
- SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, 1024, 0);
-
- break;
- }
- case CONTROL_TEMPLATE:
- {
- SetDlgItemText(hwndDlg, ctrl->nID, MNotifyGetTTemplate(hNotify, ctrl->setting, ctrl->szDefVale));
-
- if (ctrl->max > 0)
- SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, min(ctrl->max, 1024), 0);
- else
- SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, 1024, 0);
-
- break;
- }
- }
- }
-
- return TRUE;
- break;
- }
- case WM_COMMAND:
- {
- // Don't make apply enabled during buddy set crap
- if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())
- {
- for (int i = 0 ; i < controlsSize ; i++)
- {
- if (controls[i].type == CONTROL_SPIN && LOWORD(wParam) == controls[i].nID)
- {
- return 0;
- }
- }
- }
-
- SendMessage(GetParent(GetParent(hwndDlg)), PSM_CHANGED, 0, 0);
- break;
- }
- case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom)
- {
- case 0:
- {
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
- {
- HANDLE hNotify = (HANDLE)GetWindowLongPtr(hwndDlg, GWL_USERDATA);
- TCHAR tmp[1024];
-
- for (int i = 0 ; i < controlsSize ; i++)
- {
- OptPageControl *ctrl = &controls[i];
-
- switch(ctrl->type)
- {
- case CONTROL_CHECKBOX:
- {
- MNotifySetByte(hNotify, ctrl->setting, (BYTE)IsDlgButtonChecked(hwndDlg, ctrl->nID));
- break;
- }
- case CONTROL_SPIN:
- {
- MNotifySetWord(hNotify, ctrl->setting, (WORD)SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_GETPOS, 0, 0));
- break;
- }
- case CONTROL_COLOR:
- {
- MNotifySetDWord(hNotify, ctrl->setting, (DWORD)SendDlgItemMessage(hwndDlg, ctrl->nID, CPM_GETCOLOUR, 0, 0));
- break;
- }
- case CONTROL_RADIO:
- {
- if (IsDlgButtonChecked(hwndDlg, ctrl->nID))
- MNotifySetWord(hNotify, ctrl->setting, (BYTE)ctrl->value);
- break;
- }
- case CONTROL_TEXT:
- {
- GetDlgItemText(hwndDlg, ctrl->nID, tmp, MAX_REGS(tmp));
- MNotifySetTString(hNotify, ctrl->setting, tmp);
- break;
- }
- case CONTROL_TEMPLATE:
- {
- GetDlgItemText(hwndDlg, ctrl->nID, tmp, MAX_REGS(tmp));
- MNotifySetTTemplate(hNotify, ctrl->setting, tmp);
- break;
- }
- }
- }
-
- return TRUE;
- }
- }
- break;
- }
- }
- break;
- }
- }
-
- return 0;
-}
diff --git a/plugins/Utils/mir_options_notify.h b/plugins/Utils/mir_options_notify.h
deleted file mode 100644
index 1f5494863a..0000000000
--- a/plugins/Utils/mir_options_notify.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-Copyright (C) 2005 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-
-#ifndef __MIR_OPTIONS_NOTIFY_H__
-# define __MIR_OPTIONS_NOTIFY_H__
-
-#include <windows.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Dialog to save options
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-#define CONTROL_CHECKBOX 0 // Stored as BYTE
-#define CONTROL_SPIN 1 // Stored as WORD
-#define CONTROL_COLOR 2 // Stored as DWORD
-#define CONTROL_RADIO 3 // Stored as WORD
-#define CONTROL_TEXT 4 // Stored as char *
-#define CONTROL_TEMPLATE 5 // Stored as Template
-
-struct OptPageControl {
- int type;
- int nID;
- char *setting;
- union {
- DWORD dwDefValue;
- const TCHAR *szDefVale;
- };
- union {
- int nIDSpin;
- int value;
- };
- WORD min;
- WORD max;
-};
-
-BOOL CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __MIR_OPTIONS_NOTIFY_H__
diff --git a/plugins/Utils/mir_profiler.cpp b/plugins/Utils/mir_profiler.cpp
deleted file mode 100644
index b788fd2dd2..0000000000
--- a/plugins/Utils/mir_profiler.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
-Copyright (C) 2005 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-
-// Disable "...truncated to '255' characters in the debug information" warnings
-#pragma warning(disable: 4786)
-
-
-#include "mir_profiler.h"
-#include "mir_log.h"
-
-#include <stdio.h>
-
-
-MProfiler::Block MProfiler::root;
-MProfiler::Block * MProfiler::current = &MProfiler::root;
-
-
-MProfiler::Block::Block()
-{
- parent = NULL;
- memset(&total, 0, sizeof(total));
- started = false;
-}
-
-
-MProfiler::Block::~Block()
-{
- Reset();
-}
-
-
-void MProfiler::Block::Reset()
-{
- for(std::map<std::string, MProfiler::Block *>::iterator it = children.begin();
- it != children.end(); ++it)
- delete it->second;
- children.clear();
-
- memset(&total, 0, sizeof(total));
- started = false;
-}
-
-
-void MProfiler::Block::Start()
-{
- if (started)
- return;
-
- QueryPerformanceCounter(&start);
- last_step = start;
- started = true;
-}
-
-
-void MProfiler::Block::Step(const char *name)
-{
- if (!started)
- return;
-
- LARGE_INTEGER end;
- QueryPerformanceCounter(&end);
-
- GetChild(name)->total.QuadPart += end.QuadPart - last_step.QuadPart;
-
- last_step = end;
-}
-
-
-void MProfiler::Block::Stop()
-{
- if (!started)
- return;
-
- LARGE_INTEGER end;
- QueryPerformanceCounter(&end);
-
- total.QuadPart += end.QuadPart - start.QuadPart;
-
- started = false;
-}
-
-
-double MProfiler::Block::GetTimeMS() const
-{
- LARGE_INTEGER frequency;
- QueryPerformanceFrequency(&frequency);
-
- return total.QuadPart * 1000. / frequency.QuadPart;
-}
-
-
-MProfiler::Block * MProfiler::Block::GetChild(const char *name)
-{
- MProfiler::Block *ret = children[name];
- if (ret == NULL)
- {
- ret = new MProfiler::Block();
- ret->name = name;
- ret->parent = this;
- children[name] = ret;
- }
- return ret;
-}
-
-
-void MProfiler::Reset()
-{
- root.Reset();
-}
-
-void MProfiler::Start(const char *name)
-{
- current = current->GetChild(name);
- current->Start();
-}
-
-void MProfiler::Step(const char *name)
-{
- current->Step(name);
-}
-
-void MProfiler::End()
-{
- current->Stop();
-
- if (current->parent != NULL)
- {
- current = current->parent;
- QueryPerformanceCounter(&current->last_step);
- }
-}
-
-void MProfiler::Dump(const char *module)
-{
- Dump(module, "", &root, -1, -1);
-}
-
-
-void MProfiler::Dump(const char *module, std::string prefix, Block *block, double parent, double total)
-{
- for(std::map<std::string, MProfiler::Block *>::iterator it = block->children.begin();
- it != block->children.end(); ++it)
- {
- Block *child = it->second;
- double elapsed = child->GetTimeMS();
-
- if (total > 0)
- {
- mlog(module, "Profiler", "%s%-20s\t%5.1lf\t[%3.0lf%%]\t[%3.0lf%%]", prefix.c_str(), it->first.c_str(),
- elapsed, elapsed / parent * 100, elapsed / total * 100);
- }
- else
- {
- mlog(module, "Profiler", "%s%-20s\t%5.1lf", prefix.c_str(), it->first.c_str(),
- elapsed);
- }
-
- Dump(module, prefix + " ", child, elapsed, total > 0 ? total : elapsed);
- }
-}
-
diff --git a/plugins/Utils/mir_profiler.h b/plugins/Utils/mir_profiler.h
deleted file mode 100644
index 92d776f2ee..0000000000
--- a/plugins/Utils/mir_profiler.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-Copyright (C) 2005 Ricardo Pescuma Domenecci
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-
-#ifndef __PROFILER_H__
-# define __PROFILER_H__
-
-#include <windows.h>
-#include <string>
-#include <map>
-
-
-
-class MProfiler
-{
-public:
-
- static void Reset();
- static void Start(const char *name);
- static void Step(const char *name);
- static void End();
- static void Dump(const char *module);
-
-
-
- static struct Block
- {
- std::string name;
- Block *parent;
- std::map<std::string, Block *> children;
- bool started;
- LARGE_INTEGER start;
- LARGE_INTEGER last_step;
- LARGE_INTEGER total;
-
- Block();
- ~Block();
-
- void Reset();
- void Start();
- void Step(const char *name);
- void Stop();
- double GetTimeMS() const;
-
- Block * GetChild(const char *name);
- };
-
-
-private:
-
- static Block root;
- static Block *current;
-
- static void Dump(const char *module, std::string prefix, Block *block, double parent, double total);
-
-};
-
-
-
-
-#endif // __PROFILER_H__
diff --git a/plugins/Utils/mir_scope.h b/plugins/Utils/mir_scope.h
deleted file mode 100644
index 2f54044d83..0000000000
--- a/plugins/Utils/mir_scope.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef __PTR_H__
-# define __PTR_H__
-
-
-template<class T>
-class scope
-{
-public:
- scope(T t) : p(t) {}
- ~scope() { mir_free(); }
-
- void free()
- {
- if (p != NULL)
- mir_free(p);
- p = NULL;
- }
-
-// T operator->() const { return p; }
- operator T() const { return p; }
-
- T detach()
- {
- T ret = p;
- p = NULL;
- return ret;
- }
-
-private:
- T p;
-};
-
-
-
-#endif // __PTR_H__
diff --git a/plugins/Utils/templates.cpp b/plugins/Utils/templates.cpp
deleted file mode 100644
index 0fbb4715f8..0000000000
--- a/plugins/Utils/templates.cpp
+++ /dev/null
@@ -1,473 +0,0 @@
-#include "templates.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <tchar.h>
-
-extern "C"
-{
-#include <newpluginapi.h>
-#include <time.h>
-#include <win2k.h>
-#include <m_system.h>
-#include <m_options.h>
-#include <m_langpack.h>
-#include <m_database.h>
-#include <m_utils.h>
-#include <m_protocols.h>
-
-#include <m_notify.h>
-
-#include "../utils/mir_memory.h"
-}
-
-
-const char *defaultVariables[] = { "%title%", "%text%" };
-const WCHAR *defaultVariablesW[] = { L"%title%", L"%text%" };
-
-const char *defaultVariableDescriptions[] = { "Notification Title", "Notification Text" };
-const WCHAR *defaultVariableDescriptionsW[] = { L"Notification Title", L"Notification Text" };
-
-
-#define MAX_REGS(_A_) ( sizeof(_A_) / sizeof(_A_[0]) )
-
-
-#define DATA_BLOCK 128
-
-
-// ASCII VERSIONS ///////////////////////////////////////////////////////////////////////
-
-struct StringHelper
-{
- char *text;
- size_t allocated;
- size_t used;
-};
-
-
-int CopyData(StringHelper *str, const char *text, size_t len)
-{
- if (len == 0)
- return 0;
-
- if (text == NULL)
- return 0;
-
- size_t totalSize = str->used + len + 1;
-
- if (totalSize > str->allocated)
- {
- totalSize += DATA_BLOCK - (totalSize % DATA_BLOCK);
-
- if (str->text != NULL)
- {
- char *tmp = (char *) mir_realloc(str->text, sizeof(char) * totalSize);
-
- if (tmp == NULL)
- {
- mir_free(str->text);
- return -1;
- }
-
- str->text = tmp;
- }
- else
- {
- str->text = (char *) mir_alloc(sizeof(char) * totalSize);
-
- if (str->text == NULL)
- {
- return -2;
- }
- }
-
- str->allocated = totalSize;
- }
-
- memmove(&str->text[str->used], text, sizeof(char) * len);
- str->used += len;
- str->text[str->used] = '\0';
-
- return 0;
-}
-
-
-char * ParseText(const char *text,
- const char **variables, size_t variablesSize,
- const char **data, size_t dataSize)
-{
- size_t length = strlen(text);
- size_t nextPos = 0;
- StringHelper ret = {0};
-
- // length - 1 because a % in last char will be a % and point
- for (size_t i = 0 ; i < length - 1 ; i++)
- {
- if (text[i] == '%')
- {
- bool found = false;
-
- if (CopyData(&ret, &text[nextPos], i - nextPos))
- return NULL;
-
- if (text[i + 1] == '%')
- {
- if (CopyData(&ret, "%", 1))
- return NULL;
-
- i++;
-
- found = true;
- }
- else
- {
- size_t size = min(variablesSize, dataSize);
-
- // See if can find it
- for(size_t j = 0 ; j < size ; j++)
- {
- size_t vlen = strlen(variables[j]);
-
- if (strnicmp(&text[i], variables[j], vlen) == 0)
- {
- if (CopyData(&ret, data[j], strlen(data[j])))
- return NULL;
-
- i += vlen - 1;
-
- found = true;
-
- break;
- }
- }
- }
-
-
- if (found)
- nextPos = i + 1;
- else
- nextPos = i;
- }
- }
-
- if (nextPos < length)
- if (CopyData(&ret, &text[nextPos], length - nextPos))
- return NULL;
-
- return ret.text;
-}
-
-
-// UNICODE VERSIONS /////////////////////////////////////////////////////////////////////
-
-struct StringHelperW
-{
- WCHAR *text;
- size_t allocated;
- size_t used;
-};
-
-
-int CopyDataW(StringHelperW *str, const WCHAR *text, size_t len)
-{
- if (len == 0)
- return 0;
-
- if (text == NULL)
- return 0;
-
- size_t totalSize = str->used + len + 1;
-
- if (totalSize > str->allocated)
- {
- totalSize += DATA_BLOCK - (totalSize % DATA_BLOCK);
-
- if (str->text != NULL)
- {
- WCHAR *tmp = (WCHAR *) mir_realloc(str->text, sizeof(WCHAR) * totalSize);
-
- if (tmp == NULL)
- {
- mir_free(str->text);
- return -1;
- }
-
- str->text = tmp;
- }
- else
- {
- str->text = (WCHAR *) mir_alloc(sizeof(WCHAR) * totalSize);
-
- if (str->text == NULL)
- {
- return -2;
- }
- }
-
- str->allocated = totalSize;
- }
-
- memmove(&str->text[str->used], text, sizeof(WCHAR) * len);
- str->used += len;
- str->text[str->used] = '\0';
-
- return 0;
-}
-
-
-WCHAR * ParseTextW(const WCHAR *text,
- const WCHAR **variables, size_t variablesSize,
- const WCHAR **data, size_t dataSize)
-{
- size_t length = lstrlenW(text);
- size_t nextPos = 0;
- StringHelperW ret = {0};
-
- // length - 1 because a % in last char will be a % and point
- for (size_t i = 0 ; i < length - 1 ; i++)
- {
- if (text[i] == L'%')
- {
- bool found = false;
-
- if (CopyDataW(&ret, &text[nextPos], i - nextPos))
- return NULL;
-
- if (text[i + 1] == L'%')
- {
- if (CopyDataW(&ret, L"%", 1))
- return NULL;
-
- i++;
-
- found = true;
- }
- else
- {
- size_t size = min(variablesSize, dataSize);
-
- // See if can find it
- for(size_t j = 0 ; j < size ; j++)
- {
- size_t vlen = lstrlenW(variables[j]);
-
- if (_wcsnicmp(&text[i], variables[j], vlen) == 0)
- {
- if (CopyDataW(&ret, data[j], lstrlenW(data[j])))
- return NULL;
-
- i += vlen - 1;
-
- found = true;
-
- break;
- }
- }
- }
-
- if (found)
- nextPos = i + 1;
- else
- nextPos = i;
- }
- }
-
- if (nextPos < length)
- if (CopyDataW(&ret, &text[nextPos], length - nextPos))
- return NULL;
-
- return ret.text;
-}
-
-
-// INTERFACE ////////////////////////////////////////////////////////////////////////////
-
-// In future maybe pre-parse here
-void MNotifySetTemplate(HANDLE notifyORtype, const char *name, const char *value)
-{
- MNotifySetString(notifyORtype, name, value);
-}
-void MNotifySetWTemplate(HANDLE notifyORtype, const char *name, const WCHAR *value)
-{
- MNotifySetWString(notifyORtype, name, value);
-}
-
-// Well, why not?
-const char *MNotifyGetTemplate(HANDLE notifyORtype, const char *name, const char *defValue)
-{
- return MNotifyGetString(notifyORtype, name, defValue);
-}
-const WCHAR *MNotifyGetWTemplate(HANDLE notifyORtype, const char *name, const WCHAR *defValue)
-{
- return MNotifyGetWString(notifyORtype, name, defValue);
-}
-
-// You must free the return with mir_sys_free
-char *MNotifyGetParsedTemplate(HANDLE notifyORtype, const char *name, const char *defValue)
-{
- const char *temp = MNotifyGetString(notifyORtype, name, defValue);
-
- if (MNotifyHasVariables(notifyORtype))
- {
- const char ** vars = (const char **) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_STRS, NULL);
- size_t varsSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_SIZE, 0);
-
- const char ** data = (const char **) MNotifyGetDWord(notifyORtype, NFOPT_DATA_STRS, NULL);
- size_t dataSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_DATA_SIZE, 0);
-
- return ParseText(temp, vars, varsSize, data, dataSize);
- }
- else
- {
- // Default values
- const char * data[MAX_REGS(defaultVariables)];
- data[0] = MNotifyGetString(notifyORtype, NFOPT_TITLE, NULL);
- data[1] = MNotifyGetString(notifyORtype, NFOPT_TEXT, NULL);
-
- return ParseText(temp, defaultVariables, MAX_REGS(defaultVariables), data, MAX_REGS(defaultVariables));
- }
-}
-WCHAR *MNotifyGetWParsedTemplate(HANDLE notifyORtype, const char *name, const WCHAR *defValue)
-{
- const WCHAR *temp = MNotifyGetWString(notifyORtype, name, defValue);
-
- if (MNotifyHasWVariables(notifyORtype))
- {
- const WCHAR ** vars = (const WCHAR **) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_STRSW, NULL);
- size_t varsSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_SIZE, 0);
-
- const WCHAR ** data = (const WCHAR **) MNotifyGetDWord(notifyORtype, NFOPT_DATA_STRSW, NULL);
- size_t dataSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_DATA_SIZE, 0);
-
- return ParseTextW(temp, vars, varsSize, data, dataSize);
- }
- else
- {
- // Default values
- const WCHAR * data[MAX_REGS(defaultVariablesW)];
- data[0] = MNotifyGetWString(notifyORtype, NFOPT_TITLEW, NULL);
- data[1] = MNotifyGetWString(notifyORtype, NFOPT_TEXTW, NULL);
-
- return ParseTextW(temp, defaultVariablesW, MAX_REGS(defaultVariablesW), data, MAX_REGS(defaultVariablesW));
- }
-}
-
-
-BOOL MNotifyHasVariables(HANDLE notifyORtype)
-{
- return MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_STRS, NULL) != NULL &&
- MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_SIZE, 0) != 0;
-}
-
-BOOL MNotifyHasWVariables(HANDLE notifyORtype)
-{
- return MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_STRSW, NULL) != NULL &&
- MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_SIZE, 0) != 0;
-}
-
-
-
-
-void MNotifyShowVariables(HANDLE notifyORtype)
-{
- StringHelper ret = {0};
-
- const char ** vars;
- size_t varsSize;
- const char ** descs;
- size_t descsSize;
-
- if (MNotifyHasVariables(notifyORtype))
- {
- vars = (const char **) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_STRS, NULL);
- varsSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_SIZE, 0);
-
- descs = (const char **) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_DESCRIPTIONS_STRS, NULL);
- descsSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_DESCRIPTIONS_SIZE, 0);
- }
- else
- {
- // Default values
- vars = defaultVariables;
- varsSize = MAX_REGS(defaultVariables);
-
- descs = defaultVariableDescriptions;
- descsSize = MAX_REGS(defaultVariableDescriptions);
- }
-
- for(size_t i = 0 ; i < varsSize ; i++)
- {
- if (vars[i] != NULL)
- {
- if (CopyData(&ret, vars[i], strlen(vars[i])))
- return;
-
- if (i < descsSize && descs[i] != NULL && descs[i] != L'\0')
- {
- if (CopyData(&ret, " -> ", 4))
- return;
- if (CopyData(&ret, descs[i], strlen(descs[i])))
- return;
- }
-
- if (CopyData(&ret, "\r\n", 2))
- return;
- }
- }
-
- MessageBoxA(NULL, ret.text, "Variables", MB_OK);
-
- mir_free(ret.text);
-}
-
-void MNotifyShowWVariables(HANDLE notifyORtype)
-{
- StringHelperW ret = {0};
-
- const WCHAR ** vars;
- size_t varsSize;
- const WCHAR ** descs;
- size_t descsSize;
-
- if (MNotifyHasWVariables(notifyORtype))
- {
- vars = (const WCHAR **) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_STRSW, NULL);
- varsSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_SIZE, 0);
-
- descs = (const WCHAR **) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_DESCRIPTIONS_STRSW, NULL);
- descsSize = (size_t) MNotifyGetDWord(notifyORtype, NFOPT_VARIABLES_DESCRIPTIONS_SIZE, 0);
- }
- else
- {
- // Default values
- vars = defaultVariablesW;
- varsSize = MAX_REGS(defaultVariablesW);
-
- descs = defaultVariableDescriptionsW;
- descsSize = MAX_REGS(defaultVariableDescriptionsW);
- }
-
- for(size_t i = 0 ; i < varsSize ; i++)
- {
- if (vars[i] != NULL)
- {
- if (CopyDataW(&ret, vars[i], lstrlenW(vars[i])))
- return;
-
- if (i < descsSize && descs[i] != NULL && descs[i] != L'\0')
- {
- if (CopyDataW(&ret, L" -> ", 3))
- return;
- if (CopyDataW(&ret, descs[i], lstrlenW(descs[i])))
- return;
- }
-
- if (CopyDataW(&ret, L"\r\n", 2))
- return;
- }
- }
-
- MessageBoxW(NULL, ret.text, L"Variables", MB_OK);
-
- mir_free(ret.text);
-}
diff --git a/plugins/Utils/templates.h b/plugins/Utils/templates.h
deleted file mode 100644
index e55fb7a50e..0000000000
--- a/plugins/Utils/templates.h
+++ /dev/null
@@ -1,102 +0,0 @@
-#ifndef __TEMPLATES_H__
-# define __TEMPLATES_H__
-
-
-#include <windows.h>
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-// Default templates to be set by using notifiers
-
-#define NFOPT_DEFTEMPL_TEXT "General/DefaultTemplate/Text"
-#define NFOPT_DEFTEMPL_TEXTW "General/DefaultTemplate/TextW"
-#define NFOPT_DEFTEMPL_TITLE "General/DefaultTemplate/Title"
-#define NFOPT_DEFTEMPL_TITLEW "General/DefaultTemplate/TitleW"
-
-
-
-
-// All of theese have to be stored as DWORDs
-
-#define NFOPT_VARIABLES_STRS "Variables/Strings" // char ** (each has to start and end with %)
-#define NFOPT_VARIABLES_DESCRIPTIONS_STRS "VariablesDescriptions/Strings" // char **
-#define NFOPT_DATA_STRS "Data/Strings" // char **
-
-#define NFOPT_VARIABLES_STRSW "Variables/StringsW" // WCHAR ** (each has to start and end with %)
-#define NFOPT_VARIABLES_DESCRIPTIONS_STRSW "VariablesDescriptions/StringsW"// WCHAR **
-#define NFOPT_DATA_STRSW "Data/StringsW" // WCHAR **
-
-#define NFOPT_VARIABLES_SIZE "Variables/Size" // size_t
-#define NFOPT_VARIABLES_DESCRIPTIONS_SIZE "VariablesDescriptions/Size" // size_t
-#define NFOPT_DATA_SIZE "Data/Size" // size_t
-
-
-// Default variables if none is provided by the plugin calling the notification
-// char *defaultVariables[] = { "%title%", "%text%" };
-
-
-void MNotifySetTemplate(HANDLE notifyORtype, const char *name, const char *value);
-void MNotifySetWTemplate(HANDLE notifyORtype, const char *name, const WCHAR *value);
-
-const char *MNotifyGetTemplate(HANDLE notifyORtype, const char *name, const char *defValue);
-const WCHAR *MNotifyGetWTemplate(HANDLE notifyORtype, const char *name, const WCHAR *defValue);
-
-// You must free the return with mir_sys_free
-char *MNotifyGetParsedTemplate(HANDLE notifyORtype, const char *name, const char *defValue);
-WCHAR *MNotifyGetWParsedTemplate(HANDLE notifyORtype, const char *name, const WCHAR *defValue);
-
-
-BOOL MNotifyHasVariables(HANDLE notifyORtype);
-BOOL MNotifyHasWVariables(HANDLE notifyORtype);
-
-void MNotifyShowVariables(HANDLE notifyORtype);
-void MNotifyShowWVariables(HANDLE notifyORtype);
-
-
-#ifdef _UNICODE
-
-# define MNotifyGetTString MNotifyGetWString
-# define MNotifyGetTTemplate MNotifyGetWTemplate
-# define MNotifySetTString MNotifySetWString
-# define MNotifySetTTemplate MNotifyGetWTemplate
-# define MNotifyGetTParsedTemplate MNotifyGetWParsedTemplate
-# define MNotifyHasTVariables MNotifyHasWVariables
-# define MNotifyShowTVariables MNotifyShowWVariables
-
-# define NFOPT_DEFTEMPL_TEXTT NFOPT_DEFTEMPL_TEXTW
-# define NFOPT_DEFTEMPL_TITLET NFOPT_DEFTEMPL_TITLEW
-
-# define NFOPT_VARIABLES_STRST NFOPT_VARIABLES_STRSW
-# define NFOPT_VARIABLES_DESCRIPTIONS_STRST NFOPT_VARIABLES_DESCRIPTIONS_STRSW
-# define NFOPT_DATA_STRST NFOPT_DATA_STRSW
-
-
-#else
-
-# define MNotifyGetTString MNotifyGetString
-# define MNotifyGetTTemplate MNotifyGetTemplate
-# define MNotifySetTString MNotifySetString
-# define MNotifySetTTemplate MNotifySetTemplate
-# define MNotifyGetTParsedTemplate MNotifyGetParsedTemplate
-# define MNotifyHasTVariables MNotifyHasVariables
-# define MNotifyShowTVariables MNotifyShowVariables
-
-# define NFOPT_DEFTEMPL_TEXTT NFOPT_DEFTEMPL_TEXT
-# define NFOPT_DEFTEMPL_TITLET NFOPT_DEFTEMPL_TITLE
-
-# define NFOPT_VARIABLES_STRST NFOPT_VARIABLES_STRS
-# define NFOPT_VARIABLES_DESCRIPTIONS_STRST NFOPT_VARIABLES_DESCRIPTIONS_STRS
-# define NFOPT_DATA_STRST NFOPT_DATA_STRS
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __TEMPLATES_H__
diff --git a/plugins/Utils/tstring.h b/plugins/Utils/tstring.h
deleted file mode 100644
index fb340bcd03..0000000000
--- a/plugins/Utils/tstring.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __TSTRING_H__
-# define __TSTRING_H__
-
-#include <windows.h>
-#include <tchar.h>
-#include <string>
-
-
-namespace std {
- typedef basic_string<TCHAR, char_traits<TCHAR>, allocator<TCHAR> > tstring;
-}
-
-
-#endif // __TSTRING_H__
diff --git a/plugins/Variables/src/parse_inet.cpp b/plugins/Variables/src/parse_inet.cpp
index 7947294a0c..856af28d14 100644
--- a/plugins/Variables/src/parse_inet.cpp
+++ b/plugins/Variables/src/parse_inet.cpp
@@ -42,7 +42,7 @@ static TCHAR *parseUrlEnc(ARGUMENTSINFO *ai) {
return NULL;
MoveMemory(res+cur+3, res+cur+1, strlen(res+cur+1)+1);
- _snprintf(hex, sizeof(hex), "%%%x", *(res+cur));
+ mir_snprintf(hex, sizeof(hex), "%%%x", *(res+cur));
strncpy(res+cur, hex, strlen(hex));
cur+=strlen(hex);
}
diff --git a/plugins/Weather/src/weather_ini.cpp b/plugins/Weather/src/weather_ini.cpp
index 027331408c..25d1da052f 100644
--- a/plugins/Weather/src/weather_ini.cpp
+++ b/plugins/Weather/src/weather_ini.cpp
@@ -285,7 +285,7 @@ void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data)
Data->InternalVer = 6;
else
{
- wsprintfA(Line, Translate("Invalid ini format for: %s"), pszFile);
+ mir_snprintf(Line, SIZEOF(Line), Translate("Invalid ini format for: %s"), pszFile);
MessageBoxA(NULL, Line, Translate("Weather Protocol"), MB_OK|MB_ICONERROR);
fclose(pfile);
return;
diff --git a/plugins/mTextControl/src/richeditutils.cpp b/plugins/mTextControl/src/richeditutils.cpp
index ca361bc371..f5a473695f 100644
--- a/plugins/mTextControl/src/richeditutils.cpp
+++ b/plugins/mTextControl/src/richeditutils.cpp
@@ -77,14 +77,12 @@ public:
HRESULT STDMETHODCALLTYPE GetNewStorage(LPSTORAGE * lplpstg)
{
- WCHAR szwName[64];
- char szName[64];
- wsprintfA(szName, "s%u", this->nextStgId);
- MultiByteToWideChar(CP_ACP, 0, szName, -1, szwName, sizeof(szwName) / sizeof(szwName[0]));
+ TCHAR sztName[64];
+ mir_sntprintf(sztName, SIZEOF(sztName), _T("s%u"), this->nextStgId);
if (this->pictStg == NULL)
return STG_E_MEDIUMFULL;
- return this->pictStg->CreateStorage(szwName, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, lplpstg);
+ return this->pictStg->CreateStorage(sztName, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, lplpstg);
}