00001 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). 00002 // All rights reserved. 00003 // This component and the accompanying materials are made available 00004 // under the terms of "Eclipse Public License v1.0" 00005 // which accompanies this distribution, and is available 00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". 00007 // 00008 // Initial Contributors: 00009 // Nokia Corporation - initial contribution. 00010 // 00011 // Contributors: 00012 // 00013 // Description: 00014 // BASTD.H 00015 // 00016 00017 #ifndef __BASTD_H 00018 #define __BASTD_H 00019 00020 #include <e32cons.h> 00021 #include <f32file.h> 00022 #include <barsc.h> 00023 #include <barsread.h> 00024 00025 00026 // public 00027 LOCAL_D CConsoleBase* console; // write all your messages to this 00028 LOCAL_D RFs fsSession; 00029 LOCAL_C void doExampleL(); // code this function for the real example 00030 00031 // private 00032 LOCAL_C void callExampleL(); // initialize with cleanup stack, then do example 00033 00034 GLDEF_C TInt E32Main() // main function called by E32 00035 { 00036 _LIT(KBaflEx,"BAFLEX"); 00037 __UHEAP_MARK; 00038 if (fsSession.Connect()!=KErrNone) 00039 return KErrGeneral; 00040 CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack 00041 TRAPD(error,callExampleL()); // more initialization, then do example 00042 fsSession.Close(); 00043 __ASSERT_ALWAYS(!error,User::Panic(KBaflEx,error)); 00044 delete cleanup; // destroy clean-up stack 00045 __UHEAP_MARKEND; 00046 return 0; // and return 00047 } 00048 00049 LOCAL_C void callExampleL() // initialize and call example code under cleanup stack 00050 { 00051 _LIT(KExampleCode,"SDK Example Code"); 00052 _LIT(KFailedLeave,"failed: leave code=%d"); 00053 _LIT(KOk,"ok"); 00054 _LIT(KPressAnyKey," [press any key]"); 00055 00056 console=Console::NewL(KExampleCode,TSize(KConsFullScreen,KConsFullScreen)); 00057 CleanupStack::PushL(console); 00058 TRAPD(error,doExampleL()); // perform example function 00059 if (error) 00060 console->Printf(KFailedLeave, error); 00061 else 00062 console->Printf(KOk); 00063 console->Printf(KPressAnyKey); 00064 console->Getch(); // get and ignore character 00065 CleanupStack::PopAndDestroy(); // close console 00066 } 00067 00068 #endif
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.