Commit a305eb85 authored by Sam Lantinga's avatar Sam Lantinga

Fixed bug #777

Implemented SDL_GetPlatform()

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403911
parent 1035ec66
......@@ -123,4 +123,29 @@
#define __NINTENDODS__ 1
#endif
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/**
* \fn const char *SDL_GetPlatform(void)
* \brief Gets the name of the platform.
*/
extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_platform_h */
/* vi: set ts=4 sw=4 expandtab: */
......@@ -277,6 +277,62 @@ SDL_GetRevision(void)
return SDL_REVISION;
}
/* Get the name of the platform */
const char *
SDL_GetPlatform()
{
#if __AIX__
return "AIX";
#elif __HAIKU__
/* Haiku must appear here before BeOS, since it also defines __BEOS__ */
return "Haiku";
#elif __BEOS__
return "BeOS";
#elif __BSDI__
return "BSDI";
#elif __DREAMCAST__
return "Dreamcast";
#elif __FREEBSD__
return "FreeBSD";
#elif __HPUX__
return "HP-UX";
#elif __IRIX__
return "Irix";
#elif __LINUX__
return "Linux";
#elif __MINT__
return "Atari MiNT";
#elif __MACOS__
return "MacOS Classic";
#elif __MACOSX__
return "Mac OS X";
#elif __NETBSD__
return "NetBSD";
#elif __OPENBSD__
return "OpenBSD";
#elif __OS2__
return "OS/2";
#elif __OSF__
return "OSF/1";
#elif __QNXNTO__
return "QNX Neutrino";
#elif __RISCOS__
return "RISC OS";
#elif __SOLARIS__
return "Solaris";
#elif __WIN32__
#ifdef _WIN32_WCE
return "Windows CE";
#else
return "Windows";
#endif
#elif __IPHONEOS__
return "iPhone OS";
#else
return "Unknown (see SDL_platform.h)";
#endif
}
#if defined(__WIN32__)
#if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
......
......@@ -131,66 +131,6 @@ static void plat_testEndian (void)
}
/**
* @brief Gets the name of the platform.
*/
const char *platform_getPlatform (void)
{
return
#if __AIX__
"AIX"
#elif __HAIKU__
/* Haiku must appear here before BeOS, since it also defines __BEOS__ */
"Haiku"
#elif __BEOS__
"BeOS"
#elif __BSDI__
"BSDI"
#elif __DREAMCAST__
"Dreamcast"
#elif __FREEBSD__
"FreeBSD"
#elif __HPUX__
"HP-UX"
#elif __IRIX__
"Irix"
#elif __LINUX__
"Linux"
#elif __MINT__
"Atari MiNT"
#elif __MACOS__
"MacOS Classic"
#elif __MACOSX__
"Mac OS X"
#elif __NETBSD__
"NetBSD"
#elif __OPENBSD__
"OpenBSD"
#elif __OS2__
"OS/2"
#elif __OSF__
"OSF/1"
#elif __QNXNTO__
"QNX Neutrino"
#elif __RISCOS__
"RISC OS"
#elif __SOLARIS__
"Solaris"
#elif __WIN32__
#ifdef _WIN32_WCE
"Windows CE"
#else
"Windows"
#endif
#elif __IPHONEOS__
"iPhone OS"
#else
"an unknown operating system! (see SDL_platform.h)"
#endif
;
}
/**
* @brief Platform test entrypoint.
*/
......@@ -207,7 +147,7 @@ int test_platform (void)
SDL_ATinit( "Platform" );
/* Debug information. */
SDL_ATprintVerbose( 1, "%s System detected\n", platform_getPlatform() );
SDL_ATprintVerbose( 1, "%s System detected\n", SDL_GetPlatform() );
SDL_ATprintVerbose( 1, "System is %s endian\n",
#ifdef SDL_LIL_ENDIAN
"little"
......
......@@ -172,7 +172,7 @@ int main( int argc, char *argv[] )
SDL_ATprintErr( "Tests run with SDL %d.%d.%d revision %d\n",
ver.major, ver.minor, ver.patch, rev );
SDL_ATprintErr( "System is running %s and is %s endian\n",
platform_getPlatform(),
SDL_GetPlatform(),
#ifdef SDL_LIL_ENDIAN
"little"
#else
......
......@@ -157,58 +157,7 @@ main(int argc, char *argv[])
verbose = SDL_FALSE;
}
if (verbose) {
printf("This system is running %s\n",
#if __AIX__
"AIX"
#elif __HAIKU__
/* Haiku must appear here before BeOS, since it also defines __BEOS__ */
"Haiku"
#elif __BEOS__
"BeOS"
#elif __BSDI__
"BSDI"
#elif __DREAMCAST__
"Dreamcast"
#elif __FREEBSD__
"FreeBSD"
#elif __HPUX__
"HP-UX"
#elif __IRIX__
"Irix"
#elif __LINUX__
"Linux"
#elif __MINT__
"Atari MiNT"
#elif __MACOS__
"MacOS Classic"
#elif __MACOSX__
"Mac OS X"
#elif __NETBSD__
"NetBSD"
#elif __OPENBSD__
"OpenBSD"
#elif __OS2__
"OS/2"
#elif __OSF__
"OSF/1"
#elif __QNXNTO__
"QNX Neutrino"
#elif __RISCOS__
"RISC OS"
#elif __SOLARIS__
"Solaris"
#elif __WIN32__
#ifdef _WIN32_WCE
"Windows CE"
#else
"Windows"
#endif
#elif __IPHONEOS__
"iPhone OS"
#else
"an unknown operating system! (see SDL_platform.h)"
#endif
);
printf("This system is running %s\n", SDL_GetPlatform());
}
status += TestTypes(verbose);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment