added: std::wstring Request::subdomain

support for subdomains



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@828 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-04-22 18:23:44 +00:00
parent bcea4f9464
commit baf10a9ba9
17 changed files with 110 additions and 11 deletions

View File

@@ -711,4 +711,49 @@ void RemovePostFileTmp(PostFileTab & post_file_tab);
/*
short_str is removed from long_str (and a last dots are removed too)
and the result is stored in out
sample:
short_str: "mydomain.tld"
long_str: "www.subdomain.mydomain.tld"
out: "www.subdomain"
short_str: "mydomain.tld"
long_str: "otherdifferentstring"
out: ""
*/
template<class StringType1, class StringType2, class StringType3>
void CreateSubdomain(const StringType1 * short_str, const StringType2 * long_str, StringType3 & out)
{
size_t i1, i2;
out.clear();
for(i1=0 ; short_str[i1] != 0 ; ++i1);
for(i2=0 ; long_str[i2] != 0 ; ++i2);
if( i1 >= i2 )
return;
// i1 is < i2
while( i1-- > 0 )
{
i2 -= 1;
if( short_str[i1] != long_str[i2] )
return; // short_str is not a last substring of long_str
}
while( i2>0 && long_str[i2-1] == '.' )
i2 -= 1;
for(i1=0 ; i1 < i2 ; ++i1)
out += long_str[i1];
}
#endif