Fixed bug #925
Changed "win32" to "windows" --HG-- rename : include/SDL_config_win32.h => include/SDL_config_windows.h rename : src/events/scancodes_win32.h => src/events/scancodes_windows.h rename : src/haptic/win32/SDL_syshaptic.c => src/haptic/windows/SDL_syshaptic.c rename : src/joystick/win32/SDL_dxjoystick.c => src/joystick/windows/SDL_dxjoystick.c rename : src/joystick/win32/SDL_dxjoystick_c.h => src/joystick/windows/SDL_dxjoystick_c.h rename : src/joystick/win32/SDL_mmjoystick.c => src/joystick/windows/SDL_mmjoystick.c rename : src/loadso/win32/SDL_sysloadso.c => src/loadso/windows/SDL_sysloadso.c rename : src/main/win32/SDL_win32_main.c => src/main/windows/SDL_windows_main.c rename : src/main/win32/version.rc => src/main/windows/version.rc rename : src/thread/win32/SDL_sysmutex.c => src/thread/windows/SDL_sysmutex.c rename : src/thread/win32/SDL_syssem.c => src/thread/windows/SDL_syssem.c rename : src/thread/win32/SDL_systhread.c => src/thread/windows/SDL_systhread.c rename : src/thread/win32/SDL_systhread_c.h => src/thread/windows/SDL_systhread_c.h rename : src/thread/win32/win_ce_semaphore.c => src/thread/windows/win_ce_semaphore.c rename : src/thread/win32/win_ce_semaphore.h => src/thread/windows/win_ce_semaphore.h rename : src/timer/win32/SDL_systimer.c => src/timer/windows/SDL_systimer.c rename : src/video/win32/SDL_ceddrawrender.c => src/video/windows/SDL_ceddrawrender.c rename : src/video/win32/SDL_ceddrawrender.h => src/video/windows/SDL_ceddrawrender.h rename : src/video/win32/SDL_d3drender.c => src/video/windows/SDL_d3drender.c rename : src/video/win32/SDL_d3drender.h => src/video/windows/SDL_d3drender.h rename : src/video/win32/SDL_gapirender.c => src/video/windows/SDL_gapirender.c rename : src/video/win32/SDL_gapirender.h => src/video/windows/SDL_gapirender.h rename : src/video/win32/SDL_gapirender_c.h => src/video/windows/SDL_gapirender_c.h rename : src/video/win32/SDL_gdirender.c => src/video/windows/SDL_gdirender.c rename : src/video/win32/SDL_gdirender.h => src/video/windows/SDL_gdirender.h rename : src/video/win32/SDL_msctf.h => src/video/windows/SDL_msctf.h rename : src/video/win32/SDL_vkeys.h => src/video/windows/SDL_vkeys.h rename : src/video/win32/SDL_win32clipboard.c => src/video/windows/SDL_windowsclipboard.c rename : src/video/win32/SDL_win32clipboard.h => src/video/windows/SDL_windowsclipboard.h rename : src/video/win32/SDL_win32events.c => src/video/windows/SDL_windowsevents.c rename : src/video/win32/SDL_win32events.h => src/video/windows/SDL_windowsevents.h rename : src/video/win32/SDL_win32gamma.c => src/video/windows/SDL_windowsgamma.c rename : src/video/win32/SDL_win32gamma.h => src/video/windows/SDL_windowsgamma.h rename : src/video/win32/SDL_win32keyboard.c => src/video/windows/SDL_windowskeyboard.c rename : src/video/win32/SDL_win32keyboard.h => src/video/windows/SDL_windowskeyboard.h rename : src/video/win32/SDL_win32modes.c => src/video/windows/SDL_windowsmodes.c rename : src/video/win32/SDL_win32modes.h => src/video/windows/SDL_windowsmodes.h rename : src/video/win32/SDL_win32mouse.c => src/video/windows/SDL_windowsmouse.c rename : src/video/win32/SDL_win32mouse.h => src/video/windows/SDL_windowsmouse.h rename : src/video/win32/SDL_win32opengl.c => src/video/windows/SDL_windowsopengl.c rename : src/video/win32/SDL_win32opengl.h => src/video/windows/SDL_windowsopengl.h rename : src/video/win32/SDL_win32shape.c => src/video/windows/SDL_windowsshape.c rename : src/video/win32/SDL_win32shape.h => src/video/windows/SDL_windowsshape.h rename : src/video/win32/SDL_win32video.c => src/video/windows/SDL_windowsvideo.c rename : src/video/win32/SDL_win32video.h => src/video/windows/SDL_windowsvideo.h rename : src/video/win32/SDL_win32window.c => src/video/windows/SDL_windowswindow.c rename : src/video/win32/SDL_win32window.h => src/video/windows/SDL_windowswindow.h rename : src/video/win32/wmmsg.h => src/video/windows/wmmsg.h
This commit is contained in:
parent
ee1f71dd63
commit
9d25ba272a
82 changed files with 382 additions and 375 deletions
205
src/main/windows/SDL_windows_main.c
Normal file
205
src/main/windows/SDL_windows_main.c
Normal file
|
@ -0,0 +1,205 @@
|
|||
/*
|
||||
SDL_main.c, placed in the public domain by Sam Lantinga 4/13/98
|
||||
|
||||
The WinMain function -- calls your program's main() function
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
/* Include the SDL main definition header */
|
||||
#include "SDL.h"
|
||||
#include "SDL_main.h"
|
||||
|
||||
#ifdef main
|
||||
# ifndef _WIN32_WCE_EMULATION
|
||||
# undef main
|
||||
# endif /* _WIN32_WCE_EMULATION */
|
||||
#endif /* main */
|
||||
|
||||
#if defined(_WIN32_WCE) && _WIN32_WCE < 300
|
||||
/* seems to be undefined in Win CE although in online help */
|
||||
#define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t'))
|
||||
#endif /* _WIN32_WCE < 300 */
|
||||
|
||||
static void
|
||||
UnEscapeQuotes(char *arg)
|
||||
{
|
||||
char *last = NULL;
|
||||
|
||||
while (*arg) {
|
||||
if (*arg == '"' && *last == '\\') {
|
||||
char *c_curr = arg;
|
||||
char *c_last = last;
|
||||
|
||||
while (*c_curr) {
|
||||
*c_last = *c_curr;
|
||||
c_last = c_curr;
|
||||
c_curr++;
|
||||
}
|
||||
*c_last = '\0';
|
||||
}
|
||||
last = arg;
|
||||
arg++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse a command line buffer into arguments */
|
||||
static int
|
||||
ParseCommandLine(char *cmdline, char **argv)
|
||||
{
|
||||
char *bufp;
|
||||
char *lastp = NULL;
|
||||
int argc, last_argc;
|
||||
|
||||
argc = last_argc = 0;
|
||||
for (bufp = cmdline; *bufp;) {
|
||||
/* Skip leading whitespace */
|
||||
while (isspace(*bufp)) {
|
||||
++bufp;
|
||||
}
|
||||
/* Skip over argument */
|
||||
if (*bufp == '"') {
|
||||
++bufp;
|
||||
if (*bufp) {
|
||||
if (argv) {
|
||||
argv[argc] = bufp;
|
||||
}
|
||||
++argc;
|
||||
}
|
||||
/* Skip over word */
|
||||
lastp = bufp;
|
||||
while (*bufp && (*bufp != '"' || *lastp == '\\')) {
|
||||
lastp = bufp;
|
||||
++bufp;
|
||||
}
|
||||
} else {
|
||||
if (*bufp) {
|
||||
if (argv) {
|
||||
argv[argc] = bufp;
|
||||
}
|
||||
++argc;
|
||||
}
|
||||
/* Skip over word */
|
||||
while (*bufp && !isspace(*bufp)) {
|
||||
++bufp;
|
||||
}
|
||||
}
|
||||
if (*bufp) {
|
||||
if (argv) {
|
||||
*bufp = '\0';
|
||||
}
|
||||
++bufp;
|
||||
}
|
||||
|
||||
/* Strip out \ from \" sequences */
|
||||
if (argv && last_argc != argc) {
|
||||
UnEscapeQuotes(argv[last_argc]);
|
||||
}
|
||||
last_argc = argc;
|
||||
}
|
||||
if (argv) {
|
||||
argv[argc] = NULL;
|
||||
}
|
||||
return (argc);
|
||||
}
|
||||
|
||||
/* Show an error message */
|
||||
static void
|
||||
ShowError(const char *title, const char *message)
|
||||
{
|
||||
/* If USE_MESSAGEBOX is defined, you need to link with user32.lib */
|
||||
#ifdef USE_MESSAGEBOX
|
||||
MessageBox(NULL, message, title, MB_ICONEXCLAMATION | MB_OK);
|
||||
#else
|
||||
fprintf(stderr, "%s: %s\n", title, message);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Pop up an out of memory message, returns to Windows */
|
||||
static BOOL
|
||||
OutOfMemory(void)
|
||||
{
|
||||
ShowError("Fatal Error", "Out of memory - aborting");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_WIN32_WCE)
|
||||
/* The VC++ compiler needs main defined */
|
||||
#define console_main main
|
||||
#endif
|
||||
|
||||
/* This is where execution begins [console apps] */
|
||||
int
|
||||
console_main(int argc, char *argv[])
|
||||
{
|
||||
int status;
|
||||
|
||||
/* Run the application main() code */
|
||||
status = SDL_main(argc, argv);
|
||||
|
||||
/* Exit cleanly, calling atexit() functions */
|
||||
exit(status);
|
||||
|
||||
/* Hush little compiler, don't you cry... */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This is where execution begins [windowed apps] */
|
||||
int WINAPI
|
||||
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int sw)
|
||||
{
|
||||
char **argv;
|
||||
int argc;
|
||||
char *cmdline;
|
||||
#ifdef _WIN32_WCE
|
||||
wchar_t *bufp;
|
||||
int nLen;
|
||||
#else
|
||||
char *bufp;
|
||||
size_t nLen;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
nLen = wcslen(szCmdLine) + 128 + 1;
|
||||
bufp = SDL_stack_alloc(wchar_t, nLen * 2);
|
||||
wcscpy(bufp, TEXT("\""));
|
||||
GetModuleFileName(NULL, bufp + 1, 128 - 3);
|
||||
wcscpy(bufp + wcslen(bufp), TEXT("\" "));
|
||||
wcsncpy(bufp + wcslen(bufp), szCmdLine, nLen - wcslen(bufp));
|
||||
nLen = wcslen(bufp) + 1;
|
||||
cmdline = SDL_stack_alloc(char, nLen);
|
||||
if (cmdline == NULL) {
|
||||
return OutOfMemory();
|
||||
}
|
||||
WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL);
|
||||
#else
|
||||
/* Grab the command line */
|
||||
bufp = GetCommandLine();
|
||||
nLen = SDL_strlen(bufp) + 1;
|
||||
cmdline = SDL_stack_alloc(char, nLen);
|
||||
if (cmdline == NULL) {
|
||||
return OutOfMemory();
|
||||
}
|
||||
SDL_strlcpy(cmdline, bufp, nLen);
|
||||
#endif
|
||||
|
||||
/* Parse it into argv and argc */
|
||||
argc = ParseCommandLine(cmdline, NULL);
|
||||
argv = SDL_stack_alloc(char *, argc + 1);
|
||||
if (argv == NULL) {
|
||||
return OutOfMemory();
|
||||
}
|
||||
ParseCommandLine(cmdline, argv);
|
||||
|
||||
/* Run the main program */
|
||||
console_main(argc, argv);
|
||||
|
||||
/* Hush little compiler, don't you cry... */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
Loading…
Add table
Add a link
Reference in a new issue