31 using namespace SLNet;
 
   39 class RakStringCleanup
 
   86     Assign((
const char*) format,ap);
 
  165     if (bytes<= inSharedString->bytesUsed)
 
  169     size_t oldBytes = inSharedString->
bytesUsed;
 
  171     const size_t smallStringSize = 128-
sizeof(
unsigned int)-
sizeof(
size_t)-
sizeof(
char*)*2;
 
  173     if (oldBytes <=(
size_t) smallStringSize && newBytes > (
size_t) smallStringSize)
 
  179     else if (oldBytes > smallStringSize)
 
  206     if (str==0 || str[0]==0)
 
  321     size_t allocatedBytes = len1 + len2 + 1;
 
  331         for (i=0; i < 128; i++)
 
  346     const int smallStringSize = 128-
sizeof(
unsigned int)-
sizeof(
size_t)-
sizeof(
char*)*2;
 
  349     if (allocatedBytes <= (
size_t) smallStringSize)
 
  370     for (i=0; i < strLen; i++)
 
  380     for (i=0; i < strLen; i++)
 
  387     va_start(ap, format);
 
  421             case 0xE0: i += 3; 
break;
 
  422             case 0xF0: i += 4; 
break;
 
  423             default:   i += 2; 
break;
 
  437     unsigned countIndex=0;
 
  438     while (countIndex<count)
 
  464 WCHAR * RakString::ToWideChar(
void)
 
  472         WCHAR* buf = SLNet::OP_NEW_ARRAY<WCHAR>(1, __FILE__, __LINE__);
 
  480     int cchUTF16 = ::MultiByteToWideChar(
 
  491         RakAssert(
"RakString::ToWideChar exception from cchUTF16==0" && 0);
 
  498     WCHAR * pszUTF16 = SLNet::OP_NEW_ARRAY<WCHAR>(cchUTF16,__FILE__,__LINE__);
 
  503     int result = ::MultiByteToWideChar(
 
  514         RakAssert(
"RakString::ToWideChar exception from MultiByteToWideChar" && 0);
 
  520 void RakString::DeallocWideChar(WCHAR * w)
 
  524 void RakString::FromWideChar(
const wchar_t *source)
 
  527     size_t bufSize = wcslen(source)*4;
 
  530     if (bufSize > static_cast<size_t>(std::numeric_limits<int>::max())) {
 
  531         RakAssert(
"RakString::FromWideChar given string is too long and cannot be converted");
 
  536     WideCharToMultiByte ( CP_ACP,                
 
  545                           static_cast<int>(bufSize),  
 
  554     rs.FromWideChar(source);
 
  561     if (pos>=len || stringToFind==0 || stringToFind[0]==0)
 
  565     size_t matchLen= strlen(stringToFind);
 
  569     for (
size_t i=pos;i<len;i++)
 
  584         if (matchPos>=matchLen)
 
  596     unsigned int count = 0;
 
  613             case 0xE0: i += 3; 
break;
 
  614             case 0xF0: i += 4; 
break;
 
  615             default:   i += 2; 
break;
 
  634     if (index >= length || count==0)
 
  637     size_t numBytes = length-index;
 
  638     if (count < numBytes)
 
  642     for (i=0; i < numBytes; i++)
 
  654     for (i=index; i < len-count; i++)
 
  663     for (i=len-1; i >= 0; i--)
 
  676     for (i=len-1; i >= 0; i--)
 
  691     unsigned int i, len=(
unsigned int) 
GetLength();
 
  692     for (i=0; i < len; i++)
 
  706     unsigned int i, len=(
unsigned int) 
GetLength();
 
  707     for (i=0; i < len; i++)
 
  723     unsigned int i, len=(
unsigned int) 
GetLength();
 
  724     for (i=0; i < len; i++)
 
  738     unsigned int readIndex, writeIndex=0;
 
  772     unsigned characterIndex;
 
  774     if ( IP == 0 || IP[ 0 ] == 0 || strlen( IP ) > 15 )
 
  784             if ( IP[ characterIndex ] == 0 )
 
  822     for (i=0; i < strLen; i++)
 
  840     for (i=0; i < strLen; i++)
 
  846     for (i=0; i < strLen; i++)
 
  856     for (i=0; i < strLen; i++)
 
  875     unsigned int outputIndex=0;
 
  878     for (i=0; i < strLen; i++)
 
  890             output[outputIndex++]=
'%';
 
  891             output[outputIndex++]=buff[0];
 
  892             output[outputIndex++]=buff[1];
 
  896             output[outputIndex++]=c;
 
  900     output[outputIndex]=0;
 
  911     unsigned int outputIndex=0;
 
  916     for (i=0; i < strLen; i++)
 
  924             if (hexDigits[0]==
' ')
 
  927             if (hexDigits[0]>=
'A' && hexDigits[0]<=
'F')
 
  928                 hexValues[0]=hexDigits[0]-
'A'+10;
 
  929             if (hexDigits[0]>=
'a' && hexDigits[0]<=
'f')
 
  930                 hexValues[0]=hexDigits[0]-
'a'+10;
 
  932                 hexValues[0]=hexDigits[0]-
'0';
 
  934             if (hexDigits[1]>=
'A' && hexDigits[1]<=
'F')
 
  935                 hexValues[1]=hexDigits[1]-
'A'+10;
 
  936             if (hexDigits[1]>=
'a' && hexDigits[1]<=
'f')
 
  937                 hexValues[1]=hexDigits[1]-
'a'+10;
 
  939                 hexValues[1]=hexDigits[1]-
'0';
 
  941             output[outputIndex++]=hexValues[0]*16+hexValues[1];
 
  945             output[outputIndex++]=c;
 
  949     output[outputIndex]=0;
 
  965         i+=(
unsigned int) strlen(
"http://");
 
  967         i+=(
unsigned int) strlen(
"https://");
 
  970         i+=(
unsigned int) strlen(
"www.");
 
  982     unsigned int outputIndex=0;
 
  983     for (; i < strLen; i++)
 
  996     domainOutput[outputIndex]=0;
 
 1001     for (; i < strLen; i++)
 
 1005     pathOutput[outputIndex]=0;
 
 1010     int escapedCharacterCount=0;
 
 1012     for (index=0; index < strLen; index++)
 
 1017             escapedCharacterCount++;
 
 1019     if (escapedCharacterCount==0)
 
 1024     int writeIndex, readIndex;
 
 1025     writeIndex = strLen+escapedCharacterCount;
 
 1027     while (readIndex>=0)
 
 1051     uriRs.
SplitURI(header, host, remotePath);
 
 1059     if (extraHeaders!=0 && extraHeaders[0])
 
 1061         out.
Set(
"%s %s HTTP/1.1\r\n" 
 1064             "Content-Type: %s\r\n" 
 1065             "Content-Length: %u\r\n" 
 1080         out.
Set(
"%s %s HTTP/1.1\r\n" 
 1082             "Content-Type: %s\r\n" 
 1083             "Content-Length: %u\r\n" 
 1115     uriRs.
SplitURI(header, host, remotePath);
 
 1119     if (extraHeaders && extraHeaders[0])
 
 1121         out.
Set(
"GET %s HTTP/1.1\r\n" 
 1131         out.
Set(
"GET %s HTTP/1.1\r\n" 
 1151     uriRs.
SplitURI(header, host, remotePath);
 
 1155     if (extraHeaders && extraHeaders[0])
 
 1157         out.
Set(
"DELETE %s HTTP/1.1\r\n" 
 1159             "Content-Length: 0\r\n" 
 1161             "Connection: close\r\n" 
 1169         out.
Set(
"DELETE %s HTTP/1.1\r\n" 
 1170             "Content-Length: 0\r\n" 
 1172             "Connection: close\r\n" 
 1186     fixedString.
Clone();
 
 1210     if (fixedString!=*
this)
 
 1211         *
this = fixedString;
 
 1235     unsigned short l = (
unsigned short) strlen(str);
 
 1245     if (writeLanguageId)
 
 1304     static char buff[64][64];
 
 1306     sprintf_s(buff[index], 
"%I64d", i);
 
 1308     sprintf_s(buff[index], 
"%lld", (
long long unsigned int) i);
 
 1310     int lastIndex=index;
 
 1313     return buff[lastIndex];
 
 1318     static char buff[64][64];
 
 1320     sprintf_s(buff[index], 
"%I64u", i);
 
 1322     sprintf_s(buff[index], 
"%llu", (
long long unsigned int) i);
 
 1324     int lastIndex=index;
 
 1327     return buff[lastIndex];
 
 1341         for (i=0; i < 128; i++)
 
 1357     const size_t smallStringSize = 128-
sizeof(
unsigned int)-
sizeof(
size_t)-
sizeof(
char*)*2;
 
 1359     if (len <= smallStringSize)
 
 1373     if (str==0 || str[0]==0)
 
 1379     size_t len = strlen(str)+1;
 
 1385     if (str==0 || str[0]==0)
 
 1391     char stackBuff[512];
 
 1392     int numChars = vsnprintf_s(stackBuff, 511, str, ap);
 
 1398     char *buff=0, *newBuff;
 
 1399     size_t buffSize=8096;
 
 1402         newBuff = (
char*) 
rakRealloc_Ex(buff, buffSize,__FILE__,__LINE__);
 
 1418         if (vsnprintf_s(buff, buffSize, buffSize-1, str, ap)!=-1)
 
 1429     size_t incomingLen=strlen(str);
 
 1433     if (str==0 || str[0]==0||pos>=incomingLen)
 
 1439     if (pos+n>=incomingLen)
 
 1444     const char * tmpStr=&(str[pos]); 
 
 1462     unsigned long hash = 0;
 
 1465     while ((c = *str++))
 
 1466         hash = c + (hash << 6) + (hash << 16) - hash;
 
 1479     for (
size_t i=0; i < n; i++)
 
 1494         unsigned int length=(
unsigned int) 
GetLength();
 
 1531         const size_t smallStringSize = 128-
sizeof(
unsigned int)-
sizeof(
size_t)-
sizeof(
char*)*2;
 
 1554     if (c >= 
'A' && c <= 
'Z')
 
 1560     if (c >= 
'a' && c <= 
'z')