Initial commit
This commit is contained in:
@@ -0,0 +1,179 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef HttpThreadH
|
||||
#define HttpThreadH
|
||||
//---------------------------------------------------------------------------
|
||||
#define ERROR_OPEN_FILE 10
|
||||
#define ERROR_MEMORY 11
|
||||
#define ERROR_SIZE 12
|
||||
#define ERROR_INTERNET_OPEN 13
|
||||
#define ERROR_INTERNET_CONN 14
|
||||
#define ERROR_INTERNET_REQ 15
|
||||
#define ERROR_INTERNET_SEND 16
|
||||
#define ERROR_INTERNET_TMOUT 17
|
||||
#define ERROR_INTERNET_UNKNOWN 18
|
||||
#define ERROR_INTERNET_FORMAT 19
|
||||
#define ERROR_INTERNET_CANCEL 20
|
||||
#define ERROR_VCODE_NORET 21
|
||||
#define ERROR_VCODE_INVLEN 22
|
||||
#define ERROR_VCODE_INVDATA 23
|
||||
#define ERROR_VCODE_NOFUNC 24
|
||||
#define ERROR_VCODE_RCGFAIL 25
|
||||
|
||||
//#define MAX_KEY_NUM 32
|
||||
//#define MAX_STR_LEN 256
|
||||
|
||||
#define OP_VCODE 1
|
||||
#define OP_USERREG 2
|
||||
#define OP_USERLOG 3
|
||||
#define OP_HKCCHK 4
|
||||
#define OP_VCODEHDG 5
|
||||
#define OP_GETUSER 6
|
||||
#define OP_GETPROXY 7
|
||||
#define OP_SETWHITE 8
|
||||
#define OP_GETPROXYAPI 9
|
||||
#define OP_GETWHITEAPI 10
|
||||
|
||||
|
||||
typedef struct tBaseParam
|
||||
{
|
||||
int errCode;
|
||||
HINTERNET hSession,
|
||||
hRequest;
|
||||
|
||||
tBaseParam(){
|
||||
memset( this, 0, sizeof(tBaseParam) );
|
||||
};
|
||||
} TBaseParam;
|
||||
|
||||
typedef struct tVeloParam : public TBaseParam
|
||||
{
|
||||
char api[32];
|
||||
char addr[256];
|
||||
int port;
|
||||
DWORD flag;
|
||||
|
||||
HANDLE hSema;
|
||||
HINTERNET hConnect;
|
||||
|
||||
tVeloParam(){
|
||||
memset( this, 0, sizeof(tVeloParam) );
|
||||
};
|
||||
} TVeloParam;
|
||||
|
||||
typedef struct tHttpParam : public TBaseParam
|
||||
{
|
||||
char server[256];
|
||||
char api[32];
|
||||
int iMode;
|
||||
|
||||
HINTERNET hConnect;
|
||||
|
||||
DWORD sizeIn, sizeOut;
|
||||
char *dataIn, *dataOut;
|
||||
|
||||
// bool bGetDT;
|
||||
// DWORD dwDateTime;
|
||||
|
||||
tHttpParam(){
|
||||
memset( this, 0, sizeof(tHttpParam) );
|
||||
};
|
||||
} THttpParam;
|
||||
|
||||
typedef struct tProbParam : public TBaseParam
|
||||
{
|
||||
char server[256];
|
||||
|
||||
HANDLE hSema;
|
||||
|
||||
tProbParam(){
|
||||
memset( this, 0, sizeof(tProbParam) );
|
||||
};
|
||||
} TProbParam;
|
||||
|
||||
typedef struct tUrlParam : public TBaseParam
|
||||
{
|
||||
String url;
|
||||
String header;
|
||||
int sizeOut;
|
||||
char* dataOut;
|
||||
|
||||
tUrlParam(){
|
||||
memset( this, 0, sizeof(tUrlParam) );
|
||||
};
|
||||
} TUrlParam;
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
class TBaseWebThread : public TThread
|
||||
{
|
||||
protected:
|
||||
HWND m_hWnd;
|
||||
HANDLE m_hSema;
|
||||
|
||||
virtual void __fastcall Execute()=0;
|
||||
|
||||
public:
|
||||
__fastcall TBaseWebThread(HWND handle );
|
||||
__fastcall ~TBaseWebThread();
|
||||
|
||||
void __fastcall Cancel();
|
||||
};
|
||||
|
||||
class TAsynHttpThread : public TBaseWebThread //异步HTTP线程
|
||||
{
|
||||
private:
|
||||
char m_dataIn[10240];
|
||||
int m_sizeIn;
|
||||
|
||||
char m_server[256];
|
||||
String m_api;
|
||||
int m_iOp;
|
||||
int m_iMode;
|
||||
|
||||
protected:
|
||||
virtual void __fastcall Execute();
|
||||
public:
|
||||
__fastcall TAsynHttpThread(HWND handle, char* server, String api, char* dataIn, int sizeIn, int op=0, int mode=0 );
|
||||
|
||||
char m_dataOut[10240];
|
||||
int m_sizeOut;
|
||||
};
|
||||
|
||||
class TAsynUrlThread : public TBaseWebThread //异步URL访问线程
|
||||
{
|
||||
private:
|
||||
String m_url;
|
||||
String m_header;
|
||||
int& m_szOut;
|
||||
char* m_pzOut;
|
||||
int m_iOp;
|
||||
|
||||
protected:
|
||||
virtual void __fastcall Execute();
|
||||
|
||||
public:
|
||||
__fastcall TAsynUrlThread(HWND handle, String url, char* pzOut, int& szOut, int op=0, String header="");
|
||||
};
|
||||
|
||||
class TVeloThread : public TBaseWebThread //服务器选择线程
|
||||
{
|
||||
private:
|
||||
int m_nWS;
|
||||
char** m_websites;
|
||||
int* m_ports;
|
||||
int m_msWait;
|
||||
char m_sApi[128];
|
||||
|
||||
protected:
|
||||
virtual void __fastcall Execute();
|
||||
public:
|
||||
String m_sWebsite;
|
||||
__fastcall TVeloThread(HWND handle, int nWS, char* websites[], int ports[]=NULL, char* api="", int msWait=10000 );
|
||||
};
|
||||
|
||||
DWORD WINAPI ProbProc(LPVOID args); //服务器探测函数
|
||||
DWORD WINAPI HttpProc(LPVOID args); //同步线程函数
|
||||
DWORD WINAPI VeloProc(LPVOID args); //测速线程函数
|
||||
DWORD WINAPI UrlProc(LPVOID args); //URL访问函数
|
||||
bool IsPureUrl(String url); //url检查函数
|
||||
#endif
|
||||
Reference in New Issue
Block a user