url提前主机

bool Socket::GetHost(const char * url,char * host)
{
	try
	{	
		const char * before = url;
		const char * pUrl= url;

		char * pHost= host;

		bool bfind = false;
		while (*pUrl != 0 )
		{
			if (*pUrl == '/')
			{
				const char * p = pUrl;
				if (p[1] == '/')
				{
					pUrl = pUrl+2;
					bfind = true;
					continue;
				}
			}
			if (bfind)
			{
				if (*pUrl == '/')
				{
					break;
				}
			}
			if (bfind)
			{
				*pHost=*pUrl;
				pHost++;			
			}
			pUrl++;	
		}
	}
	catch(...)
	{
		std::cerr << "Caught exception: " <<  std::endl;
		
	}
	
	return true;
}

你可能感兴趣的:(url提前主机)