summaryrefslogtreecommitdiff
path: root/plugins/CountryFlags
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/CountryFlags')
-rw-r--r--plugins/CountryFlags/src/extraimg.cpp2
-rw-r--r--plugins/CountryFlags/src/icons.cpp4
-rw-r--r--plugins/CountryFlags/src/ip2country.cpp2
-rw-r--r--plugins/CountryFlags/src/utils.cpp110
4 files changed, 61 insertions, 57 deletions
diff --git a/plugins/CountryFlags/src/extraimg.cpp b/plugins/CountryFlags/src/extraimg.cpp
index 491d413742..82adffe7ef 100644
--- a/plugins/CountryFlags/src/extraimg.cpp
+++ b/plugins/CountryFlags/src/extraimg.cpp
@@ -55,7 +55,7 @@ static void CALLBACK SetExtraImage(MCONTACT hContact)
ExtraIcon_Clear(hExtraIcon, hContact);
else {
char szId[20];
- mir_snprintf(szId, _countof(szId), (countryNumber == 0xFFFF) ? "%s0x%X" : "%s%i", "flags_", countryNumber);
+ mir_snprintf(szId, (countryNumber == 0xFFFF) ? "%s0x%X" : "%s%i", "flags_", countryNumber);
ExtraIcon_SetIconByName(hExtraIcon, hContact, szId);
}
}
diff --git a/plugins/CountryFlags/src/icons.cpp b/plugins/CountryFlags/src/icons.cpp
index c11f0b4b9d..966af46b11 100644
--- a/plugins/CountryFlags/src/icons.cpp
+++ b/plugins/CountryFlags/src/icons.cpp
@@ -146,7 +146,7 @@ HICON __fastcall LoadFlagIcon(int countryNumber)
szCountry = (char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, countryNumber = 0xFFFF, 0);
char szId[20];
- mir_snprintf(szId, _countof(szId), (countryNumber == 0xFFFF) ? "%s0x%X" : "%s%i", "flags_", countryNumber); /* buffer safe */
+ mir_snprintf(szId, (countryNumber == 0xFFFF) ? "%s0x%X" : "%s%i", "flags_", countryNumber); /* buffer safe */
return IcoLib_GetIcon(szId);
}
@@ -244,7 +244,7 @@ void InitIcons(void)
sid.description.a = (char*)countries[i].szName;
/* create identifier */
- mir_snprintf(szId, _countof(szId), (countries[i].id == 0xFFFF) ? "%s0x%X" : "%s%i","flags_", countries[i].id); /* buffer safe */
+ mir_snprintf(szId, (countries[i].id == 0xFFFF) ? "%s0x%X" : "%s%i","flags_", countries[i].id); /* buffer safe */
int index = CountryNumberToBitmapIndex(countries[i].id);
/* create icon */
HICON hIcon = ImageList_GetIcon(himl,index,ILD_NORMAL);
diff --git a/plugins/CountryFlags/src/ip2country.cpp b/plugins/CountryFlags/src/ip2country.cpp
index 49dcc881b6..d39f6beecd 100644
--- a/plugins/CountryFlags/src/ip2country.cpp
+++ b/plugins/CountryFlags/src/ip2country.cpp
@@ -246,7 +246,7 @@ static int EnumIpDataLines(const char *pszFileCSV,const char *pszFileOut)
}
/* not in list */
if (i == nCountriesCount) {
- mir_snprintf(out, _countof(out), "Unknown: %s-%s [%s, %s]\n", pszFrom, pszTo, pszTwo, pszCountry);
+ mir_snprintf(out, "Unknown: %s-%s [%s, %s]\n", pszFrom, pszTo, pszTwo, pszCountry);
OutputDebugStringA(out); /* all ascii */
}
}
diff --git a/plugins/CountryFlags/src/utils.cpp b/plugins/CountryFlags/src/utils.cpp
index 958a99fb25..082f8f256e 100644
--- a/plugins/CountryFlags/src/utils.cpp
+++ b/plugins/CountryFlags/src/utils.cpp
@@ -21,7 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/************************* Buffered Functions *********************/
-struct BufferedCallData {
+struct BufferedCallData
+{
DWORD startTick;
UINT uElapse;
BUFFEREDPROC pfnBuffProc;
@@ -36,10 +37,10 @@ static struct BufferedCallData *callList;
static int nCallListCount;
// always gets called in main message loop
-static void CALLBACK BufferedProcTimer(HWND hwnd,UINT,UINT_PTR idTimer,DWORD currentTick)
+static void CALLBACK BufferedProcTimer(HWND hwnd, UINT, UINT_PTR idTimer, DWORD currentTick)
{
struct BufferedCallData *buf;
- UINT uElapsed,uElapseNext=USER_TIMER_MAXIMUM;
+ UINT uElapsed, uElapseNext = USER_TIMER_MAXIMUM;
BUFFEREDPROC pfnBuffProc;
LPARAM lParam;
#ifdef _DEBUG
@@ -47,114 +48,117 @@ static void CALLBACK BufferedProcTimer(HWND hwnd,UINT,UINT_PTR idTimer,DWORD cur
const char *pszProcName;
#endif
- for(int i=0; i < nCallListCount; ++i) {
+ for (int i = 0; i < nCallListCount; ++i) {
/* find elapsed procs */
- uElapsed=currentTick-callList[i].startTick; /* wraparound works */
- if ((uElapsed+USER_TIMER_MINIMUM)>=callList[i].uElapse) {
+ uElapsed = currentTick - callList[i].startTick; /* wraparound works */
+ if ((uElapsed + USER_TIMER_MINIMUM) >= callList[i].uElapse) {
/* call elapsed proc */
- pfnBuffProc=callList[i].pfnBuffProc;
- lParam=callList[i].lParam;
+ pfnBuffProc = callList[i].pfnBuffProc;
+ lParam = callList[i].lParam;
#ifdef _DEBUG
- pszProcName=callList[i].pszProcName;
+ pszProcName = callList[i].pszProcName;
#endif
/* resize storage array */
- if ((i+1)<nCallListCount)
- memmove(&callList[i],&callList[i+1],((nCallListCount-i-1)*sizeof(struct BufferedCallData)));
+ if ((i + 1) < nCallListCount)
+ memmove(&callList[i], &callList[i + 1], ((nCallListCount - i - 1)*sizeof(struct BufferedCallData)));
--nCallListCount;
--i; /* reiterate current */
if (nCallListCount) {
- buf=(struct BufferedCallData*)mir_realloc(callList,nCallListCount*sizeof(struct BufferedCallData));
- if (buf != NULL) callList=buf;
- } else {
+ buf = (struct BufferedCallData*)mir_realloc(callList, nCallListCount*sizeof(struct BufferedCallData));
+ if (buf != NULL) callList = buf;
+ }
+ else {
mir_free(callList);
- callList=NULL;
+ callList = NULL;
}
#ifdef _DEBUG
- mir_snprintf(szDbgLine,_countof(szDbgLine),"buffered call: %s(0x%X)\n",pszProcName,lParam); /* all ascii */
- OutputDebugStringA(szDbgLine);
+ mir_snprintf(szDbgLine, "buffered call: %s(0x%X)\n", pszProcName, lParam); /* all ascii */
+ OutputDebugStringA(szDbgLine);
#endif
- CallFunctionAsync((void (CALLBACK *)(void*))pfnBuffProc,(void*)lParam); /* compatible */
+ CallFunctionAsync((void (CALLBACK *)(void*))pfnBuffProc, (void*)lParam); /* compatible */
}
/* find next timer delay */
- else if ((callList[i].uElapse-uElapsed)<uElapseNext)
- uElapseNext=callList[i].uElapse-uElapsed;
+ else if ((callList[i].uElapse - uElapsed) < uElapseNext)
+ uElapseNext = callList[i].uElapse - uElapsed;
}
/* set next timer */
if (nCallListCount) {
#ifdef _DEBUG
- mir_snprintf(szDbgLine,_countof(szDbgLine),"next buffered timeout: %ums\n",uElapseNext); /* all ascii */
- OutputDebugStringA(szDbgLine);
+ mir_snprintf(szDbgLine, "next buffered timeout: %ums\n", uElapseNext); /* all ascii */
+ OutputDebugStringA(szDbgLine);
#endif
- idBufferedTimer=SetTimer(hwnd,idBufferedTimer,uElapseNext,BufferedProcTimer); /* will be reset */
- } else {
- KillTimer(hwnd,idTimer);
- idBufferedTimer=0;
+ idBufferedTimer = SetTimer(hwnd, idBufferedTimer, uElapseNext, BufferedProcTimer); /* will be reset */
+ }
+ else {
+ KillTimer(hwnd, idTimer);
+ idBufferedTimer = 0;
#ifdef _DEBUG
- OutputDebugStringA("empty buffered queue\n");
+ OutputDebugStringA("empty buffered queue\n");
#endif
}
}
// assumes to be called in context of main thread
#ifdef _DEBUG
-void _CallFunctionBuffered(BUFFEREDPROC pfnBuffProc,const char *pszProcName,LPARAM lParam,BOOL fAccumulateSameParam,UINT uElapse)
+void _CallFunctionBuffered(BUFFEREDPROC pfnBuffProc, const char *pszProcName, LPARAM lParam, BOOL fAccumulateSameParam, UINT uElapse)
#else
-void _CallFunctionBuffered(BUFFEREDPROC pfnBuffProc,LPARAM lParam,BOOL fAccumulateSameParam,UINT uElapse)
+void _CallFunctionBuffered(BUFFEREDPROC pfnBuffProc, LPARAM lParam, BOOL fAccumulateSameParam, UINT uElapse)
#endif
{
- struct BufferedCallData *data=NULL;
+ struct BufferedCallData *data = NULL;
int i;
/* find existing */
- for(i=0;i<nCallListCount;++i)
+ for (i = 0; i < nCallListCount; ++i)
if (callList[i].pfnBuffProc == pfnBuffProc)
if (!fAccumulateSameParam || callList[i].lParam == lParam) {
- data=&callList[i];
+ data = &callList[i];
break;
}
/* append new */
if (data == NULL) {
/* resize storage array */
- data=(struct BufferedCallData*)mir_realloc(callList,(nCallListCount+1)*sizeof(struct BufferedCallData));
+ data = (struct BufferedCallData*)mir_realloc(callList, (nCallListCount + 1)*sizeof(struct BufferedCallData));
if (data == NULL) return;
- callList=data;
- data=&callList[nCallListCount];
+ callList = data;
+ data = &callList[nCallListCount];
++nCallListCount;
}
/* set delay */
- data->startTick=GetTickCount();
- data->uElapse=uElapse;
- data->lParam=lParam;
- data->pfnBuffProc=pfnBuffProc;
+ data->startTick = GetTickCount();
+ data->uElapse = uElapse;
+ data->lParam = lParam;
+ data->pfnBuffProc = pfnBuffProc;
#ifdef _DEBUG
- { char szDbgLine[256];
- data->pszProcName=pszProcName;
- mir_snprintf(szDbgLine,_countof(szDbgLine),"buffered queue: %s(0x%X)\n",pszProcName,lParam); /* all ascii */
+ {
+ char szDbgLine[256];
+ data->pszProcName = pszProcName;
+ mir_snprintf(szDbgLine, "buffered queue: %s(0x%X)\n", pszProcName, lParam); /* all ascii */
+ OutputDebugStringA(szDbgLine);
+ if (!idBufferedTimer) {
+ mir_snprintf(szDbgLine, "next buffered timeout: %ums\n", uElapse); /* all ascii */
OutputDebugStringA(szDbgLine);
- if (!idBufferedTimer) {
- mir_snprintf(szDbgLine,_countof(szDbgLine),"next buffered timeout: %ums\n",uElapse); /* all ascii */
- OutputDebugStringA(szDbgLine);
- }
}
+ }
#endif
/* set next timer */
- if (idBufferedTimer) uElapse=USER_TIMER_MINIMUM; /* will get recalculated */
- idBufferedTimer=SetTimer(NULL,idBufferedTimer,uElapse,BufferedProcTimer);
+ if (idBufferedTimer) uElapse = USER_TIMER_MINIMUM; /* will get recalculated */
+ idBufferedTimer = SetTimer(NULL, idBufferedTimer, uElapse, BufferedProcTimer);
}
// assumes to be called in context of main thread
void PrepareBufferedFunctions(void)
{
- idBufferedTimer=0;
- nCallListCount=0;
- callList=NULL;
+ idBufferedTimer = 0;
+ nCallListCount = 0;
+ callList = NULL;
}
// assumes to be called in context of main thread
void KillBufferedFunctions(void)
{
- if (idBufferedTimer) KillTimer(NULL,idBufferedTimer);
- nCallListCount=0;
+ if (idBufferedTimer) KillTimer(NULL, idBufferedTimer);
+ nCallListCount = 0;
mir_free(callList); /* does NULL check */
}