sysstatemgmt/systemstarter/test/sysmondemo/src/changebootmode.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // changemode.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "e32base.h"
       
    19 #include "e32std.h"
       
    20 
       
    21 #include <hal.h>
       
    22 #include <hal_data.h>
       
    23 
       
    24 LOCAL_C void ChangeModeL()
       
    25 {
       
    26 
       
    27 
       
    28 	TBuf<40> command;
       
    29 	User::CommandLine(command) ;
       
    30 	TPtr8 data = command.Collapse() ;
       
    31 
       
    32 	TInt mode = 0 ;
       
    33 		
       
    34 	if (data != KNullDesC8)
       
    35 	{
       
    36 		TLex8 txt = TLex8(const_cast<TUint8*> (data.PtrZ())) ;
       
    37 		User::LeaveIfError(txt.Val(mode)) ;		
       
    38 	}
       
    39 
       
    40 	HAL::Set(HALData::EPersistStartupModeKernel, mode);	
       
    41 
       
    42 	// Initialisation complete, now signal 
       
    43 	RProcess::Rendezvous(KErrNone);
       
    44 
       
    45 }
       
    46 
       
    47 
       
    48 GLDEF_C TInt E32Main()
       
    49 	{
       
    50 	__UHEAP_MARK; // mark heap state
       
    51 
       
    52 	CTrapCleanup* theTrapCleanup=CTrapCleanup::New();
       
    53 
       
    54 	if (theTrapCleanup == NULL)
       
    55 		return KErrNoMemory;
       
    56 	else
       
    57 		{
       
    58 		TRAPD(error, ChangeModeL());
       
    59 
       
    60     	delete theTrapCleanup;
       
    61 		__UHEAP_MARKEND; // check no memory leak
       
    62 
       
    63 		return(error);
       
    64 		}
       
    65 	}