main_symbian.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //Auto-generated file. Please do not modify.
  2. //#include <e32cmn.h>
  3. //#pragma data_seg(".SYMBIAN")
  4. //__EMULATOR_IMAGE_HEADER2 (0x1000007a,0x00000000,0x00000000,EPriorityForeground,0x00000000u,0x00000000u,0x00000000,0x00000000,0x00000000,0)
  5. //#pragma data_seg()
  6. #include "test.h"
  7. #include <stdlib.h>
  8. #include <pj/errno.h>
  9. #include <pj/os.h>
  10. #include <pj/log.h>
  11. #include <pj/unicode.h>
  12. #include <stdio.h>
  13. #include <e32std.h>
  14. #if 0
  15. int main()
  16. {
  17. int err = 0;
  18. int exp = 0;
  19. err = test_main();
  20. //err = test_main();
  21. if (err)
  22. return err;
  23. return exp;
  24. //return 0;
  25. }
  26. #else
  27. #include <pj/os.h>
  28. #include <e32base.h>
  29. #include <e32std.h>
  30. #include <e32cons.h> // Console
  31. // Global Variables
  32. LOCAL_D CConsoleBase* console; // write all messages to this
  33. class MyScheduler : public CActiveScheduler
  34. {
  35. public:
  36. MyScheduler()
  37. {}
  38. void Error(TInt aError) const;
  39. };
  40. void MyScheduler::Error(TInt aError) const
  41. {
  42. PJ_UNUSED_ARG(aError);
  43. }
  44. LOCAL_C void DoStartL()
  45. {
  46. // Create active scheduler (to run active objects)
  47. CActiveScheduler* scheduler = new (ELeave) MyScheduler;
  48. CleanupStack::PushL(scheduler);
  49. CActiveScheduler::Install(scheduler);
  50. test_main();
  51. CActiveScheduler::Install(NULL);
  52. CleanupStack::Pop(scheduler);
  53. delete scheduler;
  54. }
  55. #define WRITE_TO_DEBUG_CONSOLE
  56. #ifdef WRITE_TO_DEBUG_CONSOLE
  57. #include<e32debug.h>
  58. #endif
  59. // Global Functions
  60. static void log_writer(int level, const char *buf, int len)
  61. {
  62. static wchar_t buf16[PJ_LOG_MAX_SIZE];
  63. PJ_UNUSED_ARG(level);
  64. pj_ansi_to_unicode(buf, len, buf16, PJ_ARRAY_SIZE(buf16));
  65. buf16[len] = 0;
  66. buf16[len+1] = 0;
  67. TPtrC16 aBuf((const TUint16*)buf16, (TInt)len);
  68. console->Write(aBuf);
  69. #ifdef WRITE_TO_DEBUG_CONSOLE
  70. RDebug::Print(aBuf);
  71. #endif
  72. }
  73. GLDEF_C TInt E32Main()
  74. {
  75. // Create cleanup stack
  76. __UHEAP_MARK;
  77. CTrapCleanup* cleanup = CTrapCleanup::New();
  78. // Create output console
  79. TRAPD(createError, console = Console::NewL(_L("Console"), TSize(KConsFullScreen,KConsFullScreen)));
  80. if (createError)
  81. return createError;
  82. pj_log_set_log_func(&log_writer);
  83. // Run application code inside TRAP harness, wait keypress when terminated
  84. TRAPD(mainError, DoStartL());
  85. if (mainError)
  86. console->Printf(_L(" failed, leave code = %d"), mainError);
  87. console->Printf(_L(" [press any key]\n"));
  88. console->Getch();
  89. delete console;
  90. delete cleanup;
  91. CloseSTDLIB();
  92. __UHEAP_MARKEND;
  93. return KErrNone;
  94. }
  95. #endif /* if 0 */