- updated line endings to unix style characters to fix Bug #3085838

This commit is contained in:
Mark Vejvoda
2011-01-20 15:56:30 +00:00
parent 53327900b3
commit 66261ad662
105 changed files with 26229 additions and 20874 deletions

View File

@@ -514,7 +514,7 @@ void FTPClientThread::execute() {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"FTP Client thread is running\n");
try {
while(this->getQuitStatus() == false) {
while(this->getQuitStatus() == false) {
MutexSafeWrapper safeMutex(&mutexMapFileList);
if(mapFileList.size() > 0) {
string mapFilename = mapFileList[0];
@@ -546,7 +546,7 @@ void FTPClientThread::execute() {
if(this->getQuitStatus() == false) {
sleep(25);
}
}
}
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("===> FTP Client exiting!\n");
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"===> FTP Client exiting!\n");

View File

@@ -126,21 +126,21 @@ void FTPServerThread::execute() {
}
/*
ftpCreateAccount("anonymous", "", "./", FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
ftpCreateAccount("nothing", "", "./", 0);
ftpCreateAccount("reader", "", "./", FTP_ACC_RD);
ftpCreateAccount("writer", "", "./", FTP_ACC_WR);
ftpCreateAccount("lister", "", "./", FTP_ACC_LS);
ftpCreateAccount("admin", "xxx", "./", FTP_ACC_RD | FTP_ACC_WR | FTP_ACC_LS | FTP_ACC_DIR);
*/
ftpStart(portNumber);
while(this->getQuitStatus() == false) {
ftpCreateAccount("anonymous", "", "./", FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
ftpCreateAccount("nothing", "", "./", 0);
ftpCreateAccount("reader", "", "./", FTP_ACC_RD);
ftpCreateAccount("writer", "", "./", FTP_ACC_WR);
ftpCreateAccount("lister", "", "./", FTP_ACC_LS);
ftpCreateAccount("admin", "xxx", "./", FTP_ACC_RD | FTP_ACC_WR | FTP_ACC_LS | FTP_ACC_DIR);
*/
ftpStart(portNumber);
while(this->getQuitStatus() == false) {
ftpExecute();
//if(processedWork == 0) {
//sleep(25);
//}
}
ftpShutdown();
}
ftpShutdown();
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("===> FTP Server exiting!\n");
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"===> FTP Server exiting!\n");

View File

@@ -1972,7 +1972,7 @@ void UPNP_Tools::AddUPNPPortForward(int internalPort, int externalPort) {
void UPNP_Tools::RemoveUPNPPortForward(int internalPort, int externalPort) {
UPNP_Tools::upnp_rem_redirect(externalPort);
}
}
//
// This code below handles Universal Plug and Play Router Discovery

View File

@@ -73,13 +73,13 @@ Window::Window() {
mouseState.clear();
#ifdef WIN32
init_win32();
init_win32();
#endif
}
Window::~Window() {
#ifdef WIN32
done_win32();
done_win32();
#endif
assert(global_window == this);
@@ -201,72 +201,72 @@ bool Window::handleEvent() {
break;
case SDL_ACTIVEEVENT:
{
codeLocation = "k";
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",__FILE__,__FUNCTION__,__LINE__,event.active.state,event.active.gain);
codeLocation = "k";
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",__FILE__,__FUNCTION__,__LINE__,event.active.state,event.active.gain);
// Check if the program has lost keyboard focus
/*
if (event.active.state == SDL_APPINPUTFOCUS) {
if (event.active.gain == 0) {
Window::isActive = false;
}
/*
if (event.active.state == SDL_APPINPUTFOCUS) {
if (event.active.gain == 0) {
Window::isActive = false;
}
//else if (event.active.gain == 1) {
else {
Window::isActive = true;
}
else {
Window::isActive = true;
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive);
bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly());
showCursor(willShowCursor);
}
*/
// Check if the program has lost window focus
if ((event.active.state & SDL_APPACTIVE) == SDL_APPACTIVE) {
if (event.active.gain == 0) {
Window::isActive = false;
}
//else if (event.active.gain == 1) {
else {
Window::isActive = true;
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive);
bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly());
showCursor(willShowCursor);
}
*/
// Check if the program has lost window focus
/*
if (event.active.state == SDL_APPMOUSEFOCUS) {
if (event.active.gain == 0) {
Window::isActive = false;
}
if ((event.active.state & SDL_APPACTIVE) == SDL_APPACTIVE) {
if (event.active.gain == 0) {
Window::isActive = false;
}
//else if (event.active.gain == 1) {
else {
Window::isActive = true;
}
else {
Window::isActive = true;
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive);
bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly());
showCursor(willShowCursor);
}
// Check if the program has lost window focus
/*
if (event.active.state == SDL_APPMOUSEFOCUS) {
if (event.active.gain == 0) {
Window::isActive = false;
}
//else if (event.active.gain == 1) {
else {
Window::isActive = true;
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive);
bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly());
showCursor(willShowCursor);
}
*/
*/
if ((event.active.state & SDL_APPMOUSEFOCUS) != SDL_APPMOUSEFOCUS &&
(event.active.state & SDL_APPINPUTFOCUS) != SDL_APPINPUTFOCUS &&
(event.active.state & SDL_APPACTIVE) != SDL_APPACTIVE) {
if (event.active.gain == 0) {
Window::isActive = false;
}
(event.active.state & SDL_APPACTIVE) != SDL_APPACTIVE) {
if (event.active.gain == 0) {
Window::isActive = false;
}
//else if (event.active.gain == 1) {
else {
Window::isActive = true;
}
else {
Window::isActive = true;
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d, event.active.state = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive,event.active.state);
bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly());
showCursor(willShowCursor);
}
}
}
break;
}
@@ -385,15 +385,15 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a
#ifdef WIN32
static HWND GetSDLWindow()
{
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if (SDL_GetWMInfo(&info) == -1)
return NULL;
return info.window;
}
static HWND GetSDLWindow()
{
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if (SDL_GetWMInfo(&info) == -1)
return NULL;
return info.window;
}
#endif
@@ -402,84 +402,84 @@ void Window::toggleFullscreen() {
Window::isFullScreen = !Window::isFullScreen;
#ifdef WIN32
/* -- Portable Fullscreen Toggling --
As of SDL 1.2.10, if width and height are both 0, SDL_SetVideoMode will use the
width and height of the current video mode (or the desktop mode, if no mode has been set).
Use 0 for Height, Width, and Color Depth to keep the current values. */
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(Window::allowAltEnterFullscreenToggle == true) {
SDL_Surface *cur_surface = SDL_GetVideoSurface();
if(cur_surface != NULL) {
Window::isFullScreen = !((cur_surface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN);
}
SDL_Surface *sf = SDL_GetVideoSurface();
SDL_Surface **surface = &sf;
uint32 *flags = NULL;
void *pixels = NULL;
SDL_Color *palette = NULL;
SDL_Rect clip;
int ncolors = 0;
Uint32 tmpflags = 0;
int w = 0;
int h = 0;
int bpp = 0;
if ( (!surface) || (!(*surface)) ) // don't bother if there's no surface.
return;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
tmpflags = (*surface)->flags;
w = (*surface)->w;
h = (*surface)->h;
bpp = (*surface)->format->BitsPerPixel;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n w = %d, h = %d, bpp = %d",__FILE__,__FUNCTION__,__LINE__,w,h,bpp);
if (flags == NULL) // use the surface's flags.
flags = &tmpflags;
//
if ( *flags & SDL_FULLSCREEN )
*flags &= ~SDL_FULLSCREEN;
//
else
*flags |= SDL_FULLSCREEN;
SDL_GetClipRect(*surface, &clip);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
*surface = SDL_SetVideoMode(w, h, bpp, (*flags));
if (*surface == NULL) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
*surface = SDL_SetVideoMode(w, h, bpp, tmpflags);
} // if
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
SDL_SetClipRect(*surface, &clip);
}
else {
HWND handle = GetSDLWindow();
if(Window::isFullScreen == true) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == true [%d]\n",__FILE__,__FUNCTION__,__LINE__,handle);
/* -- Portable Fullscreen Toggling --
As of SDL 1.2.10, if width and height are both 0, SDL_SetVideoMode will use the
width and height of the current video mode (or the desktop mode, if no mode has been set).
Use 0 for Height, Width, and Color Depth to keep the current values. */
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(Window::allowAltEnterFullscreenToggle == true) {
SDL_Surface *cur_surface = SDL_GetVideoSurface();
if(cur_surface != NULL) {
Window::isFullScreen = !((cur_surface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN);
}
SDL_Surface *sf = SDL_GetVideoSurface();
SDL_Surface **surface = &sf;
uint32 *flags = NULL;
void *pixels = NULL;
SDL_Color *palette = NULL;
SDL_Rect clip;
int ncolors = 0;
Uint32 tmpflags = 0;
int w = 0;
int h = 0;
int bpp = 0;
if ( (!surface) || (!(*surface)) ) // don't bother if there's no surface.
return;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
tmpflags = (*surface)->flags;
w = (*surface)->w;
h = (*surface)->h;
bpp = (*surface)->format->BitsPerPixel;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n w = %d, h = %d, bpp = %d",__FILE__,__FUNCTION__,__LINE__,w,h,bpp);
if (flags == NULL) // use the surface's flags.
flags = &tmpflags;
//
if ( *flags & SDL_FULLSCREEN )
*flags &= ~SDL_FULLSCREEN;
//
else
*flags |= SDL_FULLSCREEN;
SDL_GetClipRect(*surface, &clip);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
*surface = SDL_SetVideoMode(w, h, bpp, (*flags));
if (*surface == NULL) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
*surface = SDL_SetVideoMode(w, h, bpp, tmpflags);
} // if
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
SDL_SetClipRect(*surface, &clip);
}
else {
HWND handle = GetSDLWindow();
if(Window::isFullScreen == true) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == true [%d]\n",__FILE__,__FUNCTION__,__LINE__,handle);
ShowWindow(handle, SW_MAXIMIZE);
//if(Window::getUseDefaultCursorOnly() == false) {
// showCursor(false);
//}
}
else {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == false [%d]\n",__FILE__,__FUNCTION__,__LINE__,handle);
ShowWindow(handle, SW_RESTORE);
//showCursor(true);
}
}
//}
}
else {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == false [%d]\n",__FILE__,__FUNCTION__,__LINE__,handle);
ShowWindow(handle, SW_RESTORE);
//showCursor(true);
}
}
#else
if(Window::allowAltEnterFullscreenToggle == true) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@@ -1,456 +1,456 @@
/* /////////////////////////////////////////////////////////////////////////
* File: glob.c
*
* Purpose: Definition of the glob() API functions for the Win32 platform.
*
* Created: 13th November 2002
* Updated: 6th February 2010
*
* Home: http://synesis.com.au/software/
*
* Copyright (c) 2002-2010, Matthew Wilson and Synesis Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the names of Matthew Wilson and Synesis Software nor the names of
* any contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* ////////////////////////////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////
* Includes
*/
#include <glob.h>
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#define NOMINMAX
#include <windows.h>
#define NUM_ELEMENTS(ar) (sizeof(ar) / sizeof(ar[0]))
/* /////////////////////////////////////////////////////////////////////////
* Helper functions
*/
static char const *strrpbrk(char const *string, char const *strCharSet)
{
char *part = NULL;
char const *pch;
for(pch = strCharSet; *pch; ++pch)
{
char *p = strrchr(string, *pch);
if(NULL != p)
{
if(NULL == part)
{
part = p;
}
else
{
if(part < p)
{
part = p;
}
}
}
}
return part;
}
/* /////////////////////////////////////////////////////////////////////////
* API functions
*/
/* It gives you back the matched contents of your pattern, so for Win32, the
* directories must be included
*/
int glob( char const *pattern
, int flags
#if defined(__COMO__)
, int (*errfunc)(char const *, int)
#else /* ? compiler */
, const int (*errfunc)(char const *, int)
#endif /* compiler */
, glob_t *pglob)
{
int result;
char szRelative[1 + _MAX_PATH];
char const *file_part;
WIN32_FIND_DATAA find_data;
HANDLE hFind;
char *buffer;
char szPattern2[1 + _MAX_PATH];
char szPattern3[1 + _MAX_PATH];
char const *effectivePattern = pattern;
char const *leafMost;
const int bMagic = (NULL != strpbrk(pattern, "?*"));
int bNoMagic = 0;
int bMagic0;
size_t maxMatches = ~(size_t)(0);
assert(NULL != pglob);
if(flags & GLOB_NOMAGIC)
{
bNoMagic = !bMagic;
}
if(flags & GLOB_LIMIT)
{
maxMatches = (size_t)pglob->gl_matchc;
}
if(flags & GLOB_TILDE)
{
/* Check that begins with "~/" */
if( '~' == pattern[0] &&
( '\0' == pattern[1] ||
'/' == pattern[1] ||
'\\' == pattern[1]))
{
DWORD dw;
(void)lstrcpyA(&szPattern2[0], "%HOMEDRIVE%%HOMEPATH%");
dw = ExpandEnvironmentStringsA(&szPattern2[0], &szPattern3[0], NUM_ELEMENTS(szPattern3) - 1);
if(0 != dw)
{
(void)lstrcpynA(&szPattern3[0] + dw - 1, &pattern[1], (int)(NUM_ELEMENTS(szPattern3) - dw));
szPattern3[NUM_ELEMENTS(szPattern3) - 1] = '\0';
effectivePattern = szPattern3;
}
}
}
file_part = strrpbrk(effectivePattern, "\\/");
if(NULL != file_part)
{
leafMost = ++file_part;
(void)lstrcpyA(szRelative, effectivePattern);
szRelative[file_part - effectivePattern] = '\0';
}
else
{
szRelative[0] = '\0';
leafMost = effectivePattern;
}
bMagic0 = (leafMost == strpbrk(leafMost, "?*"));
hFind = FindFirstFileA(effectivePattern, &find_data);
buffer = NULL;
pglob->gl_pathc = 0;
pglob->gl_pathv = NULL;
if(0 == (flags & GLOB_DOOFFS))
{
pglob->gl_offs = 0;
}
if(hFind == INVALID_HANDLE_VALUE)
{
/* If this was a pattern search, and the
* directory exists, then we return 0
* matches, rather than GLOB_NOMATCH
*/
if( bMagic &&
NULL != file_part)
{
result = 0;
}
else
{
if(NULL != errfunc)
{
(void)errfunc(effectivePattern, (int)GetLastError());
}
result = GLOB_NOMATCH;
}
}
else
{
int cbCurr = 0;
size_t cbAlloc = 0;
size_t cMatches = 0;
result = 0;
do
{
int cch;
size_t new_cbAlloc;
if( bMagic0 &&
0 == (flags & GLOB_PERIOD))
{
if('.' == find_data.cFileName[0])
{
continue;
}
}
if(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
#ifdef GLOB_ONLYFILE
if(flags & GLOB_ONLYFILE)
{
continue;
}
#endif /* GLOB_ONLYFILE */
if( bMagic0 &&
GLOB_NODOTSDIRS == (flags & GLOB_NODOTSDIRS))
{
/* Pattern must begin with '.' to match either dots directory */
if( 0 == lstrcmpA(".", find_data.cFileName) ||
0 == lstrcmpA("..", find_data.cFileName))
{
continue;
}
}
if(flags & GLOB_MARK)
{
#if 0
if(find_data.cFileName[0] >= 'A' && find_data.cFileName[0] <= 'M')
#endif /* 0 */
(void)lstrcatA(find_data.cFileName, "/");
}
}
else
{
if(flags & GLOB_ONLYDIR)
{
/* Skip all further actions, and get the next entry */
#if 0
if(find_data.cFileName[0] >= 'A' && find_data.cFileName[0] <= 'M')
#endif /* 0 */
continue;
}
}
cch = lstrlenA(find_data.cFileName);
if(NULL != file_part)
{
cch += (int)(file_part - effectivePattern);
}
new_cbAlloc = (size_t)cbCurr + cch + 1;
if(new_cbAlloc > cbAlloc)
{
char *new_buffer;
new_cbAlloc *= 2;
new_cbAlloc = (new_cbAlloc + 31) & ~(31);
new_buffer = (char*)realloc(buffer, new_cbAlloc);
if(new_buffer == NULL)
{
result = GLOB_NOSPACE;
free(buffer);
buffer = NULL;
break;
}
buffer = new_buffer;
cbAlloc = new_cbAlloc;
}
(void)lstrcpynA(buffer + cbCurr, szRelative, 1 + (int)(file_part - effectivePattern));
(void)lstrcatA(buffer + cbCurr, find_data.cFileName);
cbCurr += cch + 1;
++cMatches;
}
while(FindNextFile(hFind, &find_data) && cMatches != maxMatches);
(void)FindClose(hFind);
if(result == 0)
{
/* Now expand the buffer, to fit in all the pointers. */
size_t cbPointers = (1 + cMatches + pglob->gl_offs) * sizeof(char*);
char *new_buffer = (char*)realloc(buffer, cbAlloc + cbPointers);
if(new_buffer == NULL)
{
result = GLOB_NOSPACE;
free(buffer);
}
else
{
char **pp;
char **begin;
char **end;
char *next_str;
buffer = new_buffer;
(void)memmove(new_buffer + cbPointers, new_buffer, cbAlloc);
/* Handle the offsets. */
begin = (char**)new_buffer;
end = begin + pglob->gl_offs;
for(; begin != end; ++begin)
{
*begin = NULL;
}
/* Sort, or no sort. */
pp = (char**)new_buffer + pglob->gl_offs;
begin = pp;
end = begin + cMatches;
if(flags & GLOB_NOSORT)
{
/* The way we need in order to test the removal of dots in the findfile_sequence. */
*end = NULL;
for(begin = pp, next_str = buffer + cbPointers; begin != end; --end)
{
*(end - 1) = next_str;
/* Find the next string. */
next_str += 1 + lstrlenA(next_str);
}
}
else
{
/* The normal way. */
for(begin = pp, next_str = buffer + cbPointers; begin != end; ++begin)
{
*begin = next_str;
/* Find the next string. */
next_str += 1 + lstrlenA(next_str);
}
*begin = NULL;
}
/* Return results to caller. */
pglob->gl_pathc = (int)cMatches;
pglob->gl_matchc= (int)cMatches;
pglob->gl_flags = 0;
if(bMagic)
{
pglob->gl_flags |= GLOB_MAGCHAR;
}
pglob->gl_pathv = (char**)new_buffer;
}
}
if(0 == cMatches)
{
result = GLOB_NOMATCH;
}
}
if(GLOB_NOMATCH == result)
{
if( (flags & GLOB_TILDE_CHECK) &&
effectivePattern == szPattern3)
{
result = GLOB_NOMATCH;
}
else if(bNoMagic ||
(flags & GLOB_NOCHECK))
{
const size_t effPattLen = strlen(effectivePattern);
const size_t cbNeeded = ((2 + pglob->gl_offs) * sizeof(char*)) + (1 + effPattLen);
char **pp = (char**)realloc(buffer, cbNeeded);
if(NULL == pp)
{
result = GLOB_NOSPACE;
free(buffer);
}
else
{
/* Handle the offsets. */
char** begin = pp;
char** end = pp + pglob->gl_offs;
char* dest = (char*)(pp + 2 + pglob->gl_offs);
for(; begin != end; ++begin)
{
*begin = NULL;
}
/* Synthesise the pattern result. */
#ifdef UNIXEM_USING_SAFE_STR_FUNCTIONS
pp[0 + pglob->gl_offs] = (strcpy_s(dest, effPattLen + 1, effectivePattern), dest);
#else /* ? UNIXEM_USING_SAFE_STR_FUNCTIONS */
pp[0 + pglob->gl_offs] = strcpy(dest, effectivePattern);
#endif /* UNIXEM_USING_SAFE_STR_FUNCTIONS */
pp[1 + pglob->gl_offs] = NULL;
/* Return results to caller. */
pglob->gl_pathc = 1;
pglob->gl_matchc= 1;
pglob->gl_flags = 0;
if(bMagic)
{
pglob->gl_flags |= GLOB_MAGCHAR;
}
pglob->gl_pathv = pp;
result = 0;
}
}
}
else if(0 == result)
{
if((size_t)pglob->gl_matchc == maxMatches)
{
result = GLOB_NOSPACE;
}
}
return result;
}
void globfree(glob_t *pglob)
{
if(pglob != NULL)
{
free(pglob->gl_pathv);
pglob->gl_pathc = 0;
pglob->gl_pathv = NULL;
}
}
/* ///////////////////////////// end of file //////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////
* File: glob.c
*
* Purpose: Definition of the glob() API functions for the Win32 platform.
*
* Created: 13th November 2002
* Updated: 6th February 2010
*
* Home: http://synesis.com.au/software/
*
* Copyright (c) 2002-2010, Matthew Wilson and Synesis Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the names of Matthew Wilson and Synesis Software nor the names of
* any contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* ////////////////////////////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////
* Includes
*/
#include <glob.h>
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#define NOMINMAX
#include <windows.h>
#define NUM_ELEMENTS(ar) (sizeof(ar) / sizeof(ar[0]))
/* /////////////////////////////////////////////////////////////////////////
* Helper functions
*/
static char const *strrpbrk(char const *string, char const *strCharSet)
{
char *part = NULL;
char const *pch;
for(pch = strCharSet; *pch; ++pch)
{
char *p = strrchr(string, *pch);
if(NULL != p)
{
if(NULL == part)
{
part = p;
}
else
{
if(part < p)
{
part = p;
}
}
}
}
return part;
}
/* /////////////////////////////////////////////////////////////////////////
* API functions
*/
/* It gives you back the matched contents of your pattern, so for Win32, the
* directories must be included
*/
int glob( char const *pattern
, int flags
#if defined(__COMO__)
, int (*errfunc)(char const *, int)
#else /* ? compiler */
, const int (*errfunc)(char const *, int)
#endif /* compiler */
, glob_t *pglob)
{
int result;
char szRelative[1 + _MAX_PATH];
char const *file_part;
WIN32_FIND_DATAA find_data;
HANDLE hFind;
char *buffer;
char szPattern2[1 + _MAX_PATH];
char szPattern3[1 + _MAX_PATH];
char const *effectivePattern = pattern;
char const *leafMost;
const int bMagic = (NULL != strpbrk(pattern, "?*"));
int bNoMagic = 0;
int bMagic0;
size_t maxMatches = ~(size_t)(0);
assert(NULL != pglob);
if(flags & GLOB_NOMAGIC)
{
bNoMagic = !bMagic;
}
if(flags & GLOB_LIMIT)
{
maxMatches = (size_t)pglob->gl_matchc;
}
if(flags & GLOB_TILDE)
{
/* Check that begins with "~/" */
if( '~' == pattern[0] &&
( '\0' == pattern[1] ||
'/' == pattern[1] ||
'\\' == pattern[1]))
{
DWORD dw;
(void)lstrcpyA(&szPattern2[0], "%HOMEDRIVE%%HOMEPATH%");
dw = ExpandEnvironmentStringsA(&szPattern2[0], &szPattern3[0], NUM_ELEMENTS(szPattern3) - 1);
if(0 != dw)
{
(void)lstrcpynA(&szPattern3[0] + dw - 1, &pattern[1], (int)(NUM_ELEMENTS(szPattern3) - dw));
szPattern3[NUM_ELEMENTS(szPattern3) - 1] = '\0';
effectivePattern = szPattern3;
}
}
}
file_part = strrpbrk(effectivePattern, "\\/");
if(NULL != file_part)
{
leafMost = ++file_part;
(void)lstrcpyA(szRelative, effectivePattern);
szRelative[file_part - effectivePattern] = '\0';
}
else
{
szRelative[0] = '\0';
leafMost = effectivePattern;
}
bMagic0 = (leafMost == strpbrk(leafMost, "?*"));
hFind = FindFirstFileA(effectivePattern, &find_data);
buffer = NULL;
pglob->gl_pathc = 0;
pglob->gl_pathv = NULL;
if(0 == (flags & GLOB_DOOFFS))
{
pglob->gl_offs = 0;
}
if(hFind == INVALID_HANDLE_VALUE)
{
/* If this was a pattern search, and the
* directory exists, then we return 0
* matches, rather than GLOB_NOMATCH
*/
if( bMagic &&
NULL != file_part)
{
result = 0;
}
else
{
if(NULL != errfunc)
{
(void)errfunc(effectivePattern, (int)GetLastError());
}
result = GLOB_NOMATCH;
}
}
else
{
int cbCurr = 0;
size_t cbAlloc = 0;
size_t cMatches = 0;
result = 0;
do
{
int cch;
size_t new_cbAlloc;
if( bMagic0 &&
0 == (flags & GLOB_PERIOD))
{
if('.' == find_data.cFileName[0])
{
continue;
}
}
if(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
#ifdef GLOB_ONLYFILE
if(flags & GLOB_ONLYFILE)
{
continue;
}
#endif /* GLOB_ONLYFILE */
if( bMagic0 &&
GLOB_NODOTSDIRS == (flags & GLOB_NODOTSDIRS))
{
/* Pattern must begin with '.' to match either dots directory */
if( 0 == lstrcmpA(".", find_data.cFileName) ||
0 == lstrcmpA("..", find_data.cFileName))
{
continue;
}
}
if(flags & GLOB_MARK)
{
#if 0
if(find_data.cFileName[0] >= 'A' && find_data.cFileName[0] <= 'M')
#endif /* 0 */
(void)lstrcatA(find_data.cFileName, "/");
}
}
else
{
if(flags & GLOB_ONLYDIR)
{
/* Skip all further actions, and get the next entry */
#if 0
if(find_data.cFileName[0] >= 'A' && find_data.cFileName[0] <= 'M')
#endif /* 0 */
continue;
}
}
cch = lstrlenA(find_data.cFileName);
if(NULL != file_part)
{
cch += (int)(file_part - effectivePattern);
}
new_cbAlloc = (size_t)cbCurr + cch + 1;
if(new_cbAlloc > cbAlloc)
{
char *new_buffer;
new_cbAlloc *= 2;
new_cbAlloc = (new_cbAlloc + 31) & ~(31);
new_buffer = (char*)realloc(buffer, new_cbAlloc);
if(new_buffer == NULL)
{
result = GLOB_NOSPACE;
free(buffer);
buffer = NULL;
break;
}
buffer = new_buffer;
cbAlloc = new_cbAlloc;
}
(void)lstrcpynA(buffer + cbCurr, szRelative, 1 + (int)(file_part - effectivePattern));
(void)lstrcatA(buffer + cbCurr, find_data.cFileName);
cbCurr += cch + 1;
++cMatches;
}
while(FindNextFile(hFind, &find_data) && cMatches != maxMatches);
(void)FindClose(hFind);
if(result == 0)
{
/* Now expand the buffer, to fit in all the pointers. */
size_t cbPointers = (1 + cMatches + pglob->gl_offs) * sizeof(char*);
char *new_buffer = (char*)realloc(buffer, cbAlloc + cbPointers);
if(new_buffer == NULL)
{
result = GLOB_NOSPACE;
free(buffer);
}
else
{
char **pp;
char **begin;
char **end;
char *next_str;
buffer = new_buffer;
(void)memmove(new_buffer + cbPointers, new_buffer, cbAlloc);
/* Handle the offsets. */
begin = (char**)new_buffer;
end = begin + pglob->gl_offs;
for(; begin != end; ++begin)
{
*begin = NULL;
}
/* Sort, or no sort. */
pp = (char**)new_buffer + pglob->gl_offs;
begin = pp;
end = begin + cMatches;
if(flags & GLOB_NOSORT)
{
/* The way we need in order to test the removal of dots in the findfile_sequence. */
*end = NULL;
for(begin = pp, next_str = buffer + cbPointers; begin != end; --end)
{
*(end - 1) = next_str;
/* Find the next string. */
next_str += 1 + lstrlenA(next_str);
}
}
else
{
/* The normal way. */
for(begin = pp, next_str = buffer + cbPointers; begin != end; ++begin)
{
*begin = next_str;
/* Find the next string. */
next_str += 1 + lstrlenA(next_str);
}
*begin = NULL;
}
/* Return results to caller. */
pglob->gl_pathc = (int)cMatches;
pglob->gl_matchc= (int)cMatches;
pglob->gl_flags = 0;
if(bMagic)
{
pglob->gl_flags |= GLOB_MAGCHAR;
}
pglob->gl_pathv = (char**)new_buffer;
}
}
if(0 == cMatches)
{
result = GLOB_NOMATCH;
}
}
if(GLOB_NOMATCH == result)
{
if( (flags & GLOB_TILDE_CHECK) &&
effectivePattern == szPattern3)
{
result = GLOB_NOMATCH;
}
else if(bNoMagic ||
(flags & GLOB_NOCHECK))
{
const size_t effPattLen = strlen(effectivePattern);
const size_t cbNeeded = ((2 + pglob->gl_offs) * sizeof(char*)) + (1 + effPattLen);
char **pp = (char**)realloc(buffer, cbNeeded);
if(NULL == pp)
{
result = GLOB_NOSPACE;
free(buffer);
}
else
{
/* Handle the offsets. */
char** begin = pp;
char** end = pp + pglob->gl_offs;
char* dest = (char*)(pp + 2 + pglob->gl_offs);
for(; begin != end; ++begin)
{
*begin = NULL;
}
/* Synthesise the pattern result. */
#ifdef UNIXEM_USING_SAFE_STR_FUNCTIONS
pp[0 + pglob->gl_offs] = (strcpy_s(dest, effPattLen + 1, effectivePattern), dest);
#else /* ? UNIXEM_USING_SAFE_STR_FUNCTIONS */
pp[0 + pglob->gl_offs] = strcpy(dest, effectivePattern);
#endif /* UNIXEM_USING_SAFE_STR_FUNCTIONS */
pp[1 + pglob->gl_offs] = NULL;
/* Return results to caller. */
pglob->gl_pathc = 1;
pglob->gl_matchc= 1;
pglob->gl_flags = 0;
if(bMagic)
{
pglob->gl_flags |= GLOB_MAGCHAR;
}
pglob->gl_pathv = pp;
result = 0;
}
}
}
else if(0 == result)
{
if((size_t)pglob->gl_matchc == maxMatches)
{
result = GLOB_NOSPACE;
}
}
return result;
}
void globfree(glob_t *pglob)
{
if(pglob != NULL)
{
free(pglob->gl_pathv);
pglob->gl_pathc = 0;
pglob->gl_pathv = NULL;
}
}
/* ///////////////////////////// end of file //////////////////////////// */

View File

@@ -1,212 +1,212 @@
// ==============================================================
// This file is part of Glest Shared Library (www.glest.org)
//
// Copyright (C) 2001-2008 Martio Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version
// ==============================================================
#include "platform_util.h"
#include <io.h>
#include <dbghelp.h>
#include <cassert>
#include <algorithm>
#include <string.h>
// ==============================================================
// This file is part of Glest Shared Library (www.glest.org)
//
// Copyright (C) 2001-2008 Martio Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version
// ==============================================================
#include "platform_util.h"
#include <io.h>
#include <dbghelp.h>
#include <cassert>
#include <algorithm>
#include <string.h>
#include "SDL_syswm.h"
#include <iostream>
#include "leak_dumper.h"
using namespace Shared::Util;
using namespace std;
namespace Shared { namespace Platform {
// =====================================================
// class PlatformExceptionHandler
// =====================================================
PlatformExceptionHandler *PlatformExceptionHandler::thisPointer= NULL;
LONG WINAPI PlatformExceptionHandler::handler(LPEXCEPTION_POINTERS pointers){
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
HANDLE hFile = CreateFile(
thisPointer->dumpFileName.c_str(),
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
0);
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
MINIDUMP_EXCEPTION_INFORMATION lExceptionInformation;
lExceptionInformation.ThreadId= GetCurrentThreadId();
lExceptionInformation.ExceptionPointers= pointers;
lExceptionInformation.ClientPointers= false;
#include "leak_dumper.h"
using namespace Shared::Util;
using namespace std;
namespace Shared { namespace Platform {
// =====================================================
// class PlatformExceptionHandler
// =====================================================
PlatformExceptionHandler *PlatformExceptionHandler::thisPointer= NULL;
LONG WINAPI PlatformExceptionHandler::handler(LPEXCEPTION_POINTERS pointers){
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
HANDLE hFile = CreateFile(
thisPointer->dumpFileName.c_str(),
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
0);
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
MINIDUMP_EXCEPTION_INFORMATION lExceptionInformation;
lExceptionInformation.ThreadId= GetCurrentThreadId();
lExceptionInformation.ExceptionPointers= pointers;
lExceptionInformation.ClientPointers= false;
#if defined(__WIN32__) && !defined(__GNUC__)
MiniDumpWriteDump(
GetCurrentProcess(),
GetCurrentProcessId(),
hFile,
MiniDumpNormal,
&lExceptionInformation,
NULL,
NULL );
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
thisPointer->handle();
#endif
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
return EXCEPTION_EXECUTE_HANDLER;
}
void PlatformExceptionHandler::install(string dumpFileName){
thisPointer= this;
this->dumpFileName= dumpFileName;
SetUnhandledExceptionFilter(handler);
}
// =====================================================
// class Misc
// =====================================================
//void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight) {
// // Get the current video hardware information
// //const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
// //colorBits = vidInfo->vfmt->BitsPerPixel;
// //screenWidth = vidInfo->current_w;
//
///*
// //screenHeight = vidInfo->current_h;
// int cx = GetSystemMetrics(SM_CXVIRTUALSCREEN);
// // height
// int cy = GetSystemMetrics(SM_CYVIRTUALSCREEN);
//
// printf("cx = %d, cy = %d\n",cx,cy);
//
// if(cx > screenWidth) {
// screenWidth = cx;
// screenHeight = cy;
// }
//*/
// int iMaxWidth = -1;
// int iMaxHeight = -1;
// int iMaxBits = -1;
//
// DEVMODE devMode;
// for (int i=0; EnumDisplaySettings(NULL, i, &devMode) ;i++){
//
// //printf("devMode.dmPelsWidth = %d, devMode.dmPelsHeight = %d, devMode.dmBitsPerPel = %d\n",devMode.dmPelsWidth,devMode.dmPelsHeight,devMode.dmBitsPerPel);
//
// if(devMode.dmPelsWidth > iMaxWidth) {
// iMaxWidth = devMode.dmPelsWidth;
// iMaxHeight = devMode.dmPelsHeight;
// iMaxBits = devMode.dmBitsPerPel;
// //devMode.dmDisplayFrequency=refreshFrequency;
// }
// }
// if(iMaxWidth > 0) {
// colorBits = iMaxBits;
// screenWidth = iMaxWidth;
// screenHeight = iMaxHeight;
// }
//}
//
//bool changeVideoMode(int resW, int resH, int colorBits, int refreshFrequency){
// DEVMODE devMode;
//
// for (int i=0; EnumDisplaySettings(NULL, i, &devMode) ;i++){
// if (devMode.dmPelsWidth== resW &&
// devMode.dmPelsHeight== resH &&
// devMode.dmBitsPerPel== colorBits){
//
// devMode.dmDisplayFrequency=refreshFrequency;
//
// LONG result= ChangeDisplaySettings(&devMode, 0);
// if(result == DISP_CHANGE_SUCCESSFUL){
// return true;
// }
// else{
// return false;
// }
// }
// }
//
// return false;
//}
//
//void restoreVideoMode(bool exitingApp) {
// int dispChangeErr= ChangeDisplaySettings(NULL, 0);
// assert(dispChangeErr==DISP_CHANGE_SUCCESSFUL);
//}
void message(string message){
std::cerr << "******************************************************\n";
std::cerr << " " << message << "\n";
std::cerr << "******************************************************\n";
MessageBox(NULL, message.c_str(), "Message", MB_OK);
}
bool ask(string message){
return MessageBox(NULL, message.c_str(), "Confirmation", MB_YESNO)==IDYES;
}
void exceptionMessage(const exception &excp){
string message, title;
showCursor(true);
message+= "ERROR(S):\n\n";
message+= excp.what();
title= "Error: Unhandled Exception";
printf("Error detected with text: %s\n",message.c_str());
MessageBox(NULL, message.c_str(), title.c_str(), MB_ICONSTOP | MB_OK | MB_TASKMODAL);
}
//int getScreenW(){
// return GetSystemMetrics(SM_CXSCREEN);
//}
//int getScreenH(){
// return GetSystemMetrics(SM_CYSCREEN);
//}
#if defined(__WIN32__) && !defined(__GNUC__)
MiniDumpWriteDump(
GetCurrentProcess(),
GetCurrentProcessId(),
hFile,
MiniDumpNormal,
&lExceptionInformation,
NULL,
NULL );
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
thisPointer->handle();
#endif
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
return EXCEPTION_EXECUTE_HANDLER;
}
void PlatformExceptionHandler::install(string dumpFileName){
thisPointer= this;
this->dumpFileName= dumpFileName;
SetUnhandledExceptionFilter(handler);
}
// =====================================================
// class Misc
// =====================================================
//void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight) {
// // Get the current video hardware information
// //const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
// //colorBits = vidInfo->vfmt->BitsPerPixel;
// //screenWidth = vidInfo->current_w;
//
///*
// //screenHeight = vidInfo->current_h;
// int cx = GetSystemMetrics(SM_CXVIRTUALSCREEN);
// // height
// int cy = GetSystemMetrics(SM_CYVIRTUALSCREEN);
//
// printf("cx = %d, cy = %d\n",cx,cy);
//
// if(cx > screenWidth) {
// screenWidth = cx;
// screenHeight = cy;
// }
//*/
// int iMaxWidth = -1;
// int iMaxHeight = -1;
// int iMaxBits = -1;
//
// DEVMODE devMode;
// for (int i=0; EnumDisplaySettings(NULL, i, &devMode) ;i++){
//
// //printf("devMode.dmPelsWidth = %d, devMode.dmPelsHeight = %d, devMode.dmBitsPerPel = %d\n",devMode.dmPelsWidth,devMode.dmPelsHeight,devMode.dmBitsPerPel);
//
// if(devMode.dmPelsWidth > iMaxWidth) {
// iMaxWidth = devMode.dmPelsWidth;
// iMaxHeight = devMode.dmPelsHeight;
// iMaxBits = devMode.dmBitsPerPel;
// //devMode.dmDisplayFrequency=refreshFrequency;
// }
// }
// if(iMaxWidth > 0) {
// colorBits = iMaxBits;
// screenWidth = iMaxWidth;
// screenHeight = iMaxHeight;
// }
//}
//
//bool changeVideoMode(int resW, int resH, int colorBits, int refreshFrequency){
// DEVMODE devMode;
//
// for (int i=0; EnumDisplaySettings(NULL, i, &devMode) ;i++){
// if (devMode.dmPelsWidth== resW &&
// devMode.dmPelsHeight== resH &&
// devMode.dmBitsPerPel== colorBits){
//
// devMode.dmDisplayFrequency=refreshFrequency;
//
// LONG result= ChangeDisplaySettings(&devMode, 0);
// if(result == DISP_CHANGE_SUCCESSFUL){
// return true;
// }
// else{
// return false;
// }
// }
// }
//
// return false;
//}
//
//void restoreVideoMode(bool exitingApp) {
// int dispChangeErr= ChangeDisplaySettings(NULL, 0);
// assert(dispChangeErr==DISP_CHANGE_SUCCESSFUL);
//}
void message(string message){
std::cerr << "******************************************************\n";
std::cerr << " " << message << "\n";
std::cerr << "******************************************************\n";
MessageBox(NULL, message.c_str(), "Message", MB_OK);
}
bool ask(string message){
return MessageBox(NULL, message.c_str(), "Confirmation", MB_YESNO)==IDYES;
}
void exceptionMessage(const exception &excp){
string message, title;
showCursor(true);
message+= "ERROR(S):\n\n";
message+= excp.what();
title= "Error: Unhandled Exception";
printf("Error detected with text: %s\n",message.c_str());
MessageBox(NULL, message.c_str(), title.c_str(), MB_ICONSTOP | MB_OK | MB_TASKMODAL);
}
//int getScreenW(){
// return GetSystemMetrics(SM_CXSCREEN);
//}
//int getScreenH(){
// return GetSystemMetrics(SM_CYSCREEN);
//}
// This lets us set the SDL Window Icon in Windows
// since its a console application
HICON icon;
HICON icon;
void init_win32() {
HINSTANCE handle = ::GetModuleHandle(NULL);
icon = ::LoadIcon(handle, "IDI_ICON1");
SDL_SysWMinfo wminfo;
SDL_VERSION(&wminfo.version)
if (SDL_GetWMInfo(&wminfo) != 1)
{
// error: wrong SDL version
}
HWND hwnd = wminfo.window;
::SetClassLong(hwnd, GCL_HICON, (LONG) icon);
}
void done_win32() {
::DestroyIcon(icon);
void init_win32() {
HINSTANCE handle = ::GetModuleHandle(NULL);
icon = ::LoadIcon(handle, "IDI_ICON1");
SDL_SysWMinfo wminfo;
SDL_VERSION(&wminfo.version)
if (SDL_GetWMInfo(&wminfo) != 1)
{
// error: wrong SDL version
}
HWND hwnd = wminfo.window;
::SetClassLong(hwnd, GCL_HICON, (LONG) icon);
}
}}//end namespace
void done_win32() {
::DestroyIcon(icon);
}
}}//end namespace