memspy/CommandLine/Source/MemSpyCommandLineMain.cpp
changeset 51 98307c651589
parent 42 0ff24a8f6ca2
child 52 c2f44e33b468
equal deleted inserted replaced
42:0ff24a8f6ca2 51:98307c651589
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <e32std.h>
       
    20 #include <f32file.h>
       
    21 #include <e32base.h>
       
    22 #include <e32cons.h>
       
    23 #include <f32file.h>
       
    24 #include <bacline.h>
       
    25 
       
    26 // User includes
       
    27 #include "MemSpyCommandLine.h"
       
    28 #include "MemSpyCommands.h"
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // DoMainL()
       
    32 // 
       
    33 // 
       
    34 // ---------------------------------------------------------------------------
       
    35 static void DoMainL()
       
    36     {
       
    37     // Scheduler
       
    38     CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
       
    39     CActiveScheduler::Install( scheduler );
       
    40     CleanupStack::PushL( scheduler );
       
    41     
       
    42     // Get command line 
       
    43     CCommandLineArguments* args = CCommandLineArguments::NewLC();
       
    44     
       
    45     //--
       
    46     CConsoleBase* console = Console::NewL( KMemSpyCLIName, TSize( KConsFullScreen, KConsFullScreen ) );
       
    47     CleanupStack::PushL( console );
       
    48     //--
       
    49     
       
    50     // Command line manager
       
    51     CMemSpyCommandLine* commandLineMgr = CMemSpyCommandLine::NewLC( *console );
       
    52 
       
    53     // Play nicely with external processes
       
    54     RProcess::Rendezvous( KErrNone );
       
    55 
       
    56     // Perform op
       
    57     commandLineMgr->PerformOpL( *args );  
       
    58         
       
    59     // Tidy up
       
    60     //CleanupStack::PopAndDestroy( 3, scheduler ); // scheduler, args, commandLineMgr
       
    61     CleanupStack::PopAndDestroy( 4 ); // scheduler, args,  console, commandLineMgr
       
    62     }
       
    63    
       
    64 
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // E32Main()
       
    68 // 
       
    69 // 
       
    70 // ---------------------------------------------------------------------------
       
    71 GLDEF_C TInt E32Main()
       
    72     {
       
    73     __UHEAP_MARK;
       
    74 
       
    75 #ifdef _DEBUG
       
    76     RDebug::Print(_L("[MemSpyCmdLine] E32Main() - MEMSPY COMMANDLINE - Thread %d is STARTING"), (TUint) RThread().Id() );
       
    77 #endif
       
    78 
       
    79     CTrapCleanup* cleanupTrap = CTrapCleanup::New();
       
    80     TRAPD(err, DoMainL());  
       
    81     if  ( err != KErrNone )
       
    82         {
       
    83         RDebug::Print(_L("[MemSpyCmdLine] E32Main() - MEMSPY COMMANDLINE - error: %d"), err);
       
    84         }
       
    85     delete cleanupTrap; 
       
    86 
       
    87     __UHEAP_MARKEND;
       
    88 
       
    89 #ifdef _DEBUG
       
    90     RDebug::Print(_L("[MemSpyCmdLine] E32Main() - MEMSPY COMMANDLINE - Thread %d is ENDING"), (TUint) RThread().Id() );
       
    91 #endif
       
    92 
       
    93     return err;
       
    94     }
       
    95