sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyapp.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:24:48 +0100
branchRCL_3
changeset 63 c2c61fdca848
parent 62 924385140d98
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035

/*
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  
*
*/




// INCLUDE FILES
#include <eikstart.h>
#include "t_oomdummyappApplication.h"

_LIT(KFakeUidParam,"uid=");
_LIT(KAllocParam,"alloc=");
LOCAL_C CApaApplication* NewApplication()
	{
	TUid uid(KUidt_oomdummyappApp);
	TUint alloc = 0;
	//override uid from command line (add "uid=6789ABCD" anywhere)
	TInt cmdsize = User::CommandLineLength();
	HBufC *cmdbuf = NULL;
	if(cmdsize > 0) cmdbuf = HBufC::New(cmdsize);
	if(cmdbuf)
		{
		TPtr cmdline(cmdbuf->Des());
		User::CommandLine(cmdline);
		TLex lex(*cmdbuf);
		while(!lex.Eos())
			{
			lex.SkipSpaceAndMark();
			while(!lex.Eos() && lex.Get() != '=')
				{
				}
			if(lex.MarkedToken().CompareF(KFakeUidParam) == 0)
				{
				lex.SkipSpaceAndMark();
				while(!lex.Eos() && lex.Get().IsHexDigit())
					{
					}
				TUint id;
				TLex num(lex.MarkedToken());
				if(KErrNone==num.Val(id,EHex))
					{
					RDebug::Printf("\tapp uid override %x", id);
					uid = TUid::Uid(id);
					}
				}
			else if(lex.MarkedToken().CompareF(KAllocParam) == 0)
				{
				lex.SkipSpaceAndMark();
				while(!lex.Eos() && lex.Get().IsHexDigit())
					{
					}
				TLex num(lex.MarkedToken());
				if(KErrNone!=num.Val(alloc,EHex))
					{
					alloc = 0;
					}
				}
			}
		/*
		TInt offset = cmdbuf->Find(KFakeUidParam);
		if(offset >=0 && offset + 12 <= cmdbuf->Length())
			{
			TLex lex(cmdbuf->Mid(offset+4,8));
			TUint id;
			if(KErrNone==lex.Val(id,EHex))
				{
				RDebug::Printf("\tapp uid override %x", id);
				uid = TUid::Uid(id);
				}
			}
		TInt offset = cmdbuf->Find(KAllocParam);
		if(offset >=0 && offset + 12 <= cmdbuf->Length())*/
		delete cmdbuf;
		}
	return new Ct_oomdummyappApplication(uid, alloc);
	}

GLDEF_C TInt E32Main()
	{
	return EikStart::RunApplication(NewApplication);
	}