00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00024
00025
00026
00027
00028 #define WINVER 0x0500 // Windows Version
00029 #define _WIN32_WINDOWS 0x0500 // Windows Version
00030 #define _WIN32_WINNT 0x0500 // NT Version
00031 #define _WIN32_IE 0x0500 // IE Version
00032 #define _WIN32_DCOM // DCOM
00033 #define _AFX_NO_RICHEDIT_SUPPORT // No RichEdit
00034
00035
00036
00037
00038
00039 #include <afxwin.h>
00040 #include <afxext.h>
00041 #include <afxcmn.h>
00042 #include <afxtempl.h>
00043 #include <afxmt.h>
00044 #include <afxole.h>
00045 #include <afxocc.h>
00046 #include <afxhtml.h>
00047
00048
00049
00050
00051
00052 #include <winsock2.h>
00053 #include <objbase.h>
00054 #include <shlobj.h>
00055 #include <wininet.h>
00056 #include <ddeml.h>
00057 #include <math.h>
00058
00059 #undef IDC_HAND
00060
00061
00062
00063
00064
00065 #define BIF_NEWDIALOGSTYLE 0x0040
00066 #define OFN_ENABLESIZING 0x00800000
00067
00068 #undef NULL
00069 #undef min
00070 #undef max
00071
00072
00073
00074
00075
00076 #include <algorithm>
00077 #undef NULL
00078
00079 const int NULL = 0;
00080 using std::min;
00081 using std::max;
00082
00083
00084
00085
00086
00087 typedef unsigned __int64 QWORD;
00088
00089
00090
00091
00092
00093 typedef int TRISTATE;
00094
00095 #define TS_UNKNOWN 0
00096 #define TS_FALSE 1
00097 #define TS_TRUE 2
00098
00099
00100
00101
00102
00103 typedef union
00104 {
00105 BYTE n[16];
00106 BYTE b[16];
00107 DWORD w[4];
00108 } GGUID;
00109
00110 inline bool operator==(const GGUID& guidOne, const GGUID& guidTwo)
00111 {
00112 return (
00113 ((PLONG)&guidOne)[0] == ((PLONG)&guidTwo)[0] &&
00114 ((PLONG)&guidOne)[1] == ((PLONG)&guidTwo)[1] &&
00115 ((PLONG)&guidOne)[2] == ((PLONG)&guidTwo)[2] &&
00116 ((PLONG)&guidOne)[3] == ((PLONG)&guidTwo)[3] );
00117 }
00118
00119 inline bool operator!=(const GGUID& guidOne, const GGUID& guidTwo)
00120 {
00121 return (
00122 ( (PLONG)&guidOne)[0] != ((PLONG)&guidTwo)[0] ||
00123 ( (PLONG)&guidOne)[1] != ((PLONG)&guidTwo)[1] ||
00124 ( (PLONG)&guidOne)[2] != ((PLONG)&guidTwo)[2] ||
00125 ( (PLONG)&guidOne)[3] != ((PLONG)&guidTwo)[3] );
00126 }
00127
00128 #define SIZE_UNKNOWN 0xFFFFFFFFFFFFFFFF
00129
00130
00131
00132
00133
00134 typedef union
00135 {
00136 BYTE n[20];
00137 BYTE b[20];
00138 } SHA1;
00139
00140 typedef union
00141 {
00142 BYTE n[24];
00143 BYTE b[24];
00144 QWORD w[3];
00145 } TIGEROOT;
00146
00147 typedef union
00148 {
00149 BYTE n[16];
00150 BYTE b[16];
00151 DWORD w[4];
00152 } MD4, MD5;
00153
00154 #define HASH_NULL 0
00155 #define HASH_SHA1 1
00156 #define HASH_MD5 2
00157 #define HASH_TIGERTREE 3
00158 #define HASH_ED2K 4
00159 #define HASH_TORRENT 5
00160
00161
00162
00163
00164
00165 typedef int PROTOCOLID;
00166
00167 #define PROTOCOL_NULL 0
00168 #define PROTOCOL_G1 1
00169 #define PROTOCOL_G2 2
00170 #define PROTOCOL_ED2K 3
00171
00172 #define PROTOCOL_HTTP 4
00173 #define PROTOCOL_FTP 5
00174 #define PROTOCOL_BT 6
00175
00176 class CQuickLock
00177 {
00178 public:
00179 explicit CQuickLock(CSyncObject& oMutex) : m_oMutex( oMutex ) { oMutex.Lock(); }
00180 ~CQuickLock() { m_oMutex.Unlock(); }
00181 private:
00182 CSyncObject& m_oMutex;
00183 CQuickLock(const CQuickLock&);
00184 CQuickLock& operator=(const CQuickLock&);
00185 static void* operator new(std::size_t);
00186 static void* operator new[](std::size_t);
00187 static void operator delete(void*);
00188 static void operator delete[](void*);
00189 CQuickLock* operator&();
00190 };
00191
00192 template< class T >
00193 class CGuarded
00194 {
00195 public:
00196 explicit CGuarded() : m_oSection(), m_oValue() { }
00197 explicit CGuarded(const CGuarded& other) : m_oSection(), m_oValue( other ) { }
00198 CGuarded(const T& oValue) : m_oSection(), m_oValue( oValue ) { }
00199 CGuarded& operator=(const T& oValue)
00200 {
00201 CQuickLock oLock( m_oSection );
00202 m_oValue = oValue;
00203 return *this;
00204 }
00205 operator T() const
00206 {
00207 CQuickLock oLock( m_oSection );
00208 return m_oValue;
00209 }
00210 private:
00211 mutable CCriticalSection m_oSection;
00212 T m_oValue;
00213 CGuarded* operator&();
00214 };
00215
00216 class CLowerCaseTable
00217 {
00218 public:
00219 explicit CLowerCaseTable()
00220 {
00221 for ( size_t i = 0 ; i < 65536 ; ++i ) cTable[ i ] = i;
00222 cTable[ 65536 ] = 0;
00223 CharLower( &cTable[ 1 ] );
00224 cTable[ 304 ] = 105;
00225
00226 for ( size_t i = 65281 ; i < 65313 ; ++i ) cTable[ i ] = i - 65248;
00227 for ( size_t i = 65313 ; i < 65339 ; ++i ) cTable[ i ] = i - 65216;
00228 for ( size_t i = 65339 ; i < 65375 ; ++i ) cTable[ i ] = i - 65248;
00229 };
00230 const TCHAR& operator()(const TCHAR cLookup) const { return cTable[ cLookup ]; }
00231 const TCHAR& operator[](const TCHAR cLookup) const { return ( *this )( cLookup ); }
00232 private:
00233 TCHAR CLowerCaseTable::cTable[ 65537 ];
00234 };
00235
00236 const CLowerCaseTable ToLowerCase;