Mercurial > sdl-ios-xcode
annotate src/main/win32/SDL_main.c @ 202:401f0134f4f9
Fixed crash when using double-buffering with DGA
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 30 Sep 2001 20:19:20 +0000 |
parents | 0e66fd980014 |
children | a6fa62b1be09 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL_main.c, placed in the public domain by Sam Lantinga 4/13/98 | |
3 | |
4 The WinMain function -- calls your program's main() function | |
5 */ | |
6 | |
7 #include <stdio.h> | |
8 #include <string.h> | |
9 #include <ctype.h> | |
10 #include <stdlib.h> | |
11 | |
12 #include <windows.h> | |
13 #include <malloc.h> /* For _alloca() */ | |
14 | |
15 /* Include the SDL main definition header */ | |
16 #include "SDL.h" | |
17 #include "SDL_main.h" | |
18 #ifdef main | |
112
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
19 #ifndef _WIN32_WCE_EMULATION |
0 | 20 #undef main |
21 #endif | |
112
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
22 #endif |
0 | 23 |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
24 /* Do we really not want stdio redirection with Windows CE? */ |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
25 #ifdef _WIN32_WCE |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
26 #define NO_STDIO_REDIRECT |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
27 #endif |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
28 |
0 | 29 /* The standard output files */ |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
30 #define STDOUT_FILE TEXT("stdout.txt") |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
31 #define STDERR_FILE TEXT("stderr.txt") |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
32 |
112
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
33 #if defined(_WIN32_WCE) && _WIN32_WCE < 300 |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
34 /* seems to be undefined in Win CE although in online help */ |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
35 #define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t')) |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
36 |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
37 /* seems to be undefined in Win CE although in online help */ |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
38 char *strrchr(char *str, int c) |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
39 { |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
40 char *p; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
41 |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
42 /* Skip to the end of the string */ |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
43 p=str; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
44 while (*p) |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
45 p++; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
46 |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
47 /* Look for the given character */ |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
48 while ( (p >= str) && (*p != (CHAR)c) ) |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
49 p--; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
50 |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
51 /* Return NULL if character not found */ |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
52 if ( p < str ) { |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
53 p = NULL; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
54 } |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
55 return p; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
56 } |
112
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
57 #endif /* _WIN32_WCE < 300 */ |
0 | 58 |
59 /* Parse a command line buffer into arguments */ | |
60 static int ParseCommandLine(char *cmdline, char **argv) | |
61 { | |
62 char *bufp; | |
63 int argc; | |
64 | |
65 argc = 0; | |
66 for ( bufp = cmdline; *bufp; ) { | |
67 /* Skip leading whitespace */ | |
68 while ( isspace(*bufp) ) { | |
69 ++bufp; | |
70 } | |
71 /* Skip over argument */ | |
72 if ( *bufp == '"' ) { | |
73 ++bufp; | |
74 if ( *bufp ) { | |
75 if ( argv ) { | |
76 argv[argc] = bufp; | |
77 } | |
78 ++argc; | |
79 } | |
80 /* Skip over word */ | |
81 while ( *bufp && (*bufp != '"') ) { | |
82 ++bufp; | |
83 } | |
84 } else { | |
85 if ( *bufp ) { | |
86 if ( argv ) { | |
87 argv[argc] = bufp; | |
88 } | |
89 ++argc; | |
90 } | |
91 /* Skip over word */ | |
92 while ( *bufp && ! isspace(*bufp) ) { | |
93 ++bufp; | |
94 } | |
95 } | |
96 if ( *bufp ) { | |
97 if ( argv ) { | |
98 *bufp = '\0'; | |
99 } | |
100 ++bufp; | |
101 } | |
102 } | |
103 if ( argv ) { | |
104 argv[argc] = NULL; | |
105 } | |
106 return(argc); | |
107 } | |
108 | |
109 /* Show an error message */ | |
110 static void ShowError(const char *title, const char *message) | |
111 { | |
112 /* If USE_MESSAGEBOX is defined, you need to link with user32.lib */ | |
113 #ifdef USE_MESSAGEBOX | |
114 MessageBox(NULL, message, title, MB_ICONEXCLAMATION|MB_OK); | |
115 #else | |
116 fprintf(stderr, "%s: %s\n", title, message); | |
117 #endif | |
118 } | |
119 | |
120 /* Pop up an out of memory message, returns to Windows */ | |
121 static BOOL OutOfMemory(void) | |
122 { | |
123 ShowError("Fatal Error", "Out of memory - aborting"); | |
124 return FALSE; | |
125 } | |
126 | |
127 /* Remove the output files if there was no output written */ | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
128 static void __cdecl cleanup_output(void) |
0 | 129 { |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
130 #ifndef NO_STDIO_REDIRECT |
0 | 131 FILE *file; |
132 int empty; | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
133 #endif |
0 | 134 |
135 /* Flush the output in case anything is queued */ | |
136 fclose(stdout); | |
137 fclose(stderr); | |
138 | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
139 #ifndef NO_STDIO_REDIRECT |
0 | 140 /* See if the files have any output in them */ |
141 file = fopen(STDOUT_FILE, "rb"); | |
142 if ( file ) { | |
143 empty = (fgetc(file) == EOF) ? 1 : 0; | |
144 fclose(file); | |
145 if ( empty ) { | |
146 remove(STDOUT_FILE); | |
147 } | |
148 } | |
149 file = fopen(STDERR_FILE, "rb"); | |
150 if ( file ) { | |
151 empty = (fgetc(file) == EOF) ? 1 : 0; | |
152 fclose(file); | |
153 if ( empty ) { | |
154 remove(STDERR_FILE); | |
155 } | |
156 } | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
157 #endif |
0 | 158 } |
159 | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
160 #if defined(_MSC_VER) && !defined(_WIN32_WCE) |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
161 /* The VC++ compiler needs main defined */ |
0 | 162 #define console_main main |
163 #endif | |
164 | |
165 /* This is where execution begins [console apps] */ | |
166 int console_main(int argc, char *argv[]) | |
167 { | |
168 int n; | |
169 char *bufp, *appname; | |
170 | |
171 /* Get the class name from argv[0] */ | |
172 appname = argv[0]; | |
173 if ( (bufp=strrchr(argv[0], '\\')) != NULL ) { | |
174 appname = bufp+1; | |
175 } else | |
176 if ( (bufp=strrchr(argv[0], '/')) != NULL ) { | |
177 appname = bufp+1; | |
178 } | |
179 | |
180 if ( (bufp=strrchr(appname, '.')) == NULL ) | |
181 n = strlen(appname); | |
182 else | |
183 n = (bufp-appname); | |
184 | |
185 bufp = (char *)alloca(n+1); | |
186 if ( bufp == NULL ) { | |
187 return OutOfMemory(); | |
188 } | |
189 strncpy(bufp, appname, n); | |
190 bufp[n] = '\0'; | |
191 appname = bufp; | |
192 | |
193 /* Load SDL dynamic link library */ | |
194 if ( SDL_Init(SDL_INIT_NOPARACHUTE) < 0 ) { | |
195 ShowError("WinMain() error", SDL_GetError()); | |
196 return(FALSE); | |
197 } | |
198 atexit(cleanup_output); | |
199 atexit(SDL_Quit); | |
200 | |
15
ac67f6758d63
Don't try to register the app if video code is disabled
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
201 #ifndef DISABLE_VIDEO |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
202 #if 0 |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
203 /* Create and register our class * |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
204 DJM: If we do this here, the user nevers gets a chance to |
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
205 putenv(SDL_WINDOWID). This is already called later by |
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
206 the (DIB|DX5)_CreateWindow function, so it should be |
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
207 safe to comment it out here. |
0 | 208 if ( SDL_RegisterApp(appname, CS_BYTEALIGNCLIENT, |
209 GetModuleHandle(NULL)) < 0 ) { | |
210 ShowError("WinMain() error", SDL_GetError()); | |
211 exit(1); | |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
212 }*/ |
149
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
213 #else |
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
214 /* Sam: |
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
215 We still need to pass in the application handle so that |
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
216 DirectInput will initialize properly when SDL_RegisterApp() |
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
217 is called later in the video initialization. |
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
218 */ |
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
219 SDL_SetModuleHandle(GetModuleHandle(NULL)); |
0e66fd980014
Fixed compile errors and added call to SDL_SetModuleHandle() in WinMain()
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
220 #endif /* 0 */ |
15
ac67f6758d63
Don't try to register the app if video code is disabled
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
221 #endif /* !DISABLE_VIDEO */ |
ac67f6758d63
Don't try to register the app if video code is disabled
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
222 |
ac67f6758d63
Don't try to register the app if video code is disabled
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
223 /* Run the application main() code */ |
0 | 224 SDL_main(argc, argv); |
225 | |
226 /* Exit cleanly, calling atexit() functions */ | |
227 exit(0); | |
228 } | |
229 | |
230 /* This is where execution begins [windowed apps] */ | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
231 #ifdef _WIN32_WCE |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
232 int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR szCmdLine, int sw) |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
233 #else |
0 | 234 int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
235 #endif |
0 | 236 { |
237 HINSTANCE handle; | |
238 char **argv; | |
239 int argc; | |
240 char *cmdline; | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
241 #ifdef _WIN32_WCE |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
242 wchar_t *bufp; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
243 int nLen; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
244 #else |
0 | 245 char *bufp; |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
246 #endif |
0 | 247 #ifndef NO_STDIO_REDIRECT |
248 FILE *newfp; | |
249 #endif | |
250 | |
251 /* Start up DDHELP.EXE before opening any files, so DDHELP doesn't | |
252 keep them open. This is a hack.. hopefully it will be fixed | |
253 someday. DDHELP.EXE starts up the first time DDRAW.DLL is loaded. | |
254 */ | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
255 handle = LoadLibrary(TEXT("DDRAW.DLL")); |
0 | 256 if ( handle != NULL ) { |
257 FreeLibrary(handle); | |
258 } | |
259 | |
260 #ifndef NO_STDIO_REDIRECT | |
261 /* Redirect standard input and standard output */ | |
262 newfp = freopen(STDOUT_FILE, "w", stdout); | |
263 if ( newfp == NULL ) { /* This happens on NT */ | |
264 #if !defined(stdout) | |
265 stdout = fopen(STDOUT_FILE, "w"); | |
266 #else | |
267 newfp = fopen(STDOUT_FILE, "w"); | |
268 if ( newfp ) { | |
269 *stdout = *newfp; | |
270 } | |
271 #endif | |
272 } | |
273 newfp = freopen(STDERR_FILE, "w", stderr); | |
274 if ( newfp == NULL ) { /* This happens on NT */ | |
275 #if !defined(stderr) | |
276 stderr = fopen(STDERR_FILE, "w"); | |
277 #else | |
278 newfp = fopen(STDERR_FILE, "w"); | |
279 if ( newfp ) { | |
280 *stderr = *newfp; | |
281 } | |
282 #endif | |
283 } | |
284 setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* Line buffered */ | |
285 setbuf(stderr, NULL); /* No buffering */ | |
286 #endif /* !NO_STDIO_REDIRECT */ | |
287 | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
288 #ifdef _WIN32_WCE |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
289 nLen = wcslen(szCmdLine)+128+1; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
290 bufp = (wchar_t *)alloca(nLen*2); |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
291 GetModuleFileName(NULL, bufp, 128); |
112
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
292 wcsncpy(bufp+wcslen(bufp), szCmdLine,nLen-wcslen(bufp)); |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
293 nLen = wcslen(bufp)+1; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
294 cmdline = (char *)alloca(nLen); |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
295 if ( cmdline == NULL ) { |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
296 return OutOfMemory(); |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
297 } |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
298 WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL); |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
299 #else |
0 | 300 /* Grab the command line (use alloca() on Windows) */ |
301 bufp = GetCommandLine(); | |
302 cmdline = (char *)alloca(strlen(bufp)+1); | |
303 if ( cmdline == NULL ) { | |
304 return OutOfMemory(); | |
305 } | |
306 strcpy(cmdline, bufp); | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
307 #endif |
0 | 308 |
309 /* Parse it into argv and argc */ | |
310 argc = ParseCommandLine(cmdline, NULL); | |
311 argv = (char **)alloca((argc+1)*(sizeof *argv)); | |
312 if ( argv == NULL ) { | |
313 return OutOfMemory(); | |
314 } | |
315 ParseCommandLine(cmdline, argv); | |
316 | |
317 /* Run the main program (after a little SDL initialization) */ | |
318 return(console_main(argc, argv)); | |
319 } |