本文整理汇总了C++中xbox::VString::ToCString方法的典型用法代码示例。如果您正苦于以下问题:C++ VString::ToCString方法的具体用法?C++ VString::ToCString怎么用?C++ VString::ToCString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xbox::VString
的用法示例。
在下文中一共展示了VString::ToCString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _FormatCurrentVTaskInfos
void VCacheLog::_FormatCurrentVTaskInfos(bool inForTags)
{
XBOX::VString taskName;
char nameCStr[256] = {0};
VTask *currentTask = VTask::GetCurrent();
currentTask->GetName(taskName);
taskName.ToCString(nameCStr, 256);
sLONG pNum = 0;
if(currentTask->GetKind() == '4dut')
pNum = (sLONG) currentTask->GetKindData();
/********* WARNING **********
fVTaskInfos is char[512]. If you add more infos, think about increasing its size
*/
fVTaskInfos[0] = 0;
if(inForTags)
{
sprintf(fVTaskInfos, "tname=\"%s\" pnum=\"%d\"", nameCStr, pNum);
}
else
{
sprintf(fVTaskInfos, "%s\t%d", nameCStr, pNum);
}
}
示例2: GetIPv4FromString
void GetIPv4FromString (const XBOX::VString& inIPv4String, IP4& outIPv4)
{
sLONG hostNameSize = inIPv4String.GetLength() + 1;
char * hostName = new char[hostNameSize];
outIPv4 = INADDR_NONE;
if (NULL != hostName)
{
struct hostent * remoteHost = NULL;
struct in_addr addr = {0};
inIPv4String.ToCString (hostName, hostNameSize);
if (isalpha (hostName[0])) // host address is a name
{
remoteHost = gethostbyname (hostName);
}
else
{
addr.s_addr = inet_addr (hostName);
if (addr.s_addr != INADDR_NONE)
remoteHost = gethostbyaddr ((char *) &addr, 4, AF_INET);
}
if (NULL != remoteHost)
outIPv4 = *((sLONG *)remoteHost->h_addr_list[0]);
delete [] hostName;
}
}
示例3: SetProxy
void HttpRequest::SetProxy(const XBOX::VString& inHost, uLONG inPort)
{
if(!fHandle)
return;
char host[CW_PROXY_SIZE];
inHost.ToCString(host, sizeof(host));
//si proxy est une chaine vide, aura pour effet de supprimer le proxy
curl_easy_setopt(fHandle, CURLOPT_PROXY, host);
if(inPort>0) //Par defaut, libcURL utilise le port 1080
curl_easy_setopt(fHandle, CURLOPT_PROXYPORT, inPort);
}
示例4: ReadFromStream
XBOX::VError VHTTPMessage::ReadFromStream (XBOX::VStream& inStream, const XBOX::VString& inBoundary)
{
#define MAX_BUFFER_LENGTH 32768
const char HTTP_CR = '\r';
const char HTTP_LF = '\n';
const char HTTP_CRLF [] = { HTTP_CR, HTTP_LF, 0 };
const char HTTP_CRLFCRLF [] = { HTTP_CR, HTTP_LF, HTTP_CR, HTTP_LF, 0 };
XBOX::VError streamError = XBOX::VE_OK;
HTTPParsingState parsingState;
XBOX::VError parsingError = XBOX::VE_OK;
XBOX::VSize bufferSize = MAX_BUFFER_LENGTH;
char * buffer = (char *)XBOX::vMalloc (bufferSize, 0);
XBOX::VSize bufferOffset = 0;
XBOX::VSize unreadBytes = 0;
sLONG lineLen = 0;
XBOX::VString header;
XBOX::VString value;
char * startLinePtr = NULL;
char * endLinePtr = NULL;
char * endHeaderPtr = NULL;
sLONG endLineSize = sizeof (HTTP_CRLF) - 1;
sLONG contentLength = 0;
void * bodyContentBuffer = NULL;
XBOX::VSize bodyContentSize = 0;
const sLONG MAX_REQUEST_ENTITY_SIZE = XBOX::MaxLongInt;
XBOX::VString boundaryEnd;
char * boundary = NULL;
bool stopReadingStream = false;
if (!inBoundary.IsEmpty())
{
boundaryEnd.AppendString ("--");
boundaryEnd.AppendString (inBoundary);
boundary = new char[boundaryEnd.GetLength() + 1];
if (NULL != boundary)
boundaryEnd.ToCString (boundary, boundaryEnd.GetLength() + 1);
}
if (NULL == buffer)
return XBOX::VE_MEMORY_FULL;
parsingState = PS_ReadingHeaders;
XBOX::StErrorContextInstaller errorContext (XBOX::VE_STREAM_EOF, XBOX::VE_OK);
bool isAlreadyReading = inStream.IsReading();
if (!isAlreadyReading)
streamError = inStream.OpenReading();
while ((XBOX::VE_OK == streamError) && !stopReadingStream)
{
if (0 == unreadBytes)
bufferOffset = 0;
bufferSize = MAX_BUFFER_LENGTH - bufferOffset;
streamError = inStream.GetData (buffer + bufferOffset, &bufferSize);
unreadBytes = (bufferSize + bufferOffset);
bufferOffset = 0;
while ((unreadBytes > 0) && (XBOX::VE_OK == parsingError))
{
if (parsingState <= PS_ReadingHeaders)
{
startLinePtr = buffer + bufferOffset;
endLinePtr = strstr (startLinePtr, HTTP_CRLF);
if ((NULL != endLinePtr) && (NULL == endHeaderPtr))
endHeaderPtr = strstr (startLinePtr, HTTP_CRLFCRLF);
}
/* Start to parse the Status-Line */
switch (parsingState)
{
case PS_ReadingHeaders:
{
if (NULL != endLinePtr)
{
if (startLinePtr != (endHeaderPtr + endLineSize))
{
if (_ExtractHeaderValuePair (startLinePtr, endLinePtr, header, value))
{
GetHeaders().SetHeaderValue (header, value, false);
}
}
else /*if (startLinePtr == endHeaderPtr)*/
{
parsingState = PS_ReadingBody;
XBOX::VString contentLengthString;
if (GetHeaders().GetHeaderValue (STRING_HEADER_CONTENT_LENGTH, contentLengthString))
contentLength = HTTPTools::GetLongFromString (contentLengthString);
}
}
break;
}
//.........这里部分代码省略.........