Ejemplo n.º 1
0
/**
 * Restore the heap structure
 */
static void SiftDown(ShaderVariable * first, GLsizeiptr start, GLsizeiptr end) {
	GLsizeiptr root, child;
	
	root = start;
	
	while (root * 2 + 1 <= end) {
		child = root * 2 + 1;
		
		if (child < end && 
			CompareNames(first[child].name, first[child].length, 
						 first[child + 1].name, first[child + 1].length) < 0) {
			++child;
		}
		
		if (CompareNames(first[root].name, first[root].length,
		 				 first[child].name, first[child].length) < 0) {
			ShaderVariable temp;
			
			temp = first[root];
			first[root] = first[child];
			first[child] = temp;
			
			root = child;
		} else {
			return;
		}
	}
}
Ejemplo n.º 2
0
void CTzUserDataTest::CheckTimeZoneL(const CTzId& aId, const CTzRules& aRules, const CTzUserNames& aNames)
	{
	CTzRules* rulesGet = iUserData->ReadRulesL(aId);
	CleanupStack::PushL(rulesGet);
	test(aRules.IsEqualTo(*rulesGet));
	CleanupStack::PopAndDestroy(rulesGet);
		
	CTzUserNames* namesGet = iUserData->ReadNamesL(aId);
	CleanupStack::PushL(namesGet);
	test (CompareNames(aNames, *namesGet));
	CleanupStack::PopAndDestroy(namesGet);
	}
Ejemplo n.º 3
0
/**
 * Find a specific shader variable in an array of sorted variables using
 * binary search.
 *
 * @param	first	the first element of the array to search
 * @param	count	the number of elements in the array to search
 * @param	name	pointer to the variable name to search
 * @param	length	the length of the variable name to search
 */
ShaderVariable * GlesFindShaderVariable(ShaderVariable * first, GLsizeiptr count,
	const char * name, GLsizeiptr length) {
		
	GLsizeiptr low = 0, high = count - 1;
		
	while (low < high) {
		GLsizeiptr mid = (low + high) / 2;
		
		if (CompareNames(first[mid].name, first[mid].length, name, length) < 0) {
			low = mid + 1; 
		} else {
			high = mid; 
		}
	}

	if (low < length && 
		!CompareNames(first[low].name, first[low].length, name, length)) {
		return first + low;
	} else {
		return NULL;
	}
}
Ejemplo n.º 4
0
/**
Update user-defined time zone.

@SYMTestCaseID 	PIM-APPSERV-TZS-CO-0002

@SYMTestCaseDesc
	The purpose of this test is to verify that user-defined time zone time rules
	and names can be updated.

@SYMTestActions    
	1.	Create a user-defined time zone (rules and names).
	2.	Get all existing user-defined time zones and update them with the rules
		and names created in action 1.
	3.	Read the new user-defined time zone rules and names updated in action 2. 

@SYMTestExpectedResults
	The following information is the same as the information used to update the
	user-defined time zone in action 3:
	
	- Time zone rules
	- Standard time name
	- Daylight saving time name 
	- Short standard time name
	- Short daylight saving time name
	- City name
	- Region name

@SYMTestType
	CT
	
@SYMTestPriority
	1
*/
void CTzUserDataTest::TestUpdateUserDefinedTzL()
	{
	test.Next(_L("@SYMTestCaseID PIM-APPSERV-TZS-CO-0002 "));
	CTzRules* newRule = CreateUserDefinedTzLC(0,0);
	CTzUserNames* newNames = CreateUserDefinedTzNamesLC();
	
	for(TInt ii=0; ii<iTzIds.Count(); ++ii)
		{
		iUserData->UpdateL(*(iTzIds[ii]), *newRule, *newNames);
	
		//Get and Compare
		CTzRules* userRuleGet = iUserData->ReadRulesL(*(iTzIds[ii]));
		test (userRuleGet->IsEqualTo(*newRule));
		delete userRuleGet;

		CTzUserNames* userNamesGet = iUserData->ReadNamesL(*(iTzIds[ii]));
		test(CompareNames(*userNamesGet, *newNames));
		delete userNamesGet;
		}
	
	CleanupStack::PopAndDestroy(2, newRule);
	}
Ejemplo n.º 5
0
VOID
FatInsertName (
    IN PIRP_CONTEXT IrpContext,
    IN PRTL_SPLAY_LINKS *RootNode,
    IN PFILE_NAME_NODE Name
    )

/*++

Routine Description:

    This routine will insert a name in the splay tree pointed to
    by RootNode.

    The name must not already exist in the splay tree.

Arguments:

    RootNode - Supplies a pointer to the table.

    Name - Contains the New name to enter.

Return Value:

    None.

--*/

{
    COMPARISON Comparison;
    PFILE_NAME_NODE Node;

    PAGED_CODE();

    RtlInitializeSplayLinks(&Name->Links);

Restart:

    //
    //  If we are the first entry in the tree, just become the root.
    //

    if (*RootNode == NULL) {

        *RootNode = &Name->Links;

        return;
    }

    Node = CONTAINING_RECORD( *RootNode, FILE_NAME_NODE, Links );

    while (TRUE) {

        //
        //  Compare the prefix in the tree with the prefix we want
        //  to insert.  Note that Oem here doesn't mean anything.
        //

        Comparison = CompareNames(&Node->Name.Oem, &Name->Name.Oem);

        //
        //  We should never find the name in the table already.
        //

        if (Comparison == IsEqual) {

            //
            //  Almost. If the removable media was taken to another machine and
            //  back, and we have something like:
            //
            //  Old: foobar~1  /  foobarbaz
            //  New: foobar~1  /  foobarbazbaz
            //
            //  but a handle was kept open to foobarbaz so we couldn't purge
            //  away the Fcb in the verify path ... opening foobarbazbaz will
            //  try to insert a duplicate shortname. Bang!
            //
            //  Invalidate it and the horse it came in on.  This new one wins.
            //  The old one is gone.  Only if the old one is in normal state
            //  do we really have a problem.
            //
            
            if (Node->Fcb->FcbState == FcbGood) {
                
                FatBugCheck( (ULONG_PTR)*RootNode, (ULONG_PTR)Name, (ULONG_PTR)Node );
            }

            //
            //  Note, once we zap the prefix links we need to restart our walk
            //  of the tree.
            //
            
            FatMarkFcbCondition( IrpContext, Node->Fcb, FcbBad, TRUE );
            FatRemoveNames( IrpContext, Node->Fcb );

            goto Restart;
        }

        //
        //  If the tree prefix is greater than the new prefix then
        //  we go down the left subtree
        //

        if (Comparison == IsGreaterThan) {

            //
            //  We want to go down the left subtree, first check to see
            //  if we have a left subtree
            //

            if (RtlLeftChild(&Node->Links) == NULL) {

                //
                //  there isn't a left child so we insert ourselves as the
                //  new left child
                //

                RtlInsertAsLeftChild(&Node->Links, &Name->Links);

                //
                //  and exit the while loop
                //

                break;

            } else {

                //
                //  there is a left child so simply go down that path, and
                //  go back to the top of the loop
                //

                Node = CONTAINING_RECORD( RtlLeftChild(&Node->Links),
                                          FILE_NAME_NODE,
                                          Links );
            }

        } else {

            //
            //  The tree prefix is either less than or a proper prefix
            //  of the new string.  We treat both cases a less than when
            //  we do insert.  So we want to go down the right subtree,
            //  first check to see if we have a right subtree
            //

            if (RtlRightChild(&Node->Links) == NULL) {

                //
                //  These isn't a right child so we insert ourselves as the
                //  new right child
                //

                RtlInsertAsRightChild(&Node->Links, &Name->Links);

                //
                //  and exit the while loop
                //

                break;

            } else {

                //
                //  there is a right child so simply go down that path, and
                //  go back to the top of the loop
                //

                Node = CONTAINING_RECORD( RtlRightChild(&Node->Links),
                                          FILE_NAME_NODE,
                                          Links );
            }

        }
    }

    return;
}
Ejemplo n.º 6
0
PFCB
FatFindFcb (
    IN PIRP_CONTEXT IrpContext,
    IN OUT PRTL_SPLAY_LINKS *RootNode,
    IN PSTRING Name,
    OUT PBOOLEAN FileNameDos OPTIONAL
    )

/*++

Routine Description:

    This routine searches either the Oem or Unicode splay tree looking
    for an Fcb with the specified name.  In the case the Fcb is found,
    rebalance the tree.

Arguments:

    RootNode - Supplies the parent to search.

    Name - If present, search the Oem tree.

    UnicodeName - If present, search the Unicode tree.

Return Value:

    PFCB - The Fcb, or NULL if none was found.

--*/

{
    COMPARISON Comparison;
    PFILE_NAME_NODE Node;
    PRTL_SPLAY_LINKS Links;

    PAGED_CODE();

    Links = *RootNode;

    while (Links != NULL) {

        Node = CONTAINING_RECORD(Links, FILE_NAME_NODE, Links);

        //
        //  Compare the prefix in the tree with the full name
        //

        Comparison = CompareNames(&Node->Name.Oem, Name);

        //
        //  See if they don't match
        //

        if (Comparison == IsGreaterThan) {

            //
            //  The prefix is greater than the full name
            //  so we go down the left child
            //

            Links = RtlLeftChild(Links);

            //
            //  And continue searching down this tree
            //

        } else if (Comparison == IsLessThan) {

            //
            //  The prefix is less than the full name
            //  so we go down the right child
            //

            Links = RtlRightChild(Links);

            //
            //  And continue searching down this tree
            //

        } else {

            //
            //  We found it.
            //
            //  Splay the tree and save the new root.
            //

            *RootNode = RtlSplay(Links);

            //
            //  Tell the caller what kind of name we hit
            //

            if (FileNameDos) {

                *FileNameDos = Node->FileNameDos;
            }

            return Node->Fcb;
        }
    }

    //
    //  We didn't find the Fcb.
    //

    return NULL;
}
/**
 * Checks whether the names of resources, targets and programs are unique
 *
 * @param           
 * @return          
 * @exception       -
 * @see             
*/
bool CProjectWizardData::CheckUniqueNames ()
{
    int iResource1;
    int iResource2;
    int iTask1;
    int iTask2;
    CProjectWizardResource *pResource1;
    CProjectWizardResource *pResource2;
    CProjectWizardTask *pTask1;
    CProjectWizardTask *pTask2;
    int iNumResources = GetResourceCount();

    for (iResource1 = 0; iResource1 < iNumResources; ++iResource1)
    {
        pResource1 = GetResource(iResource1);

        for (iResource2 = iResource1 + 1; iResource2 < GetResourceCount (); ++iResource2)
        {
            pResource2 = GetResource (iResource2);

            if (!CompareNames (IDS_ERR_NON_UNIQUE_RESOURCE, pResource1->GetResource (), pResource2->GetResource (), TRUE))
                return (false);

            if (!CompareNames (IDS_ERR_NON_UNIQUE_TARGET, pResource1->GetTarget (), pResource2->GetTarget (), FALSE))
                return (false);
        };

        for (iTask1 = 0; iTask1 < pResource1->GetTaskCount (); ++iTask1)
        {
            pTask1 = pResource1->GetTask (iTask1);

            if (!CompareNames (IDS_ERR_EQUAL_TASK_AND_PROGRAM_NAME, pTask1->GetName (), pTask1->GetProgram (), TRUE))
                return (false);

            for (iTask2 = iTask1 + 1; iTask2 < pResource1->GetTaskCount (); ++iTask2)
            {
                pTask2 = pResource1->GetTask (iTask2);

                if (!CompareNames (IDS_ERR_NON_UNIQUE_TASK, pTask1->GetName (), pTask2->GetName (), TRUE))
                    return (false);

                if (!CompareNames (IDS_ERR_NON_UNIQUE_PROGRAM, pTask1->GetProgram (), pTask2->GetProgram (), TRUE))
                    return (false);

                if (!CompareNames (IDS_ERR_EQUAL_TASK_AND_PROGRAM_NAME, pTask1->GetName (), pTask2->GetProgram (), TRUE))
                    return (false);

                if (!CompareNames (IDS_ERR_EQUAL_TASK_AND_PROGRAM_NAME, pTask1->GetProgram (), pTask2->GetName (), TRUE))
                    return (false);
            };

            for (iResource2 = iResource1 + 1; iResource2 < GetResourceCount (); ++iResource2)
            {
                pResource2 = GetResource (iResource2);

                for (iTask2 = 0; iTask2 < pResource2->GetTaskCount (); ++iTask2)
                {
                    pTask2 = pResource2->GetTask (iTask2);

                    if (!CompareNames (IDS_ERR_NON_UNIQUE_PROGRAM, pTask1->GetProgram (), pTask2->GetProgram (), TRUE))
                        return (false);

                    if (!CompareNames (IDS_ERR_EQUAL_TASK_AND_PROGRAM_NAME, pTask1->GetName (), pTask2->GetProgram (), TRUE))
                        return (false);

                    if (!CompareNames (IDS_ERR_EQUAL_TASK_AND_PROGRAM_NAME, pTask1->GetProgram (), pTask2->GetName (), TRUE))
                        return (false);
                };
            };
        };
    };

    return (true);
}
Ejemplo n.º 8
0
VOID
FatInsertName (
    IN PIRP_CONTEXT IrpContext,
    IN PRTL_SPLAY_LINKS *RootNode,
    IN PFILE_NAME_NODE Name
    )

/*++

Routine Description:

    This routine will insert a name in the splay tree pointed to
    by RootNode.

    The name must not already exist in the splay tree.

Arguments:

    RootNode - Supplies a pointer to the table.

    Name - Contains the New name to enter.

Return Value:

    None.

--*/

{
    COMPARISON Comparison;
    PFILE_NAME_NODE Node;

    RtlInitializeSplayLinks(&Name->Links);

    //
    //  If we are the first entry in the tree, just become the root.
    //

    if (*RootNode == NULL) {

        *RootNode = &Name->Links;

        return;
    }

    Node = CONTAINING_RECORD( *RootNode, FILE_NAME_NODE, Links );

    while (TRUE) {

        //
        //  Compare the prefix in the tree with the prefix we want
        //  to insert.  Note that Oem here doesn't mean anything.
        //

        Comparison = CompareNames(&Node->Name.Oem, &Name->Name.Oem);

        //
        //  We should never find the name in the table already.
        //

        if (Comparison == IsEqual) {

            FatBugCheck( (ULONG)*RootNode, (ULONG)Name, (ULONG)Node );
        }

        //
        //  If the tree prefix is greater than the new prefix then
        //  we go down the left subtree
        //

        if (Comparison == IsGreaterThan) {

            //
            //  We want to go down the left subtree, first check to see
            //  if we have a left subtree
            //

            if (RtlLeftChild(&Node->Links) == NULL) {

                //
                //  there isn't a left child so we insert ourselves as the
                //  new left child
                //

                RtlInsertAsLeftChild(&Node->Links, &Name->Links);

                //
                //  and exit the while loop
                //

                break;

            } else {

                //
                //  there is a left child so simply go down that path, and
                //  go back to the top of the loop
                //

                Node = CONTAINING_RECORD( RtlLeftChild(&Node->Links),
                                          FILE_NAME_NODE,
                                          Links );
            }

        } else {

            //
            //  The tree prefix is either less than or a proper prefix
            //  of the new string.  We treat both cases a less than when
            //  we do insert.  So we want to go down the right subtree,
            //  first check to see if we have a right subtree
            //

            if (RtlRightChild(&Node->Links) == NULL) {

                //
                //  These isn't a right child so we insert ourselves as the
                //  new right child
                //

                RtlInsertAsRightChild(&Node->Links, &Name->Links);

                //
                //  and exit the while loop
                //

                break;

            } else {

                //
                //  there is a right child so simply go down that path, and
                //  go back to the top of the loop
                //

                Node = CONTAINING_RECORD( RtlRightChild(&Node->Links),
                                          FILE_NAME_NODE,
                                          Links );
            }

        }
    }

    return;
}
Ejemplo n.º 9
0
//
// Adding a new manager to the manager list.  The new manager is always added 
// to the end of the list.  A connection to the manager is also made
//
Manager* ManagerList::AddManager( Manager_Info *manager_info )
{
	unsigned short network_port = manager_info->port_number;
	
	// Creating space for a new manager.
	Manager* manager;
	manager = new Manager;

	strcpy(manager->computer_name, manager_info->names[0]);

	strcpy(manager->name, manager->computer_name);
	manager->processors = manager_info->processors;
	manager->processor_speed = (double)manager_info->processor_speed;

	// Connect to the new manager using TCP/IP or named pipe as appropriate
	if ( theApp.login_port->type == PORT_TYPE_TCP )
	{
		strcpy(manager->network_name, manager_info->names[1]);

		manager->port = new PortTCP;

		// Do not connect to "network_name".  See Manager.h for detailed comments.
		if ( !manager->port->Connect( manager_info->names[1], network_port ) )
		{
			ErrorMessage( "Could not connect to new manager using "
				"TCP/IP port in ManagerList::AddManager" );
			return NULL;
		}
	}
	else if ( theApp.login_port->type == PORT_TYPE_PIPE )
	{
		CString temp_computer_name;
		CString temp_network_name;

		temp_network_name = "\\\\" + (CString)manager->computer_name + "\\";
		strcpy( manager->network_name, (LPCTSTR)temp_network_name );

		manager->port = new PortPipe;

		// Compare the network name to the Iometer machine name.
		unsigned long computer_name_length = MAX_COMPUTERNAME_LENGTH + 1;
		GetComputerName( temp_computer_name.GetBuffer( MAX_COMPUTERNAME_LENGTH ), 
			&computer_name_length );
		temp_computer_name.ReleaseBuffer();
		temp_computer_name = "\\\\" + temp_computer_name + "\\";

		// See if Dynamo logged in from another machine or on same 
		// machine as Iometer.
		if ( CompareNames( (char*)(LPCTSTR)temp_computer_name, manager_info->names[1] ) )
		{
			// Dynamo is on same machine.  Connect back without using 
			// the network.
			temp_computer_name = manager_info->names[1];
			temp_computer_name = temp_computer_name.Mid( 2 );
			temp_computer_name = "\\\\." + temp_computer_name.Mid( 
				temp_computer_name.Find( '\\' ) );
			if ( !manager->port->Connect( (char*)(LPCTSTR)temp_computer_name ) )
			{
				ErrorMessage( "Could not connect to new manager using "
					"local named pipe in ManagerList::AddManager" );
				return NULL;
			}
		}
		else
		{
			// Connecting to network attached manager to signify successful login.
			// Do not connect to "network_name".  See Manager.h for detailed comments.
			if ( !manager->port->Connect( manager_info->names[1] ) )
			{
				ErrorMessage( "Could not connect to new manager using "
					"network named pipe in ManagerList::AddManager" );
				return NULL;
			}
		}
	}
	else
	{
		ErrorMessage( "Invalid login port in ManagerList::AddManager" );
		return NULL;
	}

	// Adding manager to end of the manager list and updating the last manager accessed
	// to be the new manager.
	managers.Add( manager );

	// Assign disambiguating integer identifiers to same-named managers.
	theApp.manager_list.IndexManagers();

	// Notify the manager loadmap that a new manager has logged in.
	// This notification is only necessary if a configuration file restore
	// is taking place and some of the managers required to restore the
	// manager/worker configuration are not yet connected to Iometer.
	if ( loadmap.IsWaitingList() )
		(void) loadmap.ManagerLoggedIn( manager->name, manager->network_name, manager );

	// Return a pointer to the new manager.
	return manager;
}
Ejemplo n.º 10
0
bool CEntityManager::VisitNode(IHashString *searchString, IVisitor *visitorPattern)
{
	static CHashString compType(_T("CEntity"));
	IDTOOBJECTMAP *entityMap = GetObjectMap(&compType);
	if(entityMap == NULL)
	{
		return true;
	}
	
	if (!visitorPattern)
	{
		return false;
	}

	IDTOOBJECTMAP::iterator osIter = entityMap->begin();	
	CEntity *entity;
	if (searchString != NULL)
	{
		for(; osIter != entityMap->end(); ++osIter)
		{
			entity = dynamic_cast<CEntity *>(osIter->second);
			if (entity == NULL)
			{
				m_ToolBox->SetErrorValue(ERR_NULL_POINTER);
				m_ToolBox->Log(LOGERROR, _T("Unable to cast IObject* to CEntity* \n"));
				return false;
			}
			if (CompareNames(searchString->GetString(), entity->GetEntityTypes()) )
			{
				IComponent *visitComp = dynamic_cast<IComponent *>(osIter->second);
				if (visitComp != NULL)
				{
					visitorPattern->Visit(visitComp, true);
				}
				else
				{
					IHashString *typeName = visitComp->GetComponentType();
					EngineGetToolBox()->Log(LOGWARNING, 
						_T("component of type %s was used as IComponent and is not one.\n"),
						typeName);
				}
			}
		}
	}
	else
	{
		for(; osIter != entityMap->end(); ++osIter)
		{
			IComponent *visitComp = dynamic_cast<IComponent *>(osIter->second);
			if (visitComp != NULL)
			{
				visitorPattern->Visit(visitComp, true);
			}
			else
			{
				IHashString *typeName = visitComp->GetComponentType();
				EngineGetToolBox()->Log(LOGWARNING, 
					_T("component of type %s was used as IComponent and is not one.\n"),
					typeName);
			}
		}
	}
	return true;
}