os/persistentdata/persistentstorage/dbms/SPConv/cn_main.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2004-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 // E32Main(), DoMainL() implementations
    15 // 
    16 //
    17 
    18 #include <f32file.h>
    19 #include "D32Assert.h"
    20 #include "cn_main.h"
    21 #include "cn_cmdparse.h"
    22 #include "cn_util.h"
    23 #include "cn_proc.h"
    24 
    25 /**
    26 It will be used for parsed command line arguments.
    27 @internalComponent
    28 */
    29 static TCmdLinePrm TheCmdLinePrm;
    30 
    31 /**
    32 DoMainL() parses the command line, fills TheCmdLinePrm struct, creates the appropriate
    33 command line execution object and calls its RunL() method.
    34 @internalComponent
    35 */
    36 static void DoMainL()
    37 	{
    38 	RFs fileSession;
    39 	__LEAVE_IF_ERROR(fileSession.Connect());
    40 	CleanupClosePushL(fileSession);
    41 
    42 	CCommandLineArguments* cmdLineParser = CCommandLineArguments::NewLC();
    43 
    44 	TSPConvUtil::ParseL(*cmdLineParser, TheCmdLinePrm);
    45 	TSPConvUtil::ConstructBinFileNameL(TheCmdLinePrm.iBinFile);
    46 
    47 	CCmdProcessor* proc = TCmdProcessorFactory::NewLC(fileSession, TheCmdLinePrm);
    48 	proc->RunL();
    49 
    50 	CleanupStack::PopAndDestroy(3, &fileSession);//cmdLineParser, fileSession, proc
    51 	}
    52 
    53 /**
    54 The main function of DbSpConv tool, which can be used to load and parse a text policy file
    55 and store it in a binary policy file, which can be used by the DBMS server.
    56 */
    57 TInt E32Main()
    58 	{
    59 	__UHEAP_MARK;
    60 
    61 	CTrapCleanup* trapCleanup = CTrapCleanup::New();
    62 	__ASSERT_ALWAYS(trapCleanup != NULL, User::Invariant());
    63 	
    64 	TRAPD(err, ::DoMainL());
    65 
    66 	if(err != KErrNone)
    67 		{
    68 		_LIT(KText, "Security policy tool failed. Error code = %d\n");
    69 		TSPConvUtil::Print(KText, err);
    70 		}
    71 	else
    72 		{
    73 		_LIT(KText, "\"%S\"->\"%S\" : OK!\n");
    74 		TSPConvUtil::Print(KText, TheCmdLinePrm.iTxtFile, TheCmdLinePrm.iBinFile);
    75 		}
    76 
    77 	delete trapCleanup;
    78 
    79 	__UHEAP_MARKEND;
    80 
    81 	return err;
    82     }