diff --git a/src/OSD/FILES b/src/OSD/FILES index 28acd96926..a857f5d512 100755 --- a/src/OSD/FILES +++ b/src/OSD/FILES @@ -8,7 +8,6 @@ OSD_Getkey.c OSD_Function.hxx OSD_ErrorList.hxx OSD_WNT.cxx -OSD_WNT_1.cxx OSD_WNT.hxx OSD_WNT_1.hxx OSD_WNT_BREAK.hxx diff --git a/src/OSD/OSD_WNT.cxx b/src/OSD/OSD_WNT.cxx index b86febe37a..fdaa472b3b 100755 --- a/src/OSD/OSD_WNT.cxx +++ b/src/OSD/OSD_WNT.cxx @@ -48,7 +48,6 @@ static BOOL fInit = FALSE; static PSID* predefinedSIDs; static HANDLE hHeap; /***/ -static DELETE_DIR_PROC _delete_dir_proc; static MOVE_DIR_PROC _move_dir_proc; static COPY_DIR_PROC _copy_dir_proc; static RESPONSE_DIR_PROC _response_dir_proc; @@ -895,152 +894,6 @@ void FreeAce ( PVOID pACE ) { #define WILD_CARD TEXT( "/*.*" ) #define WILD_CARD_LEN ( sizeof ( WILD_CARD ) ) -/* LD : We do not need this routine any longer : */ -/* Dont remove a no empty directory */ - - -#if 0 - -/***/ -/******************************************************************************/ -/* Function : DeleteDirectory */ -/* Purpose : Deletes specified directory tree */ -/* Returns : TRUE on success, FALSE otherwise */ -/******************************************************************************/ -/***/ -BOOL DeleteDirectory ( LPCTSTR dirName ) { - - PWIN32_FIND_DATA pFD; - LPTSTR pName = NULL; - LPTSTR pFullName = NULL; - HANDLE hFindFile = INVALID_HANDLE_VALUE; - BOOL fFind; - BOOL retVal = FALSE; - DIR_RESPONSE response; - - if ( ( pFD = ( PWIN32_FIND_DATA )HeapAlloc ( - hHeap, 0, sizeof ( WIN32_FIND_DATA ) - ) - ) != NULL && - ( pName = ( LPTSTR )HeapAlloc ( - hHeap, 0, lstrlen ( dirName ) + WILD_CARD_LEN + - sizeof ( TEXT( '\x00' ) ) - ) - ) != NULL - ) { - - lstrcpy ( pName, dirName ); - lstrcat ( pName, WILD_CARD ); - - retVal = TRUE; - fFind = ( hFindFile = FindFirstFile ( pName, pFD ) ) != INVALID_HANDLE_VALUE; - - while ( fFind ) { - - if ( pFD -> cFileName[ 0 ] != TEXT( '.' ) || - pFD -> cFileName[ 0 ] != TEXT( '.' ) && - pFD -> cFileName[ 1 ] != TEXT( '.' ) - ) { - - if ( ( pFullName = ( LPTSTR )HeapAlloc ( - hHeap, 0, - lstrlen ( dirName ) + lstrlen ( pFD -> cFileName ) + - sizeof ( TEXT( '/' ) ) + sizeof ( TEXT( '\x00' ) ) - ) - ) == NULL - ) break; - - lstrcpy ( pFullName, dirName ); - lstrcat ( pFullName, TEXT( "/" ) ); - lstrcat ( pFullName, pFD -> cFileName ); - - if ( pFD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { - - if ( !( retVal = DeleteDirectory ( pFullName ) ) ) - - break; - - } else { -retry: - if ( !( retVal = DeleteFile ( pFullName ) ) ) { - - if ( _response_dir_proc != NULL ) { - - response = ( *_response_dir_proc ) ( pFullName ); - - if ( response == DIR_ABORT ) - - break; - - else if ( response == DIR_RETRY ) - - goto retry; - - else if ( response == DIR_IGNORE ) - - retVal = TRUE; - - else - - break; - - } /* end if */ - - } else if ( _delete_dir_proc != NULL ) - - ( *_delete_dir_proc ) ( pFullName ); - - } /* end else */ - - HeapFree ( hHeap, 0, pFullName ); - pFullName = NULL; - - } /* end if */ - - fFind = FindNextFile ( hFindFile, pFD ); - - } /* end while */ - - } /* end if */ - - if ( hFindFile != INVALID_HANDLE_VALUE ) FindClose ( hFindFile ); - - if ( pFullName != NULL ) HeapFree ( hHeap, 0, pFullName ); - if ( pName != NULL ) HeapFree ( hHeap, 0, pName ); - if ( pFD != NULL ) HeapFree ( hHeap, 0, pFD ); - - if ( retVal ) { -retry_1: - retVal = RemoveDirectory ( dirName ); - - if ( !retVal ) { - - if ( _response_dir_proc != NULL ) { - - response = ( *_response_dir_proc ) ( pFullName ); - - if ( response == DIR_RETRY ) - - goto retry_1; - - else if ( response == DIR_IGNORE ) - - retVal = TRUE; - - } /* end if */ - - } else if ( _delete_dir_proc != NULL ) - - ( *_delete_dir_proc ) ( dirName ); - - } /* end if */ - - return retVal; - -} /* end DeleteDirectory */ - -#endif - /***/ /******************************************************************************/ /* Function : MoveDirectory */ @@ -1410,20 +1263,6 @@ retry: } /* end CopyDirectory */ /***/ /******************************************************************************/ -/* Function : SetDeleteDirectoryProc */ -/* Purpose : Sets callback procedure which is calling by the */ -/* 'DeleteDirectory' after deleteion of each item in the */ -/* directory. To unregister this callback function supply NULL */ -/* pointer */ -/******************************************************************************/ -/***/ -void SetDeleteDirectoryProc ( DELETE_DIR_PROC proc ) { - - _delete_dir_proc = proc; - -} /* end SetDeleteDirectoryProc */ -/***/ -/******************************************************************************/ /* Function : SetMoveDirectoryProc */ /* Purpose : Sets callback procedure which is calling by the */ /* 'MoveDirectory' after moving of each item in the */ diff --git a/src/OSD/OSD_WNT_1.cxx b/src/OSD/OSD_WNT_1.cxx deleted file mode 100755 index 9af236cfa4..0000000000 --- a/src/OSD/OSD_WNT_1.cxx +++ /dev/null @@ -1,568 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#ifdef WNT -#include - -#include - -static FILETIME ftKernelTimeStart, ftUserTimeStart, ftElapsedStart; -static TCHAR timeBuffer[ 80 ]; - -static __int64 __fastcall FileTimeToQuadWord ( PFILETIME ); -static void __fastcall QuadWordToFileTime ( __int64, PFILETIME ); - -BOOL OSDAPI DirWalk ( - LPCTSTR dirName, LPCTSTR wildCard, BOOL ( *func ) ( LPCTSTR, BOOL, void* ), - BOOL fRecurse, void* lpClientData - ) { - - int len; - PWIN32_FIND_DATA pFD; - LPTSTR pName = NULL; - LPTSTR pFullName = NULL; - LPTSTR pTmp; - HANDLE hFindFile = INVALID_HANDLE_VALUE; - BOOL fFind; - BOOL retVal = TRUE; - HANDLE hHeap = GetProcessHeap (); - - if ( ( pFD = ( PWIN32_FIND_DATA )HeapAlloc ( - hHeap, 0, sizeof ( WIN32_FIND_DATA ) - ) - ) != NULL && - ( pName = ( LPTSTR )HeapAlloc ( - hHeap, 0, lstrlen ( dirName ) + - lstrlen ( wildCard ) + sizeof ( TEXT( '\x00' ) ) - ) - ) != NULL - ) { - - lstrcpy ( pName, dirName ); - lstrcat ( pName, wildCard ); - - fFind = ( hFindFile = FindFirstFile ( pName, pFD ) ) != INVALID_HANDLE_VALUE; - - while ( fFind ) { - - if ( pFD -> cFileName[ 0 ] != TEXT( '.' ) || - pFD -> cFileName[ 0 ] != TEXT( '.' ) && - pFD -> cFileName[ 1 ] != TEXT( '.' ) - ) { - - if ( ( pFullName = ( LPTSTR )HeapAlloc ( - hHeap, 0, - lstrlen ( dirName ) + lstrlen ( pFD -> cFileName ) + - sizeof ( TEXT( '/' ) ) + - sizeof ( TEXT( '\x00' ) ) - ) - ) == NULL - ) { - - retVal = FALSE; - break; - - } /* end if */ - - lstrcpy ( pFullName, dirName ); - lstrcat ( pFullName, pFD -> cFileName ); - - if ( pFD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && fRecurse ) { - - lstrcat ( pFullName, TEXT( "/" ) ); - - if ( !DirWalk ( pFullName, wildCard, func, fRecurse, lpClientData ) ) retVal = FALSE; - - } else if ( !( *func ) ( - pFullName, pFD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? TRUE : - FALSE, - lpClientData - ) - ) retVal = FALSE; - - HeapFree ( hHeap, 0, pFullName ); - pFullName = NULL; - - } /* end if */ - - fFind = FindNextFile ( hFindFile, pFD ); - - } /* end while */ - - } else - - retVal = FALSE; - - len = 1; - - if ( hFindFile != INVALID_HANDLE_VALUE ) FindClose ( hFindFile ); - - if ( fRecurse ) { - - if ( dirName[ len = lstrlen ( dirName ) - 1 ] == TEXT( '/' ) ) { - - if ( ( pTmp = ( LPTSTR )HeapAlloc ( hHeap, 0, len + 2 ) ) != NULL ) { - - lstrcpy ( pTmp, dirName ); - pTmp[ len ] = 0; - fFind = TRUE; - - } else { - - retVal = FALSE; - len = 0; - - } /* end else */ - - } /* end if */ - - if ( len ) { - - retVal = ( *func ) ( fFind ? pTmp : dirName, TRUE, lpClientData ); - - if ( fFind ) HeapFree ( hHeap, 0, pTmp ); - - } /* end if */ - - } /* end if */ - - if ( pFullName != NULL ) HeapFree ( hHeap, 0, pFullName ); - if ( pName != NULL ) HeapFree ( hHeap, 0, pName ); - if ( pFD != NULL ) HeapFree ( hHeap, 0, pFD ); - - return retVal; - -} // end DirWalk - -void WNT_InitTimer ( void ) { - - FILETIME ftDummy; - SYSTEMTIME stStart; - - GetProcessTimes ( - GetCurrentProcess (), &ftDummy, &ftDummy, &ftKernelTimeStart, &ftUserTimeStart - ); - - GetSystemTime ( &stStart ); - SystemTimeToFileTime ( &stStart, &ftElapsedStart ); - -} // end WNT_InitTimer - -LPCTSTR WNT_StatTimer ( void ) { - - __int64 qwKernelTimeElapsed, qwUserTimeElapsed, qwTotalTimeElapsed; - FILETIME ftKernelTimeEnd, ftUserTimeEnd, ftTotalTimeEnd, ftDummy; - SYSTEMTIME stKernel, stUser, stTotal; - - GetProcessTimes ( - GetCurrentProcess (), &ftDummy, &ftDummy, &ftKernelTimeEnd, &ftUserTimeEnd - ); - - GetSystemTime ( &stTotal ); - SystemTimeToFileTime ( &stTotal, &ftTotalTimeEnd ); - - qwKernelTimeElapsed = FileTimeToQuadWord ( &ftKernelTimeEnd ) - - FileTimeToQuadWord ( &ftKernelTimeStart ); - - qwUserTimeElapsed = FileTimeToQuadWord ( &ftUserTimeEnd ) - - FileTimeToQuadWord ( &ftUserTimeStart ); - - qwTotalTimeElapsed = FileTimeToQuadWord ( &ftTotalTimeEnd ) - - FileTimeToQuadWord ( &ftElapsedStart ); - - QuadWordToFileTime ( qwKernelTimeElapsed, &ftKernelTimeEnd ); - QuadWordToFileTime ( qwUserTimeElapsed, &ftUserTimeEnd ); - QuadWordToFileTime ( qwTotalTimeElapsed, &ftTotalTimeEnd ); - - FileTimeToSystemTime ( &ftKernelTimeEnd, &stKernel ); - FileTimeToSystemTime ( &ftUserTimeEnd, &stUser ); - FileTimeToSystemTime ( &ftTotalTimeEnd, &stTotal ); - - wsprintf ( - timeBuffer, - TEXT( "Kernel=%02d:%02d:%02d:%03d User=%02d:%02d:%02d:%03d Elapsed=%02d:%02d:%02d:%03d" ), - stKernel.wHour, stKernel.wMinute, stKernel.wSecond, stKernel.wMilliseconds, - stUser.wHour, stUser.wMinute, stUser.wSecond, stUser.wMilliseconds, - stTotal.wHour, stTotal.wMinute, stTotal.wSecond, stTotal.wMilliseconds - ); - - return timeBuffer; - -} // end WNT_StatTimer - -static __int64 __fastcall FileTimeToQuadWord ( PFILETIME pFt ) { - - __int64 qw; - - qw = pFt -> dwHighDateTime; - qw <<= 32; - qw |= pFt -> dwLowDateTime; - - return qw; - -} // end FileTimeToQuadWord - -static void __fastcall QuadWordToFileTime ( __int64 qw, PFILETIME pFt ) { - - pFt -> dwHighDateTime = ( DWORD )( qw >> 32 ); - pFt -> dwLowDateTime = ( DWORD ) ( qw & 0xFFFFFFFF ); - -} // end QuadWordToFileTime - -#if defined (_UNICODE) -#define CHR_SIZE sizeof(WORD)/2 -#else -#define CHR_SIZE sizeof(WORD) -#endif -//////////////////////////////////////////////////////////////// -LPWORD lpwAlign (LPWORD lpIn) -{ - ULONG ul; - - ul = (ULONG) lpIn; - ul +=3; - ul >>=2; - ul <<=2; - return (LPWORD) ul; -} - -int CopyAnsiToWideChar (LPWORD lpWCStr, LPSTR lpAnsiIn) -{ - int nChar = 0; - - do { - *lpWCStr++ = (WORD) *lpAnsiIn; - nChar++; - } while (*lpAnsiIn++); - - return nChar; -} - -LPWORD SetClassParams (LPWORD p, DWORD style, short x, short y, - short cx, short cy, WORD id, WORD classId) -{ - LPWORD pp = p; - *pp++ = LOWORD (style); - *pp++ = HIWORD (style); - *pp++ = 0; // LOWORD (lExtendedStyle) - *pp++ = 0; // HIWORD (lExtendedStyle) - *pp++ = x; // x - *pp++ = y; // y - *pp++ = cx; // cx - *pp++ = cy; // cy - *pp++ = id; // id - *pp++ = 0xFFFF; - *pp++ = classId; - return pp; -} - -short MapX (LONG aX) { - static LONG baseUnits = 0; - if ( !baseUnits ) { - baseUnits = GetDialogBaseUnits (); - } - return (short)(aX*4) / LOWORD (baseUnits); -} - -short MapY (LONG aY) { - static LONG baseUnits = 0; - if ( !baseUnits ) { - baseUnits = GetDialogBaseUnits (); - } - return (short)(aY*8) / HIWORD (baseUnits); -} - -#if defined(__CYGWIN32__) || defined(__MINGW32__) -#define __try -#define __finally -#define __leave return res -#endif - -LONG GetTextParams ( HDC hdc, LPCTSTR lpText ) { - LONG res = 0; - SIZE size; - _TCHAR* dummy; - __try { - dummy = _tcsdup (lpText); - if ( !dummy ) __leave; - short txtW = 0, txtH = 0; - _TCHAR* tok = _tcstok ( dummy, TEXT( "\n" ) ); - while ( tok ) { - if ( !GetTextExtentPoint32 (hdc, tok, _tcslen(tok), (LPSIZE)&size) ) __leave; - txtH += (short)size.cy; - if ( txtW < size.cx ) - txtW = (short)size.cx; - tok = _tcstok ( NULL, TEXT( "\n" ) ); - } - res = MAKELONG (MapX(txtW), MapY(txtH)); - } - - __finally { - free (dummy); - } - -#ifdef VAC -leave: ; // added for VisualAge -#endif - - return res; -} - -#if defined(__CYGWIN32__) || defined(__MINGW32__) -#undef __try -#undef __finally -#undef __leave -#endif - -/////////////////ON_COMMAND///////////////////////////////////// -void MsgBox_OnCommand (HWND hwnd, _TINT id, HWND hCtl, UINT codeNotify) { - EndDialog (hwnd, id); -} - -/////////////////ON_INIT///////////////////////////////////// -BOOL MsgBox_OnInit ( HWND hwnd, HWND hwndFocus, LPARAM lParam ) { - - SetForegroundWindow ( hwnd ); - - return TRUE; - -} // end MsgBox_OnInit -/////////////////DISPATCH_MESSAGES//////////////////////////////////// -BOOL CALLBACK MsgBoxProc (HWND hdlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) -{ - BOOL fProcessed = TRUE; - switch (uMsg) { - HANDLE_MSG (hdlg, WM_INITDIALOG, MsgBox_OnInit); - HANDLE_MSG (hdlg, WM_COMMAND, MsgBox_OnCommand); - - // Default actions - default: - fProcessed = FALSE; - break; - } - return (fProcessed); -} - -///////////////////////////////////////////////////////////////// - -#if defined(__CYGWIN32__) || defined(__MINGW32__) -#define __try -#define __finally -#define __leave return -1 -#endif - -_TINT MsgBox ( HWND hParent, - LPTSTR lpText, - LPCTSTR lpCaption, - _TINT childCount, - LPMB_DESC lpChildren - ) -{ - WORD *p = NULL, *pDlgTemplate = NULL, *pX, *pY, - *pWidth, *pHeight, *pItemsCount; - int nchar; - DWORD lStyle; - _TINT scrW = 0, scrH = 0; - UINT bufSize = 0; - HDC hDisp = NULL; - - short iconWidth = 0, iconHeight = 0; - short butCount = 0, butMaxWidth = 0, butMaxHeight = 0; - short butSpace = 8, butOffset = 0; - - __try { - /* Get dialog base units & map it to dialog units*/ - hDisp = CreateDC ( TEXT( "DISPLAY" ), NULL, NULL, NULL ); - if ( !hDisp ) __leave; - scrW = GetDeviceCaps ( hDisp, HORZRES ); - scrH = GetDeviceCaps ( hDisp, VERTRES ); - scrW = MapX (scrW); - scrH = MapY (scrH); - LONG txtParam = GetTextParams ( hDisp, lpText ); - if ( !txtParam ) __leave; - - // Calculate needed size of buffer - bufSize = 14*sizeof(WORD) + _tcslen(lpCaption)*CHR_SIZE; - bufSize += 14*sizeof(WORD) + _tcslen(lpText)*CHR_SIZE; - - _TINT i; - BOOL isIcon = FALSE; - for ( i=0; i *pWidth ) { - *pWidth = nW; - } else { - butOffset = (*pWidth - butCount*(butMaxWidth+butSpace) - butSpace) / 2; - } - *pHeight = *pHeight + butMaxHeight + 4; - // Update position of a dialog - *pX = ( scrW - (*pWidth) ) / 2; - *pY = ( scrH - (*pHeight) ) / 2; - - // Childs ============================================================ // - short butNum = 0; - for ( i=0; i -#ifdef WNT +#ifdef _WIN32 //---------------------------- Windows NT System -------------------------------- @@ -70,7 +70,7 @@ static Standard_Mutex THE_SIGNAL_MUTEX; static LONG __fastcall _osd_raise ( DWORD, LPTSTR ); static BOOL WINAPI _osd_ctrl_break_handler ( DWORD ); -extern "C" Standard_EXPORT LONG _osd_debug ( void ); +static LONG _osd_debug ( void ); MB_DESC fatalErrorDesc[] = { @@ -227,55 +227,32 @@ static LONG CallHandler (DWORD dwExceptionCode, } // end switch + // provide message to the user with possibility to stop int idx = lstrlen ( buffer ); - - if ( idx && fMsgBox && dwExceptionCode != EXCEPTION_NONCONTINUABLE_EXCEPTION ) { // reset FP operations before message box, otherwise it may fail to show up _fpreset(); _clearfp(); - MessageBeep ( MB_ICONHAND ); - int msgID = MsgBox ( NULL, buffer, TEXT( "Error detected" ), 4, fatalErrorDesc ); -// cout << "flterr" << flterr << " fFltExceptions " << fFltExceptions << endl ; - if ( flterr ) { - if ( !fFltExceptions ) - return EXCEPTION_EXECUTE_HANDLER; - _fpreset () ; - _clearfp() ; - _controlfp ( 0, _OSD_FPX ) ; // JR add : -// cout << "OSD::WntHandler _controlfp( 0, _OSD_FPX ) " << hex << _controlfp(0,0) << dec << endl ; - } - buffer[ idx ] = 0; - switch ( msgID ) { - case IDYES: { - PTCHAR ptr = _tcschr ( buffer, TEXT( '\n' ) ); - if ( ptr != NULL ) - *ptr = TEXT( ' ' ); -// cout << "CallHandler " << dwExceptionCode << endl ; - _osd_raise ( dwExceptionCode, buffer ); - } // IDYES - case IDNO: - LONG action ; - action = _osd_debug (); -// cout << "return from CallHandler -> DebugBreak " << endl ; - DebugBreak (); - _osd_raise ( dwExceptionCode, buffer ); -// cout << "CallHandler return : " << action << endl ; - return action ; - case IDCANCEL: - exit ( 0xFFFF ); - } // end switch + MessageBeep ( MB_ICONHAND ); + int aChoice = ::MessageBox (0, buffer, "OCCT Exception Handler", MB_ABORTRETRYIGNORE | MB_ICONSTOP); + if (aChoice == IDRETRY) + { + _osd_debug(); + DebugBreak(); + } + else if (aChoice == IDABORT) + exit(0xFFFF); } - else { - if ( flterr ) { - if ( !fFltExceptions ) - return EXCEPTION_EXECUTE_HANDLER; - _fpreset () ; - _clearfp() ; - _controlfp ( 0, _OSD_FPX ) ; // JR add : + + // reset FPE state + if ( flterr ) { + if ( !fFltExceptions ) + return EXCEPTION_EXECUTE_HANDLER; + _fpreset () ; + _clearfp() ; + _controlfp ( 0, _OSD_FPX ) ; // JR add : // cout << "OSD::WntHandler _controlfp( 0, _OSD_FPX ) " << hex << _controlfp(0,0) << dec << endl ; - } } return _osd_raise ( dwExceptionCode, buffer ); #else diff --git a/src/WNT/WNT_Window.cxx b/src/WNT/WNT_Window.cxx index 6c494022bb..1c42644f98 100755 --- a/src/WNT/WNT_Window.cxx +++ b/src/WNT/WNT_Window.cxx @@ -27,7 +27,7 @@ #include #include -extern "C" void _debug_break ( char* ); + //************************************************************************// //***// // callback function to manage window's background