Ejemplo n.º 1
0
BOOL CPlayProfilePage::LoadXML()
{
	CString strValue;
	CXMLAttribute* pAttri = NULL;
	
	for ( POSITION pos = m_pXML->GetElementIterator() ; pos ; )
	{
		CXMLElement* pMap = m_pXML->GetNextElement( pos );
		if ( ! pMap->IsNamed( _T("Map") ) ) continue;
		
		if ( pAttri = pMap->GetAttribute( _T("ID") ) )
		{
			strValue = pAttri->GetValue();
			int nItem = m_wndList.InsertItem(
				LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM,
				m_wndList.GetItemCount(), strValue, 0, 0,
				CoolInterface.ImageForID(ID_REPORT_MUSIC), (LPARAM)pMap );
			
			if ( pAttri = pMap->GetAttribute( _T("Play") ) )
			{
				m_wndList.SetItemText( nItem, 1, pAttri->GetValue() );
			}
		}
	}

	return TRUE;
}
Ejemplo n.º 2
0
CXMLAttribute* Engine::FileSystem::Config::CXMLElement::FindOrCreateAttribute( const char* name )
{
	CXMLAttribute* last = 0;
	CXMLAttribute* attrib = 0;
	for( attrib = rootAttribute;
		 attrib;
		 last = attrib, attrib = attrib->next )
	{		 
		if ( CXMLUtil::StringEqual( attrib->Name(), name ) ) {
			break;
		}
	}
	if ( !attrib ) {
		attrib = new (document->attributePool.Alloc() ) CXMLAttribute();
		attrib->XMLMemPool = &document->attributePool;
		if ( last ) {
			last->next = attrib;
		}
		else {
			rootAttribute = attrib;
		}
		attrib->SetName( name );
	}
	return attrib;
}
Ejemplo n.º 3
0
CXMLElement* CProfiles::FindProcess(LPCTSTR xJobId, POSITION& posNext, CXMLElement** ppActionXML)
{
    CSingleLock pLock( &m_pSection, TRUE );
    if ( ! m_pXMLMonitor ) return NULL;

    CXMLElement* pAction = NULL;
    if ( ! ppActionXML ) ppActionXML = &pAction;

    *ppActionXML = m_pXMLMonitor->GetElementByName( _T("ShortMessage") );

    if ( CXMLElement* pXML = m_pXMLMonitor->GetElementByName( _T("Process") ) )
    {
        if ( ! posNext ) posNext = pXML->GetElementIterator();
        if ( ! posNext ) return NULL;

        CXMLElement* pMap = pXML->GetNextElement( posNext );
        if ( ! pMap->IsNamed( _T("Map") ) ) return posNext ? FindProcess( xJobId, posNext ) : NULL;

        if ( ! xJobId || ! _tcscmp(xJobId, _T("ÈÎÒâ")) ) return pMap;

        CXMLAttribute* pAttri = pMap->GetAttribute( "Host" );
        if ( pAttri && pAttri->GetValue() == xJobId ) return pMap;

        return posNext ? FindProcess( xJobId, posNext, ppActionXML ) : NULL;
    }

    return NULL;
}
Ejemplo n.º 4
0
Bool CMaterialResource::Init()
{
	CXMLDocument document;
	document.Load( m_FilePath.c_str() );

	CXMLNode rootNode = document.GetRootNode();

	//Read out textures
	CXMLNode childNode = rootNode.GetChildNode( "Texture2D" );

	while ( childNode.IsEmpty() == false )
	{
		CXMLAttribute attribute = childNode.GetAttribute( "Hash" );
		const Uint hash = (Uint)strtoul( attribute.GetValue(), NULL, 0 );
		AddDependentHash( hash );
		childNode = childNode.GetNextSibling();
	}

	if ( m_DependenciesLeft == 0 )
	{
		return true;
	}

	return false;
}
Ejemplo n.º 5
0
BOOL CProfiles::IsDenied(IN_ADDR* pAddress)
{
	CSingleLock pLock( &m_pSection, TRUE );
	
	if ( ! m_pXMLSecure ) return FALSE;
	
	CString strValue;
	BOOL bFound = FALSE;
	CXMLAttribute* pAttri = NULL;
	
	for ( POSITION pos = m_pXMLSecure->GetElementIterator() ; pos ; )
	{
		CXMLElement* pMap = m_pXMLSecure->GetNextElement( pos );
		if ( ! pMap->IsNamed( _T("Map") ) ) continue;
		
		if ( pAttri = pMap->GetAttribute( _T("Host") ) )
		{
			strValue = pAttri->GetValue();
			if ( strValue.CompareNoCase( _T("任意") ) == 0
			  || inet_addr((LPCTSTR)strValue) == *(DWORD*)pAddress )
			{
				bFound = TRUE; break;
			}
		}
	}
	
	// 拒绝条件: 拒绝 && bFound ==> TRUE
	//         : !拒绝 && !Found ==> TRUE
	// 受理方法: 异或 = 0 ==> TRUE, 否则 FALSE
	CString xAction = m_pXMLSecure->GetAttributeValue( _T("Action") );
	if ( xAction.CompareNoCase( _T("拒绝") ) ^ bFound  ) return FALSE;
	
	return TRUE;
}
Ejemplo n.º 6
0
void CGroupingDlg::OnSelChangeGroup()
{
	m_wndList.DeleteAllItems();
	CWaitCursor pCursor;
	
	int nItem = m_wndGroup.GetCurSel();
	if ( nItem < 0 ) return;
	
	CXMLElement* pXML = (CXMLElement*)m_wndGroup.GetItemDataPtr( nItem );
	ASSERT( pXML != NULL );
	
	for ( POSITION posNext = pXML->GetElementIterator(); posNext; )
	{
		CXMLElement* pSync = pXML->GetNextElement( posNext );
		if ( ! pSync->IsNamed( "SyncOrder" ) ) continue;
		
		static LPCTSTR pszGroup[] = { _T("xgroupname"), _T("xgroupnum") };
		
		CXMLAttribute* pAttri = pSync->GetAttribute( pszGroup[0] );
		if ( ! pAttri || pAttri->GetValue().IsEmpty() ) pAttri = pSync->GetAttribute( pszGroup[1] );
		
		if ( pAttri && m_wndGroup.FindStringExact( -1, pAttri->GetValue() ) != nItem ) continue;
		
		static LPCTSTR pszSuffix[] = { _T("xphone"), _T("xname"), NULL };
		
		int nItem = m_wndList.InsertItem( LVIF_TEXT|LVIF_PARAM,
				m_wndList.GetItemCount(), NULL, 0, 0, 0, (LPARAM)pSync );
		
		for ( int i = 0; pszSuffix[i] != NULL; i ++ )
		{
			CXMLAttribute* pAttri = pSync->GetAttribute( pszSuffix[i] );
			if ( pAttri ) m_wndList.SetItemText( nItem, i, pAttri->GetValue() );
		}
	}
}
Ejemplo n.º 7
0
CXMLAttribute* CXMLElement::AddAttribute(LPCTSTR pszName, LPCTSTR pszValue)
{
	ASSERT( pszName && *pszName );

	CXMLAttribute* pAttribute = GetAttribute( pszName );

	if ( ! pAttribute )
	{
		pAttribute = new CXMLAttribute( this, pszName );
		if ( ! pAttribute )
			return NULL;

		CString strNameLower( pszName );
		strNameLower.MakeLower();

		// Delete the old attribute if one exists
		CXMLAttribute* pExisting;
		if ( m_pAttributes.Lookup( strNameLower, pExisting ) )
			delete pExisting;

		m_pAttributes.SetAt( strNameLower, pAttribute );

		if ( ! m_pAttributesInsertion.Find( strNameLower ) )
			m_pAttributesInsertion.AddTail( strNameLower );		// Track output order workaround
	}

	if ( pszValue )
		pAttribute->SetValue( pszValue );

	return pAttribute;
}
Ejemplo n.º 8
0
BOOL CAnalogProfilePage::LoadXML()
{
	CString strValue;
	CXMLAttribute* pAttri = NULL;
	
	for ( POSITION pos = m_pXML->GetElementIterator() ; pos ; )
	{
		CXMLElement* pMap = m_pXML->GetNextElement( pos );
		if ( ! pMap->IsNamed( _T("Map") ) ) continue;
		
		if ( pAttri = pMap->GetAttribute( _T("ID") ) )
		{
			int nItem = m_wndList.InsertItem( LVIF_IMAGE|LVIF_PARAM,
				m_wndList.GetItemCount(), NULL, 0, 0, 28, (LPARAM)pMap );
			
			strValue = pAttri->GetValue();
			m_wndList.SetItemText( nItem, 1, pAttri->GetValue() );
			
			if ( pAttri = pMap->GetAttribute( _T("LinkId") ) )
			{
				m_wndList.SetItemText( nItem, 0, pAttri->GetValue() );
			}
			
			if ( pAttri = pMap->GetAttribute( _T("LocalId") ) )
			{
				m_wndList.SetItemText( nItem, 2, pAttri->GetValue() );
			}
		}
	}

	return TRUE;
}
Ejemplo n.º 9
0
//////////////////////////////////////////////////////////////////////
//
// Fetch multiple values for a named setting from the server config
//
//  <module src="module_test.dll" />
//  <resource src="admin" startup="1" protected="0" />
//
//////////////////////////////////////////////////////////////////////
bool CMainConfig::GetSettingTable ( const SString& strName, const char** szAttribNames, uint uiNumAttribNames, CLuaArguments* outTable )
{
    uint uiXMLIndex = 0;
    uint uiLuaIndex = 1;
    CXMLNode* pNode = NULL;
    do
    {
        // Grab the current script node
        pNode = m_pRootNode->FindSubNode ( strName, uiXMLIndex++ );
        if ( pNode )
        {
            CLuaArguments resultLine;
            CXMLAttributes& attributes = pNode->GetAttributes();
            for ( uint i = 0 ; i < attributes.Count() ; i++ )
            {
                CXMLAttribute* pAttribute = attributes.Get( i );
                resultLine.PushString( pAttribute->GetName() );
                resultLine.PushString( pAttribute->GetValue() );
            }

            if ( resultLine.Count() != 0 )
            {
                outTable->PushNumber( uiLuaIndex++ );
                outTable->PushTable( &resultLine );
            }
        }
    }
    while( pNode );

    return outTable->Count() != 0;
}
Ejemplo n.º 10
0
bool CXMLDocumentFile::ResolveIncludes()
{
	CXMLElement* pInclude = nullptr;

	while ((pInclude = (CXMLElement*)(this->DescendantsNamed(STRING("include")))) != 0)
	{
		CXMLAttribute* pFile = pInclude->AttributeNamed(STRING("file"));
		if (!pFile) { return false; }

		CFile File(m_pFile->Path() + STRING("\\") + pFile->ValueString());

		if (File.Exists())
		{
			CStreamFileRead        ReadStream(File);
			CStreamReadTextGeneric ReadStreamText(ReadStream);

			CXMLDocument* pDocument = new CXMLDocument(ReadStreamText);

			if (pDocument)
			{
				//This replaces the include node with the root element node from the resolved document (severs the ties to the XML document object)
				pInclude->ReplaceWith(*pDocument->RootElementRetrieve());

				delete pInclude;
				delete pDocument;
			}
			else { return false; }
		}
		else { return false; }
	}

	return true;
}
Ejemplo n.º 11
0
BOOL CUserMeetingDlg::CreateMenuGroup(CXMLElement* pXML, HMENU hParent)
{
	UINT nMenuId = MIN_GROUP;
	
	for ( POSITION pos = pXML->GetElementIterator() ; pos ; )
	{
		CXMLElement* pSync = pXML->GetNextElement( pos );
		if ( ! pSync->IsNamed( "SyncOrder" ) ) continue;
		
		static LPCTSTR pszGroup[] = { _T("xgroupname"), _T("xgroupnum") };
		
		CXMLAttribute* pAttri = pSync->GetAttribute( pszGroup[0] );
		if ( ! pAttri || pAttri->GetValue().IsEmpty() ) pAttri = pSync->GetAttribute( pszGroup[1] );
		
		if ( pAttri && m_wndGroup.FindStringExact( -1, pAttri->GetValue() ) != m_wndGroup.GetCurSel() ) continue;
		
		HMENU hMenu = FindMenuGroup( hParent, pAttri->GetValue() );	if ( ! hMenu )
		{
			hMenu = CreatePopupMenu();
			AppendMenu( hParent, MF_STRING|MF_POPUP, (UINT)hMenu, pAttri->GetValue() );
		}
		
		CString strText = pSync->GetAttributeValue( _T("xname") );
		if ( ! strText.IsEmpty() ) strText += '\t';
		
		strText += pSync->GetAttributeValue( _T("xphone") );
		AppendMenu( hMenu, MF_STRING, nMenuId++, strText );
		
		if ( nMenuId > MAX_GROUP ) break;
	}
	
	return TRUE;
}
Ejemplo n.º 12
0
BOOL CGroupingDlg::OnSyncDataViewResp(CXMLElement* pXML)
{
	CWaitCursor pCursor;
	
	m_wndGroup.ResetContent();
	m_pXML->Delete(); m_pXML = pXML;
	
	for ( POSITION posNext = pXML->GetElementIterator(); posNext; )
	{
		CXMLElement* pSync = pXML->GetNextElement( posNext );
		if ( ! pSync->IsNamed( "SyncOrder" ) ) continue;
		
		static LPCTSTR pszGroup[] = { _T("xgroupname"), _T("xgroupnum") };
		
		CXMLAttribute* pAttri = pSync->GetAttribute( pszGroup[0] );
		if ( ! pAttri || pAttri->GetValue().IsEmpty() ) pAttri = pSync->GetAttribute( pszGroup[1] );
		
		if ( pAttri && m_wndGroup.FindStringExact( -1, pAttri->GetValue() ) == CB_ERR )
		m_wndGroup.SetItemDataPtr( m_wndGroup.AddString( pAttri->GetValue() ), pXML );
	}
	
	m_wndGroup.SetCurSel( 0 );
	SendMessage(WM_COMMAND, MAKELONG(m_wndGroup.GetDlgCtrlID(),CBN_SELCHANGE), (LPARAM)m_hWnd);
	
	return TRUE;
}
Ejemplo n.º 13
0
BOOL CBitziDownloader::MergeMetaData(CXMLElement* pOutput, CXMLElement* pInput)
{
	if ( ! pOutput || ! pInput ) return FALSE;

	pOutput	= pOutput->GetFirstElement();

	if ( ! pOutput || pOutput->GetName() != pInput->GetName() ) return FALSE;

	for ( POSITION pos = pInput->GetElementIterator() ; pos ; )
	{
		CXMLElement* pElement	= pInput->GetNextElement( pos );
		CXMLElement* pTarget	= pOutput->GetElementByName( pElement->GetName() );

		if ( pTarget == NULL ) pOutput->AddElement( pElement->Clone() );
	}

	for ( POSITION pos = pInput->GetAttributeIterator() ; pos ; )
	{
		CXMLAttribute* pAttribute	= pInput->GetNextAttribute( pos );
		CXMLAttribute* pTarget		= pOutput->GetAttribute( pAttribute->GetName() );

		if ( pTarget == NULL ) pOutput->AddAttribute( pAttribute->Clone() );
	}

	return TRUE;
}
Ejemplo n.º 14
0
void CElement::ReadCustomData ( CLuaMain* pLuaMain, CEvents* pEvents )
{
    assert ( pLuaMain );
    assert ( pEvents );

    // Got an XML node?
    if ( m_pXMLNode )
    {
        // Iterate the attributes of our XML node
        CXMLAttributes* pAttributes = &(m_pXMLNode->GetAttributes ());
        unsigned int uiAttributeCount = pAttributes->Count ();
        for ( unsigned int uiIndex = 0; uiIndex < uiAttributeCount; uiIndex++ )
        {
            // Grab the node (we can assume it exists here)
            CXMLAttribute* pAttribute = pAttributes->Get ( uiIndex );

            // Make a lua argument from it and set the content
            CLuaArguments args;
            if ( !args.ReadFromJSONString ( pAttribute->GetValue ().c_str() ) )
                args.PushString ( pAttribute->GetValue ().c_str () );

            // Don't trigger onElementDataChanged event
            SetCustomData ( pAttribute->GetName ().c_str (), *args[0], pLuaMain, g_pGame->GetConfig ()->GetSyncMapElementData (), NULL, false );
        }
    }
}
Ejemplo n.º 15
0
std::string CServerBrowser::GetServerPassword ( std::string strHost )
{
    CXMLNode* pConfig = CCore::GetSingletonPtr ()->GetConfig ();
    CXMLNode* pServerPasswords = pConfig->FindSubNode ( CONFIG_NODE_SERVER_SAVED );
    if ( !pServerPasswords )
    {
        pServerPasswords = pConfig ->CreateSubNode ( CONFIG_NODE_SERVER_SAVED );
    }
    //Check if the server password already exists
    for ( unsigned int i = 0 ; i < pServerPasswords->GetSubNodeCount() ; i++ )
    {    
        CXMLAttributes* pAttributes = &(pServerPasswords->GetSubNode(i)->GetAttributes());
        if ( pAttributes->Find( "host" ) )
        {
            if ( CXMLAttribute* pHost = pAttributes->Find ( "host" ) )
            {
                std::string strXMLHost = pHost->GetValue();
                if ( strXMLHost == strHost )
                {
                    CXMLAttribute* pPassword = pAttributes->Create( "password" );
                    std::string strPassword = pPassword->GetValue();
                    return strPassword;
                }
            }
        }
        
    }
    return "";
}
Ejemplo n.º 16
0
bool CServerBrowser::SaveServerList ( CXMLNode* pNode, std::string strTagName, CServerList *pList )
{
    if ( !pNode )
        return false;

    // Start by clearing out all previous nodes
    pNode->DeleteAllSubNodes ();

    // Iterate through the list, adding any items to our node
    CServerListIterator i, i_b = pList->IteratorBegin (), i_e = pList->IteratorEnd ();
    int j = 0;
    int k = pList->GetServerCount ();
    if ( k > 0 )
    {
        for ( CServerListIterator i = i_b; i != i_e; i++ )
        {
            CServerListItem * pServer = *i;

            // Add the item to the node
            CXMLNode * pSubNode = pNode->CreateSubNode ( strTagName.c_str () );
            if ( pSubNode )
            {
                CXMLAttribute* pHostAttribute = pSubNode->GetAttributes ().Create ( "host" );
				pHostAttribute->SetValue ( pServer->strHost.c_str () );
                
                CXMLAttribute* pPortAttribute = pSubNode->GetAttributes ().Create ( "port" );
				pPortAttribute->SetValue ( pServer->usGamePort );
            }
            j++;
        }
    }
    return true;
}
Ejemplo n.º 17
0
bool CServerBrowser::LoadServerList ( CXMLNode* pNode, std::string strTagName, CServerList *pList )
{
    CXMLNode* pSubNode = NULL;
    in_addr Address;
    int iPort;

    if ( !pNode )
        return false;

    // Loop through all subnodes looking for relevant nodes
    unsigned int uiCount = pNode->GetSubNodeCount ();
    for ( unsigned int i = 0; i < uiCount; i++ )
    {
        pSubNode = pNode->GetSubNode ( i );
        if ( pSubNode && pSubNode->GetTagName ().compare ( strTagName ) == 0 )
        {
            // This node is relevant, so get the attributes we need and add it to the list
            CXMLAttribute* pHostAttribute = pSubNode->GetAttributes ().Find ( "host" );
            CXMLAttribute* pPortAttribute = pSubNode->GetAttributes ().Find ( "port" );
            if ( pHostAttribute && pPortAttribute ) {
                if ( CServerListItem::Parse ( pHostAttribute->GetValue ().c_str (), Address ) )
                {
                    iPort = atoi ( pPortAttribute->GetValue ().c_str () ) + SERVER_LIST_QUERY_PORT_OFFSET;
                    if ( iPort > 0 )
                        pList->Add ( CServerListItem ( Address, iPort ) );
                }
            }
        }
    }
    pList->SetUpdated ( true );
    return true;
}
Ejemplo n.º 18
0
void CXMLElement::AddRecursiveWords(CString& strWords) const
{
	for ( POSITION pos = GetAttributeIterator() ; pos ; )
	{
		CXMLAttribute* pAttribute = GetNextAttribute( pos );
		CString strText = pAttribute->GetName();

		if ( strText.Find( ':' ) >= 0 ) continue;
		if ( strText.CompareNoCase( _T("SHA1") ) == 0 ) continue;	// NOTE: PeerProject/Shareaza Specific

		if ( ! strWords.IsEmpty() ) strWords += ' ';
		strWords += pAttribute->GetValue();
	}

	for ( POSITION pos = GetElementIterator() ; pos ; )
	{
		GetNextElement( pos )->AddRecursiveWords( strWords );
	}

	if ( ! m_sValue.IsEmpty() )
	{
		if ( ! strWords.IsEmpty() )
			strWords += ' ';
		strWords += m_sValue;
	}
}
Ejemplo n.º 19
0
int CLuaXMLDefs::xmlNodeGetAttribute ( lua_State* luaVM )
{
    CXMLNode* pNode = nullptr;
    SString strAttributeName = "";
    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pNode );
    argStream.ReadString ( strAttributeName );

    if ( !argStream.HasErrors () )
    {
        // Find the attribute with that name
        CXMLAttribute * pAttribute = pNode->GetAttributes ().Find ( strAttributeName );
        if ( pAttribute )
        {
            // Read the attribute and return the string
            lua_pushstring ( luaVM, pAttribute->GetValue ().c_str () );
            return 1;
        }
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    lua_pushboolean ( luaVM, false );
    return 1;
}
Ejemplo n.º 20
0
const CXMLAttribute* Engine::FileSystem::Config::CXMLElement::FindAttribute( const char* name ) const
{
	CXMLAttribute* a = 0;
	for( a=rootAttribute; a; a = a->next ) {
		if ( CXMLUtil::StringEqual( a->Name(), name ) )
			return a;
	}
	return 0;
}
Ejemplo n.º 21
0
int CLuaXMLDefs::xmlNodeSetAttribute ( lua_State* luaVM )
{
    // pNode, Attribute Name, Value
    int iType1 = lua_type ( luaVM, 1 );
    int iType2 = lua_type ( luaVM, 2 );
    int iType3 = lua_type ( luaVM, 3 );
    if ( ( iType1 == LUA_TLIGHTUSERDATA ) &&
         ( iType2 == LUA_TSTRING ) &&
         ( iType3 == LUA_TSTRING || iType3 == LUA_TNUMBER || iType3 == LUA_TNIL ) )
    {
        // Grab the xml node
        CXMLNode* pNode = lua_toxmlnode ( luaVM, 1 );
        if ( pNode )
        {
            // Grab the attribute name and value
            const char * szAttributeName = lua_tostring ( luaVM, 2 );

            // Are we going to set it to a value?
            if ( iType3 == LUA_TSTRING || iType3 == LUA_TNUMBER )
            {
                const char * szAttributeValue = lua_tostring ( luaVM, 3 );

                // Write the node
                CXMLAttribute* pAttribute = pNode->GetAttributes ().Create ( szAttributeName );
                if ( pAttribute )
                {
                    pAttribute->SetValue ( szAttributeValue );

                    lua_pushboolean ( luaVM, true );
                    return 1;
                }
            }
            else
            {
                // Delete the attribute if it exists
                CXMLAttribute* pAttribute = pNode->GetAttributes ().Find ( szAttributeName );
                if ( pAttribute )
                {
                    delete pAttribute;

                    lua_pushboolean ( luaVM, true );
                    return 1;
                }
            }
        }
    }
    else
    {
        m_pScriptDebugging->LogBadType ( luaVM, "xmlNodeSetAttribute" );

        lua_pushboolean ( luaVM, false );
        return 1;
    }

    lua_pushboolean ( luaVM, false );
    return 1;
}
void CAccessControlListGroup::WriteToXMLNode ( CXMLNode* pNode )
{
    assert ( pNode );

    // Create the subnode for this
    CXMLNode* pSubNode = pNode->CreateSubNode ( "group" );
    assert ( pSubNode );

    // Create attribute for the name and set it
    CXMLAttribute* pAttribute = pSubNode->GetAttributes ().Create ( "name" );
    pAttribute->SetValue ( m_strGroupName );

    // Write the ACL's this group use
    ACLsList::iterator iterACL = m_ACLs.begin ();
    for ( ; iterACL != m_ACLs.end (); iterACL++ )
    {
        CAccessControlList* pACL = *iterACL;

        // Create the subnode for this object and write the name attribute we generated
        CXMLNode* pObjectNode = pSubNode->CreateSubNode ( "acl" );
        pAttribute = pObjectNode->GetAttributes ().Create ( "name" );
        pAttribute->SetValue ( pACL->GetName () );
    }

    // Write every object
    ObjectList::iterator iter = m_Objects.begin ();
    for ( ; iter != m_Objects.end (); iter++ )
    {
        CAccessControlListGroupObject* pObject = *iter;

        // Find out the object type string
        char szObjectType [255];
        switch ( pObject->GetObjectType () )
        {
            case CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE:
                strcpy ( szObjectType, "resource" );
                break;

            case CAccessControlListGroupObject::OBJECT_TYPE_USER:
                strcpy ( szObjectType, "user" );
                break;

            default:
                strcpy ( szObjectType, "error" );
                break;
        }

        // Append a dot append the name of the node
        strcat ( szObjectType, "." );
        strncat ( szObjectType, pObject->GetObjectName (), NUMELMS( szObjectType ) - 1 );

        // Create the subnode for this object and write the name attribute we generated
        CXMLNode* pObjectNode = pSubNode->CreateSubNode ( "object" );
        pAttribute = pObjectNode->GetAttributes ().Create ( "name" );
        pAttribute->SetValue ( szObjectType );
    }
}
Ejemplo n.º 23
0
void CXMLElement::Serialize(CArchive& ar)
{
	CXMLNode::Serialize( ar );

	if ( ar.IsStoring() )
	{
		ar.WriteCount( GetAttributeCount() );

		for ( POSITION pos = GetAttributeIterator() ; pos ; )
		{
			GetNextAttribute( pos )->Serialize( ar );
		}

		ar.WriteCount( GetElementCount() );

		for ( POSITION pos = GetElementIterator() ; pos ; )
		{
			GetNextElement( pos )->Serialize( ar );
		}
	}
	else // Loading
	{
		for ( int nCount = (int)ar.ReadCount() ; nCount > 0 ; nCount-- )
		{
			CXMLAttribute* pAttribute = new CXMLAttribute( this );
			pAttribute->Serialize( ar );

			// Skip attribute if name is missing
			if ( pAttribute->m_sName.IsEmpty() )
			{
				delete pAttribute;
				continue;
			}

			CString strNameLower( pAttribute->m_sName );
			strNameLower.MakeLower();

			// Delete the old attribute if one exists
			CXMLAttribute* pExisting;
			if ( m_pAttributes.Lookup( strNameLower, pExisting ) )
				delete pExisting;

			m_pAttributes.SetAt( strNameLower, pAttribute );

			if ( ! m_pAttributesInsertion.Find( strNameLower ) )
				m_pAttributesInsertion.AddTail( strNameLower );		// Track output order workaround
		}

		for ( int nCount = (int)ar.ReadCount() ; nCount > 0 ; nCount-- )
		{
			CXMLElement* pElement = new CXMLElement( this );
			pElement->Serialize( ar );
			m_pElements.AddTail( pElement );
		}
	}
}
Ejemplo n.º 24
0
std::string CBanManager::SafeGetValue ( CXMLNode* pNode, const char* szKey )
{
    CXMLAttribute* pAttribute = pNode->GetAttributes ().Find ( szKey );

    if ( pAttribute )
    {
        return pAttribute->GetValue ();
    }
    return std::string();
}
Ejemplo n.º 25
0
void CModelNode::Load( const Core::CXMLNode& a_Node )
{
	CSceneNode::Load( a_Node );
	CXMLAttribute attribute = a_Node.GetAttribute( "Reference" );
	const Char* referencePath = attribute.GetValue( "UNKOWN" );	
	if ( strcmp( referencePath, "UNKOWN" ) == 0 )
	{
		CLog::GetInstance()->OutMessage( "Model node with no reference set in XML file\n", CLog::MESSAGETYPE_WARNING );
	}
}
Ejemplo n.º 26
0
char* Engine::FileSystem::Config::CXMLElement::ParseAttributes( char* p )
{
	const char* start = p;
	CXMLAttribute* prevAttribute = 0;

	// Read the attributes.
	while( p ) {
		p = CXMLUtil::SkipWhiteSpace( p );
		if ( !p || !(*p) ) {
			document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() );
			return 0;
		}

		// attribute.
		if ( CXMLUtil::IsAlpha( *p ) ) {
			CXMLAttribute* attrib = new (document->attributePool.Alloc() ) CXMLAttribute();
			attrib->XMLMemPool = &document->attributePool;

			p = attrib->ParseDeep( p, document->ProcessEntities() );
			if ( !p || Attribute( attrib->Name() ) ) {
				DELETE_ATTRIBUTE( attrib );
				document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p );
				return 0;
			}
			// There is a minor bug here: if the attribute in the source xml
			// document is duplicated, it will not be detected and the
			// attribute will be doubly added. However, tracking the 'prevAttribute'
			// avoids re-scanning the attribute list. Preferring performance for
			// now, may reconsider in the future.
			if ( prevAttribute ) { 
				prevAttribute->next = attrib;
			}
			else {
				rootAttribute = attrib;
			}	
			prevAttribute = attrib;
		}
		// end of the tag
		else if ( *p == '/' && *(p+1) == '>' ) {
			closingType = CLOSED;
			return p+2;	// done; sealed element.
		}
		// end of the tag
		else if ( *p == '>' ) {
			++p;
			break;
		}
		else {
			document->SetError( XML_ERROR_PARSING_ELEMENT, start, p );
			return 0;
		}
	}
	return p;
}
Ejemplo n.º 27
0
void CBanManager::SafeSetValue ( CXMLNode* pNode, const char* szKey, std::string strValue )
{
    if ( !strValue.empty() )
	{
        CXMLAttribute* pAttribute = pNode->GetAttributes ().Create ( szKey );
        if ( pAttribute )
        {
            pAttribute->SetValue ( strValue.c_str () );
        }
	}
}
Ejemplo n.º 28
0
void CBanManager::SafeSetValue ( CXMLNode* pNode, const char* szKey, unsigned int uiValue )
{
    if ( uiValue )
	{
        CXMLAttribute* pAttribute = pNode->GetAttributes ().Create ( szKey );
        if ( pAttribute )
        {
            pAttribute->SetValue ( uiValue );
        }
	}
}
Ejemplo n.º 29
0
BOOL CNetworkMonitorBox::ProcessXML(POSITION posNext)
{
	CXMLElement* pXML = Profiles.FindProcess( NULL, posNext );
	if ( pXML == NULL ) return FALSE;
	
	CSingleLock pLock( &Network.m_pSection, TRUE );
	
	CString strValue = pXML->GetAttributeValue( "Host" );
	
	if ( CChannel* pChannel = Network.FindChannel( strValue ) )
	{
		if ( pChannel->m_hSocket == INVALID_SOCKET && pChannel->TimeOut( 60 * 1000 ) ) 
		{
			CXMLAttribute* pAttri = pXML->GetAttribute( "Retry" );
			if ( ! pAttri ) pAttri = pXML->AddAttribute( "Retry" );
			
			if ( _ttoi( pAttri->GetValue() ) >= 2 )
			{
				AlarmToShortMessage( (LPCTSTR)strValue );
				strValue = pXML->GetAttributeValue( _T("Path") );
				RestartMachine( (LPCTSTR)strValue );
				
				pXML->DeleteAttribute( "Retry" );
			}
			else
			{
				strValue.Format( "%i", _ttoi( pAttri->GetValue() ) + 1 );
				pAttri->SetValue( (LPCTSTR)strValue );
				
				pChannel->LinkRestart();
				pChannel->m_tConnected	= GetTickCount();
			}
		}
		else
		if ( pChannel->IsConnected() )
		{
			pXML->DeleteAttribute( "Retry" );
		}
	}
	else
	{
		CChannel* pChannel = new CSentryChannel( pXML );
		Network.SetChannel( pChannel );
		
		pChannel->LinkRestart();
	}
	
	if ( posNext ) return ProcessXML( posNext );
	return TRUE;
}
Ejemplo n.º 30
0
// MDW-2013-07-09: [[ RevXmlXPath ]]
int CXMLElement::AttributeCount(char *attributename)
{
	if (!isinited()) return 0;
	CXMLAttribute tattribute;
	int attributecount = 0;
	if (GetFirstAttribute(&tattribute)){
		do {
			if (!attributename || 
				util_strnicmp(tattribute.GetName(),attributename,strlen(attributename)) == 0)
				attributecount++;
		} while (tattribute.GoNext());
	}
	return attributecount;
}