get paid to paste

#pragma comment(lib, "Wininet.lib") //for InternetCrackUrl()

#define MAX_HOSTNAME_LENGTH 256
#define MAX_PATH_LENGTH 4096

/**
CUrlParser url(L"https://host/path/hoge.html");
assert(wcscmp(url.scheme, L"https")==0);
assert(wcscmp(url.hostName, L"host")==0);
assert(wcscmp(url.path, L"/path/hoge.html")==0);
assert(url.urlComp.nPort==443);
  */
class CUrlParser{

public:
	URL_COMPONENTSW urlComp;

	wchar_t scheme[10];
	wchar_t hostName[MAX_HOSTNAME_LENGTH];
	wchar_t path[MAX_PATH_LENGTH];

	CUrlParser(const wchar_t* url){
		::memset(&urlComp,0,sizeof(urlComp));
		urlComp.dwStructSize=sizeof(urlComp);
		urlComp.lpszScheme=scheme;
		urlComp.dwSchemeLength=10;
		urlComp.lpszHostName=hostName;
		urlComp.dwHostNameLength=MAX_HOSTNAME_LENGTH;
		urlComp.lpszUrlPath=path;
		urlComp.dwUrlPathLength=MAX_PATH_LENGTH;

		InternetCrackUrlW(url, 0, 0, &urlComp);
	}
};

Pasted: Apr 17, 2009, 7:16:06 am
Views: 375