summaryrefslogtreecommitdiff
path: root/plugins/Clist_modern/modern_commonheaders.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Clist_modern/modern_commonheaders.cpp')
-rw-r--r--plugins/Clist_modern/modern_commonheaders.cpp125
1 files changed, 62 insertions, 63 deletions
diff --git a/plugins/Clist_modern/modern_commonheaders.cpp b/plugins/Clist_modern/modern_commonheaders.cpp
index 4b4fe7f9be..2556a9f624 100644
--- a/plugins/Clist_modern/modern_commonheaders.cpp
+++ b/plugins/Clist_modern/modern_commonheaders.cpp
@@ -1,16 +1,16 @@
#define DB_USEHELPERFUNCTIONS
#include "hdr/modern_commonheaders.h"
-BYTE gl_TrimText=1;
+BYTE gl_TrimText = 1;
char * __cdecl strstri( char *a, const char *b)
{
char * x, *y;
if (!a || !b) return FALSE;
- x=_strdup(a);
- y=_strdup(b);
- x=_strupr(x);
- y=_strupr(y);
+ x = _strdup(a);
+ y = _strdup(b);
+ x = _strupr(x);
+ y = _strupr(y);
char * pos = strstr(x,y);
if ( pos )
{
@@ -25,29 +25,29 @@ char * __cdecl strstri( char *a, const char *b)
}
int __cdecl mir_strcmpi(const char *a, const char *b)
{
- if (a==NULL && b==NULL) return 0;
- if (a==NULL || b==NULL) return _stricmp(a?a:"",b?b:"");
+ if (a == NULL && b == NULL) return 0;
+ if (a == NULL || b == NULL) return _stricmp(a?a:"",b?b:"");
return _stricmp(a,b);
}
int __cdecl mir_tstrcmpi(const TCHAR *a, const TCHAR *b)
{
- if (a==NULL && b==NULL) return 0;
- if (a==NULL || b==NULL) return _tcsicmp(a?a:TEXT(""),b?b:TEXT(""));
+ if (a == NULL && b == NULL) return 0;
+ if (a == NULL || b == NULL) return _tcsicmp(a?a:TEXT(""),b?b:TEXT(""));
return _tcsicmp(a,b);
}
BOOL __cdecl mir_bool_strcmpi(const char *a, const char *b)
{
- if (a==NULL && b==NULL) return 1;
- if (a==NULL || b==NULL) return _stricmp(a?a:"",b?b:"")==0;
- return _stricmp(a,b)==0;
+ if (a == NULL && b == NULL) return 1;
+ if (a == NULL || b == NULL) return _stricmp(a?a:"",b?b:"") == 0;
+ return _stricmp(a,b) == 0;
}
BOOL __cdecl mir_bool_tstrcmpi(const TCHAR *a, const TCHAR *b)
{
- if (a==NULL && b==NULL) return 1;
- if (a==NULL || b==NULL) return _tcsicmp(a?a:TEXT(""),b?b:TEXT(""))==0;
- return _tcsicmp(a,b)==0;
+ if (a == NULL && b == NULL) return 1;
+ if (a == NULL || b == NULL) return _tcsicmp(a?a:TEXT(""),b?b:TEXT("")) == 0;
+ return _tcsicmp(a,b) == 0;
}
#ifdef strlen
@@ -57,13 +57,13 @@ BOOL __cdecl mir_bool_tstrcmpi(const TCHAR *a, const TCHAR *b)
int __cdecl mir_strcmp (const char *a, const char *b)
{
- if (!(a&&b)) return a!=b;
+ if (!(a&&b)) return a != b;
return (strcmp(a,b));
};
int mir_strlen (const char *a)
{
- if (a==NULL) return 0;
+ if (a == NULL) return 0;
return (int)(strlen(a));
};
@@ -73,8 +73,8 @@ int mir_strlen (const char *a)
/*
__inline void *mir_calloc( size_t num, size_t size )
{
- void *p=mir_alloc(num*size);
- if (p==NULL) return NULL;
+ void *p = mir_alloc(num*size);
+ if (p == NULL) return NULL;
memset(p,0,num*size);
return p;
};
@@ -82,8 +82,8 @@ __inline void *mir_calloc( size_t num, size_t size )
wchar_t * mir_strdupW(const wchar_t * src)
{
wchar_t * p;
- if (src==NULL) return NULL;
- p=(wchar_t *) mir_alloc((lstrlenW(src)+1)*sizeof(wchar_t));
+ if (src == NULL) return NULL;
+ p = (wchar_t *) mir_alloc((lstrlenW(src)+1)*sizeof(wchar_t));
if (!p) return 0;
lstrcpyW(p, src);
return p;
@@ -93,11 +93,11 @@ wchar_t * mir_strdupW(const wchar_t * src)
char * strdupn(const char * src, int len)
{
char * p;
- if (src==NULL) return NULL;
- p= (char*)malloc(len+1);
+ if (src == NULL) return NULL;
+ p = (char*)malloc(len+1);
if (!p) return 0;
memcpy(p,src,len);
- p[len]='\0';
+ p[len] = '\0';
return p;
}
@@ -151,7 +151,7 @@ void TRACE_ERROR()
BOOL DebugDeleteObject(HGDIOBJ a)
{
- BOOL res=DeleteObject(a);
+ BOOL res = DeleteObject(a);
if (!res) TRACE_ERROR();
return res;
}
@@ -170,16 +170,16 @@ BOOL mod_DeleteDC(HDC hdc)
HICON LoadSmallIconShared(HINSTANCE hInstance, LPCTSTR lpIconName)
{
- int cx=GetSystemMetrics(SM_CXSMICON);
+ int cx = GetSystemMetrics(SM_CXSMICON);
return (HICON)LoadImage(hInstance,lpIconName, IMAGE_ICON,cx,cx, LR_DEFAULTCOLOR|LR_SHARED);
}
// load small icon (not shared) it IS NEED to be destroyed
HICON LoadSmallIcon(HINSTANCE hInstance, LPCTSTR lpIconName)
{
- HICON hIcon=NULL; // icon handle
- int index=-(int)lpIconName;
- TCHAR filename[MAX_PATH]={0};
+ HICON hIcon = NULL; // icon handle
+ int index = -(int)lpIconName;
+ TCHAR filename[MAX_PATH] = {0};
GetModuleFileName(hInstance,filename,MAX_PATH);
ExtractIconEx(filename,index,NULL,&hIcon,1);
return hIcon;
@@ -188,12 +188,12 @@ HICON LoadSmallIcon(HINSTANCE hInstance, LPCTSTR lpIconName)
// load small icon from hInstance
HICON LoadIconEx(HINSTANCE hInstance, LPCTSTR lpIconName, BOOL bShared)
{
- HICON hResIcon=bShared?LoadSmallIcon(hInstance,lpIconName):LoadSmallIconShared(hInstance,lpIconName);
+ HICON hResIcon = bShared?LoadSmallIcon(hInstance,lpIconName):LoadSmallIconShared(hInstance,lpIconName);
if (!hResIcon) //Icon not found in hInstance lets try to load it from core
{
- HINSTANCE hCoreInstance=GetModuleHandle(NULL);
- if (hCoreInstance!=hInstance)
- hResIcon=bShared?LoadSmallIcon(hInstance,lpIconName):LoadSmallIconShared(hInstance,lpIconName);
+ HINSTANCE hCoreInstance = GetModuleHandle(NULL);
+ if (hCoreInstance != hInstance)
+ hResIcon = bShared?LoadSmallIcon(hInstance,lpIconName):LoadSmallIconShared(hInstance,lpIconName);
}
return hResIcon;
}
@@ -206,16 +206,16 @@ BOOL DestroyIcon_protect(HICON icon)
void li_ListDestruct(SortedList *pList, ItemDestuctor pItemDestructor)
{
- int i=0;
+ int i = 0;
if (!pList) return;
- for (i=0; i<pList->realCount; i++) pItemDestructor(pList->items[i]);
+ for (i = 0; i < pList->realCount; i++) pItemDestructor(pList->items[i]);
List_Destroy(pList);
mir_free(pList);
}
void li_RemoveDestruct(SortedList *pList, int index, ItemDestuctor pItemDestructor)
{
- if (index>=0 && index<pList->realCount)
+ if (index >= 0 && index < pList->realCount)
{
pItemDestructor(pList->items[index]);
List_Remove(pList, index);
@@ -230,20 +230,20 @@ void li_RemovePtrDestruct(SortedList *pList, void * ptr, ItemDestuctor pItemDest
void li_SortList(SortedList *pList, FSortFunc pSortFunct)
{
- FSortFunc pOldSort=pList->sortFunc;
+ FSortFunc pOldSort = pList->sortFunc;
int i;
- if (!pSortFunct) pSortFunct=pOldSort;
- pList->sortFunc=NULL;
- for (i=0; i<pList->realCount-1; i++)
- if (pOldSort(pList->items[i],pList->items[i+1])<0)
+ if (!pSortFunct) pSortFunct = pOldSort;
+ pList->sortFunc = NULL;
+ for (i = 0; i < pList->realCount-1; i++)
+ if (pOldSort(pList->items[i],pList->items[i+1]) < 0)
{
- void * temp=pList->items[i];
- pList->items[i]=pList->items[i+1];
- pList->items[i+1]=temp;
+ void * temp = pList->items[i];
+ pList->items[i] = pList->items[i+1];
+ pList->items[i+1] = temp;
i--;
if (i>0) i--;
}
- pList->sortFunc=pOldSort;
+ pList->sortFunc = pOldSort;
}
typedef struct _HookRec
@@ -256,33 +256,32 @@ typedef struct _HookRec
#endif
} HookRec;
-static HookRec * hooksrec=NULL;
-static DWORD hooksRecAlloced=0;
+static HookRec * hooksrec = NULL;
+static DWORD hooksRecAlloced = 0;
HANDLE ModernHookEvent(char *EventID, MIRANDAHOOK HookProc)
{
- HookRec * hr=NULL;
+ HookRec * hr = NULL;
DWORD i;
//1. Find free
- for (i=0;i<hooksRecAlloced;i++)
- {
- if (hooksrec[i].hHook==NULL)
+ for (i = 0;i < hooksRecAlloced;i++) {
+ if (hooksrec[i].hHook == NULL)
{
- hr=&(hooksrec[i]);
+ hr = &(hooksrec[i]);
break;
}
}
- if (hr==NULL)
+ if (hr == NULL)
{
//2. Need realloc
- hooksrec=(HookRec*)mir_realloc(hooksrec,sizeof(HookRec)*(hooksRecAlloced+1));
- hr=&(hooksrec[hooksRecAlloced]);
+ hooksrec = (HookRec*)mir_realloc(hooksrec,sizeof(HookRec)*(hooksRecAlloced+1));
+ hr = &(hooksrec[hooksRecAlloced]);
hooksRecAlloced++;
}
- hr->hHook=HookEvent(EventID,HookProc);
+ hr->hHook = HookEvent(EventID,HookProc);
return hr->hHook;
}
@@ -291,12 +290,12 @@ int ModernUnhookEvent(HANDLE hHook)
DWORD i;
//1. Find free
- for (i=0;i<hooksRecAlloced;i++)
+ for (i = 0;i < hooksRecAlloced;i++)
{
- if (hooksrec[i].hHook==hHook)
+ if (hooksrec[i].hHook == hHook)
{
UnhookEvent(hHook);
- hooksrec[i].hHook=NULL;
+ hooksrec[i].hHook = NULL;
return 1;
}
}
@@ -308,15 +307,15 @@ int UnhookAll()
DWORD i;
TRACE("Unhooked Events:\n");
if (!hooksrec) return 0;
- for (i=0;i<hooksRecAlloced;i++)
+ for (i = 0;i < hooksRecAlloced;i++)
{
- if (hooksrec[i].hHook!=NULL)
+ if (hooksrec[i].hHook != NULL)
{
UnhookEvent(hooksrec[i].hHook);
- hooksrec[i].hHook=NULL;
+ hooksrec[i].hHook = NULL;
}
}
mir_free_and_nill(hooksrec);
- hooksRecAlloced=0;
+ hooksRecAlloced = 0;
return 1;
}