USING_TOOLBOX_NAMESPACE


VError SetHTTPResponseString( IHTTPResponse* inResponse, const VString& inString, const VString* inContentType)
{
	if (inResponse == NULL)
		return VE_INVALID_PARAMETER;
	
	StStringConverter<char> buffer( inString, VTC_UTF_8);

	inResponse->GetResponseBody().OpenWriting();
	inResponse->GetResponseBody().PutData( buffer.GetCPointer(), buffer.GetLength());
	inResponse->GetResponseBody().CloseWriting();

	VError err = inResponse->GetResponseBody().GetLastError();
	if (err == VE_OK)
	{
		inResponse->SetExpiresHeader( GMT_NOW);
		inResponse->AddResponseHeader( HEADER_PRAGMA, CVSTR ("no-cache"));
		if (inContentType != NULL)
		{
			inResponse->AddResponseHeader( HEADER_CONTENT_TYPE, *inContentType);
		}
		/* We send a String encoded using UTF-8, so set the correct header value */
		XBOX::CharSet	charSet = XBOX::VTC_UNKNOWN;
		XBOX::VString	contentType;
		inResponse->GetContentTypeHeader (contentType, &charSet);
		if (contentType.IsEmpty() || charSet !=  VTC_UTF_8)
		{
			inResponse->SetContentTypeHeader (contentType.IsEmpty() ? CVSTR ("text/html"): contentType, VTC_UTF_8);
		}
#if HTTP_SERVER_VERBOSE_MODE
		inResponse->AddResponseHeader( HEADER_X_POWERED_BY, "RIA Server");
#endif
		inResponse->SetContentLengthHeader( buffer.GetLength());
		inResponse->AllowCompression (false);
	}
	return err;
}
/* private */
void VVirtualFolder::_NormalizeFolder()
{
	assert (NULL != fFolder);

	if (!fFolder->Exists())
		fFolder->CreateRecursive();

	if (fFolder->Exists())
	{
		XBOX::VFilePath folderPath (fFolder->GetPath());
		XBOX::VFilePath indexPath;

		indexPath = folderPath.ToSubFile (fIndexFileName);

		if (indexPath.IsFile())
		{
			XBOX::VFile indexFile (indexPath);

			if (!indexFile.Exists())
			{
				XBOX::VFolder *componentFolder = VHTTPServer::RetainComponentFolder (kBF_RESOURCES_FOLDER);

				if (NULL != componentFolder)
				{
					XBOX::VFilePath		defaultIndexPath = componentFolder->GetPath();
					XBOX::DialectCode	dialectCode = XBOX::VIntlMgr::GetDefaultMgr()->GetCurrentDialectCode();
					XBOX::VString		languageCode;
					XBOX::VString		fileName;

					XBOX::VIntlMgr::GetDefaultMgr()->GetISO6391LanguageCode (dialectCode, languageCode);

					fileName.AppendCString ("index_");
					fileName.AppendString (languageCode);
					fileName.AppendCString (".html");

					defaultIndexPath.ToSubFolder (CVSTR ("Default Page")).ToSubFile (fileName);

					if (defaultIndexPath.IsFile())
					{
						XBOX::VFile defaultIndexFile (defaultIndexPath);

						if (defaultIndexFile.Exists())
							indexFile.CopyFrom (defaultIndexFile);
					}

					XBOX::QuickReleaseRefCountable (componentFolder);
				}
			}
		}
	}
}
Пример #3
0
bool VCommand::Trigger(const VValueSingle& inValue, const ICommandListener* inExcept)
{
	bool called = false;
	VValueBag* bag = new VValueBag;
	if (bag != NULL)
	{
		bag->SetAttribute(CVSTR("__command_value__"), dynamic_cast<VValueSingle*>(inValue.Clone()));
		
		called = Trigger(bag, inExcept);
		
		bag->Release();
	}
	return called;
}
Пример #4
0
bool VJSValue::GetTime( VTime& outTime, JS4D::ExceptionRef *outException) const
{
	bool ok;
	if (JS4D::ValueIsInstanceOf( fContext, fValue, CVSTR( "Date"), outException))
	{
		JSObjectRef dateObject = JSValueToObject( fContext, fValue, outException);
		ok = JS4D::DateObjectToVTime( fContext, dateObject, outTime, outException, false);
	}
	else
	{
		outTime.SetNull( true);
		ok = false;
	}
	return ok;
}
void VHTTPServerLog::_StartBackgroundLogFlusher()
{
	if (NULL == fBackgroundFlusherTask)
	{
		if (fBackgroundFlusherAccessLock.Lock())
		{
			fBackgroundFlusherTask = new XBOX::VTask (this, 0, XBOX::eTaskStylePreemptive, &_BackgroundFlushLog);
			fBackgroundFlusherTask->SetName (CVSTR ("HTTP Server Log Flush"));
			fBackgroundFlusherTask->SetKindData ((sLONG_PTR)this);
			fBackgroundFlusherTask->Run();

			fBackgroundFlusherAccessLock.Unlock();
		}
	}
}
Пример #6
0
bool VProcess::DoCheckSystemVersion( SystemVersion inMinimalSystemVersion)
{
	bool ok = VSystem::IsSystemVersionOrAbove( inMinimalSystemVersion);
	if (!ok)
	{
#if VERSIONWIN
		VString msg = (inMinimalSystemVersion == WIN_XP) ? "This application needs at least Windows XP" : "This application needs at least Windows Vista";
#elif VERSIONMAC
		VString msg = (inMinimalSystemVersion == MAC_OSX_10_5) ? "This application needs at least OS X 10.5" : "This application needs at least OS X 10.6";
#elif VERSION_LINUX
		VString msg="Need a Linux Implementation !";	// Postponed Linux Implementation !
#endif
		VSystem::DisplayNotification( CVSTR( "Initialization failed"), msg, EDN_OK);
	}
	return ok;
}
Пример #7
0
Boolean VDBFlushMgr::Init()
{
#if debuglr
	debug_tools_started = false;
#endif
	if (sTableFlushinfo.GetCount() == 0)
		sTableFlushinfo.Add(nil);

	BtreeFlush::AllocateBtreeFlush();
	BtreeFlush::AllocateBtreeFlushRegular();

	fFlushTask = new VDBFlushTask( this);
	fFlushTask->SetName( CVSTR( "DB4D Flush"));
	fFlushTask->Run();
	return true;
}
VVirtualFolder * VVirtualHostManager::RetainVirtualFolder (const XBOX::VString& inLocationPath, const XBOX::VString& inIndexPage, const XBOX::VString& inKeyword)
{
	VVirtualFolder * resultVirtualFolder = NULL;
	XBOX::VTaskLock	lock (&fLock);

	for (VVirtualHostVector::const_iterator it = fVirtualHosts.begin(); it != fVirtualHosts.end(); ++it)
	{
		if (NULL != (resultVirtualFolder = (*it)->RetainVirtualFolder (inLocationPath, inIndexPage, inKeyword)))
			break;
	}
	
	if (NULL == resultVirtualFolder)
		resultVirtualFolder = new VVirtualFolder (inLocationPath, inIndexPage, inKeyword, CVSTR (""));

	return resultVirtualFolder;
}
Пример #9
0
bool HTMLLexer::IsMultiLineCommentStart( UniChar inChar, sLONG &outType )
{
	// We are looking for <!--, which requires three more tokens of lookahead.
	if (CHAR_LESS_THAN_SIGN != inChar)	return false;
	if (!fLexerInput->HasMoreChars())	return false;

	VString subStr;
	fLexerInput->GetSubString( fLexerInput->GetCurrentPosition(), 4, subStr );


	if (subStr.EqualTo( CVSTR( "<!--" ), false )) {
		outType = kHTMLMultilineComment;
		return true;
	}

	return false;
}
VString XPosixEnvironmentVariables::GetVariable(const VString& inVariableName, VError& outError)
{
    outError = VE_OK;
    
	VString variableValue = CVSTR("");

	VStringConvertBuffer inVariableNameBuffer(inVariableName, VTC_UTF_8);

	const char* variableBuffer = getenv(inVariableNameBuffer.GetCPointer());

	if (variableBuffer != NULL)
	{
		variableValue.FromBlock(variableBuffer, ::strlen(variableBuffer), VTC_UTF_8);
	}

	return variableValue;
}
Пример #11
0
VError VArchiveStream::AddFolder( VFolder* inFolder )
{
	/**
	 * ACI0076147 folder's existence to report error to caller
	 */
	VError result = VE_OK;
	if ( inFolder->Exists() )
	{	
		///ACI0077162, Jul 11 2012, O.R.: lazily add path of folder. Proceed() will eventually recurse thru the tree
		result = AddFolder( inFolder, CVSTR("") );
	}	
	else {
		result = VE_STREAM_CANNOT_FIND_SOURCE;
		
	}

	return result;
}
Пример #12
0
bool JS4D::GetURLFromPath( const VString& inPath, XBOX::VURL& outURL)
{
	VIndex index = inPath.FindRawString( CVSTR( "://"));
	if (index > 0)//URL
	{
		outURL.FromString( inPath, true);
	}
	else if (!inPath.IsEmpty()) //system path
	{
		outURL.FromFilePath( inPath, eURL_POSIX_STYLE);
	}
	else
	{
		outURL.Clear();
	}

	return outURL.IsConformRFC();
}
VHTTPConnectionListener::VHTTPConnectionListener (VHTTPServer *inServer, IRequestLogger* inRequestLogger)
: XBOX::VTask (NULL, 0, XBOX::eTaskStylePreemptive, NULL)
, fCertificatesFolderPath()
, fServerListener (NULL)
, fWorkerPool (NULL)
, fSelectIOPool (NULL)
, fRequestLogger (inRequestLogger)
, fListeningIP (DEFAULT_LISTENING_ADDRESS)	// 0: All IP addresses
, fPort (DEFAULT_LISTENING_PORT)
, fSSLPort (DEFAULT_LISTENING_SSL_PORT)
, fSSLEnabled (false)
, fSSLMandatory (false)
, fConnectionHandlerFactory (NULL)
, fHTTPServer (NULL)
, fUsageCounter (1)
, fSocketDescriptor (-1)
, fSSLSocketDescriptor (-1)
, fReuseAddressSocketOption (true)
, fAbortTask (false)
{
	fHTTPServer = XBOX::RetainRefCountable (inServer);

	XBOX::VString taskName;
	if (testAssert (NULL != fHTTPServer))
		fHTTPServer->LocalizeString (CVSTR ("SNET_CONNECTION_LISTENER"), taskName);
		
	SetName (taskName);
	SetKind (kServerNetTaskKind);
	SetKindData (kSNET_ConnectionListenerTaskKindData);

	const short	SHARED_WORKER_COUNT = 0;
	const short	SHARED_WORKER_MAX_COUNT = 0;
	const short	SHARED_WORKER_MAX_BUSYNESS = 0;
	const short	EXCLUSIVE_WORKER_COUNT = 5;
	const short	EXCLUSIVE_WORKER_MAX_COUNT = kMAX_sWORD;

	fWorkerPool = new VWorkerPool (	SHARED_WORKER_COUNT,
									SHARED_WORKER_MAX_COUNT,
									SHARED_WORKER_MAX_BUSYNESS,
									EXCLUSIVE_WORKER_COUNT,
									EXCLUSIVE_WORKER_MAX_COUNT);

	fSelectIOPool = new VTCPSelectIOPool();
}
IXMLHandler* VLocalizationGroupHandler::StartElement( const VString& inElementName)
{
	IXMLHandler *handler = NULL;

	if (inElementName.EqualToUSASCIICString( "trans-unit"))
	{
		
		// optim: collect trans-unit attributes only for typed groups
		VValueBag *groupBag = fGroupRestype.IsEmpty() ? NULL : fGroupBag;

		handler = new VLocalizationTransUnitHandler( fGroupID, fGroupResnamesStack, groupBag, fShouldOverwriteAnyExistentLocalizationValue, fLocalizationManager);
	}
	else if (inElementName.EqualToUSASCIICString( "group"))
	{
		fGroupResnamesStack.push(CVSTR(""));
		this->Retain();
		handler = this;
	}

	return handler;
}
Пример #15
0
bool HTMLLexer::IsMultiLineCommentEnd( UniChar inChar, sLONG &outCharsToConsume, sLONG inType )
{
	// We have to check for newlines for no other reason than bookkeeping.  This records when we
	// locate a newline so that the fLineNumber property remains properly in-sync.  We will consume
	// the newline for the caller if that's what we've gotten.
	if (IsLineEnding( inChar ))	ConsumeLineEnding( inChar );

	// We are looking for -->
	if (inType != kCommentContinuationType &&
		inType != kHTMLMultilineComment)				return false;
	if (CHAR_HYPHEN_MINUS != inChar)					return false;
	if (!fLexerInput->HasMoreChars())					return false;

	VString subStr;
	fLexerInput->GetSubString( fLexerInput->GetCurrentPosition() + 1, 2, subStr );
	if (subStr.EqualTo( CVSTR( "->" ), false )) {
		// We're at the end of the comment, but the caller still needs to consume two characters
		outCharsToConsume = 2;
		return true;
	}
	return false;
}
XBOX::VError VChromeDbgHdlPage::SendMsg(const XBOX::VString& inValue)
{
	XBOX::VError			err;
	VStringConvertBuffer	buffer(inValue,VTC_UTF_8);
	VSize					size;
	VString					trace;

	err = VE_OK;

	DebugMsg(" treat '%S' ... resp-><%S>\n",&fMethod,&inValue);
	size = buffer.GetSize();
	err = fWS->WriteMessage( buffer.GetCPointer(), size, true );
	trace = CVSTR("VChromeDbgHdlPage::SendMsg WriteMessage err=");
	trace.AppendLong8(err);
	trace += ", size:";
	trace.AppendLong8(size);
	trace += ", val <";
	trace += inValue;
	trace += ">";
	sPrivateLogHandler->Put( (err != VE_OK ? WAKDBG_ERROR_LEVEL : WAKDBG_INFO_LEVEL),trace);

	return err;
}
XBOX::VFile *VXMLParser::ResolveEntityFromFolder( const VString& inEntityBase, VFolder *inEntityLocalFolder, const VString& inSystemID)
{
	VFile *file = NULL;
	if (inEntityLocalFolder != NULL)
	{
		if (inSystemID.BeginsWith( inEntityBase))
		{
			VString relativePath = inSystemID;
			relativePath.Exchange( inEntityBase, CVSTR( ""));

			// convert into native path to please VFile
			for( UniChar *p = relativePath.GetCPointerForWrite() ; *p ; ++p)
			{
				if (*p == '/')
					*p = FOLDER_SEPARATOR;
			}
			
			VFilePath path( inEntityLocalFolder->GetPath(), relativePath);
			if (path.IsFile())
				file = new VFile( path);
		}
	}
	return file;
}
XBOX::VError VChromeDbgHdlPage::TreatWS(IHTTPResponse* ioResponse)
{
	XBOX::VError	l_err;
	ChrmDbgMsg_t	l_msg;
	bool			l_msg_found;
	intptr_t		l_src_id;
	RemoteDebugPilot*	l_pilot;
	VString			l_tmp;
	l_err = fSem.TryToLock();

	if (!l_err)
	{
		DebugMsg("VChromeDbgHdlPage::TreatWS already in use\n"); 
		return VE_OK;// so that HTTP server does not send error
	}

	l_err = fWS->TreatNewConnection(ioResponse);

	l_tmp = CVSTR("VChromeDbgHdlPage::TreatWS TreatNewConnection status=");
	l_tmp.AppendLong8(l_err);
	sPrivateLogHandler->Put( (l_err != VE_OK ? WAKDBG_ERROR_LEVEL : WAKDBG_INFO_LEVEL),l_tmp);
	
	fFileName = K_EMPTY_FILENAME;
	fOffset = 0;

	while(!l_err)
	{
		fMsgLen = K_MAX_SIZE - fOffset;
		l_err = fWS->ReadMessage(fMsgData+fOffset,(uLONG*)&fMsgLen,&fIsMsgTerminated);

		// only display this trace on error (otherwise there are lots of msgs due to polling
		if (l_err)
		{
			l_tmp = CVSTR("VChromeDbgHdlPage::TreatWS ReadMessage status=");
			l_tmp.AppendLong8(l_err);
			l_tmp += " len=";
			l_tmp.AppendLong(fMsgLen);
			l_tmp += " fIsMsgTerminated=";
			l_tmp += (fIsMsgTerminated ? "1" : "0" );
			sPrivateLogHandler->Put( (l_err != VE_OK ? WAKDBG_ERROR_LEVEL : WAKDBG_INFO_LEVEL),l_tmp);
		}

		if (!l_err)
		{
			if (!fMsgLen)
			{
				l_err = fFifo.Get(&l_msg,&l_msg_found,200);
				
				if (l_err || l_msg_found)
				{
					l_tmp = VString("VChromeDbgHdlPage::TreatWS page=");
					l_tmp.AppendLong(fPageNb);
					l_tmp += " ,fFifo.get status=";
					l_tmp.AppendLong8(l_err);
					l_tmp += ", msg_found=";
					l_tmp += (l_msg_found ? "1" : "0" );
					l_tmp += ", type=";
					l_tmp.AppendLong8(l_msg.type);
					sPrivateLogHandler->Put( (l_err != VE_OK ? WAKDBG_ERROR_LEVEL : WAKDBG_INFO_LEVEL),l_tmp);
				}

				if (testAssert( l_err == VE_OK ))
				{
					if (!l_msg_found)
					{
						l_msg.type = NO_MSG;
					}
					switch(l_msg.type)
					{
					case NO_MSG:
						break;
					case BRKPT_REACHED_MSG:
						fLineNb = (sLONG)l_msg.data.Msg.fLineNumber;
					
						l_tmp = VString("VChromeDbgHdlPage::TreatWS page=");
						l_tmp.AppendLong(fPageNb);
						l_tmp += " BRKPT_REACHED_MSG fLineNb=";
						l_tmp.AppendLong(fLineNb);
						l_tmp += ", found=";
						l_tmp += (l_msg_found ? "1" : "0" );
						l_tmp += ", msgType=";
						l_tmp.AppendLong8(l_msg.type);
						sPrivateLogHandler->Put(WAKDBG_INFO_LEVEL,l_tmp);

						fSrcId = l_msg.data.Msg.fSrcId;
						fFileName = l_msg.data._urlStr;
						VURL::Decode( fFileName );
						VIndex				l_idx;
						l_pilot = l_msg.data._pilot;
						l_idx = fFileName.FindUniChar( L'/', fFileName.GetLength(), true );
						if (l_idx  > 1)
						{
							VString	l_tmp_str;
							fFileName.GetSubString(l_idx+1,fFileName.GetLength()-l_idx,l_tmp_str);
							fFileName = l_tmp_str;
						}
						if (!l_msg.data._dataStr.GetSubStrings(K_DEFAULT_LINE_SEPARATOR,fSource,true))
						{
							if (!l_msg.data._dataStr.GetSubStrings(K_ALTERNATIVE_LINE_SEPARATOR,fSource,true))
							{
								fSource = VectorOfVString(1,VString("No line separator detected in source CODE"));
							}
						}
						for(VectorOfVString::iterator l_it = fSource.begin(); (l_it != fSource.end()); )
						{
							l_tmp = *l_it;
							if (l_tmp.GetJSONString(*l_it) != VE_OK)
							{
								//l_res = false;
								xbox_assert(false);
							}
							++l_it;
						}

#if 1
						l_src_id = l_msg.data.Msg.fSrcId;

						l_msg.type = SEND_CMD_MSG;
						l_msg.data.Msg.fType = WAKDebuggerServerMessage::SRV_GET_CALLSTACK_MSG;
						l_err = fOutFifo.Put(l_msg);
						xbox_assert( (l_err == VE_OK) );
again:
						l_err = fFifo.Get(&l_msg,&l_msg_found,0);

						l_tmp = CVSTR("VChromeDbgHdlPage::TreatWS page=");
						l_tmp.AppendLong(fPageNb);
						l_tmp += " fFifo.Get2 found=";
						l_tmp += ( l_msg_found ? "1" : "0" );
						l_tmp += ", type=";
						l_tmp.AppendLong8(l_msg.type);
						sPrivateLogHandler->Put( (l_err != VE_OK ? WAKDBG_ERROR_LEVEL : WAKDBG_INFO_LEVEL),l_tmp);

						xbox_assert( (l_err == VE_OK) );
						{
							if (!l_msg_found)
							{
								l_msg.type = NO_MSG;
							}
							if (l_msg.type == CALLSTACK_MSG)
							{
								XBOX::VError	 l_err;
								l_err = TreatPageReload(&l_msg.data._dataStr,l_src_id);
								if (!l_err)
								{
									//l_pilot->ContextUpdated(l_msg.data._debugContext);
								}
							}
							else
							{
								/*if (l_msg.type == SET_SOURCE_MSG)
								{
									// already treated (we consider source does not change for the moment
									goto again;
								}*/
								xbox_assert(false);
								DebugMsg("VChromeDbgHdlPage::TreatWS page=%d unexpected msg=%d\n",fPageNb,l_msg.type);
							}
						}
#endif
						break;
					default:
						DebugMsg("VChromeDbgHdlPage::TreatWS bad msg=%d\n",l_msg.type);
						l_tmp = CVSTR("VChromeDbgHdlPage::TreatWS bad msg=");
						l_tmp.AppendLong8(l_msg.type);
						sPrivateLogHandler->Put(WAKDBG_ERROR_LEVEL,l_tmp);
						xbox_assert(false);
					}
				}
				continue;
			}
			//printf("ReadMessage len=%d term=%d\n",fMsgLen,fIsMsgTerminated);
			fOffset += fMsgLen;
			if (fIsMsgTerminated)
			{
				l_err = TreatMsg();
				if (l_err)
				{
					l_tmp = CVSTR("VChromeDbgHdlPage::TreatWS TreatMsg pb...closing");
					sPrivateLogHandler->Put(WAKDBG_ERROR_LEVEL,l_tmp);
					DebugMsg("VChromeDbgHdlPage::TreatWS TreatMsg pb...closing\n");
					fWS->Close();
				}
				fOffset = 0;
			}
		}
		else
		{
			DebugMsg("VChromeDbgHdlPage::TreatWS ReadMessage ERR!!!\n");
		}
	}
	fSem.Unlock();
	return l_err;
}
Пример #19
0
void VJSONValue::test()
{
    const char *sTestJson = "{\"good\":true,\"name\":\"smith\",\"paul\":{\"good\":false,\"name\":\"paul\",\"Nul\":null,\"age\":10.321,\"text\":\"\"\\/\b\f\n\r\t\"},\"age\":42}";

    VJSONValue	object( JSON_object);

    object.SetProperty( CVSTR( "name"), VJSONValue( CVSTR( "smith")));
    object.SetProperty( CVSTR( "age"), VJSONValue( 42));
    object.SetProperty( CVSTR( "good"), VJSONValue::sTrue);

    for( VJSONPropertyIterator i( object.GetObject()) ; i.IsValid() ; ++i)
    {
        VString propertyName = i.GetName();
        VJSONValue propertyValue = i.GetValue();
    }

    VJSONValue	object_child( JSON_object);

    object_child.SetProperty( CVSTR( "name"), VJSONValue( CVSTR( "paul")));
    object_child.SetProperty( CVSTR( "age"), VJSONValue( 10.321));
    object_child.SetProperty( CVSTR( "good"), VJSONValue::sFalse);
    object_child.SetProperty( CVSTR( "text"), VJSONValue( CVSTR( "\"\\/\b\f\n\r\t")));
    object_child.SetProperty( CVSTR( "Nul"), VJSONValue::sNull);
    object_child.SetProperty( CVSTR( "undef"), VJSONValue::sUndefined);

    VJSONArray		*object_children = new VJSONArray;
    object_children->Push( object_child);

    object.SetProperty( CVSTR( "children"), VJSONValue( object_children));

    ReleaseRefCountable( &object_children);

    VString s;
    VJSONWriter writer( JSON_WithQuotesIfNecessary);
    VError err = writer.StringifyValue( object, s);

    DebugMsg( s);
    DebugMsg( "\n");

    VJSONWriter writer2( JSON_WithQuotesIfNecessary | JSON_PrettyFormatting);
    err = writer2.StringifyValue( object, s);

    DebugMsg( s);
    DebugMsg( "\n");

    VJSONValue value;
    VJSONImporter importer(s);
    err = importer.Parse( value);
    VString s2;
    writer2.StringifyValue( value, s2);
    DebugMsg( s2);
    DebugMsg( "\n");
    xbox_assert( s == s2);

    {
        VJSONImporter importer2( CVSTR( "[1,2,3,[4,5],6]"));
        err = importer2.Parse( value);
        value.GetString( s2);
        DebugMsg( s2);
        DebugMsg( "\n");
    }

}
Пример #20
0
static bool GetEntityValue( const VString &inEntityName, UniChar &outReplacement )
{
	typedef std::map< VString, UniChar, StrComp_For_Map_Less > EntityMap;
	static EntityMap sEntityMap;
	if (!sEntityMap.size()) {
		// Thank goodness for regular expressions.  This list was pulled from the HTML 4.01 specification, found here:
		// <http://www.w3.org/TR/html4/sgml/entities.html>, and it was generated by the following regular expression:
		//		search: <!ENTITY[ ]*\([A-Za-z0-9]*\)[ ]*CDATA[ ]*\"&#\([0-9]+\);\"[ ]*--
		//		replace: sEntityMap\[ CVSTR( \"\1\" ) \] = (UniChar)\2; //
		// There was a bit of post-processing required because some of the comments spanned multiple lines, but it sure
		// saved a ton of typing.
		sEntityMap[ CVSTR( "nbsp" ) ] = (UniChar)160; // no-break space = non-breaking space, U+00A0 ISOnum
		sEntityMap[ CVSTR( "iexcl" ) ] = (UniChar)161; // inverted exclamation mark, U+00A1 ISOnum
		sEntityMap[ CVSTR( "cent" ) ] = (UniChar)162; // cent sign, U+00A2 ISOnum
		sEntityMap[ CVSTR( "pound" ) ] = (UniChar)163; // pound sign, U+00A3 ISOnum
		sEntityMap[ CVSTR( "curren" ) ] = (UniChar)164; // currency sign, U+00A4 ISOnum
		sEntityMap[ CVSTR( "yen" ) ] = (UniChar)165; // yen sign = yuan sign, U+00A5 ISOnum
		sEntityMap[ CVSTR( "brvbar" ) ] = (UniChar)166; // broken bar = broken vertical bar, U+00A6 ISOnum
		sEntityMap[ CVSTR( "sect" ) ] = (UniChar)167; // section sign, U+00A7 ISOnum
		sEntityMap[ CVSTR( "uml" ) ] = (UniChar)168; // diaeresis = spacing diaeresis, U+00A8 ISOdia
		sEntityMap[ CVSTR( "copy" ) ] = (UniChar)169; // copyright sign, U+00A9 ISOnum
		sEntityMap[ CVSTR( "ordf" ) ] = (UniChar)170; // feminine ordinal indicator, U+00AA ISOnum
		sEntityMap[ CVSTR( "laquo" ) ] = (UniChar)171; // left-pointing double angle quotation mark = left pointing guillemet, U+00AB ISOnum
		sEntityMap[ CVSTR( "not" ) ] = (UniChar)172; // not sign, U+00AC ISOnum
		sEntityMap[ CVSTR( "shy" ) ] = (UniChar)173; // soft hyphen = discretionary hyphen, U+00AD ISOnum
		sEntityMap[ CVSTR( "reg" ) ] = (UniChar)174; // registered sign = registered trade mark sign, U+00AE ISOnum
		sEntityMap[ CVSTR( "macr" ) ] = (UniChar)175; // macron = spacing macron = overline = APL overbar, U+00AF ISOdia
		sEntityMap[ CVSTR( "deg" ) ] = (UniChar)176; // degree sign, U+00B0 ISOnum
		sEntityMap[ CVSTR( "plusmn" ) ] = (UniChar)177; // plus-minus sign = plus-or-minus sign, U+00B1 ISOnum
		sEntityMap[ CVSTR( "sup2" ) ] = (UniChar)178; // superscript two = superscript digit two = squared, U+00B2 ISOnum
		sEntityMap[ CVSTR( "sup3" ) ] = (UniChar)179; // superscript three = superscript digit three = cubed, U+00B3 ISOnum
		sEntityMap[ CVSTR( "acute" ) ] = (UniChar)180; // acute accent = spacing acute, U+00B4 ISOdia
		sEntityMap[ CVSTR( "micro" ) ] = (UniChar)181; // micro sign, U+00B5 ISOnum
		sEntityMap[ CVSTR( "para" ) ] = (UniChar)182; // pilcrow sign = paragraph sign, U+00B6 ISOnum
		sEntityMap[ CVSTR( "middot" ) ] = (UniChar)183; // middle dot = Georgian comma = Greek middle dot, U+00B7 ISOnum
		sEntityMap[ CVSTR( "cedil" ) ] = (UniChar)184; // cedilla = spacing cedilla, U+00B8 ISOdia
		sEntityMap[ CVSTR( "sup1" ) ] = (UniChar)185; // superscript one = superscript digit one, U+00B9 ISOnum
		sEntityMap[ CVSTR( "ordm" ) ] = (UniChar)186; // masculine ordinal indicator, U+00BA ISOnum
		sEntityMap[ CVSTR( "raquo" ) ] = (UniChar)187; // right-pointing double angle quotation mark = right pointing guillemet, U+00BB ISOnum
		sEntityMap[ CVSTR( "frac14" ) ] = (UniChar)188; // vulgar fraction one quarter = fraction one quarter, U+00BC ISOnum
		sEntityMap[ CVSTR( "frac12" ) ] = (UniChar)189; // vulgar fraction one half = fraction one half, U+00BD ISOnum
		sEntityMap[ CVSTR( "frac34" ) ] = (UniChar)190; // vulgar fraction three quarters = fraction three quarters, U+00BE ISOnum
		sEntityMap[ CVSTR( "iquest" ) ] = (UniChar)191; // inverted question mark = turned question mark, U+00BF ISOnum
		sEntityMap[ CVSTR( "Agrave" ) ] = (UniChar)192; // latin capital letter A with grave = latin capital letter A grave, U+00C0 ISOlat1
		sEntityMap[ CVSTR( "Aacute" ) ] = (UniChar)193; // latin capital letter A with acute, U+00C1 ISOlat1
		sEntityMap[ CVSTR( "Acirc" ) ] = (UniChar)194; // latin capital letter A with circumflex, U+00C2 ISOlat1
		sEntityMap[ CVSTR( "Atilde" ) ] = (UniChar)195; // latin capital letter A with tilde, U+00C3 ISOlat1
		sEntityMap[ CVSTR( "Auml" ) ] = (UniChar)196; // latin capital letter A with diaeresis, U+00C4 ISOlat1
		sEntityMap[ CVSTR( "Aring" ) ] = (UniChar)197; // latin capital letter A with ring above = latin capital letter A ring, U+00C5 ISOlat1
		sEntityMap[ CVSTR( "AElig" ) ] = (UniChar)198; // latin capital letter AE = latin capital ligature AE, U+00C6 ISOlat1
		sEntityMap[ CVSTR( "Ccedil" ) ] = (UniChar)199; // latin capital letter C with cedilla, U+00C7 ISOlat1
		sEntityMap[ CVSTR( "Egrave" ) ] = (UniChar)200; // latin capital letter E with grave, U+00C8 ISOlat1
		sEntityMap[ CVSTR( "Eacute" ) ] = (UniChar)201; // latin capital letter E with acute, U+00C9 ISOlat1
		sEntityMap[ CVSTR( "Ecirc" ) ] = (UniChar)202; // latin capital letter E with circumflex, U+00CA ISOlat1
		sEntityMap[ CVSTR( "Euml" ) ] = (UniChar)203; // latin capital letter E with diaeresis, U+00CB ISOlat1
		sEntityMap[ CVSTR( "Igrave" ) ] = (UniChar)204; // latin capital letter I with grave, U+00CC ISOlat1
		sEntityMap[ CVSTR( "Iacute" ) ] = (UniChar)205; // latin capital letter I with acute, U+00CD ISOlat1
		sEntityMap[ CVSTR( "Icirc" ) ] = (UniChar)206; // latin capital letter I with circumflex, U+00CE ISOlat1
		sEntityMap[ CVSTR( "Iuml" ) ] = (UniChar)207; // latin capital letter I with diaeresis, U+00CF ISOlat1
		sEntityMap[ CVSTR( "ETH" ) ] = (UniChar)208; // latin capital letter ETH, U+00D0 ISOlat1
		sEntityMap[ CVSTR( "Ntilde" ) ] = (UniChar)209; // latin capital letter N with tilde, U+00D1 ISOlat1
		sEntityMap[ CVSTR( "Ograve" ) ] = (UniChar)210; // latin capital letter O with grave, U+00D2 ISOlat1
		sEntityMap[ CVSTR( "Oacute" ) ] = (UniChar)211; // latin capital letter O with acute, U+00D3 ISOlat1
		sEntityMap[ CVSTR( "Ocirc" ) ] = (UniChar)212; // latin capital letter O with circumflex, U+00D4 ISOlat1
		sEntityMap[ CVSTR( "Otilde" ) ] = (UniChar)213; // latin capital letter O with tilde, U+00D5 ISOlat1
		sEntityMap[ CVSTR( "Ouml" ) ] = (UniChar)214; // latin capital letter O with diaeresis, U+00D6 ISOlat1
		sEntityMap[ CVSTR( "times" ) ] = (UniChar)215; // multiplication sign, U+00D7 ISOnum
		sEntityMap[ CVSTR( "Oslash" ) ] = (UniChar)216; // latin capital letter O with stroke = latin capital letter O slash, U+00D8 ISOlat1
		sEntityMap[ CVSTR( "Ugrave" ) ] = (UniChar)217; // latin capital letter U with grave, U+00D9 ISOlat1
		sEntityMap[ CVSTR( "Uacute" ) ] = (UniChar)218; // latin capital letter U with acute, U+00DA ISOlat1
		sEntityMap[ CVSTR( "Ucirc" ) ] = (UniChar)219; // latin capital letter U with circumflex, U+00DB ISOlat1
		sEntityMap[ CVSTR( "Uuml" ) ] = (UniChar)220; // latin capital letter U with diaeresis, U+00DC ISOlat1
		sEntityMap[ CVSTR( "Yacute" ) ] = (UniChar)221; // latin capital letter Y with acute, U+00DD ISOlat1
		sEntityMap[ CVSTR( "THORN" ) ] = (UniChar)222; // latin capital letter THORN, U+00DE ISOlat1
		sEntityMap[ CVSTR( "szlig" ) ] = (UniChar)223; // latin small letter sharp s = ess-zed, U+00DF ISOlat1
		sEntityMap[ CVSTR( "agrave" ) ] = (UniChar)224; // latin small letter a with grave = latin small letter a grave, U+00E0 ISOlat1
		sEntityMap[ CVSTR( "aacute" ) ] = (UniChar)225; // latin small letter a with acute, U+00E1 ISOlat1
		sEntityMap[ CVSTR( "acirc" ) ] = (UniChar)226; // latin small letter a with circumflex, U+00E2 ISOlat1
		sEntityMap[ CVSTR( "atilde" ) ] = (UniChar)227; // latin small letter a with tilde, U+00E3 ISOlat1
		sEntityMap[ CVSTR( "auml" ) ] = (UniChar)228; // latin small letter a with diaeresis, U+00E4 ISOlat1
		sEntityMap[ CVSTR( "aring" ) ] = (UniChar)229; // latin small letter a with ring above = latin small letter a ring, U+00E5 ISOlat1
		sEntityMap[ CVSTR( "aelig" ) ] = (UniChar)230; // latin small letter ae = latin small ligature ae, U+00E6 ISOlat1
		sEntityMap[ CVSTR( "ccedil" ) ] = (UniChar)231; // latin small letter c with cedilla, U+00E7 ISOlat1
		sEntityMap[ CVSTR( "egrave" ) ] = (UniChar)232; // latin small letter e with grave, U+00E8 ISOlat1
		sEntityMap[ CVSTR( "eacute" ) ] = (UniChar)233; // latin small letter e with acute, U+00E9 ISOlat1
		sEntityMap[ CVSTR( "ecirc" ) ] = (UniChar)234; // latin small letter e with circumflex, U+00EA ISOlat1
		sEntityMap[ CVSTR( "euml" ) ] = (UniChar)235; // latin small letter e with diaeresis, U+00EB ISOlat1
		sEntityMap[ CVSTR( "igrave" ) ] = (UniChar)236; // latin small letter i with grave, U+00EC ISOlat1
		sEntityMap[ CVSTR( "iacute" ) ] = (UniChar)237; // latin small letter i with acute, U+00ED ISOlat1
		sEntityMap[ CVSTR( "icirc" ) ] = (UniChar)238; // latin small letter i with circumflex, U+00EE ISOlat1
		sEntityMap[ CVSTR( "iuml" ) ] = (UniChar)239; // latin small letter i with diaeresis, U+00EF ISOlat1
		sEntityMap[ CVSTR( "eth" ) ] = (UniChar)240; // latin small letter eth, U+00F0 ISOlat1
		sEntityMap[ CVSTR( "ntilde" ) ] = (UniChar)241; // latin small letter n with tilde, U+00F1 ISOlat1
		sEntityMap[ CVSTR( "ograve" ) ] = (UniChar)242; // latin small letter o with grave, U+00F2 ISOlat1
		sEntityMap[ CVSTR( "oacute" ) ] = (UniChar)243; // latin small letter o with acute, U+00F3 ISOlat1
		sEntityMap[ CVSTR( "ocirc" ) ] = (UniChar)244; // latin small letter o with circumflex, U+00F4 ISOlat1
		sEntityMap[ CVSTR( "otilde" ) ] = (UniChar)245; // latin small letter o with tilde, U+00F5 ISOlat1
		sEntityMap[ CVSTR( "ouml" ) ] = (UniChar)246; // latin small letter o with diaeresis, U+00F6 ISOlat1
		sEntityMap[ CVSTR( "divide" ) ] = (UniChar)247; // division sign, U+00F7 ISOnum
		sEntityMap[ CVSTR( "oslash" ) ] = (UniChar)248; // latin small letter o with stroke, = latin small letter o slash, U+00F8 ISOlat1
		sEntityMap[ CVSTR( "ugrave" ) ] = (UniChar)249; // latin small letter u with grave, U+00F9 ISOlat1
		sEntityMap[ CVSTR( "uacute" ) ] = (UniChar)250; // latin small letter u with acute, U+00FA ISOlat1
		sEntityMap[ CVSTR( "ucirc" ) ] = (UniChar)251; // latin small letter u with circumflex, U+00FB ISOlat1
		sEntityMap[ CVSTR( "uuml" ) ] = (UniChar)252; // latin small letter u with diaeresis, U+00FC ISOlat1
		sEntityMap[ CVSTR( "yacute" ) ] = (UniChar)253; // latin small letter y with acute, U+00FD ISOlat1
		sEntityMap[ CVSTR( "thorn" ) ] = (UniChar)254; // latin small letter thorn, U+00FE ISOlat1
		sEntityMap[ CVSTR( "yuml" ) ] = (UniChar)255; // latin small letter y with diaeresis, U+00FF ISOlat1
		sEntityMap[ CVSTR( "fnof" ) ] = (UniChar)402; // latin small f with hook = function = florin, U+0192 ISOtech
		sEntityMap[ CVSTR( "Alpha" ) ] = (UniChar)913; // greek capital letter alpha, U+0391
		sEntityMap[ CVSTR( "Beta" ) ] = (UniChar)914; // greek capital letter beta, U+0392
		sEntityMap[ CVSTR( "Gamma" ) ] = (UniChar)915; // greek capital letter gamma, U+0393 ISOgrk3
		sEntityMap[ CVSTR( "Delta" ) ] = (UniChar)916; // greek capital letter delta, U+0394 ISOgrk3
		sEntityMap[ CVSTR( "Epsilon" ) ] = (UniChar)917; // greek capital letter epsilon, U+0395
		sEntityMap[ CVSTR( "Zeta" ) ] = (UniChar)918; // greek capital letter zeta, U+0396
		sEntityMap[ CVSTR( "Eta" ) ] = (UniChar)919; // greek capital letter eta, U+0397
		sEntityMap[ CVSTR( "Theta" ) ] = (UniChar)920; // greek capital letter theta, U+0398 ISOgrk3
		sEntityMap[ CVSTR( "Iota" ) ] = (UniChar)921; // greek capital letter iota, U+0399
		sEntityMap[ CVSTR( "Kappa" ) ] = (UniChar)922; // greek capital letter kappa, U+039A
		sEntityMap[ CVSTR( "Lambda" ) ] = (UniChar)923; // greek capital letter lambda, U+039B ISOgrk3
		sEntityMap[ CVSTR( "Mu" ) ] = (UniChar)924; // greek capital letter mu, U+039C
		sEntityMap[ CVSTR( "Nu" ) ] = (UniChar)925; // greek capital letter nu, U+039D
		sEntityMap[ CVSTR( "Xi" ) ] = (UniChar)926; // greek capital letter xi, U+039E ISOgrk3
		sEntityMap[ CVSTR( "Omicron" ) ] = (UniChar)927; // greek capital letter omicron, U+039F
		sEntityMap[ CVSTR( "Pi" ) ] = (UniChar)928; // greek capital letter pi, U+03A0 ISOgrk3
		sEntityMap[ CVSTR( "Rho" ) ] = (UniChar)929; // greek capital letter rho, U+03A1
		sEntityMap[ CVSTR( "Sigma" ) ] = (UniChar)931; // greek capital letter sigma, U+03A3 ISOgrk3
		sEntityMap[ CVSTR( "Tau" ) ] = (UniChar)932; // greek capital letter tau, U+03A4
		sEntityMap[ CVSTR( "Upsilon" ) ] = (UniChar)933; // greek capital letter upsilon, U+03A5 ISOgrk3
		sEntityMap[ CVSTR( "Phi" ) ] = (UniChar)934; // greek capital letter phi, U+03A6 ISOgrk3
		sEntityMap[ CVSTR( "Chi" ) ] = (UniChar)935; // greek capital letter chi, U+03A7
		sEntityMap[ CVSTR( "Psi" ) ] = (UniChar)936; // greek capital letter psi, U+03A8 ISOgrk3
		sEntityMap[ CVSTR( "Omega" ) ] = (UniChar)937; // greek capital letter omega, U+03A9 ISOgrk3
		sEntityMap[ CVSTR( "alpha" ) ] = (UniChar)945; // greek small letter alpha, U+03B1 ISOgrk3
		sEntityMap[ CVSTR( "beta" ) ] = (UniChar)946; // greek small letter beta, U+03B2 ISOgrk3
		sEntityMap[ CVSTR( "gamma" ) ] = (UniChar)947; // greek small letter gamma, U+03B3 ISOgrk3
		sEntityMap[ CVSTR( "delta" ) ] = (UniChar)948; // greek small letter delta, U+03B4 ISOgrk3
		sEntityMap[ CVSTR( "epsilon" ) ] = (UniChar)949; // greek small letter epsilon, U+03B5 ISOgrk3
		sEntityMap[ CVSTR( "zeta" ) ] = (UniChar)950; // greek small letter zeta, U+03B6 ISOgrk3
		sEntityMap[ CVSTR( "eta" ) ] = (UniChar)951; // greek small letter eta, U+03B7 ISOgrk3
		sEntityMap[ CVSTR( "theta" ) ] = (UniChar)952; // greek small letter theta, U+03B8 ISOgrk3
		sEntityMap[ CVSTR( "iota" ) ] = (UniChar)953; // greek small letter iota, U+03B9 ISOgrk3
		sEntityMap[ CVSTR( "kappa" ) ] = (UniChar)954; // greek small letter kappa, U+03BA ISOgrk3
		sEntityMap[ CVSTR( "lambda" ) ] = (UniChar)955; // greek small letter lambda, U+03BB ISOgrk3
		sEntityMap[ CVSTR( "mu" ) ] = (UniChar)956; // greek small letter mu, U+03BC ISOgrk3
		sEntityMap[ CVSTR( "nu" ) ] = (UniChar)957; // greek small letter nu, U+03BD ISOgrk3
		sEntityMap[ CVSTR( "xi" ) ] = (UniChar)958; // greek small letter xi, U+03BE ISOgrk3
		sEntityMap[ CVSTR( "omicron" ) ] = (UniChar)959; // greek small letter omicron, U+03BF NEW
		sEntityMap[ CVSTR( "pi" ) ] = (UniChar)960; // greek small letter pi, U+03C0 ISOgrk3
		sEntityMap[ CVSTR( "rho" ) ] = (UniChar)961; // greek small letter rho, U+03C1 ISOgrk3
		sEntityMap[ CVSTR( "sigmaf" ) ] = (UniChar)962; // greek small letter final sigma, U+03C2 ISOgrk3
		sEntityMap[ CVSTR( "sigma" ) ] = (UniChar)963; // greek small letter sigma, U+03C3 ISOgrk3
		sEntityMap[ CVSTR( "tau" ) ] = (UniChar)964; // greek small letter tau, U+03C4 ISOgrk3
		sEntityMap[ CVSTR( "upsilon" ) ] = (UniChar)965; // greek small letter upsilon, U+03C5 ISOgrk3
		sEntityMap[ CVSTR( "phi" ) ] = (UniChar)966; // greek small letter phi, U+03C6 ISOgrk3
		sEntityMap[ CVSTR( "chi" ) ] = (UniChar)967; // greek small letter chi, U+03C7 ISOgrk3
		sEntityMap[ CVSTR( "psi" ) ] = (UniChar)968; // greek small letter psi, U+03C8 ISOgrk3
		sEntityMap[ CVSTR( "omega" ) ] = (UniChar)969; // greek small letter omega, U+03C9 ISOgrk3
		sEntityMap[ CVSTR( "thetasym" ) ] = (UniChar)977; // greek small letter theta symbol, U+03D1 NEW
		sEntityMap[ CVSTR( "upsih" ) ] = (UniChar)978; // greek upsilon with hook symbol, U+03D2 NEW
		sEntityMap[ CVSTR( "piv" ) ] = (UniChar)982; // greek pi symbol, U+03D6 ISOgrk3
		sEntityMap[ CVSTR( "bull" ) ] = (UniChar)8226; // bullet = black small circle, U+2022 ISOpub 
		sEntityMap[ CVSTR( "hellip" ) ] = (UniChar)8230; // horizontal ellipsis = three dot leader, U+2026 ISOpub 
		sEntityMap[ CVSTR( "prime" ) ] = (UniChar)8242; // prime = minutes = feet, U+2032 ISOtech
		sEntityMap[ CVSTR( "Prime" ) ] = (UniChar)8243; // double prime = seconds = inches, U+2033 ISOtech
		sEntityMap[ CVSTR( "oline" ) ] = (UniChar)8254; // overline = spacing overscore, U+203E NEW
		sEntityMap[ CVSTR( "frasl" ) ] = (UniChar)8260; // fraction slash, U+2044 NEW
		sEntityMap[ CVSTR( "weierp" ) ] = (UniChar)8472; // script capital P = power set = Weierstrass p, U+2118 ISOamso
		sEntityMap[ CVSTR( "image" ) ] = (UniChar)8465; // blackletter capital I = imaginary part, U+2111 ISOamso
		sEntityMap[ CVSTR( "real" ) ] = (UniChar)8476; // blackletter capital R = real part symbol, U+211C ISOamso
		sEntityMap[ CVSTR( "trade" ) ] = (UniChar)8482; // trade mark sign, U+2122 ISOnum
		sEntityMap[ CVSTR( "alefsym" ) ] = (UniChar)8501; // alef symbol = first transfinite cardinal,
		sEntityMap[ CVSTR( "larr" ) ] = (UniChar)8592; // leftwards arrow, U+2190 ISOnum
		sEntityMap[ CVSTR( "uarr" ) ] = (UniChar)8593; // upwards arrow, U+2191 ISOnum-->
		sEntityMap[ CVSTR( "rarr" ) ] = (UniChar)8594; // rightwards arrow, U+2192 ISOnum
		sEntityMap[ CVSTR( "darr" ) ] = (UniChar)8595; // downwards arrow, U+2193 ISOnum
		sEntityMap[ CVSTR( "harr" ) ] = (UniChar)8596; // left right arrow, U+2194 ISOamsa
		sEntityMap[ CVSTR( "crarr" ) ] = (UniChar)8629; // downwards arrow with corner leftwards = carriage return, U+21B5 NEW
		sEntityMap[ CVSTR( "lArr" ) ] = (UniChar)8656; // leftwards double arrow, U+21D0 ISOtech
		sEntityMap[ CVSTR( "uArr" ) ] = (UniChar)8657; // upwards double arrow, U+21D1 ISOamsa
		sEntityMap[ CVSTR( "rArr" ) ] = (UniChar)8658; // rightwards double arrow, U+21D2 ISOtech
		sEntityMap[ CVSTR( "dArr" ) ] = (UniChar)8659; // downwards double arrow, U+21D3 ISOamsa
		sEntityMap[ CVSTR( "hArr" ) ] = (UniChar)8660; // left right double arrow,
		sEntityMap[ CVSTR( "forall" ) ] = (UniChar)8704; // for all, U+2200 ISOtech
		sEntityMap[ CVSTR( "part" ) ] = (UniChar)8706; // partial differential, U+2202 ISOtech 
		sEntityMap[ CVSTR( "exist" ) ] = (UniChar)8707; // there exists, U+2203 ISOtech
		sEntityMap[ CVSTR( "empty" ) ] = (UniChar)8709; // empty set = null set = diameter, U+2205 ISOamso
		sEntityMap[ CVSTR( "nabla" ) ] = (UniChar)8711; // nabla = backward difference, U+2207 ISOtech
		sEntityMap[ CVSTR( "isin" ) ] = (UniChar)8712; // element of, U+2208 ISOtech
		sEntityMap[ CVSTR( "notin" ) ] = (UniChar)8713; // not an element of, U+2209 ISOtech
		sEntityMap[ CVSTR( "ni" ) ] = (UniChar)8715; // contains as member, U+220B ISOtech
		sEntityMap[ CVSTR( "prod" ) ] = (UniChar)8719; // n-ary product = product sign, U+220F ISOamsb
		sEntityMap[ CVSTR( "sum" ) ] = (UniChar)8721; // n-ary sumation, U+2211 ISOamsb
		sEntityMap[ CVSTR( "minus" ) ] = (UniChar)8722; // minus sign, U+2212 ISOtech
		sEntityMap[ CVSTR( "lowast" ) ] = (UniChar)8727; // asterisk operator, U+2217 ISOtech
		sEntityMap[ CVSTR( "radic" ) ] = (UniChar)8730; // square root = radical sign, U+221A ISOtech
		sEntityMap[ CVSTR( "prop" ) ] = (UniChar)8733; // proportional to, U+221D ISOtech
		sEntityMap[ CVSTR( "infin" ) ] = (UniChar)8734; // infinity, U+221E ISOtech
		sEntityMap[ CVSTR( "ang" ) ] = (UniChar)8736; // angle, U+2220 ISOamso
		sEntityMap[ CVSTR( "and" ) ] = (UniChar)8743; // logical and = wedge, U+2227 ISOtech
		sEntityMap[ CVSTR( "or" ) ] = (UniChar)8744; // logical or = vee, U+2228 ISOtech
		sEntityMap[ CVSTR( "cap" ) ] = (UniChar)8745; // intersection = cap, U+2229 ISOtech
		sEntityMap[ CVSTR( "cup" ) ] = (UniChar)8746; // union = cup, U+222A ISOtech
		sEntityMap[ CVSTR( "int" ) ] = (UniChar)8747; // integral, U+222B ISOtech
		sEntityMap[ CVSTR( "there4" ) ] = (UniChar)8756; // therefore, U+2234 ISOtech
		sEntityMap[ CVSTR( "sim" ) ] = (UniChar)8764; // tilde operator = varies with = similar to, U+223C ISOtech
		sEntityMap[ CVSTR( "cong" ) ] = (UniChar)8773; // approximately equal to, U+2245 ISOtech
		sEntityMap[ CVSTR( "asymp" ) ] = (UniChar)8776; // almost equal to = asymptotic to, U+2248 ISOamsr
		sEntityMap[ CVSTR( "ne" ) ] = (UniChar)8800; // not equal to, U+2260 ISOtech
		sEntityMap[ CVSTR( "equiv" ) ] = (UniChar)8801; // identical to, U+2261 ISOtech
		sEntityMap[ CVSTR( "le" ) ] = (UniChar)8804; // less-than or equal to, U+2264 ISOtech
		sEntityMap[ CVSTR( "ge" ) ] = (UniChar)8805; // greater-than or equal to, U+2265 ISOtech
		sEntityMap[ CVSTR( "sub" ) ] = (UniChar)8834; // subset of, U+2282 ISOtech
		sEntityMap[ CVSTR( "sup" ) ] = (UniChar)8835; // superset of, U+2283 ISOtech
		sEntityMap[ CVSTR( "nsub" ) ] = (UniChar)8836; // not a subset of, U+2284 ISOamsn
		sEntityMap[ CVSTR( "sube" ) ] = (UniChar)8838; // subset of or equal to, U+2286 ISOtech
		sEntityMap[ CVSTR( "supe" ) ] = (UniChar)8839; // superset of or equal to, U+2287 ISOtech
		sEntityMap[ CVSTR( "oplus" ) ] = (UniChar)8853; // circled plus = direct sum, U+2295 ISOamsb
		sEntityMap[ CVSTR( "otimes" ) ] = (UniChar)8855; // circled times = vector product, U+2297 ISOamsb
		sEntityMap[ CVSTR( "perp" ) ] = (UniChar)8869; // up tack = orthogonal to = perpendicular, U+22A5 ISOtech
		sEntityMap[ CVSTR( "sdot" ) ] = (UniChar)8901; // dot operator, U+22C5 ISOamsb
		sEntityMap[ CVSTR( "lceil" ) ] = (UniChar)8968; // left ceiling = apl upstile, U+2308 ISOamsc 
		sEntityMap[ CVSTR( "rceil" ) ] = (UniChar)8969; // right ceiling, U+2309 ISOamsc 
		sEntityMap[ CVSTR( "lfloor" ) ] = (UniChar)8970; // left floor = apl downstile, U+230A ISOamsc 
		sEntityMap[ CVSTR( "rfloor" ) ] = (UniChar)8971; // right floor, U+230B ISOamsc 
		sEntityMap[ CVSTR( "lang" ) ] = (UniChar)9001; // left-pointing angle bracket = bra, U+2329 ISOtech
		sEntityMap[ CVSTR( "rang" ) ] = (UniChar)9002; // right-pointing angle bracket = ket, U+232A ISOtech
		sEntityMap[ CVSTR( "loz" ) ] = (UniChar)9674; // lozenge, U+25CA ISOpub
		sEntityMap[ CVSTR( "spades" ) ] = (UniChar)9824; // black spade suit, U+2660 ISOpub
		sEntityMap[ CVSTR( "clubs" ) ] = (UniChar)9827; // black club suit = shamrock, U+2663 ISOpub
		sEntityMap[ CVSTR( "hearts" ) ] = (UniChar)9829; // black heart suit = valentine, U+2665 ISOpub
		sEntityMap[ CVSTR( "diams" ) ] = (UniChar)9830; // black diamond suit, U+2666 ISOpub
		sEntityMap[ CVSTR( "quot" ) ] = (UniChar)34; // quotation mark = APL quote, U+0022 ISOnum
		sEntityMap[ CVSTR( "amp" ) ] = (UniChar)38; // ampersand, U+0026 ISOnum
		sEntityMap[ CVSTR( "lt" ) ] = (UniChar)60; // less-than sign, U+003C ISOnum
		sEntityMap[ CVSTR( "gt" ) ] = (UniChar)62; // greater-than sign, U+003E ISOnum
		sEntityMap[ CVSTR( "OElig" ) ] = (UniChar)338; // latin capital ligature OE, U+0152 ISOlat2
		sEntityMap[ CVSTR( "oelig" ) ] = (UniChar)339; // latin small ligature oe, U+0153 ISOlat2
		sEntityMap[ CVSTR( "Scaron" ) ] = (UniChar)352; // latin capital letter S with caron, U+0160 ISOlat2
		sEntityMap[ CVSTR( "scaron" ) ] = (UniChar)353; // latin small letter s with caron, U+0161 ISOlat2
		sEntityMap[ CVSTR( "Yuml" ) ] = (UniChar)376; // latin capital letter Y with diaeresis, U+0178 ISOlat2
		sEntityMap[ CVSTR( "circ" ) ] = (UniChar)710; // modifier letter circumflex accent, U+02C6 ISOpub
		sEntityMap[ CVSTR( "tilde" ) ] = (UniChar)732; // small tilde, U+02DC ISOdia
		sEntityMap[ CVSTR( "ensp" ) ] = (UniChar)8194; // en space, U+2002 ISOpub
		sEntityMap[ CVSTR( "emsp" ) ] = (UniChar)8195; // em space, U+2003 ISOpub
		sEntityMap[ CVSTR( "thinsp" ) ] = (UniChar)8201; // thin space, U+2009 ISOpub
		sEntityMap[ CVSTR( "zwnj" ) ] = (UniChar)8204; // zero width non-joiner, U+200C NEW RFC 2070
		sEntityMap[ CVSTR( "zwj" ) ] = (UniChar)8205; // zero width joiner, U+200D NEW RFC 2070
		sEntityMap[ CVSTR( "lrm" ) ] = (UniChar)8206; // left-to-right mark, U+200E NEW RFC 2070
		sEntityMap[ CVSTR( "rlm" ) ] = (UniChar)8207; // right-to-left mark, U+200F NEW RFC 2070
		sEntityMap[ CVSTR( "ndash" ) ] = (UniChar)8211; // en dash, U+2013 ISOpub
		sEntityMap[ CVSTR( "mdash" ) ] = (UniChar)8212; // em dash, U+2014 ISOpub
		sEntityMap[ CVSTR( "lsquo" ) ] = (UniChar)8216; // left single quotation mark, U+2018 ISOnum
		sEntityMap[ CVSTR( "rsquo" ) ] = (UniChar)8217; // right single quotation mark, U+2019 ISOnum
		sEntityMap[ CVSTR( "sbquo" ) ] = (UniChar)8218; // single low-9 quotation mark, U+201A NEW
		sEntityMap[ CVSTR( "ldquo" ) ] = (UniChar)8220; // left double quotation mark, U+201C ISOnum
		sEntityMap[ CVSTR( "rdquo" ) ] = (UniChar)8221; // right double quotation mark, U+201D ISOnum
		sEntityMap[ CVSTR( "bdquo" ) ] = (UniChar)8222; // double low-9 quotation mark, U+201E NEW
		sEntityMap[ CVSTR( "dagger" ) ] = (UniChar)8224; // dagger, U+2020 ISOpub
		sEntityMap[ CVSTR( "Dagger" ) ] = (UniChar)8225; // double dagger, U+2021 ISOpub
		sEntityMap[ CVSTR( "permil" ) ] = (UniChar)8240; // per mille sign, U+2030 ISOtech
		sEntityMap[ CVSTR( "lsaquo" ) ] = (UniChar)8249; // single left-pointing angle quotation mark, U+2039 ISO proposed
		sEntityMap[ CVSTR( "rsaquo" ) ] = (UniChar)8250; // single right-pointing angle quotation mark, U+203A ISO proposed
		sEntityMap[ CVSTR( "euro" ) ] = (UniChar)8364; // euro sign, U+20AC NEW
	}

	EntityMap::iterator iter = sEntityMap.find( inEntityName );
	if (iter != sEntityMap.end()) {
		outReplacement = iter->second;
		return true;
	}
	return false;
}
Пример #21
0
bool HTMLLexer::ConsumeMultiLineComment( TokenList *ioTokens, sLONG inType )
{
	// We have to override the default behavior for multiline comment consumption because we define
	// a bunch of "special" comment types for 4D.  So we will let the default consumer do its job, but
	// we will look at the comment that was consumed afterwards to see if we have a special comment
	// type.  If we do, we need only modify the token's type accordingly.
	bool ret = VLexerBase::ConsumeMultiLineComment( ioTokens, inType );

	// Look at the last token in the list (it should be a comment or an open comment), and grab its text
	ILexerToken *token = ioTokens->back();
	xbox_assert( token->GetType() == ILexerToken::TT_COMMENT || token->GetType() == ILexerToken::TT_OPEN_COMMENT );

	// For right now, we only care about finished comments because it makes the logic easier.  We don't have to
	// worry so much about handling the syntax highlighting aspects of things.
	VString tokenText = token->GetText();
	if (token->GetType() == ILexerToken::TT_COMMENT && tokenText.BeginsWith( CVSTR( "<!--#4D" ) )) {
		// We probably have one of the special comment types.  We're going to remove the old token and create a new
		// one with the appropriate information, but only after we've verified that this isn't just garbage!
		if (tokenText.BeginsWith( CVSTR( "<!--#4DVAR" ) ) ||
			tokenText.BeginsWith( CVSTR( "<!--#4DHTMLVAR" ) ) ||
			tokenText.BeginsWith( CVSTR( "<!--#4DINCLUDE" ) ) ||
			tokenText.BeginsWith( CVSTR( "<!--#4DACTION" ) ) ||
			tokenText.BeginsWith( CVSTR( "<!--#4DSCRIPT" ) ) ||
			tokenText.BeginsWith( CVSTR( "<!--#4DMETHOD" ) ) ||
			tokenText.BeginsWith( CVSTR( "<!--#4DIF" ) ) ||
			tokenText.BeginsWith( CVSTR( "<!--#4DELSE" ) ) ||
			tokenText.BeginsWith( CVSTR( "<!--#4DENDIF" ) ) ||
			tokenText.BeginsWith( CVSTR( "<!--#4DLOOP" ) ) ||
			tokenText.BeginsWith( CVSTR( "<!--#4DENDLOOP" ) )) {
				ioTokens->pop_back();
				ioTokens->push_back( new HTMLLexerToken( ILexerToken::TT_SPECIAL_4D_COMMENT, token->GetPosition(), token->GetLength(), tokenText, token->GetValue() ) );
		}
	}

	return ret;
}
XBOX::VError VHTTPServerProjectSettings::LoadFromBag (const XBOX::VValueBag *inBag)
{
	if (NULL == inBag)
		return XBOX::VE_INVALID_PARAMETER;

#if 0 /*VERSIONDEBUG*/
	XBOX::VString xmlString ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
	inBag->DumpXML (xmlString, CVSTR ("settings"), true);
#endif

	/* Project settings */
	const XBOX::VValueBag *projectSettings = RetainSettings (inBag, RIASettingsKeys::Project::kXmlElement);
	if (projectSettings)
	{
		XBOX::VString ipString = RIASettingsKeys::Project::listen.Get (projectSettings);
#if WITH_DEPRECATED_IPV4_API
		fListeningAddress = ServerNetTools::GetIPAddress (ipString);
#else
		fListeningAddress.FromString (ipString);
#endif		
		fHostName = RIASettingsKeys::Project::hostName.Get (projectSettings);
#if HTTP_SERVER_USE_PROJECT_PATTERNS
		fProjectPattern = RIASettingsKeys::Project::pattern.Get (projectSettings);
#endif

#if WITH_DEPRECATED_IPV4_API
		if ((fListeningAddress != 0) && (fListeningAddress != LOCALHOST_ADDRESS))
#else
		if ((fListeningAddress != XBOX::VNetAddress::GetAnyIP()) && (fListeningAddress != XBOX::VNetAddress::GetLoopbackIP()))
#endif		
		{
#if WITH_DEPRECATED_IPV4_API
			std::vector<IP4> ipv4Addresses;
			if (ServerNetTools::GetLocalIPv4Addresses (ipv4Addresses) > 0)
			{
				if (!FindValueInVector (ipv4Addresses, fListeningAddress))
					fListeningAddress = 0; // Listening on all IP addresses
			}
#else
			XBOX::VectorOfVString	localIPAddresses;

			if (HTTPServerTools::GetLocalIPAddresses (localIPAddresses) > 0)
			{
				if (!FindValueInVector (localIPAddresses, fListeningAddress))
					fListeningAddress.FromString (XBOX::VNetAddress::GetAnyIP()); // Listening on all IP addresses
			}
#endif			
		}

		XBOX::VString authType;
		RIASettingsKeys::Project::realm.Get (projectSettings, fRealm);
		RIASettingsKeys::Project::authType.Get (projectSettings, authType);
		fAuthType = HTTPServerTools::GetAuthenticationMethodFromName (authType);

		XBOX::QuickReleaseRefCountable (projectSettings);
	}


	/*  HTTP Settings */
	const XBOX::VValueBag *httpSettings = RetainSettings (inBag, RIASettingsKeys::HTTP::kXmlElement);
	if (httpSettings)
	{
		fPort = RIASettingsKeys::HTTP::port.Get (httpSettings);
		fAllowSSL = RIASettingsKeys::HTTP::allowSSL.Get (httpSettings);
		fSSLMandatory = RIASettingsKeys::HTTP::SSLMandatory.Get (httpSettings);
		fSSLPort = RIASettingsKeys::HTTP::SSLPort.Get (httpSettings);

		if (fSSLMandatory && !fAllowSSL)
			fAllowSSL = true;

		if (fAllowSSL)
		{
			XBOX::VString certificatePath = RIASettingsKeys::HTTP::SSLCertificatePath.Get (httpSettings);
			BuildFolderPath (fProjectFolderPath, certificatePath, fSSLCertificatesFolderPath);
		}

		XBOX::VString charSetString = RIASettingsKeys::HTTP::standardSet.Get (httpSettings);
		XBOX::CharSet charSet = VTextConverters::Get()->GetCharSetFromName (charSetString);
		fDefaultCharSet = (charSet != XBOX::VTC_UNKNOWN) ? charSet : XBOX::VTC_UTF_8;

		/* cache settings */
		fEnableCache = RIASettingsKeys::HTTP::useCache.Get (httpSettings);
		fCacheMaxSize = RIASettingsKeys::HTTP::pageCacheSize.Get (httpSettings) * 1024;			// expressed in Kilo-Bytes in settings file
		fCachedObjectMaxSize = RIASettingsKeys::HTTP::cachedObjectMaxSize.Get (httpSettings);	// expressed in Bytes in settings file

		/* compression settings */
		fEnableCompression = RIASettingsKeys::HTTP::allowCompression.Get (httpSettings);
		fCompressionMinThreshold = RIASettingsKeys::HTTP::compressionMinThreshold.Get (httpSettings);
		fCompressionMaxThreshold = RIASettingsKeys::HTTP::compressionMaxThreshold.Get (httpSettings);

		/* Keep-Alive settings */
		fEnableKeepAlive = RIASettingsKeys::HTTP::acceptKeepAliveConnections.Get (httpSettings);
/* Temporary disable theses settings loading... because of a bug with long timeout values (sic...)
		fKeepAliveTimeout = RIASettingsKeys::HTTP::maximumTimeout.Get (httpSettings);
		fKeepAliveMaxConnections = RIASettingsKeys::HTTP::maximumRequestsByConnection.Get (httpSettings);
*/

		/* Log settings */
		fLogFormat = HTTPServerTools::GetLogFormatFromName (RIASettingsKeys::HTTP::logFormat.Get (httpSettings));
		SetLogRotationMode (LRC_ROTATE_ON_FILE_SIZE);
		SetLogMaxSize (RIASettingsKeys::HTTP::logMaxSize.Get (httpSettings));
		XBOX::VString logFolderPathString = RIASettingsKeys::HTTP::logPath.Get (httpSettings);
		BuildFolderPath (fProjectFolderPath, logFolderPathString, fLogFolderPath);
		fLogFileName = RIASettingsKeys::HTTP::logFileName.Get (httpSettings);

		const XBOX::VBagArray *logTokens = RetainMultipleSettings (httpSettings, RIASettingsKeys::HTTP::Log::kXmlElement);
		if (NULL != logTokens)
		{
			XBOX::VIndex count = logTokens->GetCount();

			if (count > 0)
			{
				XBOX::VString tokenName;
				XBOX::VTaskLock lock (&fLogTokensVectorLock);

				fLogTokensVector.clear();
				for (XBOX::VIndex i = 1; i <= count; ++i)
				{
					const XBOX::VValueBag *bag = logTokens->GetNth (i);
					if (NULL != bag)
					{
						bag->GetString (RIASettingsKeys::HTTP::Log::field, tokenName);
						if (!tokenName.IsEmpty())
						{
							EHTTPServerLogToken token = HTTPServerTools::GetLogTokenFromName (tokenName);
							if (token != LOG_TOKEN_NONE)
								AppendUniqueValueToVector (fLogTokensVector, token);
						}
					}
				}
			}

			XBOX::QuickReleaseRefCountable (logTokens);
		}

		XBOX::QuickReleaseRefCountable (httpSettings);
	}

	/* Web App settings */
	const XBOX::VValueBag *webAppSettings = RetainSettings (inBag, RIASettingsKeys::WebApp::kXmlElement);
	if (webAppSettings)
	{
		XBOX::VString webFolderPath;
		webFolderPath = RIASettingsKeys::WebApp::documentRoot.Get (webAppSettings);
		BuildFolderPath (fProjectFolderPath, webFolderPath, fWebFolderPath);
		fIndexPageName = RIASettingsKeys::WebApp::directoryIndex.Get (webAppSettings);

		XBOX::QuickReleaseRefCountable (webAppSettings);
	}

	/* Resources settings */
	LoadResourcesSettingsFromBag( *inBag);

	/* Virtual Folders settings */
	LoadVirtualFoldersSettingsFromBag( *inBag);

	Tell_SettingsChanged();

	return XBOX::VE_OK;
}
Пример #23
0
* other than those specified in the applicable license is granted.
*/
#include "VJavaScriptPrecompiled.h"

#include "VJSTLS.h"

#include "VJSContext.h"
#include "VJSGlobalClass.h"
#include "VJSWorker.h"
#include "VJSNet.h"
#include "VJSNetServer.h"
#include "VJSNetSocket.h"

USING_TOOLBOX_NAMESPACE

const XBOX::VString	VJSTLSClass::kModuleName	= CVSTR("tls");

void VJSTLSClass::RegisterModule ()
{
	VJSGlobalClass::RegisterModuleConstructor(kModuleName, _ModuleConstructor);
}

XBOX::VJSObject VJSTLSClass::_ModuleConstructor (const VJSContext &inContext, const VString &inModuleName)
{
	xbox_assert(inModuleName.EqualToString(kModuleName, true));

	VJSTLSClass::Class();
	return VJSTLSClass::CreateInstance(inContext, NULL);
}

void VJSTLSClass::GetDefinition (ClassDefinition &outDefinition)
	void StOptionsInfos::HelpUsage(const VString& inArgv0) const
	{
		HelpUsagePrinter printer;

		// first line
		printer.out += CVSTR("Usage: ");
		printer.out += inArgv0; // FIXME : extractFilePath(inArgv0)
		printer.out += CVSTR(" [OPTION]...");
		if (remainingOption)
			printer.out += CVSTR(" [FILE]...");
		printer.out += '\n';

		// iterating through all options
		if (! options.empty())
		{
			Private::CommandLineParser::VOptionBase::Vector::const_iterator end = options.end();
			Private::CommandLineParser::VOptionBase::Vector::const_iterator i   = options.begin();

			// Add a space if the first option is not a paragraph
			// (otherwise the user would do what he wants)
			if (! (*i)->IsParagraph())
			{
				// deal with hidden options at the beginning
				if ((*i)->IsVisibleFromHelpUsage())
				{
					printer.out += '\n';
				}
				else
				{
					// the first element is not visible, thus we can not determine what to do
					// trying to find the first visible element
					for (; i != end; ++i)
					{
						if ((*i)->IsVisibleFromHelpUsage())
						{
							if (! (*i)->IsParagraph())
								printer.out += '\n';
							break;
						}
					}

					// reset the iterator
					i = options.begin();
				}
			}

			// temporary string for description manipulation
			VString tmpDesc;

			for (; i != end; ++i)
			{
				const Private::CommandLineParser::VOptionBase& opt = *(*i);

				if (opt.IsVisibleFromHelpUsage())
				{
					// we should remove all \t produced by end-of-line backslashes
					// (used for writing long text on several lines)
					// anyway the tab-character should not be used within descriptions
					tmpDesc = opt.GetDescription();
					tmpDesc.ExchangeAll(CVSTR("\t"), VString());

					if (! opt.IsParagraph())
					{
						printer.ExportOptionHelpUsage(opt.GetShortName(), opt.GetLongName(), tmpDesc, opt.IsRequiresParameter());
					}
					else
						printer.ExportParagraph(tmpDesc);
				}
			}
		}

		// determining if the --help option is implicit or not
		if (0 == byLongNames.count(CVSTR("help")))
		{
			// --help is implicit
			VString desc = CVSTR("Display the help and exit");

			#if VERSIONWIN
			{
				if (byShortNames.count('h') == 0)
					printer.ExportOptionHelpUsage('?', CVSTR("h, /help"), desc, false);
				else
					printer.ExportOptionHelpUsage('?', CVSTR("help"), desc, false);
			}
			#else
			{
				if (byShortNames.count('h') == 0)
					printer.ExportOptionHelpUsage('h', CVSTR("help"), desc, false);
				else
					printer.ExportOptionHelpUsage(' ', CVSTR("help"), desc, false);
			}
			#endif
		}

		// display the help usage to the console
		#if VERSIONWIN
		std::wcout.write(printer.out.GetCPointer(), printer.out.GetLength());
		#else
		StStringConverter<char> buff(printer.out, VTC_UTF_8);
		if (buff.IsOK())
			std::cout.write(buff.GetCPointer(), buff.GetSize());
		#endif
	}
* such license does not include any other license or rights on this file,
* 4D's and/or its licensors' trademarks and/or other proprietary rights.
* Consequently, no title, copyright or other proprietary rights
* other than those specified in the applicable license is granted.
*/
#include "HTTPServer.h"
#include "VHTTPServer.h"

#if !VERSIONWIN
	#include <arpa/inet.h>
#endif

//--------------------------------------------------------------------------------------------------


const XBOX::VString STRING_EMPTY						= CVSTR ("");
const XBOX::VString STRING_STAR							= CVSTR ("*");


	/**
	*	Some common HTTP Request headers
	*/
const XBOX::VString STRING_HEADER_ACCEPT				= CVSTR ("Accept");
const XBOX::VString STRING_HEADER_ACCEPT_CHARSET		= CVSTR ("Accept-Charset");
const XBOX::VString STRING_HEADER_ACCEPT_ENCODING		= CVSTR ("Accept-Encoding");
const XBOX::VString STRING_HEADER_ACCEPT_LANGUAGE		= CVSTR ("Accept-Language");
const XBOX::VString STRING_HEADER_AUTHORIZATION			= CVSTR ("Authorization");
const XBOX::VString STRING_HEADER_CONTENT_DISPOSITION	= CVSTR ("Content-Disposition");
const XBOX::VString STRING_HEADER_COOKIE				= CVSTR ("Cookie");
const XBOX::VString STRING_HEADER_EXPECT				= CVSTR ("Expect");
const XBOX::VString STRING_HEADER_FROM					= CVSTR ("From");
/*
	static
*/
DialectCode	VComponentManager::GetLocalizationLanguage(VFolder * inLocalizationResourcesFolder,bool inGotoResourceFolder)
{
	DialectCode sResult = XBOX::DC_NONE;	// sc 19/05/2008 was XBOX::DC_ENGLISH_US
	VFolder * localizationResourcesFolder = NULL;
	
	if(testAssert(inLocalizationResourcesFolder != NULL && inLocalizationResourcesFolder->Exists()))
	{
		if (inGotoResourceFolder)
		{
			XBOX::VFilePath componentOrPluginFolderPath = inLocalizationResourcesFolder->GetPath();
			componentOrPluginFolderPath.ToSubFolder(CVSTR("Contents")).ToSubFolder(CVSTR("Resources"));
			localizationResourcesFolder = new XBOX::VFolder(componentOrPluginFolderPath);
		}
		else
		{
			localizationResourcesFolder = inLocalizationResourcesFolder;
			localizationResourcesFolder->Retain();
		}

		bool englishFolderDetected = false;
		XBOX::DialectCode dialectCode = XBOX::DC_NONE;
		
		//Detect what is the favorite language of the OS/App
#if VERSIONWIN
		LCID lcid = ::GetUserDefaultLCID();
		XBOX::DialectCode currentDialectCode = (XBOX::DialectCode)LANGIDFROMLCID(lcid);

#elif VERSION_LINUX

		//jmo - Be coherent with code in VIntlMgr.cpp
		XBOX::DialectCode currentDialectCode=XBOX::DC_ENGLISH_US;   // Postponed Linux Implementation !
		
#else

		CFBundleRef	bundle = ::CFBundleGetMainBundle();
		XBOX::DialectCode currentDialectCode = XBOX::DC_ENGLISH_US;
		if ( bundle != nil ){
			CFArrayRef array_ref = ::CFBundleCopyBundleLocalizations(bundle);			
			if (array_ref != nil){
				CFArrayRef usedLanguages = ::CFBundleCopyPreferredLocalizationsFromArray(array_ref);
				CFStringRef cfPrimaryLanguage = (CFStringRef)CFArrayGetValueAtIndex(usedLanguages, 0);
				XBOX::VString xboxPrimaryLanguage;
				xboxPrimaryLanguage.MAC_FromCFString(cfPrimaryLanguage);
				::CFRelease(usedLanguages);
				if(!XBOX::VIntlMgr::GetDialectCodeWithISOLanguageName(xboxPrimaryLanguage, currentDialectCode))
					if(!XBOX::VIntlMgr::GetDialectCodeWithRFC3066BisLanguageCode(xboxPrimaryLanguage, currentDialectCode))
						currentDialectCode = XBOX::DC_ENGLISH_US;
				CFRelease(array_ref);
			}
		}
#endif
		//Try to see if we have this language. If not, take english
		for ( XBOX::VFolderIterator folderIter( localizationResourcesFolder ); folderIter.IsValid() && currentDialectCode != dialectCode ; ++folderIter )
		{
			XBOX::VString folderName;
			folderIter->GetName(folderName);
			uLONG posStr = folderName.Find(CVSTR(".lproj"), 1, false);
			if ( posStr > 0 )
			{
				folderName.Remove(posStr, folderName.GetLength() - posStr + 1);
				if( XBOX::VIntlMgr::GetDialectCodeWithRFC3066BisLanguageCode(folderName, dialectCode ) || XBOX::VIntlMgr::GetDialectCodeWithISOLanguageName(folderName, dialectCode)){
					if(dialectCode == XBOX::DC_ENGLISH_US)
						englishFolderDetected = true;
					
					if(currentDialectCode == dialectCode)
						sResult = dialectCode;
				}
			}
		}
		
		if ( sResult == XBOX::DC_NONE ){
			if ( englishFolderDetected ) 
				sResult = XBOX::DC_ENGLISH_US;
			else 
				sResult = dialectCode;
		}
		
		ReleaseRefCountable(&localizationResourcesFolder);
	}
	
	return sResult;
}
Пример #27
0
VFolder* VProcess::RetainFolder( VProcess::EFolderKind inSelector) const
{
	VFolder* folder = NULL;
	
	switch (inSelector)
	{
		case eFS_Executable:
			folder = new VFolder( GetExecutableFolderPath());
			break;
		
		case eFS_Bundle:
			#if VERSIONWIN || VERSION_LINUX
			folder = new VFolder( GetExecutableFolderPath());
			#elif VERSIONMAC
			folder = new VFolder( GetExecutableFolderPath().ToParent().ToParent());
			#endif
			break;

		case eFS_Resources:
			{
				#if VERSIONWIN || VERSION_LINUX
				VFolder *parent = new VFolder( GetExecutableFolderPath());
				#elif VERSIONMAC
				VFolder *parent = new VFolder( GetExecutableFolderPath().ToParent());	// Contents
				#endif

				if (parent != NULL)
					folder = new VFolder( *parent, CVSTR( "Resources"));
				
				ReleaseRefCountable( &parent);
				break;
			}
		
		case eFS_InfoPlist:
			{
				// Resources folder on windows.
				// Contents folder on mac.
				#if VERSIONWIN || VERSION_LINUX
				folder = RetainFolder( eFS_Resources);
				#elif VERSIONMAC
				folder = new VFolder( GetExecutableFolderPath().ToParent());
				#endif
				break;
			}
		
		case eFS_NativeComponents:
			{
				#if VERSIONWIN || VERSION_LINUX
				folder = new VFolder( GetExecutableFolderPath().ToSubFolder( CVSTR( "Native Components")));
				#elif VERSIONMAC
				folder = new VFolder( GetExecutableFolderPath().ToParent().ToSubFolder( CVSTR( "Native Components")));
				#endif
				
				// in debug mode the "Native Components" might be next the bundle folder to be shared among mono, server, studio, server
				#if VERSIONDEBUG
				if ( (folder == NULL) || !folder->Exists() )
				{
					ReleaseRefCountable( &folder);
					#if VERSIONWIN || VERSION_LINUX
					folder = new VFolder( GetExecutableFolderPath().ToParent().ToSubFolder( CVSTR( "Native Components")));
					#elif VERSIONMAC
					folder = new VFolder( GetExecutableFolderPath().ToParent().ToParent().ToParent().ToSubFolder( CVSTR( "Native Components")));
					#endif
				}
				#endif
				
				break;
			}
		
		case eFS_DTDs:
			{
				VFolder *parent = RetainFolder( eFS_Resources);
				if (parent != NULL)
					folder = new VFolder( *parent, CVSTR( "DTD"));
				ReleaseRefCountable( &parent);
				break;
			}
		
		case eFS_XSDs:
			{
				VFolder *parent = RetainFolder( eFS_Resources);
				if (parent != NULL)
					folder = new VFolder( *parent, CVSTR( "XSD"));
				ReleaseRefCountable( &parent);
				break;
			}
		
		case eFS_XSLs:
			{
				VFolder *parent = RetainFolder( eFS_Resources);
				if (parent != NULL)
					folder = new VFolder( *parent, CVSTR( "XSL"));
				ReleaseRefCountable( &parent);
				break;
			}
		
		default:
			break;
	}

	return folder;
}
XBOX::VError VChromeDbgHdlPage::TreatMsg()
{		
	XBOX::VError		l_err;
	XBOX::VString		l_cmd;
	XBOX::VString		l_resp;
	bool				l_found;
	sBYTE*				l_id;
	ChrmDbgMsg_t		l_msg;
	bool				l_msg_found;

	l_err = VE_OK;

	l_cmd = K_UNKNOWN_CMD;
	l_found = false;
	l_err = CheckInputData();

	VString l_trace("VChromeDbgHdlPage::TreatMsg Method=");
	l_trace += fMethod;
	if (fParams)
	{
		l_trace += " ,";
		VString l_params = "params=<";
		l_params.AppendCString(fParams);
		l_params += ">";
		l_trace += l_params;
	}
	sPrivateLogHandler->Put( (l_err != VE_OK ? WAKDBG_ERROR_LEVEL : WAKDBG_INFO_LEVEL),l_trace);

	if (!l_err)
	{
		DebugMsg("VChromeDbgHdlPage::TreatMsg Method='%S', Id='%s',Params='%s'\n",&fMethod,fId,(fParams ? fParams : "."));
	}
	else
	{
		DebugMsg("VChromeDbgHdlPage::TreatMsg CheckInputData pb !!!!\n");
	}

	l_cmd = K_APP_CAC_GET_FRA_WIT_MAN;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_APP_CAC_GET_FRA_WIT_MAN_STR1);
	}
#if 1
	l_cmd = K_APP_CAC_ENA;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {	

		l_resp = K_APP_CAC_ENA_STR1;
		l_err = SendMsg(l_resp);
		if (!l_err)
		{
			l_err = SendResult(K_EMPTY_STR);
		}
	}

	l_cmd = K_DBG_REM_BRE;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		sBYTE	*l_end;
		sBYTE	*l_tmp;
		l_tmp = strstr(fParams,K_BRK_PT_ID_STR);
		if (l_tmp)
		{
			l_tmp += strlen(K_BRK_PT_ID_STR)+1;// +1 to skip the '"'

			l_end = strchr(l_tmp,'"');
			if (l_end)
			{
				*l_end = 0;
				/*if (strstr(l_tmp,K_FILE_STR) == l_tmp)
				{
					l_tmp += strlen(K_FILE_STR);
				}*/
				l_end = strchr(l_tmp,':');
				if (l_end)
				{
					sscanf(l_end,":%d:",&l_msg.data.Msg.fLineNumber);
					*l_end = 0;
					l_msg.type = SEND_CMD_MSG;
					l_msg.data.Msg.fType = WAKDebuggerServerMessage::SRV_REMOVE_BREAKPOINT_MSG;
					l_msg.data.Msg.fSrcId = fSrcId;
					//l_msg.data.Msg.fUrl[fURL.ToBlock(l_msg.data.Msg.fUrl,K_MAX_FILESIZE-1,VTC_UTF_8,false,false)] = 0;
					l_err = fOutFifo.Put(l_msg);
					if (testAssert( l_err == VE_OK ))
					{
						// we answer as success since wakanda is not able to return a status regarding bkpt handling
						l_err = SendResult(K_EMPTY_STR);
					}
				}
			}
		}
	}

	l_cmd = K_DBG_EVA_ON_CAL_FRA;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		sBYTE*		l_tmp_exp;
		sBYTE*		l_ord;
		l_tmp_exp = strstr(fParams,K_EXPRESSION_STR);
		l_ord = strstr(fParams,K_ORDINAL_STR);
		if (l_tmp_exp && l_ord)
		{
			l_tmp_exp += strlen(K_EXPRESSION_STR);
			sBYTE *l_end_str;
			l_end_str = strchr(l_tmp_exp,'"');
			if (l_end_str)
			{
				l_msg.data.Msg.fLineNumber = atoi(l_ord+strlen(K_ORDINAL_STR));
				*l_end_str = 0;
				VString l_exp(l_tmp_exp);
				DebugMsg("requiring value of '%S'\n",&l_exp);
				//l_resp = CVSTR("\"result\":{\"type\":\"number\",\"value\":3,\"description\":\"3\"}");
				l_msg.type = SEND_CMD_MSG;
				l_msg.data.Msg.fType = WAKDebuggerServerMessage::SRV_EVALUATE_MSG;
				l_msg.data.Msg.fSrcId = fSrcId;
				l_msg.data.Msg.fString[l_exp.ToBlock(l_msg.data.Msg.fString,K_MAX_FILESIZE-1,VTC_UTF_8,false,false)] = 0;
				l_err = fOutFifo.Put(l_msg);
				if (testAssert( l_err == VE_OK ))
				{
					l_err = fFifo.Get(&l_msg,&l_msg_found,0);
					if (testAssert( l_err == VE_OK ))
					{
						if (l_msg_found && (l_msg.type == EVAL_MSG))
						{
						}
						else
						{
							l_err = VE_INVALID_PARAMETER;
							xbox_assert(false);
						}
					}
				}
				l_resp = l_msg.data._dataStr;
				VString		l_hdr = CVSTR("\"result\":{\"value\":{");
				VString		l_sub;
				if (l_resp.GetLength() > l_hdr.GetLength())
				{
					l_resp.GetSubString(l_hdr.GetLength(),l_resp.GetLength()-l_hdr.GetLength()+1,l_sub);
				}
				l_resp = CVSTR("\"result\":");
				l_resp += l_sub;
				if (!l_err)
				{
					l_err = SendResult(l_resp);
				}
			}
			else
			{
				l_err = VE_INVALID_PARAMETER;
			}
		}
		else
		{
			l_err = VE_INVALID_PARAMETER;
		}
	}

	l_cmd = K_DBG_SET_BRE_BY_URL;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		sBYTE	*l_line_nb;
		sBYTE	*l_col_nb;
		sBYTE	*l_url;
		l_err = GetBrkptParams(fParams,&l_url,&l_col_nb,&l_line_nb);

		if (!l_err)
		{
			l_msg.type = SEND_CMD_MSG;
			l_msg.data.Msg.fType = WAKDebuggerServerMessage::SRV_SET_BREAKPOINT_MSG;
			l_msg.data.Msg.fSrcId = fSrcId;
			l_msg.data.Msg.fLineNumber = atoi(l_line_nb);
			//l_msg.data.Msg.fUrl[fURL.ToBlock(l_msg.data.Msg.fUrl,K_MAX_FILESIZE-1,VTC_UTF_8,false,false)] = 0;
			l_err = fOutFifo.Put(l_msg);
			xbox_assert( l_err == VE_OK );
		}
		if (!l_err)
		{
			l_resp = K_DBG_SET_BRE_BY_URL_STR1;
			l_url[strlen(l_url)-1] = 0;// -1 is aimed to remove the final '"'
			l_resp += l_url;
			l_resp += ":";
			l_resp += l_line_nb;
			l_resp += ":";
			l_resp += l_col_nb;
			l_resp += K_DBG_SET_BRE_BY_URL_STR2;
			l_resp += fId;
			l_resp += "}";
			// we answer as success since wakanda is not able to return a status regarding bkpt handling
			l_err = SendMsg(l_resp);
		}
	}

	l_cmd = K_NET_GET_RES_BOD;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {	
		l_resp = K_NET_GET_RES_BOD_STR1;
		l_resp += K_LINE_1;
		l_resp += K_LINE_2;
		l_resp += K_LINE_3;
		l_resp += K_LINE_4;
		l_resp += K_LINE_5;
		l_resp += K_LINE_6;
		l_resp += K_NET_GET_RES_BOD_STR2;
		l_resp += fId;
		l_resp += "}";
		l_err = SendMsg(l_resp);
	}
	
	l_cmd = K_PAG_GET_RES_CON;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {	
		l_resp = K_PAG_GET_RES_CON_STR1;
		l_resp += K_LINE_1;
		l_resp += K_LINE_2;
		l_resp += K_LINE_3;
		l_resp += K_LINE_4;
		l_resp += K_LINE_5;
		l_resp += K_LINE_6;
		l_resp += K_PAG_GET_RES_CON_STR2;
		l_resp += fId;
		l_resp += "}";
		l_err = SendMsg(l_resp);
	}

	l_cmd = K_DOM_SET_INS_MOD_ENA;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {	
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_DOM_PUS_NOD_BY_PAT_TO_FRO_END;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_resp = K_DOM_PUS_NOD_BY_PAT_TO_FRO_END_STR1;
		l_resp.AppendLong(fBodyNodeId);
		l_resp += K_ID_FMT_STR;
		l_resp += fId;
		l_resp += "}";
		l_err = SendMsg(l_resp);
	}
	
	l_cmd = K_PAG_REL;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		// page reload from CHrome not handled
		xbox_assert(false);
		l_err = VE_UNKNOWN_ERROR;
		return l_err;
#if 0

if (s_brkpt_line_nb.GetLength())
{
	return TreatPageReload(NULL);
	return l_err;
}
		l_resp = K_PAG_REL_STR1;
		l_err = SendMsg(l_resp);
		if (!l_err)
		{
			l_err = SendResult(K_EMPTY_STR);
		}
		if (!l_err)
		{
			l_resp = K_PAG_REL_STR2;
			l_err = SendMsg(l_resp);
		}
		if (!l_err)
		{
			l_resp = K_PAG_REL_STR3;
			l_err = SendMsg(l_resp);
		}
		if (!l_err)
		{
			l_resp = K_PAG_REL_STR4;
			l_err = SendMsg(l_resp);
		}
		if (!l_err)
		{
			l_resp = K_PAG_REL_STR5;
			l_err = SendMsg(l_resp);
		}
		if (!l_err)
		{
			l_resp = K_PAG_REL_STR6;
			l_err = SendMsg(l_resp);
		}

		if (!l_err)
		{
			l_resp = K_PAG_REL_STR7;
			l_err = SendMsg(l_resp);
		}

		if (!l_err)
		{
			l_resp = K_PAG_REL_STR8;
			l_err = SendMsg(l_resp);
		}
				if (!l_err)
		{
			l_resp = K_PAG_REL_STR9;
			l_err = SendMsg(l_resp);
		}

		if (!l_err)
		{
			l_resp = K_PAG_REL_STR10;
			l_err = SendMsg(l_resp);
		}		

		if (!l_err)
		{
			l_resp = K_PAG_REL_STR11;
			l_err = SendMsg(l_resp);
		}	
#endif
	}

	l_cmd = K_DBG_GET_SCR_SOU;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_id = strstr(fParams,K_SCRIPTID_ID_STR);
		if (!l_id)
		{
			DebugMsg("NO %s param found for %S\n",K_SCRIPTID_ID_STR,&fMethod);
			l_err = VE_INVALID_PARAMETER;
		}
		if (!l_err)
		{
			l_id += strlen(K_SCRIPTID_ID_STR);
			sBYTE*	l_end = strchr(l_id,'"');
			if (l_end)
			{
				*l_end = 0;
				strncpy(l_msg.data.Msg.fString,l_id,K_STR_MAX_SIZE);
				l_msg.data.Msg.fString[K_STR_MAX_SIZE-1] = 0;
			}
			else
			{
				l_err = VE_INVALID_PARAMETER;
			}
		}
		l_resp = K_DBG_GET_SCR_SOU_STR1;

		if (!l_err)
		{
			for(VectorOfVString::iterator l_it = fSource.begin(); (l_it != fSource.end()); )
			{
				l_resp += *l_it;
				l_resp += K_LINE_FEED_STR;
				++l_it;
			}
		}
		else
		{
			l_resp += CVSTR(" NO SOURCE AVAILABLE ");
			l_resp += K_LINE_FEED_STR;
		}
		l_resp += "\"},\"id\":";
		l_resp += fId;
		l_resp += "}";
		l_err = SendMsg(l_resp);
	}
	
	l_cmd = K_RUN_GET_PRO;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_id = strstr(fParams,K_BACKSLASHED_ID_STR);
		if (!l_id)
		{
			DebugMsg("NO %s param found for %S\n",K_BACKSLASHED_ID_STR,&fMethod);
			l_err = VE_INVALID_PARAMETER;
		}
		if (!l_err)
		{
			l_msg.type = SEND_CMD_MSG;
			l_msg.data.Msg.fType = WAKDebuggerServerMessage::SRV_LOOKUP_MSG;
			l_msg.data.Msg.fObjRef = atoi(l_id+strlen(K_BACKSLASHED_ID_STR));
			l_err = fOutFifo.Put(l_msg);
			if (testAssert( l_err == VE_OK ))
			{
				l_err = fFifo.Get(&l_msg,&l_msg_found,0);
				xbox_assert( l_err == VE_OK );
			}
			if (!l_err)
			{
				if (l_msg_found && (l_msg.type != LOOKUP_MSG))
				{
					l_err = VE_INVALID_PARAMETER;
				}
				xbox_assert(l_err == VE_OK);
			}
		}
		if (!l_err)
		{
			l_resp = l_msg.data._dataStr;
			l_resp += fId;
			l_resp += "}";
			l_err = SendMsg(l_resp);
		}
	}

	l_cmd = K_DOM_HIG_FRA;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_DOM_HIG_NOD;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);

	}

	l_cmd = K_RUN_REL_OBJ_GRO;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_DOM_REQ_CHI_NOD;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_id = strstr(fParams,K_NODE_ID_STR);
		if (!l_id)
		{
			DebugMsg("NO %s param found for %S\n",K_NODE_ID_STR,&fMethod);
			l_err = VE_INVALID_PARAMETER;
		}
		if (!l_err && (atoi(l_id+strlen(K_NODE_ID_STR)) != fBodyNodeId) )
		{
			DebugMsg("INCORRECT BODY node id for %S\n",&fMethod);
			l_err = VE_INVALID_PARAMETER;
		}
		if (!l_err)
		{
			l_resp = K_DOM_REQ_CHI_NOD_STR1;
			l_resp.AppendLong(fBodyNodeId);
			l_resp += K_DOM_REQ_CHI_NOD_STR2;
			l_resp.AppendLong(s_node_id++);
			l_resp += K_DOM_REQ_CHI_NOD_STR3;
			l_resp.AppendLong(s_node_id++);
			l_resp += K_DOM_REQ_CHI_NOD_STR4A;
			//l_resp += K_DOM_REQ_CHI_NOD_STR4B;
			//l_resp += K_DOM_REQ_CHI_NOD_STR4C;
			//l_resp += K_DOM_REQ_CHI_NOD_STR4D;
#if 1
			l_resp += "n";
			/*VectorOfVString::const_iterator l_it = fSource.begin();
			for(; l_it != fSource.end(); l_it++)
			{
				l_resp += *l_it;
				l_resp += K_LINE_FEED_STR;
			}*/
			l_resp+= "\\";
#endif
			l_resp += K_DOM_REQ_CHI_NOD_STR4E;
			l_resp.AppendLong(s_node_id++);
			l_resp += K_DOM_REQ_CHI_NOD_STR5;
			l_resp.AppendLong(s_node_id++);
			l_resp += K_DOM_REQ_CHI_NOD_STR6;
			l_resp.AppendLong(s_node_id++);
			l_resp += K_DOM_REQ_CHI_NOD_STR7;
			l_resp.AppendLong(s_node_id++);
			l_resp += K_DOM_REQ_CHI_NOD_STR8;
			l_resp.AppendLong(s_node_id++);
			l_resp += K_DOM_REQ_CHI_NOD_STR9;
			l_resp.AppendLong(s_node_id++);
			l_resp += K_DOM_REQ_CHI_NOD_STR10;

			l_err = SendMsg(l_resp);

			if (!l_err)
			{
				l_err = SendResult(K_EMPTY_STR);
			}
		}

	}

	l_cmd = K_CON_ADD_INS_NOD;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {	
		l_err = SendResult(K_EMPTY_STR);
	}
	
	l_cmd = K_CSS_GET_MAT_STY_FOR_NOD;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_id = strstr(fParams,K_NODE_ID_STR);
		if (!l_id)
		{
			DebugMsg("NO %s param found for %S\n",K_NODE_ID_STR,&fMethod);
			l_err = VE_INVALID_PARAMETER;
		}
		if (!l_err && (atoi(l_id+strlen(K_NODE_ID_STR)) != fBodyNodeId) )
		{
			DebugMsg("INCORRECT BODY node id for %S\n",&fMethod);
			l_err = VE_INVALID_PARAMETER;
		}
		if (!l_err)
		{
			l_resp.AppendBlock(_binary_getMatchedStylesForNode,sizeof(_binary_getMatchedStylesForNode),VTC_UTF_8);
			l_resp += fId;
			l_resp += "}";
			l_err = SendMsg(l_resp);
		}
	}

	l_cmd = K_CSS_GET_INL_STY_FOR_NOD;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_id = strstr(fParams,K_NODE_ID_STR);
		if (!l_id)
		{
			DebugMsg("NO %s param found for %S\n",K_NODE_ID_STR,&fMethod);
			l_err = VE_INVALID_PARAMETER;
		}
		if (!l_err && (atoi(l_id+strlen(K_NODE_ID_STR)) != fBodyNodeId) )
		{
			DebugMsg("INCORRECT BODY node id for %S\n",&fMethod);
			l_err = VE_INVALID_PARAMETER;
		}
		if (!l_err)
		{
			l_resp.AppendBlock(_binary_getInlineStylesForNode,sizeof(_binary_getInlineStylesForNode),VTC_UTF_8);
			l_resp += fId;
			l_resp += "}";
			l_err = SendMsg(l_resp);
		}
	}
	l_cmd = K_CSS_GET_COM_STY_FOR_NOD;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_id = strstr(fParams,K_NODE_ID_STR);
		if (!l_id)
		{
			DebugMsg("NO %s param found for %S\n",K_NODE_ID_STR,&fMethod);
			l_err = VE_INVALID_PARAMETER;
		}
		if (!l_err && (atoi(l_id+strlen(K_NODE_ID_STR)) != fBodyNodeId) )
		{
			DebugMsg("INCORRECT BODY node id for %S\n",&fMethod);
			l_err = VE_INVALID_PARAMETER;
		}
		if (!l_err)
		{
			l_resp.AppendBlock(_binary_getComputedStyleForNode,sizeof(_binary_getComputedStyleForNode),VTC_UTF_8);
			l_resp += fId;
			l_resp += "}";
			l_err = SendMsg(l_resp);
		}
	}
	
	l_cmd = K_DOM_GET_DOC;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {

		l_resp = K_GET_DOC_STR1;
		l_resp.AppendLong(s_node_id++);
		l_resp += K_GET_DOC_STR2;
		l_resp.AppendLong(s_node_id++);
		l_resp += K_GET_DOC_STR3;
		l_resp.AppendLong(s_node_id++);
		l_resp += K_GET_DOC_STR4;
		l_resp.AppendLong(s_node_id++);
		l_resp += K_GET_DOC_STR5;
		l_resp.AppendLong(s_node_id++);
		l_resp += K_GET_DOC_STR6;
		fBodyNodeId = s_node_id;
		l_resp.AppendLong(s_node_id++);
		l_resp += K_GET_DOC_STR7A;
		l_resp += fFileName;
		l_resp += K_GET_DOC_STR7B;
		l_resp += fId;
		l_resp += "}";

		l_err = SendMsg(l_resp);
	}

	l_cmd = K_DOM_HID_HIG;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {	
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_DBG_SET_PAU_ON_EXC;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_TIM_SET_INC_MEM_DET;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_CSS_ENA;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_CSS_GET_SUP_PRO;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_resp.AppendBlock(_binary_getSupportedCSSProperties,sizeof(_binary_getSupportedCSSProperties),VTC_UTF_8);
		l_resp += fId;
		l_resp += "}";
		l_err = SendMsg(l_resp);

	}	
	
	l_cmd = K_DOM_STO_ENA;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_DAT_ENA;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {	
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_INS_ENA;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {	
		fEnabled = true;
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_CON_ENA;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {	
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_PRO_ENA;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_DBG_ENA;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_DBG_CAN_SET_SCR_SOU;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_RESULT_TRUE_STR);
	}

	l_cmd = K_WOR_SET_WOR_INS_ENA;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_NET_CAN_CLE_BRO_CAC;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_RESULT_TRUE_STR);
	}

	l_cmd = K_NET_CAN_CLE_BRO_COO;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_RESULT_TRUE_STR);
	}

	l_cmd = K_PAG_GET_RES_TRE;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_resp = K_PAG_GET_RES_TRE_STR1A;
		l_resp.AppendLong(fPageNb*K_FRAME_FACTOR);
		l_resp += K_PAG_GET_RES_TRE_STR1B;
		l_resp += fFileName;
		l_resp.AppendLong(fPageNb);
		l_resp += ".html";
		l_resp += K_PAG_GET_RES_TRE_STR1C;
		l_resp += fFileName;
		l_resp += K_PAG_GET_RES_TRE_STR1D;
		l_resp += fId;
		l_resp += "}";
		l_err = SendMsg(l_resp);

	}
	l_cmd = K_PAG_ENA;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {	
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_NET_ENA;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);
	}

	l_cmd = K_PRO_HAS_HEA_PRO;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_RESULT_TRUE_STR);
	}

	l_cmd = K_PRO_IS_SAM;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_RESULT_TRUE_STR);
	}

	l_cmd = K_PRO_CAU_REC;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {	
		l_err = SendResult(K_RESULT_FALSE_STR);
	}

	l_cmd = K_DBG_SUP_NAT_BRE;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_RESULT_TRUE_STR);
	}

	l_cmd = K_DBG_RES;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);
		fState = RUNNING_STATE;
		if (!l_err)
		{
			l_resp = K_DBG_RES_STR;
			l_err = SendMsg(l_resp);
		}
		l_msg.type = SEND_CMD_MSG;
		l_msg.data.Msg.fType = WAKDebuggerServerMessage::SRV_CONTINUE_MSG;
		l_err = fOutFifo.Put(l_msg);
		xbox_assert( l_err == VE_OK );
	}
	l_cmd = K_DBG_STE_INT;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);
		//fState = IJSWChrmDebugger::RUNNING_STATE;
		if (!l_err)
		{
			l_resp = K_DBG_RES_STR;
			l_err = SendMsg(l_resp);
		}
		l_msg.type = SEND_CMD_MSG;
		l_msg.data.Msg.fType = WAKDebuggerServerMessage::SRV_STEP_INTO_MSG;
		l_err = fOutFifo.Put(l_msg);
		xbox_assert( l_err == VE_OK );
	}
	l_cmd = K_DBG_STE_OUT;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);
		//fState = IJSWChrmDebugger::RUNNING_STATE;
		if (!l_err)
		{
			l_resp = K_DBG_RES_STR;
			l_err = SendMsg(l_resp);
		}
		l_msg.type = SEND_CMD_MSG;
		l_msg.data.Msg.fType = WAKDebuggerServerMessage::SRV_STEP_OUT_MSG;
		l_err = fOutFifo.Put(l_msg);
		xbox_assert( l_err == VE_OK );
	}
	l_cmd = K_DBG_STE_OVE;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);
		//fState = IJSWChrmDebugger::RUNNING_STATE;
		if (!l_err)
		{
			l_resp = K_DBG_RES_STR;
			l_err = SendMsg(l_resp);
		}
		l_msg.type = SEND_CMD_MSG;
		l_msg.data.Msg.fType = WAKDebuggerServerMessage::SRV_STEP_OVER_MSG;
		l_err = fOutFifo.Put(l_msg);
		xbox_assert( l_err == VE_OK );
	}
	l_cmd = K_DBG_CAU_REC;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_RESULT_FALSE_STR);
	}
	l_cmd = K_DBG_PAU;
	if (!l_err && !l_found && (l_found = fMethod.EqualToString(l_cmd)) ) {
		l_err = SendResult(K_EMPTY_STR);
	}
	if (!l_found)
	{
		DebugMsg("VChromeDbgHdlPage::TreatMsg Method='%S' UNKNOWN!!!\n",&fMethod);
		exit(-1);
		return VE_OK;// --> pour l'instant on renvoit OK  !!! VE_INVALID_PARAMETER;
	}
#endif
	return l_err;

}
XBOX::VError VHTTPServerProjectSettings::SaveToBag (XBOX::VValueBag *outBag)
{
	if (NULL == outBag)
		return XBOX::VE_INVALID_PARAMETER;

	XBOX::VValueBag *projectSettings = new XBOX::VValueBag ();
	if (projectSettings)
	{
		XBOX::VString	ipString;
		XBOX::VString	authTypeString;

#if WITH_DEPRECATED_IPV4_API
		ServerNetTools::GetIPAdress (fListeningAddress, ipString);
#else
		ipString.FromString (fListeningAddress);
#endif
		HTTPServerTools::GetAuthenticationMethodName (fAuthType, authTypeString);

		projectSettings->SetLong (RIASettingsKeys::Project::refCount, GetRefCount());
		projectSettings->SetString (RIASettingsKeys::Project::listen, ipString);
		projectSettings->SetString (RIASettingsKeys::Project::hostName, fHostName);
#if HTTP_SERVER_USE_PROJECT_PATTERNS
		projectSettings->SetString (RIASettingsKeys::Project::pattern, fProjectPattern);
#endif
		projectSettings->SetString (RIASettingsKeys::Project::realm, fRealm);
		projectSettings->SetString (RIASettingsKeys::Project::authType, authTypeString);
		outBag->AddElement (RIASettingsKeys::Project::kXmlElement, projectSettings);
		XBOX::ReleaseRefCountable (&projectSettings);
	}

	XBOX::VValueBag *httpSettings = new XBOX::VValueBag ();
	if (httpSettings)
	{
		XBOX::VString posixPath;

		httpSettings->SetLong (RIASettingsKeys::HTTP::port, fPort);
		httpSettings->SetBool (RIASettingsKeys::HTTP::allowSSL, fAllowSSL);
		httpSettings->SetBool (RIASettingsKeys::HTTP::SSLMandatory, fSSLMandatory);
		httpSettings->SetLong (RIASettingsKeys::HTTP::SSLPort, fSSLPort);

		if (fSSLCertificatesFolderPath.IsValid())
		{
			fSSLCertificatesFolderPath.GetPosixPath (posixPath);
			httpSettings->SetString (RIASettingsKeys::HTTP::SSLCertificatePath, posixPath);
		}

		XBOX::VString charSetName;
		VTextConverters::Get()->GetNameFromCharSet (fDefaultCharSet, charSetName);
		httpSettings->SetString (RIASettingsKeys::HTTP::standardSet, charSetName);

		/* cache settings */
		httpSettings->SetBool (RIASettingsKeys::HTTP::useCache, fEnableCache);
		httpSettings->SetLong (RIASettingsKeys::HTTP::pageCacheSize, fCacheMaxSize);
		httpSettings->SetLong (RIASettingsKeys::HTTP::cachedObjectMaxSize, fCachedObjectMaxSize);

		/* compression settings */
		httpSettings->SetBool (RIASettingsKeys::HTTP::allowCompression, fEnableCompression);
		httpSettings->SetLong (RIASettingsKeys::HTTP::compressionMinThreshold, fCompressionMinThreshold);
		httpSettings->SetLong (RIASettingsKeys::HTTP::compressionMaxThreshold, fCompressionMaxThreshold);

		/* Keep-Alive settings */
		httpSettings->SetBool (RIASettingsKeys::HTTP::acceptKeepAliveConnections, fEnableKeepAlive);
		httpSettings->SetLong (RIASettingsKeys::HTTP::maximumTimeout, fKeepAliveTimeout);
		httpSettings->SetLong (RIASettingsKeys::HTTP::maximumRequestsByConnection, fKeepAliveMaxConnections);

		/* Log settings */
		XBOX::VString logFormatName;
		HTTPServerTools::GetLogFormatName ((EHTTPServerLogFormat)fLogFormat, logFormatName);
		posixPath.Clear();
		fLogFolderPath.GetPosixPath (posixPath);
		httpSettings->SetString (RIASettingsKeys::HTTP::logFormat, logFormatName);
		httpSettings->SetString (RIASettingsKeys::HTTP::logPath, posixPath);
		httpSettings->SetString (RIASettingsKeys::HTTP::logFileName, fLogFileName);
		httpSettings->SetLong (RIASettingsKeys::HTTP::logMaxSize, GetLogMaxSize());

		/* Log Tokens settings */
		XBOX::VBagArray *logTokenSettings = new XBOX::VBagArray ();
		if (NULL != logTokenSettings)
		{
			XBOX::VTaskLock lock (&fLogTokensVectorLock);
			XBOX::VString	tokenName;

			for (VectorOfLogToken::const_iterator it = fLogTokensVector.begin(); it != fLogTokensVector.end(); ++it)
			{
				XBOX::VValueBag *bag = new XBOX::VValueBag ();
				if (NULL != bag)
				{
					HTTPServerTools::GetLogTokenName (*it, tokenName);
					bag->SetString (RIASettingsKeys::HTTP::Log::field, tokenName);
					logTokenSettings->AddTail (bag);
					bag->Release();
				}
			}

			if (logTokenSettings->GetCount())
				httpSettings->SetElements (RIASettingsKeys::HTTP::Log::kXmlElement, logTokenSettings);

			XBOX::ReleaseRefCountable (&logTokenSettings);
		}

		outBag->AddElement (RIASettingsKeys::HTTP::kXmlElement, httpSettings);
		XBOX::ReleaseRefCountable (&httpSettings);
	}

	/* Web App settings */
	XBOX::VValueBag *webAppSettings = new XBOX::VValueBag ();
	if (webAppSettings)
	{
		XBOX::VString posixPath;
		fWebFolderPath.GetPosixPath (posixPath);
		webAppSettings->SetString (RIASettingsKeys::WebApp::documentRoot, posixPath);
		webAppSettings->SetString (RIASettingsKeys::WebApp::directoryIndex, fIndexPageName);

		outBag->AddElement (RIASettingsKeys::WebApp::kXmlElement, webAppSettings);
		XBOX::ReleaseRefCountable (&webAppSettings);
	}

	/* Resources settings */
	XBOX::VBagArray *resourcesSettings = new XBOX::VBagArray ();
	if (resourcesSettings)
	{
		XBOX::VTaskLock lock (&fResourcesVectorLock);

		for (VHTTPResourcesVector::const_iterator it = fResourcesVector.begin(); it != fResourcesVector.end(); ++it)
		{
			if (!it->IsNull())
			{
				XBOX::VValueBag *bag = new XBOX::VValueBag ();
				if (bag)
				{
					(*it)->SaveToBag (*bag);
					resourcesSettings->AddTail (bag);
					bag->Release();
				}
			}
		}

		if (resourcesSettings->GetCount())
			outBag->SetElements (RIASettingsKeys::Resources::kXmlElement, resourcesSettings);

		XBOX::ReleaseRefCountable (&resourcesSettings);
	}

#if 0 /*VERSIONDEBUG*/
	XBOX::VString xmlString ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
	outBag->DumpXML (xmlString, CVSTR ("settings"), true);
#endif

	return XBOX::VE_OK;
}
* This file remains the exclusive property of 4D and/or its licensors
* and is protected by national and international legislations.
* In any event, Licensee's compliance with the terms and conditions
* of the applicable license constitutes a prerequisite to any use of this file.
* Except as otherwise expressly stated in the applicable license,
* such license does not include any other license or rights on this file,
* 4D's and/or its licensors' trademarks and/or other proprietary rights.
* Consequently, no title, copyright or other proprietary rights
* other than those specified in the applicable license is granted.
*/
#include "HTTPServer.h"
#include "HTTPServerSettings.h"
#include "HTTPServerLog.h"


const XBOX::VString	HTTP_SERVER_LOG_FILE_PATH = CVSTR ("Logs/");
const XBOX::VString	HTTP_SERVER_LOG_FILE_EXTENSION = CVSTR ("waLog");
const XBOX::VString	HTTP_SERVER_LOG_FILE_NAME = CVSTR ("HTTPServer.") + HTTP_SERVER_LOG_FILE_EXTENSION;


const XBOX::VString DEFAULT_WEB_FOLDER_PATH = "./WebFolder";
const XBOX::VString DEFAULT_INDEX_PAGE_NAME = "index.html";
const XBOX::VString DEFAULT_SSL_CERTIFICATE_FOLDER_PATH = "";	//"./Certificates";
const bool			DEFAULT_ALLOW_SSL = false;
const bool			DEFAULT_SSL_MANDATORY = false;
const bool			DEFAULT_ENABLE_CACHE = true;
const sLONG			DEFAULT_CACHE_MAX_SIZE = 5 * 1024 * 1024;		// in bytes
const sLONG			DEFAULT_CACHED_OBJECT_MAX_SIZE = 512 * 1024;	// in bytes
const bool			DEFAULT_COMPRESSION_ENABLED = true;
const sLONG			DEFAULT_COMPRESSION_MIN_THRESHOLD = 1024;				// 1 KBytes (in bytes)
const sLONG			DEFAULT_COMPRESSION_MAX_THRESHOLD = 10 * 1024 * 1024;	// 10 MBytes (in bytes)