From 682993040a473718ce5aaf1a09462c37ac8b0775 Mon Sep 17 00:00:00 2001 From: abv Date: Fri, 9 Oct 2015 11:29:18 +0300 Subject: [PATCH] 0026585: Eliminate compile warnings obtained by building occt with vc14: 'type cast' pointer truncation and 'type cast' truncation - Class OSD_EnvironmentIterator is removed (not used, and would definitely fail under Windows if tried) - Methods UserId() and GroupId() removed from OSD_FileNode (cannot be made portable, as there is no integer IDs of user and group on Windows) - Draw_ProgressIndicator corrected to properly pass address via Tcl - OSD_File.cxx: local function is refactored to avoid senseless encoding / decoding of results - OSD_Process::UserId() method removed, as it cannot be made cross-platform (no integer IDs on Windows) - OSD_Thread: use WinAPI conversion functions to avoid warnings - OSD_WNT.cxx: recursion counter passed via function argument instead of TLS - TDF_LabelMapHasher revised to use correct hasher function for an address --- src/BRepFeat/BRepFeat_MakeDPrism.cxx | 1 - src/DBRep/DBRep.cxx | 4 +- src/Draw/Draw_ProgressIndicator.cxx | 11 +- src/Draw/Draw_ProgressIndicator.hxx | 28 +-- src/OSD/FILES | 2 - src/OSD/OSD_EnvironmentIterator.cxx | 177 ------------------ src/OSD/OSD_EnvironmentIterator.hxx | 99 ---------- src/OSD/OSD_File.cxx | 124 ++++-------- src/OSD/OSD_FileNode.cxx | 119 ------------ src/OSD/OSD_FileNode.hxx | 6 - src/OSD/OSD_Process.cxx | 32 ---- src/OSD/OSD_Process.hxx | 3 - src/OSD/OSD_Thread.cxx | 6 +- src/OSD/OSD_WNT.cxx | 30 +-- .../STEPConstruct_AP203Context.cxx | 2 +- src/TDF/FILES | 2 - src/TDF/TDF_LabelMapHasher.cxx | 22 --- src/TDF/TDF_LabelMapHasher.hxx | 48 +---- src/TDF/TDF_LabelMapHasher.lxx | 40 ---- 19 files changed, 77 insertions(+), 679 deletions(-) delete mode 100644 src/OSD/OSD_EnvironmentIterator.cxx delete mode 100644 src/OSD/OSD_EnvironmentIterator.hxx delete mode 100644 src/TDF/TDF_LabelMapHasher.cxx delete mode 100644 src/TDF/TDF_LabelMapHasher.lxx diff --git a/src/BRepFeat/BRepFeat_MakeDPrism.cxx b/src/BRepFeat/BRepFeat_MakeDPrism.cxx index 172e522da4..115018837a 100644 --- a/src/BRepFeat/BRepFeat_MakeDPrism.cxx +++ b/src/BRepFeat/BRepFeat_MakeDPrism.cxx @@ -1039,7 +1039,6 @@ void BRepFeat_MakeDPrism::BossEdges (const Standard_Integer signature) for (itLS.Initialize(theLastShape);itLS.More();itLS.Next()) { const TopoDS_Face& TopFace = TopoDS::Face(itLS.Value()); if (!FF.IsSame(TopFace)) { - TopExp_Explorer ExpE; for (ExpE.Init(FF,TopAbs_EDGE);ExpE.More() && !Found ;ExpE.Next()) { const TopoDS_Edge& E1 = TopoDS::Edge(ExpE.Current()); TopoDS_Vertex V1,V2; diff --git a/src/DBRep/DBRep.cxx b/src/DBRep/DBRep.cxx index 46dd941a9a..08465d7484 100644 --- a/src/DBRep/DBRep.cxx +++ b/src/DBRep/DBRep.cxx @@ -1241,7 +1241,9 @@ static Standard_Integer XProgress (Draw_Interpretor& di, Standard_Integer argc, if ( argv[i][1] == 't' ) Draw_ProgressIndicator::DefaultTextMode() = turn; else if ( argv[i][1] == 'g' ) Draw_ProgressIndicator::DefaultGraphMode() = turn; else if ( ! strcmp ( argv[i], "-stop" ) && i+1 < argc ) { - Draw_ProgressIndicator::StopIndicator() = atol(argv[++i]); + Standard_Address aPtr = 0; + if (sscanf (argv[++i], "%p", &aPtr) == 1) + Draw_ProgressIndicator::StopIndicator() = aPtr; return 0; } } diff --git a/src/Draw/Draw_ProgressIndicator.cxx b/src/Draw/Draw_ProgressIndicator.cxx index 7cf8d1a333..ae5b983573 100644 --- a/src/Draw/Draw_ProgressIndicator.cxx +++ b/src/Draw/Draw_ProgressIndicator.cxx @@ -115,9 +115,8 @@ Standard_Boolean Draw_ProgressIndicator::Show(const Standard_Boolean force) ".xprogress.bar create rectangle 2 2 2 21 -fill blue -tags progress;" ".xprogress.bar create rectangle 2 2 2 21 -outline black -tags progress_next;" "message .xprogress.text -width 400 -text \"Progress 0%%\";" - "button .xprogress.stop -text \"Break\" -relief groove -width 9 -command {XProgress -stop %ld};" - "pack .xprogress.bar .xprogress.text .xprogress.stop -side top;", - (long)(void*)this ); + "button .xprogress.stop -text \"Break\" -relief groove -width 9 -command {XProgress -stop %p};" + "pack .xprogress.bar .xprogress.text .xprogress.stop -side top;", this ); ((Draw_Interpretor*)myDraw)->Eval ( command ); myShown = Standard_True; } @@ -146,7 +145,7 @@ Standard_Boolean Draw_ProgressIndicator::Show(const Standard_Boolean force) Standard_Boolean Draw_ProgressIndicator::UserBreak() { - if ( StopIndicator() == (long)(void*)this ) { + if ( StopIndicator() == this ) { // cout << "Progress Indicator - User Break: " << StopIndicator() << ", " << (void*)this << endl; myBreak = Standard_True; ((Draw_Interpretor*)myDraw)->Eval ( "XProgress -stop 0" ); @@ -221,9 +220,9 @@ Standard_Boolean &Draw_ProgressIndicator::DefaultGraphMode () //purpose : //======================================================================= -Standard_Integer &Draw_ProgressIndicator::StopIndicator () +Standard_Address &Draw_ProgressIndicator::StopIndicator () { - static Standard_Integer stopIndicator = 0; + static Standard_Address stopIndicator = 0; return stopIndicator; } diff --git a/src/Draw/Draw_ProgressIndicator.hxx b/src/Draw/Draw_ProgressIndicator.hxx index d11a5fcac2..ded67d148d 100644 --- a/src/Draw/Draw_ProgressIndicator.hxx +++ b/src/Draw/Draw_ProgressIndicator.hxx @@ -17,16 +17,10 @@ #define _Draw_ProgressIndicator_HeaderFile #include -#include -#include -#include -#include -#include #include #include - class Draw_ProgressIndicator; DEFINE_STANDARD_HANDLE(Draw_ProgressIndicator, Message_ProgressIndicator) @@ -79,21 +73,13 @@ public: //! Get/Set default values for output modes Standard_EXPORT static Standard_Boolean& DefaultGraphMode(); - //! Internal method for implementation of UserBreak mechanism - Standard_EXPORT static Standard_Integer& StopIndicator(); - - + //! Internal method for implementation of UserBreak mechanism; + //! note that it uses static variable and thus not thread-safe! + Standard_EXPORT static Standard_Address& StopIndicator(); DEFINE_STANDARD_RTTI(Draw_ProgressIndicator,Message_ProgressIndicator) -protected: - - - - private: - - Standard_Boolean myTextMode; Standard_Boolean myGraphMode; Standard_Address myDraw; @@ -102,14 +88,6 @@ private: Standard_Integer myUpdateTime; Standard_Size myLastUpdate; Standard_Size myStartTime; - - }; - - - - - - #endif // _Draw_ProgressIndicator_HeaderFile diff --git a/src/OSD/FILES b/src/OSD/FILES index 471e35a604..a7742466fa 100755 --- a/src/OSD/FILES +++ b/src/OSD/FILES @@ -10,8 +10,6 @@ OSD_Disk.cxx OSD_Disk.hxx OSD_Environment.cxx OSD_Environment.hxx -OSD_EnvironmentIterator.cxx -OSD_EnvironmentIterator.hxx OSD_Error.cxx OSD_Error.hxx OSD_ErrorList.hxx diff --git a/src/OSD/OSD_EnvironmentIterator.cxx b/src/OSD/OSD_EnvironmentIterator.cxx deleted file mode 100644 index 6a4af2f0c2..0000000000 --- a/src/OSD/OSD_EnvironmentIterator.cxx +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _WIN32 - -//---------- All Systems except windowsNT : ---------------------------------- - -#include -#include -#include -#include - -//const OSD_WhoAmI Iam = OSD_WEnvironmentIterator; -#ifdef __APPLE__ - #import - #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE - extern char **environ; - #else - #include - #define environ (*_NSGetEnviron()) - #endif -#else - extern char **environ; -#endif - -OSD_EnvironmentIterator::OSD_EnvironmentIterator(){ - myCount = 0; -} - -// For Windows NT compatibility - -void OSD_EnvironmentIterator::Destroy () {} - -// Is there another environment variable entry ? - -Standard_Boolean OSD_EnvironmentIterator::More(){ - if (environ[myCount+1] == NULL) return(Standard_False); - else return(Standard_True); -} - -// Find next environment variable - -void OSD_EnvironmentIterator::Next(){ - if (More()) myCount++; -} - - -OSD_Environment OSD_EnvironmentIterator::Values(){ - TCollection_AsciiString name,value; - - name = environ[myCount]; // Copy environment variable - -// Pour DEBUG cout << name << endl; - - value = &environ[myCount][name.Search("=")]; // Gets its value - if (name.Length() != 0){ - name = name.Token("="); // Gets its name - } - - OSD_Environment result(name,value); - return(result); -} - - -void OSD_EnvironmentIterator::Reset(){ - myError.Reset(); -} - -Standard_Boolean OSD_EnvironmentIterator::Failed()const{ - return( myError.Failed()); -} - -void OSD_EnvironmentIterator::Perror() { - myError.Perror(); -} - - -Standard_Integer OSD_EnvironmentIterator::Error()const{ - return( myError.Error()); -} - -#else - -//------------------------------------------------------------------------ -//------------------- Windows NT sources for OSD_Directory -------------- -//------------------------------------------------------------------------ - -#define STRICT -#include - - -#include -#include -#include - -OSD_EnvironmentIterator :: OSD_EnvironmentIterator () { - - myEnv = GetEnvironmentStrings (); - myCount = ( Standard_Integer )myEnv; - -} // end constructor - -void OSD_EnvironmentIterator :: Destroy () { - - FreeEnvironmentStrings ( ( LPTSTR )myEnv ); - -} // end OSD_EnvironmentIterator :: Destroy - -Standard_Boolean OSD_EnvironmentIterator :: More () { - - return *( ( Standard_CString )myCount ) ? Standard_True : Standard_False; - -} // end OSD_EnvironmentIterator :: More - -void OSD_EnvironmentIterator :: Next () { - - if ( More () ) { - - while ( *( Standard_CString )myCount ) ++myCount; - - ++myCount; - - } // end if - -} // end OSD_EnvironmentIterator :: Next - -OSD_Environment OSD_EnvironmentIterator :: Values () { - - TCollection_AsciiString env, name, value; - - env = ( Standard_CString )myCount; - - name = env.Token ( TEXT( "=" ), 1 ); - value = env.Token ( TEXT( "=" ), 2 ); - - if ( env.Value ( 1 ) == TEXT( '=' ) ) name.Insert ( 1, TEXT( '=' ) ); - - return OSD_Environment ( name, value ); - -} // end OSD_EnvironmentIterator :: Values - -Standard_Boolean OSD_EnvironmentIterator :: Failed () const { - - return myError.Failed (); - -} // end OSD_EnvironmentIterator :: Failed - -void OSD_EnvironmentIterator :: Reset () { - - myError.Reset (); - -} // end OSD_EnvironmentIterator :: Reset - -void OSD_EnvironmentIterator :: Perror () { - - myError.Perror (); - -} // end OSD_EnvironmentIterator :: Perror - -Standard_Integer OSD_EnvironmentIterator :: Error () const { - - return myError.Error (); - -} // end OSD_EnvironmentIterator :: Error - -#endif diff --git a/src/OSD/OSD_EnvironmentIterator.hxx b/src/OSD/OSD_EnvironmentIterator.hxx deleted file mode 100644 index 46824fbffe..0000000000 --- a/src/OSD/OSD_EnvironmentIterator.hxx +++ /dev/null @@ -1,99 +0,0 @@ -// Created on: 1992-09-11 -// Created by: Stephan GARNAUD -// Copyright (c) 1992-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _OSD_EnvironmentIterator_HeaderFile -#define _OSD_EnvironmentIterator_HeaderFile - -#include -#include -#include - -#include -#include -#include -#include -class OSD_OSDError; -class OSD_Environment; - - -//! This allows consultation of every environment variable. -//! There is no specific order of results. -class OSD_EnvironmentIterator -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! Instantiates Object as Iterator; - Standard_EXPORT OSD_EnvironmentIterator(); - - Standard_EXPORT void Destroy(); -~OSD_EnvironmentIterator() -{ - Destroy(); -} - - //! Returns TRUE if there are other environment variables. - Standard_EXPORT Standard_Boolean More(); - - //! Sets the iterator to the next item. - //! Returns the item value corresponding to the current - //! position of the iterator. - Standard_EXPORT void Next(); - - //! Returns the next environment variable found. - Standard_EXPORT OSD_Environment Values(); - - //! Returns TRUE if an error occurs - Standard_EXPORT Standard_Boolean Failed() const; - - //! Resets error counter to zero - Standard_EXPORT void Reset(); - - //! Raises OSD_Error - Standard_EXPORT void Perror(); - - //! Returns error number if 'Failed' is TRUE. - Standard_EXPORT Standard_Integer Error() const; - - - - -protected: - - - - - -private: - - - - Standard_Address myEnv; - Standard_Integer myCount; - OSD_Error myError; - - -}; - - - - - - - -#endif // _OSD_EnvironmentIterator_HeaderFile diff --git a/src/OSD/OSD_File.cxx b/src/OSD/OSD_File.cxx index c26b39edb9..01e986ed53 100644 --- a/src/OSD/OSD_File.cxx +++ b/src/OSD/OSD_File.cxx @@ -852,7 +852,7 @@ BOOL __fastcall _osd_wnt_sd_to_protection ( BOOL __fastcall _osd_print (const Standard_PCharacter, const wchar_t* ); static void __fastcall _test_raise ( HANDLE, Standard_CString ); -static DWORDLONG __fastcall _get_line ( Standard_PCharacter&, DWORD ); +static Standard_Integer __fastcall _get_line (Standard_PCharacter& buffer, DWORD dwBuffSize, LONG& theSeekPos); static int __fastcall _get_buffer ( HANDLE, Standard_PCharacter&, DWORD, BOOL, BOOL ); static DWORD __fastcall _get_access_mask ( OSD_SingleProtection ); static DWORD __fastcall _get_dir_access_mask ( OSD_SingleProtection prt ); @@ -1068,14 +1068,12 @@ void OSD_File :: ReadLine ( const Standard_Integer NByte, Standard_Integer& NbyteRead ) { - DWORDLONG status; DWORD dwBytesRead; DWORD dwDummy; Standard_Character peekChar; Standard_PCharacter ppeekChar; Standard_PCharacter cBuffer; - Standard_CString eos; - DWORD dwSeekPos; + LONG aSeekPos; if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) { Standard_ProgramError::Raise("OSD_File::Read : it is a directory"); @@ -1096,7 +1094,7 @@ void OSD_File :: ReadLine ( if ( myIO & FLAG_FILE ) { - if (!ReadFile (myFileHandle, cBuffer, (DWORD)NByte, &dwBytesRead, NULL)) { // an error occured + if (!ReadFile (myFileHandle, cBuffer, NByte, &dwBytesRead, NULL)) { // an error occured _osd_wnt_set_error ( myError, OSD_WFile ); Buffer.Clear (); @@ -1110,16 +1108,10 @@ void OSD_File :: ReadLine ( } else { myIO &= ~FLAG_EOF ; // if the file increased since last read (LD) - status = _get_line ( cBuffer, dwBytesRead ); + NbyteRead = _get_line (cBuffer, dwBytesRead, aSeekPos); - dwSeekPos = LODWORD( status ); - eos = ( Standard_CString )HIDWORD( status ); -#ifdef VAC - if ( (__int64) status == (__int64) -1 ) { // last character in the buffer is - -#else - if ( status == 0xFFFFFFFFFFFFFFFF ) { // last character in the buffer is - - // peek next character to see if it is a -#endif + if ( NbyteRead == -1 ) // last character in the buffer is - + { // peek next character to see if it is a if (!ReadFile (myFileHandle, ppeekChar, 1, &dwDummy, NULL)) { _osd_wnt_set_error ( myError, OSD_WFile ); @@ -1137,13 +1129,9 @@ void OSD_File :: ReadLine ( NbyteRead = dwBytesRead; - } else { - - if ( dwSeekPos != 0 ) - SetFilePointer (myFileHandle, (LONG)dwSeekPos, NULL, FILE_CURRENT); - - NbyteRead = ( Standard_Integer )( eos - cBuffer ); - + } else if ( aSeekPos != 0 ) + { + SetFilePointer (myFileHandle, aSeekPos, NULL, FILE_CURRENT); } } // end else @@ -1167,18 +1155,10 @@ void OSD_File :: ReadLine ( } else { - status = _get_line ( cBuffer, dwBytesRead ); - - dwSeekPos = LODWORD( status ); - eos = ( Standard_CString )HIDWORD( status ); - -#ifdef VAC - if ( (__int64) status == (__int64) -1 ) { // last character in the buffer is - -#else - if ( status == 0xFFFFFFFFFFFFFFFF ) { // last character in the buffer is - - // peek next character to see if it is a -#endif + NbyteRead = _get_line (cBuffer, dwBytesRead, aSeekPos); + if (NbyteRead == -1) // last character in the buffer is - + { // peek next character to see if it is a NbyteRead = dwBytesRead; // (LD) always fits this case. dwDummy = _get_buffer (myFileHandle, ppeekChar, 1, TRUE, myIO & FLAG_SOCKET); @@ -1195,13 +1175,9 @@ void OSD_File :: ReadLine ( myIO |= FLAG_EOF; - } else { - - if ( dwSeekPos != 0 ) - dwBytesRead = dwBytesRead + dwSeekPos; - - NbyteRead = ( Standard_Integer )( eos - cBuffer ); - + } else if (aSeekPos != 0) + { + dwBytesRead = dwBytesRead + aSeekPos; } // Don't rewrite datas in cBuffer. @@ -1957,12 +1933,11 @@ static void __fastcall _test_raise ( HANDLE hFile, Standard_CString str ) { } // end _test_raise -// Modified so that we have at end of line if we have read or -// by LD 17 dec 98 for B4.4 - -static DWORDLONG __fastcall _get_line ( Standard_PCharacter& buffer, DWORD dwBuffSize ) { +// Returns number of bytes in the string (including end \n, but excluding \r); +// +static Standard_Integer __fastcall _get_line (Standard_PCharacter& buffer, DWORD dwBuffSize, LONG& theSeekPos) +{ - DWORDLONG retVal; Standard_PCharacter ptr; buffer[ dwBuffSize ] = 0; @@ -1970,55 +1945,30 @@ static DWORDLONG __fastcall _get_line ( Standard_PCharacter& buffer, DWORD dwBuf while ( *ptr != 0 ) { - if ( *ptr == '\n' ) { - - ptr++ ; // jump newline char. - *ptr = 0 ; - retVal = ptr - buffer - dwBuffSize; - retVal &= 0x0000000FFFFFFFF;// import 32-bit to 64-bit -#ifdef VAC - retVal = (DWORDLONG) ( (unsigned __int64) retVal | (((unsigned __int64) ptr) << 32) ); -#else - retVal |= ( ( ( DWORDLONG )( DWORD )ptr ) << 32 ); -#endif - return retVal; - - } else if ( *ptr == '\r' && ptr[ 1 ] == '\n' ) { - - *(ptr++) = '\n' ; // Substitue carriage return by newline. - *ptr = 0 ; - retVal = ptr + 1 - buffer - dwBuffSize; - retVal &= 0x0000000FFFFFFFF;// import 32-bit to 64-bit -#ifdef VAC - retVal = (DWORDLONG) ( (unsigned __int64) retVal | (((unsigned __int64) ptr) << 32) ); -#else - retVal |= ( ( ( DWORDLONG )( DWORD )ptr ) << 32 ); -#endif - return retVal; - - } else if ( *ptr == '\r' && ptr[ 1 ] == 0 ) { + if ( *ptr == '\n' ) + { + ptr++ ; // jump newline char. + *ptr = 0 ; + theSeekPos = (LONG)(ptr - buffer - dwBuffSize); + return (Standard_Integer)(ptr - buffer); + } + else if ( *ptr == '\r' && ptr[ 1 ] == '\n' ) + { + *(ptr++) = '\n' ; // Substitue carriage return by newline. + *ptr = 0 ; + theSeekPos = (LONG)(ptr + 1 - buffer - dwBuffSize); + return (Standard_Integer)(ptr - buffer); + } + else if ( *ptr == '\r' && ptr[ 1 ] == 0 ) { *ptr = '\n' ; // Substitue carriage return by newline - -#ifdef VAC - return (DWORDLONG) (__int64) (-1); -#else - return 0xFFFFFFFFFFFFFFFF; -#endif + return -1; } ++ptr; } // end while -#ifdef VAC - retVal = (DWORDLONG) ( ( (unsigned __int64) ((DWORD) buffer + dwBuffSize) ) << 32 ); - retVal = (DWORDLONG) ( (unsigned __int64) retVal & (((unsigned __int64) 0xFFFFFFFF) << 32) ); -#else - retVal = ( ( ( DWORDLONG )( ( DWORD )buffer + dwBuffSize ) ) << 32 ); - retVal &= 0xFFFFFFFF00000000; -#endif - - return retVal; - + theSeekPos = 0; + return dwBuffSize; } // end _get_line static int __fastcall _get_buffer ( diff --git a/src/OSD/OSD_FileNode.cxx b/src/OSD/OSD_FileNode.cxx index e30439846c..ebf969456d 100644 --- a/src/OSD/OSD_FileNode.cxx +++ b/src/OSD/OSD_FileNode.cxx @@ -282,50 +282,6 @@ int status; if (status == -1) myError.SetValue (errno, Iam, "SetProtection"); } - - -// Returns User Id - -Standard_Integer OSD_FileNode::UserId(){ -struct stat buffer; - -// if (myPath.Name().Length()==0) -// OSD_OSDError::Raise("OSD_FileNode::UserId : no name was given"); - -// if (Failed()) Perror(); - - /* Get File Informations */ - - TCollection_AsciiString aBuffer; - myPath.SystemName ( aBuffer ); - stat ( aBuffer.ToCString(), &buffer ); - - return ( buffer.st_uid ); -} - - -// Returns Group Id - -Standard_Integer OSD_FileNode::GroupId(){ -struct stat buffer; - -// if (myPath.Name().Length()==0) -// OSD_OSDError::Raise("OSD_FileNode::GroupId : no name was given"); - -// if (Failed()) Perror(); - - /* Get File Informations */ - - TCollection_AsciiString aBuffer; - myPath.SystemName ( aBuffer ); - stat ( aBuffer.ToCString(), &buffer ); - - return ( buffer.st_gid ); -} - - - - // return the date of last access of file/directory Quantity_Date OSD_FileNode::CreationMoment(){ @@ -806,81 +762,6 @@ Quantity_Date OSD_FileNode::CreationMoment () { } // end OSD_FileNode :: CreationMoment -//======================================================================= -//function : UserId -//purpose : -//======================================================================= - -Standard_Integer OSD_FileNode::UserId () { - - PSID pSIDowner = NULL; - PSID retVal = NULL; - BOOL fDefaulted; - TCollection_AsciiString fName; - PSECURITY_DESCRIPTOR pSD; - - myPath.SystemName ( fName ); - TCollection_ExtendedString fNameW(fName); - - TEST_RAISE( "UserId" ); - - if ( ( pSD = GetFileSecurityEx ( - (const wchar_t*) fNameW.ToExtString (), - OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION - ) - ) != NULL && - GetSecurityDescriptorOwner ( pSD, &pSIDowner, &fDefaulted ) && - pSIDowner != NULL - ) - - retVal = CopySidEx ( pSIDowner ); - - else - - _osd_wnt_set_error ( myError, OSD_WFileNode ); - - if ( pSD != NULL ) - - FreeFileSecurity ( pSD ); - - return ( Standard_Integer )retVal; - -} // end OSD_FileNode :: UserId - -//======================================================================= -//function : GroupId -//purpose : -//======================================================================= - -Standard_Integer OSD_FileNode::GroupId () { - - PGROUP_SID retVal = NULL; - TCollection_AsciiString fName; - PSECURITY_DESCRIPTOR pSD; - - myPath.SystemName ( fName ); - TCollection_ExtendedString fNameW(fName); - - TEST_RAISE( "GroupId" ); - - if ( ( pSD = GetFileSecurityEx ( - (const wchar_t*) fNameW.ToExtString (), - OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION - ) - ) != NULL - ) { - - retVal = AllocGroupSid ( pSD ); - FreeFileSecurity ( pSD ); - - } else - - _osd_wnt_set_error ( myError, OSD_WFileNode ); - - return ( Standard_Integer )retVal; - -} // end OSD_FileNode :: GroupId - //======================================================================= //function : Failed //purpose : diff --git a/src/OSD/OSD_FileNode.hxx b/src/OSD/OSD_FileNode.hxx index 067e8ccda8..99dcd78dc6 100644 --- a/src/OSD/OSD_FileNode.hxx +++ b/src/OSD/OSD_FileNode.hxx @@ -74,12 +74,6 @@ public: //! same value. Standard_EXPORT Quantity_Date CreationMoment(); - //! Returns User Identification. - Standard_EXPORT Standard_Integer UserId(); - - //! Returns Group Identification. - Standard_EXPORT Standard_Integer GroupId(); - //! Returns TRUE if an error occurs Standard_EXPORT Standard_Boolean Failed() const; diff --git a/src/OSD/OSD_Process.cxx b/src/OSD/OSD_Process.cxx index 9eb168ba2a..251af5e91d 100644 --- a/src/OSD/OSD_Process.cxx +++ b/src/OSD/OSD_Process.cxx @@ -85,12 +85,6 @@ Standard_Integer OSD_Process::ProcessId(){ return (getpid()); } - -Standard_Integer OSD_Process::UserId(){ - return (getuid()); -} - - TCollection_AsciiString OSD_Process::UserName(){ struct passwd *infos; infos = getpwuid(getuid()); @@ -272,32 +266,6 @@ Quantity_Date OSD_Process :: SystemDate () { } // end OSD_Process :: SystemDate -Standard_Integer OSD_Process :: UserId () { - - PSID retVal = NULL; - HANDLE hProcessToken = INVALID_HANDLE_VALUE; - PTOKEN_OWNER pTKowner = NULL; - - if ( !OpenProcessToken ( - GetCurrentProcess (), - TOKEN_QUERY, &hProcessToken - ) || - ( pTKowner = ( PTOKEN_OWNER )GetTokenInformationEx ( - hProcessToken, TokenOwner - ) - ) == NULL || - ( retVal = CopySidEx ( pTKowner -> Owner ) ) == NULL - ) - - _osd_wnt_set_error ( myError, OSD_WProcess ); - - if ( hProcessToken != INVALID_HANDLE_VALUE ) CloseHandle ( hProcessToken ); - if ( pTKowner != NULL ) FreeTokenInformation ( pTKowner ); - - return ( Standard_Integer )retVal; - -} // end OSD_Process :: UserId - TCollection_AsciiString OSD_Process :: UserName () { Standard_PCharacter pBuff = new char[UNLEN + 1]; diff --git a/src/OSD/OSD_Process.hxx b/src/OSD/OSD_Process.hxx index 4f6bb79de1..5095b87aa9 100644 --- a/src/OSD/OSD_Process.hxx +++ b/src/OSD/OSD_Process.hxx @@ -51,9 +51,6 @@ public: //! Gets system date. Standard_EXPORT Quantity_Date SystemDate(); - //! Returns the 'User Id'. - Standard_EXPORT Standard_Integer UserId(); - //! Returns the user name. Standard_EXPORT TCollection_AsciiString UserName(); diff --git a/src/OSD/OSD_Thread.cxx b/src/OSD/OSD_Thread.cxx index 35f2a08798..598fa5717e 100644 --- a/src/OSD/OSD_Thread.cxx +++ b/src/OSD/OSD_Thread.cxx @@ -137,7 +137,7 @@ static DWORD WINAPI WNTthread_func (LPVOID data) WNTthread_data *adata = (WNTthread_data*)data; void* ret = adata->func ( adata->data ); free ( adata ); - return (DWORD)ret; + return PtrToLong (ret); } #endif @@ -243,7 +243,7 @@ Standard_Boolean OSD_Thread::Wait (Standard_Address &result) const // and convert result of the thread execution to Standard_Address DWORD anExitCode; if ( GetExitCodeThread ( myThread, &anExitCode ) ) - result = (Standard_Address)anExitCode; + result = ULongToPtr (anExitCode); return Standard_True; #else @@ -273,7 +273,7 @@ Standard_Boolean OSD_Thread::Wait (const Standard_Integer time, Standard_Address { DWORD anExitCode; if ( GetExitCodeThread ( myThread, &anExitCode ) ) - result = (Standard_Address)anExitCode; + result = ULongToPtr (anExitCode); return Standard_True; } else if (ret == WAIT_TIMEOUT) diff --git a/src/OSD/OSD_WNT.cxx b/src/OSD/OSD_WNT.cxx index 06b9b23f38..9a55ba585f 100644 --- a/src/OSD/OSD_WNT.cxx +++ b/src/OSD/OSD_WNT.cxx @@ -28,13 +28,11 @@ /***/ static void Init ( void ); /***/ -static DWORD dwLevel; -/***/ class Init_OSD_WNT { // provides initialization public: - Init_OSD_WNT () { Init (); dwLevel = TlsAlloc (); } + Init_OSD_WNT () { Init (); } }; // end Init_OSD_WNT @@ -897,7 +895,7 @@ void FreeAce ( PVOID pACE ) { /* Returns : TRUE on success, FALSE otherwise */ /******************************************************************************/ /***/ -BOOL MoveDirectory ( LPCWSTR oldDir, LPCWSTR newDir ) { +static BOOL MoveDirectory ( LPCWSTR oldDir, LPCWSTR newDir, DWORD& theRecurseLevel ) { PWIN32_FIND_DATAW pFD; LPWSTR pName; @@ -909,12 +907,10 @@ BOOL MoveDirectory ( LPCWSTR oldDir, LPCWSTR newDir ) { BOOL fFind; BOOL retVal = FALSE; DIR_RESPONSE response; - DWORD level; - if ( ( level = ( DWORD )TlsGetValue ( dwLevel ) ) == NULL ) { + if (theRecurseLevel == 0) { - ++level; - TlsSetValue ( dwLevel, ( LPVOID )level ); + ++theRecurseLevel; fFind = FALSE; driveSrc = driveDst = pathSrc = pathDst = NULL; @@ -968,16 +964,14 @@ retry: if ( fFind ) { - --level; - TlsSetValue ( dwLevel, ( LPVOID )level ); + --theRecurseLevel; return retVal; } // end if } else { - ++level; - TlsSetValue ( dwLevel, ( LPVOID )level ); + ++theRecurseLevel; } // end else @@ -1039,7 +1033,7 @@ retry: if ( pFD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { - retVal = MoveDirectory ( pFullNameSrc, pFullNameDst ); + retVal = MoveDirectory ( pFullNameSrc, pFullNameDst, theRecurseLevel ); if (!retVal) break; } else { @@ -1121,12 +1115,18 @@ retry_2: } /* end if */ - --level; - TlsSetValue ( dwLevel, ( LPVOID )level ); + --theRecurseLevel; return retVal; } /* end MoveDirectory */ + +BOOL MoveDirectory (LPCWSTR oldDir, LPCWSTR newDir) +{ + DWORD aRecurseLevel = 0; + return MoveDirectory (oldDir, newDir, aRecurseLevel); +} + /***/ /******************************************************************************/ /* Function : CopyDirectory */ diff --git a/src/STEPConstruct/STEPConstruct_AP203Context.cxx b/src/STEPConstruct/STEPConstruct_AP203Context.cxx index d57da3a770..666688945e 100644 --- a/src/STEPConstruct/STEPConstruct_AP203Context.cxx +++ b/src/STEPConstruct/STEPConstruct_AP203Context.cxx @@ -224,7 +224,7 @@ Handle(StepBasic_PersonAndOrganization) STEPConstruct_AP203Context::DefaultPerso Handle(StepBasic_Person) aPerson = new StepBasic_Person; Handle(TCollection_HAsciiString) uid = new TCollection_HAsciiString ( orgId ); uid->AssignCat ( "," ); - uid->AssignCat ( TCollection_AsciiString ( sys.UserId() ).ToCString() ); + uid->AssignCat (sys.UserName().ToCString()); Handle(Interface_HArray1OfHAsciiString) suffix, prefix; aPerson->Init ( uid, Standard_True, lname, Standard_True, fname, ( ! mname.IsNull() ), mname, Standard_False, suffix, Standard_False, prefix ); diff --git a/src/TDF/FILES b/src/TDF/FILES index 54ffddeb7e..581f1bcf9a 100755 --- a/src/TDF/FILES +++ b/src/TDF/FILES @@ -80,9 +80,7 @@ TDF_LabelIndexedMap.hxx TDF_LabelIntegerMap.hxx TDF_LabelList.hxx TDF_LabelMap.hxx -TDF_LabelMapHasher.cxx TDF_LabelMapHasher.hxx -TDF_LabelMapHasher.lxx TDF_LabelNode.cxx TDF_LabelNode.hxx TDF_LabelNodePtr.hxx diff --git a/src/TDF/TDF_LabelMapHasher.cxx b/src/TDF/TDF_LabelMapHasher.cxx deleted file mode 100644 index 3b28b6c4c9..0000000000 --- a/src/TDF/TDF_LabelMapHasher.cxx +++ /dev/null @@ -1,22 +0,0 @@ -// Created by: DAUTRY Philippe -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -// ---------------------- -// Version: 0.0 -//Version Date Purpose -// 0.0 Feb 13 1997 Creation - -#include -#include diff --git a/src/TDF/TDF_LabelMapHasher.hxx b/src/TDF/TDF_LabelMapHasher.hxx index 63c0fe6828..c7840d2498 100644 --- a/src/TDF/TDF_LabelMapHasher.hxx +++ b/src/TDF/TDF_LabelMapHasher.hxx @@ -16,54 +16,26 @@ #ifndef _TDF_LabelMapHasher_HeaderFile #define _TDF_LabelMapHasher_HeaderFile -#include -#include -#include - -#include -#include -class TDF_Label; - +#include //! A label hasher for label maps. class TDF_LabelMapHasher { public: - DEFINE_STANDARD_ALLOC + //! Returns a HasCode value for the Key in the range 0..Upper. + static Standard_Integer HashCode(const TDF_Label& aLab, const Standard_Integer Upper) + { + return ::HashCode((Standard_Address)aLab.myLabelNode, Upper); + } - - //! Returns a HasCode value for the Key in the - //! range 0..Upper. - static Standard_Integer HashCode (const TDF_Label& aLab, const Standard_Integer Upper); - //! Returns True when the two keys are the same. Two //! same keys must have the same hashcode, the //! contrary is not necessary. - static Standard_Boolean IsEqual (const TDF_Label& aLab1, const TDF_Label& aLab2); - - - - -protected: - - - - - -private: - - - - - + static Standard_Boolean IsEqual(const TDF_Label& aLab1, const TDF_Label& aLab2) + { + return aLab1.IsEqual(aLab2); + } }; - -#include - - - - - #endif // _TDF_LabelMapHasher_HeaderFile diff --git a/src/TDF/TDF_LabelMapHasher.lxx b/src/TDF/TDF_LabelMapHasher.lxx deleted file mode 100644 index dccf6c6706..0000000000 --- a/src/TDF/TDF_LabelMapHasher.lxx +++ /dev/null @@ -1,40 +0,0 @@ -// Created by: DAUTRY Philippe -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -// ---------------------- - -// Version: 0.0 -//Version Date Purpose -// 0.0 Feb 13 1997 Creation - - -//======================================================================= -//function : HashCode -//purpose : -//======================================================================= - -inline Standard_Integer TDF_LabelMapHasher::HashCode -(const TDF_Label& aLab, const Standard_Integer Upper) -{ return 1 + ( (int) (labs((long int) aLab.myLabelNode) % Upper) ); } - - -//======================================================================= -//function : IsEqual -//purpose : -//======================================================================= - -inline Standard_Boolean TDF_LabelMapHasher::IsEqual -(const TDF_Label& aLab1,const TDF_Label& aLab2) -{ return aLab1.IsEqual(aLab2); } -- 2.39.5