Mercurial > sdl-ios-xcode
comparison src/main/epoc/SDL_main.cpp @ 173:83018110dce8
Added initial support for EPOC/Symbian OS (thanks Hannu!)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 11 Sep 2001 20:38:49 +0000 |
parents | |
children | e8157fcb3114 |
comparison
equal
deleted
inserted
replaced
172:37e3ca9254c7 | 173:83018110dce8 |
---|---|
1 /* | |
2 SDL - Simple DirectMedia Layer | |
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga | |
4 | |
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. | |
9 | |
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. | |
14 | |
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 | |
18 | |
19 Sam Lantinga | |
20 slouken@devolution.com | |
21 */ | |
22 | |
23 /* | |
24 SDL_main.cpp | |
25 The Epoc executable startup functions | |
26 | |
27 Epoc version by Hannu Viitala (hannu.j.viitala@mbnet.fi) | |
28 */ | |
29 | |
30 #include <e32std.h> | |
31 #include <e32def.h> | |
32 #include <e32svr.h> | |
33 #include <e32base.h> | |
34 #include <estlib.h> | |
35 #include <stdlib.h> | |
36 #include <stdio.h> | |
37 #include <w32std.h> | |
38 #include <apgtask.h> | |
39 | |
40 #include "SDL_error.h" | |
41 | |
42 #ifndef EXPORT_C | |
43 # ifdef __VC32__ | |
44 # define IMPORT_C __declspec(dllexport) | |
45 # define EXPORT_C __declspec(dllexport) | |
46 # endif | |
47 # ifdef __GCC32__ | |
48 # define IMPORT_C | |
49 # define EXPORT_C __declspec(dllexport) | |
50 # endif | |
51 #endif | |
52 | |
53 #if defined(__WINS__) | |
54 #include <estw32.h> | |
55 IMPORT_C void RegisterWsExe(const TDesC &aName); | |
56 #endif | |
57 | |
58 /* The prototype for the application's main() function */ | |
59 #define main SDL_main | |
60 extern "C" int main (int argc, char *argv[], char *envp[]); | |
61 extern "C" void exit (int ret); | |
62 | |
63 | |
64 /* Epoc main function */ | |
65 | |
66 GLDEF_C TInt E32Main() | |
67 { | |
68 /* Get the clean-up stack */ | |
69 CTrapCleanup* cleanup = CTrapCleanup::New(); | |
70 | |
71 #if defined(__WINS__) | |
72 /* arrange for access to Win32 stdin/stdout/stderr */ | |
73 RWin32Stream::StartServer(); | |
74 #endif | |
75 | |
76 /* Arrange for multi-threaded operation */ | |
77 SpawnPosixServerThread(); | |
78 | |
79 /* Get args and environment */ | |
80 int argc=0; | |
81 char** argv=0; | |
82 char** envp=0; | |
83 __crt0(argc,argv,envp); | |
84 | |
85 #if defined(__WINS__) | |
86 /* Cause the graphical Window Server to come into existence */ | |
87 RSemaphore sem; | |
88 sem.CreateGlobal(_L("WsExeSem"),0); | |
89 RegisterWsExe(sem.FullName()); | |
90 #endif | |
91 | |
92 | |
93 /* Start the application! */ | |
94 | |
95 /* Create stdlib */ | |
96 _REENT; | |
97 | |
98 /* Set process and thread priority */ | |
99 RThread currentThread; | |
100 | |
101 currentThread.Rename(_L("SdlProgram")); | |
102 currentThread.SetProcessPriority(EPriorityLow); | |
103 currentThread.SetPriority(EPriorityMuchLess); | |
104 | |
105 /* Call stdlib main */ | |
106 int ret = main(argc, argv, envp); /* !! process exits here if there is "exit()" in main! */ | |
107 | |
108 /* Call exit */ | |
109 exit(ret); /* !! process exits here! */ | |
110 | |
111 /* Free resources and return */ | |
112 CloseSTDLIB(); | |
113 delete cleanup; | |
114 return(KErrNone); | |
115 } | |
116 | |
117 /* Epoc dll entry point */ | |
118 #if defined(__WINS__) | |
119 GLDEF_C TInt E32Dll(TDllReason) | |
120 { | |
121 return(KErrNone); | |
122 } | |
123 | |
124 EXPORT_C TInt WinsMain(TAny *) | |
125 { | |
126 E32Main(); | |
127 return KErrNone; | |
128 } | |
129 #endif |