Mercurial > sdl-ios-xcode
annotate src/main/win32/SDL_main.c @ 468:0b0c2e63eb27
Fixed 2048 pixel limitation in DirectX blit code
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 24 Aug 2002 17:15:45 +0000 |
parents | a6fa62b1be09 |
children | 8c4a35e3c507 |
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); | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
228 |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
229 /* Hush little compiler, don't you cry... */ |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
149
diff
changeset
|
230 return(0); |
0 | 231 } |
232 | |
233 /* 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
|
234 #ifdef _WIN32_WCE |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
235 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
|
236 #else |
0 | 237 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
|
238 #endif |
0 | 239 { |
240 HINSTANCE handle; | |
241 char **argv; | |
242 int argc; | |
243 char *cmdline; | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
244 #ifdef _WIN32_WCE |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
245 wchar_t *bufp; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
246 int nLen; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
247 #else |
0 | 248 char *bufp; |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
249 #endif |
0 | 250 #ifndef NO_STDIO_REDIRECT |
251 FILE *newfp; | |
252 #endif | |
253 | |
254 /* Start up DDHELP.EXE before opening any files, so DDHELP doesn't | |
255 keep them open. This is a hack.. hopefully it will be fixed | |
256 someday. DDHELP.EXE starts up the first time DDRAW.DLL is loaded. | |
257 */ | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
258 handle = LoadLibrary(TEXT("DDRAW.DLL")); |
0 | 259 if ( handle != NULL ) { |
260 FreeLibrary(handle); | |
261 } | |
262 | |
263 #ifndef NO_STDIO_REDIRECT | |
264 /* Redirect standard input and standard output */ | |
265 newfp = freopen(STDOUT_FILE, "w", stdout); | |
266 if ( newfp == NULL ) { /* This happens on NT */ | |
267 #if !defined(stdout) | |
268 stdout = fopen(STDOUT_FILE, "w"); | |
269 #else | |
270 newfp = fopen(STDOUT_FILE, "w"); | |
271 if ( newfp ) { | |
272 *stdout = *newfp; | |
273 } | |
274 #endif | |
275 } | |
276 newfp = freopen(STDERR_FILE, "w", stderr); | |
277 if ( newfp == NULL ) { /* This happens on NT */ | |
278 #if !defined(stderr) | |
279 stderr = fopen(STDERR_FILE, "w"); | |
280 #else | |
281 newfp = fopen(STDERR_FILE, "w"); | |
282 if ( newfp ) { | |
283 *stderr = *newfp; | |
284 } | |
285 #endif | |
286 } | |
287 setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* Line buffered */ | |
288 setbuf(stderr, NULL); /* No buffering */ | |
289 #endif /* !NO_STDIO_REDIRECT */ | |
290 | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
291 #ifdef _WIN32_WCE |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
292 nLen = wcslen(szCmdLine)+128+1; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
293 bufp = (wchar_t *)alloca(nLen*2); |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
294 GetModuleFileName(NULL, bufp, 128); |
112
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
295 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
|
296 nLen = wcslen(bufp)+1; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
297 cmdline = (char *)alloca(nLen); |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
298 if ( cmdline == NULL ) { |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
299 return OutOfMemory(); |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
300 } |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
301 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
|
302 #else |
0 | 303 /* Grab the command line (use alloca() on Windows) */ |
304 bufp = GetCommandLine(); | |
305 cmdline = (char *)alloca(strlen(bufp)+1); | |
306 if ( cmdline == NULL ) { | |
307 return OutOfMemory(); | |
308 } | |
309 strcpy(cmdline, bufp); | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
15
diff
changeset
|
310 #endif |
0 | 311 |
312 /* Parse it into argv and argc */ | |
313 argc = ParseCommandLine(cmdline, NULL); | |
314 argv = (char **)alloca((argc+1)*(sizeof *argv)); | |
315 if ( argv == NULL ) { | |
316 return OutOfMemory(); | |
317 } | |
318 ParseCommandLine(cmdline, argv); | |
319 | |
320 /* Run the main program (after a little SDL initialization) */ | |
321 return(console_main(argc, argv)); | |
322 } |