1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
#define db_free(A) DBFreeVariant(A)
#define db_get_b(A,B,C,D) DBGetContactSettingByte(A,B,C,D)
#define db_get_dw(A,B,C,D) DBGetContactSettingDword(A,B,C,D)
#define db_get_s(A,B,C,D) DBGetContactSettingString(A,B,C,D)
#define db_get_ts(A,B,C,D) DBGetContactSettingTString(A,B,C,D)
#define db_set_b(A,B,C,D) DBWriteContactSettingByte(A,B,C,D)
#define db_set_dw(A,B,C,D) DBWriteContactSettingDword(A,B,C,D)
#define db_set_s(A,B,C,D) DBWriteContactSettingString(A,B,C,D)
#define db_set_ts(A,B,C,D) DBWriteContactSettingTString(A,B,C,D)
#define db_get_sa DBGetStringA
#define db_get_wsa DBGetStringW
#define db_get_tsa DBGetStringT
template<class T> class mir_ptr
{
T *data;
public:
__inline mir_ptr() : data((T*)mir_calloc(sizeof(T))) {}
__inline mir_ptr(T *_p) : data(_p) {}
__inline ~mir_ptr() { mir_free(data); }
__inline T *operator = (T *_p) { if (data) mir_free(data); data = _p; return data; }
__inline T *operator->() const { return data; }
__inline operator T*() const { return data; }
__inline operator INT_PTR() const { return (INT_PTR)data; }
};
typedef mir_ptr<char> ptrA;
typedef mir_ptr<TCHAR> ptrT;
struct VARST : public ptrT
{
__forceinline VARST(const TCHAR *str) :
ptrT( Utils_ReplaceVarsT(str))
{}
};
class _A2T
{
TCHAR *buf;
public:
__forceinline _A2T(const char *s) : buf(mir_a2t(s)) {}
__forceinline _A2T(const char *s, int cp) : buf(mir_a2t_cp(s, cp)) {}
~_A2T() { mir_free(buf); }
__forceinline operator TCHAR*() const
{ return buf;
}
};
class _T2A
{
char *buf;
public:
__forceinline _T2A(const TCHAR *s) : buf(mir_t2a(s)) {}
__forceinline _T2A(const TCHAR *s, int cp) : buf(mir_t2a_cp(s, cp)) {}
__forceinline ~_T2A() { mir_free(buf); }
__forceinline operator char*() const
{ return buf;
}
};
__forceinline INT_PTR Options_Open(OPENOPTIONSDIALOG *ood)
{
return CallService("Opt/OpenOptions", 0, (LPARAM)ood);
}
__forceinline INT_PTR Options_AddPage(WPARAM wParam, OPTIONSDIALOGPAGE *odp)
{
return CallService("Opt/AddPage", wParam, (LPARAM)odp);
}
char* bin2hex(const void *pData, size_t len, char *dest);
char *rtrim(char *str);
int CreatePathToFileT(const TCHAR *ptszPath);
#define NEWTSTR_ALLOCA(A) (A == NULL)?NULL:_tcscpy((TCHAR*)alloca((_tcslen(A)+1) *sizeof(TCHAR)), A)
__forceinline HANDLE Skin_AddIcon(SKINICONDESC *si)
{ return (HANDLE)CallService("Skin2/Icons/AddIcon", 0, (LPARAM)si);
}
__forceinline HICON Skin_GetIconByHandle(HANDLE hIcolibIcon, int size=0)
{ return (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, size, (LPARAM)hIcolibIcon);
}
__forceinline HANDLE Skin_GetIconHandle(const char *szIconName)
{ return (HANDLE)CallService(MS_SKIN2_GETICONHANDLE, 0, (LPARAM)szIconName);
}
__forceinline HICON Skin_GetIcon(const char *szIconName, int size=0)
{ return (HICON)CallService(MS_SKIN2_GETICON, size, (LPARAM)szIconName);
}
__forceinline void Skin_ReleaseIcon(const char* szIconName)
{ CallService(MS_SKIN2_RELEASEICON, 0, (LPARAM)szIconName);
}
__forceinline void Skin_ReleaseIcon(HICON hIcon)
{ CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0);
}
__forceinline HGENMENU Menu_AddMainMenuItem(CLISTMENUITEM *mi)
{ return (HGENMENU)CallService("CList/AddMainMenuItem", 0, (LPARAM)mi);
}
__forceinline INT_PTR Hotkey_Register(HOTKEYDESC *hk)
{ return CallService("CoreHotkeys/Register", 0, (LPARAM)hk);
}
__forceinline INT_PTR CreateDirectoryTreeT(const TCHAR *ptszPath)
{ return CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)ptszPath);
}
int __forceinline PUDeletePopup(HWND hWndPopup)
{ return (int)SendMessage(hWndPopup, UM_DESTROYPOPUP, 0, 0);
}
#define _qtoupper(_c) (((_c) >= 'a' && (_c) <= 'z')?((_c)-('a'+'A')):(_c))
int __forceinline wildcmpit(const WCHAR *name, const WCHAR *mask)
{
if (name == NULL || mask == NULL)
return false;
const WCHAR* last = NULL;
for (;; mask++, name++) {
if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) break;
if (*name == '\0') return ((BOOL)!*mask);
}
if (*mask != '*') return FALSE;
for (;; mask++, name++) {
while(*mask == '*') {
last = mask++;
if (*mask == '\0') return ((BOOL)!*mask); /* true */
}
if (*name == '\0') return ((BOOL)!*mask); /* *mask == EOS */
if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) name -= (size_t)(mask - last) - 1, mask = last;
}
}
|