Mercurial > sdl-ios-xcode
annotate src/main/win32/SDL_win32_main.c @ 2576:034440120c38 gsoc2008_force_feedback
Converted some functions to SDL_mem*.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Thu, 31 Jul 2008 17:15:36 +0000 |
parents | 41a6675d8700 |
children | ae7799d16c87 |
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 |
2286
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
28 static void |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
29 UnEscapeQuotes(char *arg) |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
30 { |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
31 char *last = NULL; |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
32 |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
33 while (*arg) { |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
34 if (*arg == '"' && *last == '\\') { |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
35 char *c_curr = arg; |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
36 char *c_last = last; |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
37 |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
38 while (*c_curr) { |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
39 *c_last = *c_curr; |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
40 c_last = c_curr; |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
41 c_curr++; |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
42 } |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
43 *c_last = '\0'; |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
44 } |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
45 last = arg; |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
46 arg++; |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
47 } |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
48 } |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
49 |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 /* 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
|
51 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
|
52 ParseCommandLine(char *cmdline, char **argv) |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 { |
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
|
54 char *bufp; |
2286
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
55 char *lastp = NULL; |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
56 int argc, last_argc; |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 |
2286
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
58 argc = last_argc = 0; |
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
|
59 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
|
60 /* 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
|
61 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
|
62 ++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 } |
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 /* 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
|
65 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
|
66 ++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 (*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
|
68 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
|
69 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
|
70 } |
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 ++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
|
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 /* Skip over word */ |
2286
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
74 while (*bufp && (*bufp != '"' || *lastp == '\\')) { |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
75 lastp = bufp; |
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
|
76 ++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
|
77 } |
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
|
78 } 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
|
79 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
|
80 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
|
81 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
|
82 } |
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
|
83 ++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
|
84 } |
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 /* 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
|
86 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
|
87 ++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
|
88 } |
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
|
89 } |
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
|
90 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
|
91 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
|
92 *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
|
93 } |
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
|
94 ++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
|
95 } |
2286
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
96 |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
97 /* Strip out \ from \" sequences */ |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
98 if (argv && last_argc != argc) { |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
99 UnEscapeQuotes(argv[last_argc]); |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
100 } |
41a6675d8700
Merged fix for bug #503 from SDL 1.2 revision 3487
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
101 last_argc = argc; |
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
|
102 } |
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
|
103 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
|
104 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
|
105 } |
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 return (argc); |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 } |
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 |
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 /* 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
|
110 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
|
111 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
|
112 { |
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 /* 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
|
114 #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
|
115 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
|
116 #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
|
117 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
|
118 #endif |
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 |
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 /* 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
|
122 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
|
123 OutOfMemory(void) |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 { |
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
|
125 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
|
126 return FALSE; |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 } |
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 |
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 #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
|
130 /* The VC++ compiler needs main defined */ |
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 #define console_main main |
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 #endif |
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 |
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 /* 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
|
135 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
|
136 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
|
137 { |
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
|
138 int status; |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 |
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
|
140 /* 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
|
141 status = SDL_main(argc, argv); |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 |
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
|
143 /* 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
|
144 exit(status); |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 |
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
|
146 /* 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
|
147 return 0; |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 } |
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 |
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 /* 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
|
151 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
|
152 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
|
153 { |
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
|
154 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
|
155 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
|
156 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
|
157 #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
|
158 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
|
159 int nLen; |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 #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
|
161 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
|
162 size_t nLen; |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 #endif |
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
165 #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
|
166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 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
|
173 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
|
174 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
|
175 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
|
176 } |
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
|
177 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
|
178 #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
|
179 /* 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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 } |
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
|
186 SDL_strlcpy(cmdline, bufp, nLen); |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1433
diff
changeset
|
187 #endif |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 |
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
|
189 /* 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
|
190 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
|
191 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
|
192 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
|
193 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
|
194 } |
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
|
195 ParseCommandLine(cmdline, argv); |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 |
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
|
197 /* 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
|
198 console_main(argc, argv); |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 |
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
|
200 /* 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
|
201 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
|
202 } |
754
623b453a3219
Fixed "dist" make target for newer versions of automake
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 |
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
|
204 /* vi: set ts=4 sw=4 expandtab: */ |