|
1 // BASTD.H |
|
2 // |
|
3 // Copyright (c) 1997-1999 Symbian Ltd. All rights reserved. |
|
4 // |
|
5 |
|
6 #ifndef __BASTD_H |
|
7 #define __BASTD_H |
|
8 |
|
9 #include <e32cons.h> |
|
10 #include <f32file.h> |
|
11 #include <barsc.h> |
|
12 #include <barsread.h> |
|
13 |
|
14 |
|
15 // public |
|
16 LOCAL_D CConsoleBase* console; // write all your messages to this |
|
17 LOCAL_D RFs fsSession; |
|
18 LOCAL_C void doExampleL(); // code this function for the real example |
|
19 |
|
20 // private |
|
21 LOCAL_C void callExampleL(); // initialize with cleanup stack, then do example |
|
22 |
|
23 GLDEF_C TInt E32Main() // main function called by E32 |
|
24 { |
|
25 _LIT(KBaflEx,"BAFLEX"); |
|
26 __UHEAP_MARK; |
|
27 if (fsSession.Connect()!=KErrNone) |
|
28 return KErrGeneral; |
|
29 CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack |
|
30 TRAPD(error,callExampleL()); // more initialization, then do example |
|
31 fsSession.Close(); |
|
32 __ASSERT_ALWAYS(!error,User::Panic(KBaflEx,error)); |
|
33 delete cleanup; // destroy clean-up stack |
|
34 __UHEAP_MARKEND; |
|
35 return 0; // and return |
|
36 } |
|
37 |
|
38 LOCAL_C void callExampleL() // initialize and call example code under cleanup stack |
|
39 { |
|
40 _LIT(KExampleCode,"SDK Example Code"); |
|
41 _LIT(KFailedLeave,"failed: leave code=%d"); |
|
42 _LIT(KOk,"ok"); |
|
43 _LIT(KPressAnyKey," [press any key]"); |
|
44 |
|
45 console=Console::NewL(KExampleCode,TSize(KConsFullScreen,KConsFullScreen)); |
|
46 CleanupStack::PushL(console); |
|
47 TRAPD(error,doExampleL()); // perform example function |
|
48 if (error) |
|
49 console->Printf(KFailedLeave, error); |
|
50 else |
|
51 console->Printf(KOk); |
|
52 console->Printf(KPressAnyKey); |
|
53 console->Getch(); // get and ignore character |
|
54 CleanupStack::PopAndDestroy(); // close console |
|
55 } |
|
56 |
|
57 #endif |