TSE源码分析-url.h

//根据一个给定的URL,组成消息体,发送给该URL指向的服务器。

//为此,定义Url类
//url.h
#ifndef _URL_H_030728_
#define _URL_H_030728_

#include<string>

//定义URL和HOST长度

const unsigned int URL_LEN=256;
const unsigned int HOST_LEN= 256;

using namespace std;

//URL类型为HTTP、FTP、或无效
enum url_scheme {
SCHEME_HTTP,
SCHEME_FTP,
SCHEME_INVALID
};

//定义HTTP和FTP的默认端口

const int DEFAULT_HTTP_PORT = 80;
const int DEFAULT_FTP_PORT = 21;

class CUrl
{
public:
stringm_sUrl;//Original URL
enum url_scheme m_eScheme;//URL scheme

stringm_sHost;//Extracted hostname
intm_nPort;//Port number
stringm_sPath;//请求

public:
CUrl();
~CUrl();

//bool ParseUrl(string strUrl);

//解析URL的scheme, host, port and request

// break an URL into scheme,host, port and request.
// result as member variants
bool ParseUrlEx(string strUrl);

//解析URL的scheme, host, port and request

// break an URL into scheme, host, port andrequest.
// result url as argvs

//解析URL的scheme, host, port and request
void ParseUrlEx(const char *url, char *protocol,int lprotocol,
char *host,int lhost,
char*request, int lrequest, int *port);

// get the ip address by hostname通过主机名得到IP
char *GetIpByHost(const char *host);

//基本判断函数

bool IsValidHost(const char *ip);
bool IsForeignHost(string host);
bool IsImageUrl(string url);
bool IsValidIp(const char *ip);
bool IsVisitedUrl(const char *url);
bool IsUnReachedUrl(const char *url);
bool IsValidHostChar(char ch);

private:
void ParseScheme (const char *url);

};

extern pthread_mutex_t mutexMemory;

#endif

你可能感兴趣的:(Scheme)