コード例 #1
0
void AXMLAttribute::AppendRawData(VString &pDestination) const
{
	pDestination.AppendString(fName);
	pDestination.AppendCString("=\"");
	pDestination.AppendString(fValue);
	pDestination.AppendCString("\"");
}
コード例 #2
0
void AXMLComment::AppendRawData(VString &pDestination,bool pIndented) const
{
	if (pIndented)
		SetIndent(pDestination);
	pDestination.AppendCString("<!--");
	pDestination.AppendString(fComment);
	pDestination.AppendCString("-->");
}
コード例 #3
0
void AXMLCData::AppendRawData(VString &pDestination,bool pIndented) const
{
	if (pIndented)
		SetIndent(pDestination);
	pDestination.AppendCString("<![CDATA[");
	pDestination.AppendString(fCData);
	pDestination.AppendCString("]]>");
}
コード例 #4
0
void AXMLElement::AppendRawData(VString &pDestination,bool pIndented) const
{
	AXMLGenericElement		*elem;
	AXMLAttribute			*attr;

	if (pIndented)
		SetIndent(pDestination);

	pDestination.AppendCString("<");
	pDestination.AppendString(fElementName);
	
	// attributs
	attr = fFirstAttribute;
	while(attr)
	{
		pDestination.AppendCString(" ");
		attr->AppendRawData(pDestination);
		attr = attr->fNext;
	}
	

	if (!fFirstChild)
	{	
		pDestination.AppendCString(" />");
	}
	else
	{
		pDestination.AppendCString(">");

		// enfants
		elem = Get_FirstChild();
		while (elem)
		{
			elem->AppendRawData(pDestination,pIndented);
			elem = elem->GetNext();
		}
		
		if (pIndented)
			SetIndent(pDestination);
		pDestination.AppendCString("</");
		pDestination.AppendString(fElementName);
		pDestination.AppendCString(">");
	}

}
コード例 #5
0
void AXMLDOCTYPE::AppendRawData(VString &pDestination,bool pIndented) const
{

	if (pIndented)
		SetIndent(pDestination);
	pDestination.AppendCString("<!DOCTYPE ");
	pDestination.AppendString(fDOCTYPE);
	pDestination.AppendCString(">");
}
コード例 #6
0
void AXMLDocument::AppendRawData(VString &pDestination,bool pIndented) const
{
	AXMLGenericElement		*elem;

	pDestination.AppendCString("<?xml version=\"");
	pDestination.AppendString(fVersion);
	pDestination.AppendCString("\" encoding=\"");
	pDestination.AppendString(fEncoding);
	pDestination.AppendCString("\"?>");

	elem = Get_FirstChild();
	while (elem)
	{
		elem->AppendRawData(pDestination,pIndented);
//		pDestination.AppendCString((uBYTE*)pDestination.LockAndGetCPointer());
//		pDestination.Unlock();
		elem = elem->GetNext();
	}
}
コード例 #7
0
wchar_t * XWinProcessLauncher::_CreateConcatenetedArguments()
{
	sLONG		nbArguments	= (sLONG) fArrayArg.size();
	wchar_t *	theArgs		= NULL;
	
	if(nbArguments < 1)
	{
		theArgs = new wchar_t[1];
		theArgs[0] = 0;
	}
	else
	{
		VString		concatenetedArgs;
		concatenetedArgs.SetEmpty();
		
		for(sLONG i = 0; i < nbArguments; ++i)
		{
			// ACI0065260 - 2010-03-11, T.A.
			// Add quotes if the path contains a space and is not already quoted
			if( !fArrayArg[i].IsEmpty() && fArrayArg[i].FindUniChar(CHAR_SPACE) > 0 && fArrayArg[i][0] != CHAR_QUOTATION_MARK )
			{
				VString		quotedArg;

				quotedArg = CHAR_QUOTATION_MARK;
				quotedArg += fArrayArg[i];
				quotedArg += CHAR_QUOTATION_MARK;

				concatenetedArgs.AppendString(quotedArg);
			}
			else
			{
				concatenetedArgs.AppendString(fArrayArg[i]);
			}
			if(i < (nbArguments - 1))
				concatenetedArgs.AppendChar(' ');
		}

		theArgs = _CreateCString(concatenetedArgs, true);
	}
	
	return theArgs;
}
コード例 #8
0
ファイル: VValueBag.cpp プロジェクト: StephaneH/core-XToolbox
void VValueBag::DumpXMLCData( VString& ioDump, VIndex inCDataAttributeIndex) const
{
	VStr<1000> cdata;

	GetNthAttribute( inCDataAttributeIndex, NULL)->GetString( cdata);

	if (NeedsEscapeSequence( cdata, sXMLEscapeChars_Contents, sXMLEscapeChars_Contents + sizeof(sXMLEscapeChars_Contents)/sizeof(UniChar)))
	{
		ioDump += CVSTR( "<![CDATA[");

		// see if there's a "]]>" for which we need to split
		// someting like: hello ]]> world
		// becomes: <![CDATA[hello ]]>]]<![CDATA[> world]]>
		
		VIndex pos = 1;
		while( pos <= cdata.GetLength())
		{
			VIndex endTag = cdata.Find( CVSTR( "]]>"), pos, true);
			if (endTag > 0)
			{
				// add everything including ]]>
				ioDump.AppendBlock( cdata.GetCPointer() + pos - 1, (endTag - pos + 3) * sizeof( UniChar), VTC_UTF_16);
				// add ]] outside CDATA section
				ioDump.AppendString( CVSTR( "]]"));
				// open a new CDATA section and add remaining >
				ioDump += CVSTR( "<![CDATA[>");
				pos = endTag + 3;
			}
			else
			{
				// add everything left
				ioDump.AppendBlock( cdata.GetCPointer() + pos - 1, (cdata.GetLength() - pos + 1) * sizeof( UniChar), VTC_UTF_16);
				break;
			}
		}
		ioDump += CVSTR( "]]>");
	}
	else
	{
		VString toInsert;
		for (sLONG i = 0, n = cdata.GetLength(); i < n; i++)
		{
			UniChar c = cdata[ i ];
			if (c != 13 && c != 10 && c != 9)
			{
				toInsert += c;
			}
		}
		if ( ! toInsert.IsEmpty() )
			ioDump += toInsert;
	}
}
コード例 #9
0
void AXMLElement::GetData( VString &pCData)
{
	AXMLGenericElement	*elem;
	VString			vCData;

	vCData.Clear();
	pCData.Clear();
	elem = Get_FirstChild();
	while (elem) {
		elem->GetData(vCData);
		pCData.AppendString(vCData);
//		pCData.AppendChar((uBYTE)0x0D);
		elem = elem->GetNext();
	}
}
コード例 #10
0
VError VServiceDiscoveryClient::_EncodePTRQuery (uBYTE *outBuffer, uLONG *ioSize, const VString &inServiceName, uWORD inIdentifier)
{
	xbox_assert(outBuffer != NULL && ioSize != NULL);
	
	uBYTE	*p;
	VString	vString;
	uLONG	size;
	VError	error;
	
	if (*ioSize < 12) 
	
		return VE_SRVR_BONJOUR_CANT_FIT_PACKET;
	
	p = outBuffer;
	
	::memset(p, 0, 12);
	Bonjour::Write2Bytes(p, inIdentifier);
	Bonjour::Write2Bytes(p + 4, 1);
	p += 12;
	
	vString = inServiceName;
	vString.AppendString(".local");
	size = *ioSize - 12;
	if ((error = Bonjour::EncodeDNSName(p, &size, vString)) != VE_OK)
		
		return error;
	
	p += size;
	
	if (*ioSize < 12 + size + 4) 
			
		return VE_SRVR_BONJOUR_CANT_FIT_PACKET;
	
	Bonjour::Write2Bytes(p, Bonjour::kTypePTR);
	Bonjour::Write2Bytes(p + 2, 1);

	xbox_assert(*ioSize >=  12 + size + 4);		// Check encoded packet size.
	*ioSize = 12 + size + 4;	
	
	return VE_OK;
}
コード例 #11
0
VString VNetAddress::GetProperties(const VString& inSep) const
{
	VString props;

	xbox_assert(IsV4() || IsV6());
	xbox_assert(!(IsV4() && IsV6()));

#if !VERSIONWIN
	if(!GetName().IsEmpty())
		props.AppendString(GetName()).AppendString(inSep);
#endif
	
	props.AppendCString(IsV4() ? "v4" : "");
	props.AppendCString(IsV6() ? "v6" : "");

	if(IsV4MappedV6())
		props.AppendString(inSep).AppendCString("v4 mapped v6");
	
	if(IsLoopBack())
		props.AppendString(inSep).AppendCString("loopback");
	
	if(IsAny())
		props.AppendString(inSep).AppendCString("any");
	
	if(IsAPIPA())
		props.AppendString(inSep).AppendCString("APIPA");
	
	if(IsULA())
		props.AppendString(inSep).AppendCString("ULA");
	
	if(IsLocal())
		props.AppendString(inSep).AppendCString("Local");
	
	if(IsLocallyAssigned())
		props.AppendString(inSep).AppendCString("LocallyAssigned");

	return props;
}
コード例 #12
0
ファイル: VValueBag.cpp プロジェクト: StephaneH/core-XToolbox
void VValueBag::AppendToCData( const VString& inValue)
{
	VValueSingle *val = fAttributes.GetValue( CDataAttributeName());
	if (val != NULL)
	{
		VString *val_str = dynamic_cast<VString*>( val);
		if (val_str)
			val_str->AppendString( inValue);
		else
		{
			VString *temp = new VString;
			if (temp)
			{
				val->GetString( *temp);
				temp->AppendString( inValue);
				fAttributes.Replace( val, temp);
			}
		}
	}
	else
	{
		fAttributes.SetValue( CDataAttributeName(), inValue);
	}
}
コード例 #13
0
void VSysLogOutput::Put( std::vector< const XBOX::VValueBag* >& inValuesVector)
{
	for (std::vector< const XBOX::VValueBag* >::iterator bagIter = inValuesVector.begin() ; bagIter != inValuesVector.end() ; ++bagIter)
	{
		EMessageLevel bagLevel = ILoggerBagKeys::level.Get( *bagIter);
		if ((fFilter & (1 << bagLevel)) != 0)
		{
			VString logMsg;
						
			VError errorCode = VE_OK;
			ILoggerBagKeys::error_code.Get( *bagIter, errorCode);
		
			VString loggerID;
			ILoggerBagKeys::source.Get( *bagIter, loggerID);
			
			OsType componentSignature = 0;
			if (!ILoggerBagKeys::component_signature.Get( *bagIter, componentSignature))
				componentSignature = COMPONENT_FROM_VERROR( errorCode);
			
			if (componentSignature != 0)
			{
				if (!loggerID.IsEmpty())
					loggerID.AppendUniChar( L'.');
				loggerID.AppendOsType( componentSignature);
			}
			
			if (!loggerID.IsEmpty())
				logMsg.Printf( "[%S]", &loggerID);
			
			// build message string
			VString message;
			
			if (errorCode != VE_OK)
				message.AppendPrintf( "error %d", ERRCODE_FROM_VERROR( errorCode));
			
			VString bagMsg;
			if (ILoggerBagKeys::message.Get( *bagIter, bagMsg))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( bagMsg);
			}
						
			sLONG taskId=-1;
			if (ILoggerBagKeys::task_id.Get( *bagIter, taskId))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L"task #");
				message.AppendLong( taskId);
			}
			
			VString taskName;
			if (!ILoggerBagKeys::task_name.Get( *bagIter, taskName))
				VTask::GetCurrent()->GetName( taskName);
			if (!taskName.IsEmpty())
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( taskName);
			}
			
			sLONG socketDescriptor=-1;
			if (ILoggerBagKeys::socket.Get( *bagIter, socketDescriptor))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L"socket ");
				message.AppendLong(socketDescriptor);
			}
			
			VString localAddr;
			if (ILoggerBagKeys::local_addr.Get( *bagIter, localAddr))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L"local addr is ");
				message.AppendString( localAddr);
			}
			
			VString peerAddr;
			if (ILoggerBagKeys::peer_addr.Get( *bagIter, peerAddr))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L"peer addr is ");
				message.AppendString( peerAddr);
			}
			
			bool exchangeEndPointID=false;
			if (ILoggerBagKeys::exchange_id.Get( *bagIter, exchangeEndPointID))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( (exchangeEndPointID) ? L"exchange endpoint id" : L"do not exchange endpoint id");
			}
			
			bool isBlocking=false;
			if (ILoggerBagKeys::is_blocking.Get( *bagIter, isBlocking))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( (isBlocking) ? L"is blocking" : L"is not blocking");
			}
			
			bool isSSL=false;
			if (ILoggerBagKeys::is_ssl.Get( *bagIter, isSSL))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( (isSSL) ? L"with SSL" : L"without SSL");
			}
			
			bool isSelectIO=false;
			if (ILoggerBagKeys::is_select_io.Get( *bagIter, isSelectIO))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( (isSelectIO) ? L"with SelectIO" : L"without SelectIO");
			}
			
			sLONG ioTimeout=-1;
			if (ILoggerBagKeys::ms_timeout.Get( *bagIter, ioTimeout))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L"with ");
				message.AppendLong( ioTimeout);
				message.AppendString( L"ms timeout");
			}
			
			sLONG askedCount=-1;
			if (ILoggerBagKeys::count_bytes_asked.Get( *bagIter, askedCount))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L"asked for ");
				message.AppendLong( askedCount);
				message.AppendString( L" byte(s)");
			}
			
			sLONG sentCount=-1;
			if (ILoggerBagKeys::count_bytes_sent.Get(*bagIter, sentCount))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L"sent ");
				message.AppendLong( sentCount);
				message.AppendString( L" byte(s)");
			}
			
			sLONG receivedCount=-1;
			if (ILoggerBagKeys::count_bytes_received.Get( *bagIter, receivedCount))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L"received ");
				message.AppendLong( receivedCount);
				message.AppendString( L" byte(s)");
			}
			
			sLONG ioSpent=-1;
			if (ILoggerBagKeys::ms_spent.Get( *bagIter, ioSpent))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L"done in ");
				message.AppendLong( ioSpent);
				message.AppendString( L"ms");
			}
			
			sLONG dumpOffset=-1;
			if (ILoggerBagKeys::dump_offset.Get( *bagIter, dumpOffset))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L"offset ");
				message.AppendLong( dumpOffset);
			}
			
			VString dumpBuffer;
			if (ILoggerBagKeys::dump_buffer.Get( *bagIter, dumpBuffer))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L"data : ");
				message.AppendString( dumpBuffer);
			}
			
			VString fileName;
			if (ILoggerBagKeys::file_name.Get( *bagIter, fileName))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( fileName);
			}
			
			sLONG lineNumber;
			if (ILoggerBagKeys::line_number.Get( *bagIter, lineNumber))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendLong( lineNumber);
			}
			
			VString stackCrawl;
			if (ILoggerBagKeys::stack_crawl.Get( *bagIter, stackCrawl))
			{
				if (!message.IsEmpty())
					message.AppendString( L", ");
				message.AppendString( L", {");
				stackCrawl.ExchangeAll( L"\n", L" ; ");
				message.AppendString( stackCrawl);
				message.AppendUniChar( L'}');
			}
			
			if (!logMsg.IsEmpty())
				logMsg.AppendUniChar( L' ');
			logMsg.AppendString( message);
			
			if (!logMsg.IsEmpty())
			{
				StStringConverter<char> messageConverter( VTC_StdLib_char);
		
				switch( bagLevel)
				{
					case EML_Dump:
					case EML_Assert:
					case EML_Debug:
						syslog( LOG_DEBUG, messageConverter.ConvertString( logMsg));
						break;
						
					case EML_Trace:
						syslog( LOG_NOTICE, messageConverter.ConvertString( logMsg));
						break;

					case EML_Information:
						syslog( LOG_INFO, messageConverter.ConvertString( logMsg));
						break;
							   
					case EML_Warning:
						syslog( LOG_WARNING, messageConverter.ConvertString( logMsg));
						break;
							   
					case EML_Error:
						syslog( LOG_ERR, messageConverter.ConvertString( logMsg));
						break;
						
					case EML_Fatal:
						syslog( LOG_CRIT, messageConverter.ConvertString( logMsg));
						break;
							   
				   default:
					   assert(false);
					   break;
				}
			}
		}
	}
}
コード例 #14
0
void VJSONWriter::AppendIndentString( VString& ioString)
{
    if ( (fOptions & JSON_PrettyFormatting) != 0)
        ioString.AppendString( fIndentStringCurrentLevel);
}
コード例 #15
0
VError VServiceDiscoveryServer::_SendServiceList (VUDPEndPoint *inEndPoint, uBYTE *ioPacket, uLONG inBufferSize, uLONG inOffset)
{
	xbox_assert(inEndPoint != NULL);
	xbox_assert(ioPacket != NULL);
	
	VError									error;
	std::list<VServiceRecord>::iterator		i;
	std::map<VString, bool>					allServices;
	std::map<VString, bool>::iterator		j;
	
	error = VE_OK;

	for (i = fServiceRecords.begin(); i != fServiceRecords.end(); i++)

		allServices[i->fServiceName] = true;
	
	for (j = allServices.begin(); j != allServices.end(); ) {
		
		uBYTE	*p, *q, buffer[Bonjour::kBufferSize];
		uLONG	size, dataSize, numberPTRs;
		VString	serviceName;

		p = &ioPacket[inOffset];
		q = ioPacket + inBufferSize;

		// Try to pack as many PTR resource records as possible in each packet.

		numberPTRs = 0;
		for ( ; j != allServices.end(); j++) {
			
			serviceName = j->first;
			serviceName.AppendString(".");
			
			dataSize = Bonjour::kMaximumNameLength + 1;
			size = q - p;	
			if ((error = Bonjour::EncodeDNSName(buffer, &dataSize, serviceName)) != VE_OK	
			|| (error = Bonjour::EncodeResourceRecord(p, &size, 
													  "_services._dns-sd._udp.local", Bonjour::kTypePTR, 
													  buffer, dataSize, 
													  Bonjour::kDefaultTimeToLive)) != VE_OK) {

				if (error == VE_SRVR_BONJOUR_CANT_FIT_PACKET) 

					break;		// Packet is full, send it.

				else 
										
					continue;	// Silently ignore any other form of error.

			} else {

				p += size;
				numberPTRs++;

			}

		}

		if (numberPTRs) {

			ioPacket[2] |= 0x80;
			Bonjour::Write2Bytes(&ioPacket[6], numberPTRs);
			Bonjour::Write2Bytes(&ioPacket[8], 0);
			Bonjour::Write2Bytes(&ioPacket[10], 0);

			xbox_assert(p - ioPacket <= inBufferSize);
			inEndPoint->WriteExactly(ioPacket, p - ioPacket);

		}
	}
	
	return error;
}
コード例 #16
0
void AXMLText::AppendRawData(VString &pDestination,bool pIndented) const
{
	if (pIndented)
		SetIndent(pDestination);
	pDestination.AppendString(fText);
}