annotate src/main/win32/SDL_win32_main.c @ 2064:c66852194386

(none)
author Sam Lantinga <slouken@libsdl.org>
date Sun, 29 Oct 2006 14:47:20 +0000
parents c121d94672cb
children 41a6675d8700
rev   line source
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL_main.c, placed in the public domain by Sam Lantinga 4/13/98
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4 The WinMain function -- calls your program's main() function
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 */
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 #include <stdio.h>
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 #include <stdlib.h>
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
1433
bb6839704ed6 SDL_windows.h is no longer necessary
Sam Lantinga <slouken@libsdl.org>
parents: 1423
diff changeset
10 #define WIN32_LEAN_AND_MEAN
bb6839704ed6 SDL_windows.h is no longer necessary
Sam Lantinga <slouken@libsdl.org>
parents: 1423
diff changeset
11 #include <windows.h>
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1286
diff changeset
12
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 /* Include the SDL main definition header */
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14 #include "SDL.h"
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 #include "SDL_main.h"
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 #ifdef main
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18 # ifndef _WIN32_WCE_EMULATION
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 # undef main
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 # endif /* _WIN32_WCE_EMULATION */
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 #endif /* main */
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 #if defined(_WIN32_WCE) && _WIN32_WCE < 300
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 /* seems to be undefined in Win CE although in online help */
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 #define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t'))
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #endif /* _WIN32_WCE < 300 */
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 /* Parse a command line buffer into arguments */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
29 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
30 ParseCommandLine(char *cmdline, char **argv)
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
32 char *bufp;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
33 int argc;
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
35 argc = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
36 for (bufp = cmdline; *bufp;) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
37 /* Skip leading whitespace */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
38 while (isspace(*bufp)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
39 ++bufp;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
40 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
41 /* Skip over argument */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
42 if (*bufp == '"') {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
43 ++bufp;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
44 if (*bufp) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
45 if (argv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
46 argv[argc] = bufp;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
47 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
48 ++argc;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
49 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
50 /* Skip over word */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
51 while (*bufp && (*bufp != '"')) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
52 ++bufp;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
53 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
54 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
55 if (*bufp) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
56 if (argv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
57 argv[argc] = bufp;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
58 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
59 ++argc;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
60 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
61 /* Skip over word */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
62 while (*bufp && !isspace(*bufp)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
63 ++bufp;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
64 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
65 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
66 if (*bufp) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
67 if (argv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
68 *bufp = '\0';
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
69 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
70 ++bufp;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
71 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
72 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
73 if (argv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
74 argv[argc] = NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
75 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
76 return (argc);
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 }
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 /* Show an error message */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
80 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
81 ShowError(const char *title, const char *message)
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 {
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 /* If USE_MESSAGEBOX is defined, you need to link with user32.lib */
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 #ifdef USE_MESSAGEBOX
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
85 MessageBox(NULL, message, title, MB_ICONEXCLAMATION | MB_OK);
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 #else
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
87 fprintf(stderr, "%s: %s\n", title, message);
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 #endif
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 }
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 /* Pop up an out of memory message, returns to Windows */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
92 static BOOL
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
93 OutOfMemory(void)
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
95 ShowError("Fatal Error", "Out of memory - aborting");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
96 return FALSE;
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 }
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 #if defined(_MSC_VER) && !defined(_WIN32_WCE)
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 /* The VC++ compiler needs main defined */
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 #define console_main main
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 #endif
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 /* This is where execution begins [console apps] */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
105 int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
106 console_main(int argc, char *argv[])
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
108 int status;
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
110 /* Run the application main() code */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
111 status = SDL_main(argc, argv);
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
113 /* Exit cleanly, calling atexit() functions */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
114 exit(status);
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
116 /* Hush little compiler, don't you cry... */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
117 return 0;
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 }
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 /* This is where execution begins [windowed apps] */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
121 int WINAPI
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
122 WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int sw)
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
124 char **argv;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
125 int argc;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
126 char *cmdline;
1286
d7bca8c8161e Use the executable directory, not the current directory, for stdio output files
Sam Lantinga <slouken@libsdl.org>
parents: 766
diff changeset
127 #ifdef _WIN32_WCE
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
128 wchar_t *bufp;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
129 int nLen;
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 #else
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
131 char *bufp;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
132 size_t nLen;
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 #endif
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134
1465
8dfa9a6d69a5 Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents: 1433
diff changeset
135 #ifdef _WIN32_WCE
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
136 nLen = wcslen(szCmdLine) + 128 + 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
137 bufp = SDL_stack_alloc(wchar_t, nLen * 2);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
138 wcscpy(bufp, TEXT("\""));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
139 GetModuleFileName(NULL, bufp + 1, 128 - 3);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
140 wcscpy(bufp + wcslen(bufp), TEXT("\" "));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
141 wcsncpy(bufp + wcslen(bufp), szCmdLine, nLen - wcslen(bufp));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
142 nLen = wcslen(bufp) + 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
143 cmdline = SDL_stack_alloc(char, nLen);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
144 if (cmdline == NULL) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
145 return OutOfMemory();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
146 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
147 WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL);
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 #else
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
149 /* Grab the command line */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
150 bufp = GetCommandLine();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
151 nLen = SDL_strlen(bufp) + 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
152 cmdline = SDL_stack_alloc(char, nLen);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
153 if (cmdline == NULL) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
154 return OutOfMemory();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
155 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
156 SDL_strlcpy(cmdline, bufp, nLen);
1465
8dfa9a6d69a5 Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents: 1433
diff changeset
157 #endif
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
159 /* Parse it into argv and argc */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
160 argc = ParseCommandLine(cmdline, NULL);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
161 argv = SDL_stack_alloc(char *, argc + 1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
162 if (argv == NULL) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
163 return OutOfMemory();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
164 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
165 ParseCommandLine(cmdline, argv);
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
167 /* Run the main program */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
168 console_main(argc, argv);
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
170 /* Hush little compiler, don't you cry... */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
171 return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
172 }
754
623b453a3219 Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
174 /* vi: set ts=4 sw=4 expandtab: */