2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2009 Sam Lantinga
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 slouken@devolution.com
25 The Epoc executable startup functions
27 Epoc version by Hannu Viitala (hannu.j.viitala@mbnet.fi)
40 #include "SDL_error.h"
44 IMPORT_C void RegisterWsExe(const TDesC &aName);
47 /* The prototype for the application's main() function */
49 extern "C" int main (int argc, char *argv[], char *envp[]);
50 extern "C" void exit (int ret);
53 /* Epoc main function */
58 void GetCmdLine(int& aArgc, char**& aArgv)
62 if(chunk.OpenGlobal(RThread().Name(), ETrue) != KErrNone)
65 TUint* ptr = (TUint*) chunk.Base();
68 aArgc = (int) *(ptr); // count
69 aArgv = (char**) *(ptr + 1);
79 /* Get the clean-up stack */
80 CTrapCleanup* cleanup = CTrapCleanup::New();
82 /* Arrange for multi-threaded operation */
83 SpawnPosixServerThread();
85 /* Get args and environment */
91 __crt0(argc,argv,envp);
93 GetCmdLine(argc, argv);
95 /* Start the application! */
100 /* Set process and thread priority and name */
102 RThread currentThread;
103 RProcess thisProcess;
105 exeName.Set(thisProcess.FileName(), NULL, NULL);
106 currentThread.Rename(exeName.Name());
107 currentThread.SetProcessPriority(EPriorityLow);
108 currentThread.SetPriority(EPriorityMuchLess);
110 /* Call stdlib main */
111 int ret = main(argc, argv, envp); /* !! process exits here if there is "exit()" in main! */
114 //exit(ret); /* !! process exits here! */
115 //Markus: I do not understand above
116 //I commented it at let this function
117 //to return ret value - was it purpose
118 //that cleanup below is not called at all - why?
120 /* Free resources and return */
122 _cleanup(); //this is normally called at exit, I call it here, Markus
127 // User::Panic(_L("exit"), ret);
128 // RThread().Kill(ret); //Markus get rid of this thread
129 // RThread().RaiseException(EExcKill);
131 return ret;//Markus, or exit(ret); ??
137 EXPORT_C TInt WinsMain()
140 // return WinsMain(0, 0, 0);
144 /* Epoc dll entry point */
145 #if defined(__WINS__)
146 GLDEF_C TInt E32Dll(TDllReason)