comparison src/main/win32/SDL_win32_main.c @ 1465:8dfa9a6d69a5

Updated WinCE support by Dmitry (with some tweaks) Converted the disk audio driver to SDL_RWops for portability
author Sam Lantinga <slouken@libsdl.org>
date Sat, 04 Mar 2006 08:24:35 +0000
parents bb6839704ed6
children 4aac8563c296
comparison
equal deleted inserted replaced
1464:af30090c0330 1465:8dfa9a6d69a5
49 #endif 49 #endif
50 50
51 #if defined(_WIN32_WCE) && _WIN32_WCE < 300 51 #if defined(_WIN32_WCE) && _WIN32_WCE < 300
52 /* seems to be undefined in Win CE although in online help */ 52 /* seems to be undefined in Win CE although in online help */
53 #define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t')) 53 #define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t'))
54
55 /* seems to be undefined in Win CE although in online help */
56 char *SDL_strrchr(char *str, int c)
57 {
58 char *p;
59
60 /* Skip to the end of the string */
61 p=str;
62 while (*p)
63 p++;
64
65 /* Look for the given character */
66 while ( (p >= str) && (*p != (CHAR)c) )
67 p--;
68
69 /* Return NULL if character not found */
70 if ( p < str ) {
71 p = NULL;
72 }
73 return p;
74 }
75 #endif /* _WIN32_WCE < 300 */ 54 #endif /* _WIN32_WCE < 300 */
76 55
77 /* Parse a command line buffer into arguments */ 56 /* Parse a command line buffer into arguments */
78 static int ParseCommandLine(char *cmdline, char **argv) 57 static int ParseCommandLine(char *cmdline, char **argv)
79 { 58 {
279 while ( pathlen > 0 && path[pathlen] != '\\' ) { 258 while ( pathlen > 0 && path[pathlen] != '\\' ) {
280 --pathlen; 259 --pathlen;
281 } 260 }
282 path[pathlen] = '\0'; 261 path[pathlen] = '\0';
283 262
263 #ifdef _WIN32_WCE
264 wcsncpy( stdoutPath, path, SDL_arraysize(stdoutPath) );
265 wcsncat( stdoutPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath) );
266 #else
284 SDL_strlcpy( stdoutPath, path, SDL_arraysize(stdoutPath) ); 267 SDL_strlcpy( stdoutPath, path, SDL_arraysize(stdoutPath) );
285 SDL_strlcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath) ); 268 SDL_strlcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath) );
269 #endif
286 270
287 /* Redirect standard input and standard output */ 271 /* Redirect standard input and standard output */
288 newfp = freopen(stdoutPath, TEXT("w"), stdout); 272 newfp = freopen(stdoutPath, TEXT("w"), stdout);
289 273
290 #ifndef _WIN32_WCE 274 #ifndef _WIN32_WCE
298 } 282 }
299 #endif 283 #endif
300 } 284 }
301 #endif /* _WIN32_WCE */ 285 #endif /* _WIN32_WCE */
302 286
287 #ifdef _WIN32_WCE
288 wcsncpy( stderrPath, path, SDL_arraysize(stdoutPath) );
289 wcsncat( stderrPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath) );
290 #else
303 SDL_strlcpy( stderrPath, path, SDL_arraysize(stderrPath) ); 291 SDL_strlcpy( stderrPath, path, SDL_arraysize(stderrPath) );
304 SDL_strlcat( stderrPath, DIR_SEPERATOR STDERR_FILE, SDL_arraysize(stderrPath) ); 292 SDL_strlcat( stderrPath, DIR_SEPERATOR STDERR_FILE, SDL_arraysize(stderrPath) );
293 #endif
305 294
306 newfp = freopen(stderrPath, TEXT("w"), stderr); 295 newfp = freopen(stderrPath, TEXT("w"), stderr);
307 #ifndef _WIN32_WCE 296 #ifndef _WIN32_WCE
308 if ( newfp == NULL ) { /* This happens on NT */ 297 if ( newfp == NULL ) { /* This happens on NT */
309 #if !defined(stderr) 298 #if !defined(stderr)
327 wcscpy (bufp, TEXT("\"")); 316 wcscpy (bufp, TEXT("\""));
328 GetModuleFileName(NULL, bufp+1, 128-3); 317 GetModuleFileName(NULL, bufp+1, 128-3);
329 wcscpy (bufp+wcslen(bufp), TEXT("\" ")); 318 wcscpy (bufp+wcslen(bufp), TEXT("\" "));
330 wcsncpy(bufp+wcslen(bufp), szCmdLine,nLen-wcslen(bufp)); 319 wcsncpy(bufp+wcslen(bufp), szCmdLine,nLen-wcslen(bufp));
331 nLen = wcslen(bufp)+1; 320 nLen = wcslen(bufp)+1;
332 cmdline = SDL_stack_alloc(wchar_t, nLen); 321 cmdline = SDL_stack_alloc(char, nLen);
333 if ( cmdline == NULL ) { 322 if ( cmdline == NULL ) {
334 return OutOfMemory(); 323 return OutOfMemory();
335 } 324 }
336 WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL); 325 WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL);
337 #else 326 #else