1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

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
This commit is contained in:
abv 2015-10-09 11:29:18 +03:00 committed by bugmaster
parent 2f220b97b7
commit 682993040a
19 changed files with 77 additions and 679 deletions

View File

@ -1039,7 +1039,6 @@ void BRepFeat_MakeDPrism::BossEdges (const Standard_Integer signature)
for (itLS.Initialize(theLastShape);itLS.More();itLS.Next()) { for (itLS.Initialize(theLastShape);itLS.More();itLS.Next()) {
const TopoDS_Face& TopFace = TopoDS::Face(itLS.Value()); const TopoDS_Face& TopFace = TopoDS::Face(itLS.Value());
if (!FF.IsSame(TopFace)) { if (!FF.IsSame(TopFace)) {
TopExp_Explorer ExpE;
for (ExpE.Init(FF,TopAbs_EDGE);ExpE.More() && !Found ;ExpE.Next()) { for (ExpE.Init(FF,TopAbs_EDGE);ExpE.More() && !Found ;ExpE.Next()) {
const TopoDS_Edge& E1 = TopoDS::Edge(ExpE.Current()); const TopoDS_Edge& E1 = TopoDS::Edge(ExpE.Current());
TopoDS_Vertex V1,V2; TopoDS_Vertex V1,V2;

View File

@ -1241,7 +1241,9 @@ static Standard_Integer XProgress (Draw_Interpretor& di, Standard_Integer argc,
if ( argv[i][1] == 't' ) Draw_ProgressIndicator::DefaultTextMode() = turn; if ( argv[i][1] == 't' ) Draw_ProgressIndicator::DefaultTextMode() = turn;
else if ( argv[i][1] == 'g' ) Draw_ProgressIndicator::DefaultGraphMode() = turn; else if ( argv[i][1] == 'g' ) Draw_ProgressIndicator::DefaultGraphMode() = turn;
else if ( ! strcmp ( argv[i], "-stop" ) && i+1 < argc ) { 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; return 0;
} }
} }

View File

@ -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 -fill blue -tags progress;"
".xprogress.bar create rectangle 2 2 2 21 -outline black -tags progress_next;" ".xprogress.bar create rectangle 2 2 2 21 -outline black -tags progress_next;"
"message .xprogress.text -width 400 -text \"Progress 0%%\";" "message .xprogress.text -width 400 -text \"Progress 0%%\";"
"button .xprogress.stop -text \"Break\" -relief groove -width 9 -command {XProgress -stop %ld};" "button .xprogress.stop -text \"Break\" -relief groove -width 9 -command {XProgress -stop %p};"
"pack .xprogress.bar .xprogress.text .xprogress.stop -side top;", "pack .xprogress.bar .xprogress.text .xprogress.stop -side top;", this );
(long)(void*)this );
((Draw_Interpretor*)myDraw)->Eval ( command ); ((Draw_Interpretor*)myDraw)->Eval ( command );
myShown = Standard_True; myShown = Standard_True;
} }
@ -146,7 +145,7 @@ Standard_Boolean Draw_ProgressIndicator::Show(const Standard_Boolean force)
Standard_Boolean Draw_ProgressIndicator::UserBreak() Standard_Boolean Draw_ProgressIndicator::UserBreak()
{ {
if ( StopIndicator() == (long)(void*)this ) { if ( StopIndicator() == this ) {
// cout << "Progress Indicator - User Break: " << StopIndicator() << ", " << (void*)this << endl; // cout << "Progress Indicator - User Break: " << StopIndicator() << ", " << (void*)this << endl;
myBreak = Standard_True; myBreak = Standard_True;
((Draw_Interpretor*)myDraw)->Eval ( "XProgress -stop 0" ); ((Draw_Interpretor*)myDraw)->Eval ( "XProgress -stop 0" );
@ -221,9 +220,9 @@ Standard_Boolean &Draw_ProgressIndicator::DefaultGraphMode ()
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Integer &Draw_ProgressIndicator::StopIndicator () Standard_Address &Draw_ProgressIndicator::StopIndicator ()
{ {
static Standard_Integer stopIndicator = 0; static Standard_Address stopIndicator = 0;
return stopIndicator; return stopIndicator;
} }

View File

@ -17,16 +17,10 @@
#define _Draw_ProgressIndicator_HeaderFile #define _Draw_ProgressIndicator_HeaderFile
#include <Standard.hxx> #include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Address.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Size.hxx>
#include <Message_ProgressIndicator.hxx> #include <Message_ProgressIndicator.hxx>
#include <Draw_Interpretor.hxx> #include <Draw_Interpretor.hxx>
class Draw_ProgressIndicator; class Draw_ProgressIndicator;
DEFINE_STANDARD_HANDLE(Draw_ProgressIndicator, Message_ProgressIndicator) DEFINE_STANDARD_HANDLE(Draw_ProgressIndicator, Message_ProgressIndicator)
@ -79,21 +73,13 @@ public:
//! Get/Set default values for output modes //! Get/Set default values for output modes
Standard_EXPORT static Standard_Boolean& DefaultGraphMode(); Standard_EXPORT static Standard_Boolean& DefaultGraphMode();
//! Internal method for implementation of UserBreak mechanism //! Internal method for implementation of UserBreak mechanism;
Standard_EXPORT static Standard_Integer& StopIndicator(); //! note that it uses static variable and thus not thread-safe!
Standard_EXPORT static Standard_Address& StopIndicator();
DEFINE_STANDARD_RTTI(Draw_ProgressIndicator,Message_ProgressIndicator) DEFINE_STANDARD_RTTI(Draw_ProgressIndicator,Message_ProgressIndicator)
protected:
private: private:
Standard_Boolean myTextMode; Standard_Boolean myTextMode;
Standard_Boolean myGraphMode; Standard_Boolean myGraphMode;
Standard_Address myDraw; Standard_Address myDraw;
@ -102,14 +88,6 @@ private:
Standard_Integer myUpdateTime; Standard_Integer myUpdateTime;
Standard_Size myLastUpdate; Standard_Size myLastUpdate;
Standard_Size myStartTime; Standard_Size myStartTime;
}; };
#endif // _Draw_ProgressIndicator_HeaderFile #endif // _Draw_ProgressIndicator_HeaderFile

View File

@ -10,8 +10,6 @@ OSD_Disk.cxx
OSD_Disk.hxx OSD_Disk.hxx
OSD_Environment.cxx OSD_Environment.cxx
OSD_Environment.hxx OSD_Environment.hxx
OSD_EnvironmentIterator.cxx
OSD_EnvironmentIterator.hxx
OSD_Error.cxx OSD_Error.cxx
OSD_Error.hxx OSD_Error.hxx
OSD_ErrorList.hxx OSD_ErrorList.hxx

View File

@ -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 <OSD_Environment.hxx>
#include <OSD_EnvironmentIterator.hxx>
#include <OSD_OSDError.hxx>
#include <OSD_WhoAmI.hxx>
//const OSD_WhoAmI Iam = OSD_WEnvironmentIterator;
#ifdef __APPLE__
#import <TargetConditionals.h>
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
extern char **environ;
#else
#include <crt_externs.h>
#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 <windows.h>
#include <OSD_Environment.hxx>
#include <OSD_EnvironmentIterator.hxx>
#include <OSD_OSDError.hxx>
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

View File

@ -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 <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Address.hxx>
#include <Standard_Integer.hxx>
#include <OSD_Error.hxx>
#include <Standard_Boolean.hxx>
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

View File

@ -852,7 +852,7 @@ BOOL __fastcall _osd_wnt_sd_to_protection (
BOOL __fastcall _osd_print (const Standard_PCharacter, const wchar_t* ); BOOL __fastcall _osd_print (const Standard_PCharacter, const wchar_t* );
static void __fastcall _test_raise ( HANDLE, Standard_CString ); 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 int __fastcall _get_buffer ( HANDLE, Standard_PCharacter&, DWORD, BOOL, BOOL );
static DWORD __fastcall _get_access_mask ( OSD_SingleProtection ); static DWORD __fastcall _get_access_mask ( OSD_SingleProtection );
static DWORD __fastcall _get_dir_access_mask ( OSD_SingleProtection prt ); 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 const Standard_Integer NByte, Standard_Integer& NbyteRead
) { ) {
DWORDLONG status;
DWORD dwBytesRead; DWORD dwBytesRead;
DWORD dwDummy; DWORD dwDummy;
Standard_Character peekChar; Standard_Character peekChar;
Standard_PCharacter ppeekChar; Standard_PCharacter ppeekChar;
Standard_PCharacter cBuffer; Standard_PCharacter cBuffer;
Standard_CString eos; LONG aSeekPos;
DWORD dwSeekPos;
if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) { if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) {
Standard_ProgramError::Raise("OSD_File::Read : it is a directory"); Standard_ProgramError::Raise("OSD_File::Read : it is a directory");
@ -1096,7 +1094,7 @@ void OSD_File :: ReadLine (
if ( myIO & FLAG_FILE ) { 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 ); _osd_wnt_set_error ( myError, OSD_WFile );
Buffer.Clear (); Buffer.Clear ();
@ -1110,16 +1108,10 @@ void OSD_File :: ReadLine (
} else { } else {
myIO &= ~FLAG_EOF ; // if the file increased since last read (LD) 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 ); if ( NbyteRead == -1 ) // last character in the buffer is <CR> -
eos = ( Standard_CString )HIDWORD( status ); { // peek next character to see if it is a <LF>
#ifdef VAC
if ( (__int64) status == (__int64) -1 ) { // last character in the buffer is <CR> -
#else
if ( status == 0xFFFFFFFFFFFFFFFF ) { // last character in the buffer is <CR> -
// peek next character to see if it is a <LF>
#endif
if (!ReadFile (myFileHandle, ppeekChar, 1, &dwDummy, NULL)) { if (!ReadFile (myFileHandle, ppeekChar, 1, &dwDummy, NULL)) {
_osd_wnt_set_error ( myError, OSD_WFile ); _osd_wnt_set_error ( myError, OSD_WFile );
@ -1137,13 +1129,9 @@ void OSD_File :: ReadLine (
NbyteRead = dwBytesRead; NbyteRead = dwBytesRead;
} else { } else if ( aSeekPos != 0 )
{
if ( dwSeekPos != 0 ) SetFilePointer (myFileHandle, aSeekPos, NULL, FILE_CURRENT);
SetFilePointer (myFileHandle, (LONG)dwSeekPos, NULL, FILE_CURRENT);
NbyteRead = ( Standard_Integer )( eos - cBuffer );
} }
} // end else } // end else
@ -1167,18 +1155,10 @@ void OSD_File :: ReadLine (
} else { } else {
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 <CR> -
#else
if ( status == 0xFFFFFFFFFFFFFFFF ) { // last character in the buffer is <CR> -
// peek next character to see if it is a <LF>
#endif
if (NbyteRead == -1) // last character in the buffer is <CR> -
{ // peek next character to see if it is a <LF>
NbyteRead = dwBytesRead; // (LD) always fits this case. NbyteRead = dwBytesRead; // (LD) always fits this case.
dwDummy = _get_buffer (myFileHandle, ppeekChar, 1, TRUE, myIO & FLAG_SOCKET); dwDummy = _get_buffer (myFileHandle, ppeekChar, 1, TRUE, myIO & FLAG_SOCKET);
@ -1195,13 +1175,9 @@ void OSD_File :: ReadLine (
myIO |= FLAG_EOF; myIO |= FLAG_EOF;
} else { } else if (aSeekPos != 0)
{
if ( dwSeekPos != 0 ) dwBytesRead = dwBytesRead + aSeekPos;
dwBytesRead = dwBytesRead + dwSeekPos;
NbyteRead = ( Standard_Integer )( eos - cBuffer );
} }
// Don't rewrite datas in cBuffer. // Don't rewrite datas in cBuffer.
@ -1957,12 +1933,11 @@ static void __fastcall _test_raise ( HANDLE hFile, Standard_CString str ) {
} // end _test_raise } // end _test_raise
// Modified so that we have <nl> at end of line if we have read <nl> or <cr> // Returns number of bytes in the string (including end \n, but excluding \r);
// by LD 17 dec 98 for B4.4 //
static Standard_Integer __fastcall _get_line (Standard_PCharacter& buffer, DWORD dwBuffSize, LONG& theSeekPos)
{
static DWORDLONG __fastcall _get_line ( Standard_PCharacter& buffer, DWORD dwBuffSize ) {
DWORDLONG retVal;
Standard_PCharacter ptr; Standard_PCharacter ptr;
buffer[ dwBuffSize ] = 0; buffer[ dwBuffSize ] = 0;
@ -1970,55 +1945,30 @@ static DWORDLONG __fastcall _get_line ( Standard_PCharacter& buffer, DWORD dwBuf
while ( *ptr != 0 ) { while ( *ptr != 0 ) {
if ( *ptr == '\n' ) { if ( *ptr == '\n' )
{
ptr++ ; // jump newline char. ptr++ ; // jump newline char.
*ptr = 0 ; *ptr = 0 ;
retVal = ptr - buffer - dwBuffSize; theSeekPos = (LONG)(ptr - buffer - dwBuffSize);
retVal &= 0x0000000FFFFFFFF;// import 32-bit to 64-bit return (Standard_Integer)(ptr - buffer);
#ifdef VAC }
retVal = (DWORDLONG) ( (unsigned __int64) retVal | (((unsigned __int64) ptr) << 32) ); else if ( *ptr == '\r' && ptr[ 1 ] == '\n' )
#else {
retVal |= ( ( ( DWORDLONG )( DWORD )ptr ) << 32 );
#endif
return retVal;
} else if ( *ptr == '\r' && ptr[ 1 ] == '\n' ) {
*(ptr++) = '\n' ; // Substitue carriage return by newline. *(ptr++) = '\n' ; // Substitue carriage return by newline.
*ptr = 0 ; *ptr = 0 ;
retVal = ptr + 1 - buffer - dwBuffSize; theSeekPos = (LONG)(ptr + 1 - buffer - dwBuffSize);
retVal &= 0x0000000FFFFFFFF;// import 32-bit to 64-bit return (Standard_Integer)(ptr - buffer);
#ifdef VAC }
retVal = (DWORDLONG) ( (unsigned __int64) retVal | (((unsigned __int64) ptr) << 32) ); else if ( *ptr == '\r' && ptr[ 1 ] == 0 ) {
#else
retVal |= ( ( ( DWORDLONG )( DWORD )ptr ) << 32 );
#endif
return retVal;
} else if ( *ptr == '\r' && ptr[ 1 ] == 0 ) {
*ptr = '\n' ; // Substitue carriage return by newline *ptr = '\n' ; // Substitue carriage return by newline
return -1;
#ifdef VAC
return (DWORDLONG) (__int64) (-1);
#else
return 0xFFFFFFFFFFFFFFFF;
#endif
} }
++ptr; ++ptr;
} // end while } // end while
#ifdef VAC theSeekPos = 0;
retVal = (DWORDLONG) ( ( (unsigned __int64) ((DWORD) buffer + dwBuffSize) ) << 32 ); return dwBuffSize;
retVal = (DWORDLONG) ( (unsigned __int64) retVal & (((unsigned __int64) 0xFFFFFFFF) << 32) );
#else
retVal = ( ( ( DWORDLONG )( ( DWORD )buffer + dwBuffSize ) ) << 32 );
retVal &= 0xFFFFFFFF00000000;
#endif
return retVal;
} // end _get_line } // end _get_line
static int __fastcall _get_buffer ( static int __fastcall _get_buffer (

View File

@ -282,50 +282,6 @@ int status;
if (status == -1) myError.SetValue (errno, Iam, "SetProtection"); 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 // return the date of last access of file/directory
Quantity_Date OSD_FileNode::CreationMoment(){ Quantity_Date OSD_FileNode::CreationMoment(){
@ -806,81 +762,6 @@ Quantity_Date OSD_FileNode::CreationMoment () {
} // end 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 //function : Failed
//purpose : //purpose :

View File

@ -74,12 +74,6 @@ public:
//! same value. //! same value.
Standard_EXPORT Quantity_Date CreationMoment(); 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 //! Returns TRUE if an error occurs
Standard_EXPORT Standard_Boolean Failed() const; Standard_EXPORT Standard_Boolean Failed() const;

View File

@ -85,12 +85,6 @@ Standard_Integer OSD_Process::ProcessId(){
return (getpid()); return (getpid());
} }
Standard_Integer OSD_Process::UserId(){
return (getuid());
}
TCollection_AsciiString OSD_Process::UserName(){ TCollection_AsciiString OSD_Process::UserName(){
struct passwd *infos; struct passwd *infos;
infos = getpwuid(getuid()); infos = getpwuid(getuid());
@ -272,32 +266,6 @@ Quantity_Date OSD_Process :: SystemDate () {
} // end 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 () TCollection_AsciiString OSD_Process :: UserName ()
{ {
Standard_PCharacter pBuff = new char[UNLEN + 1]; Standard_PCharacter pBuff = new char[UNLEN + 1];

View File

@ -51,9 +51,6 @@ public:
//! Gets system date. //! Gets system date.
Standard_EXPORT Quantity_Date SystemDate(); Standard_EXPORT Quantity_Date SystemDate();
//! Returns the 'User Id'.
Standard_EXPORT Standard_Integer UserId();
//! Returns the user name. //! Returns the user name.
Standard_EXPORT TCollection_AsciiString UserName(); Standard_EXPORT TCollection_AsciiString UserName();

View File

@ -137,7 +137,7 @@ static DWORD WINAPI WNTthread_func (LPVOID data)
WNTthread_data *adata = (WNTthread_data*)data; WNTthread_data *adata = (WNTthread_data*)data;
void* ret = adata->func ( adata->data ); void* ret = adata->func ( adata->data );
free ( adata ); free ( adata );
return (DWORD)ret; return PtrToLong (ret);
} }
#endif #endif
@ -243,7 +243,7 @@ Standard_Boolean OSD_Thread::Wait (Standard_Address &result) const
// and convert result of the thread execution to Standard_Address // and convert result of the thread execution to Standard_Address
DWORD anExitCode; DWORD anExitCode;
if ( GetExitCodeThread ( myThread, &anExitCode ) ) if ( GetExitCodeThread ( myThread, &anExitCode ) )
result = (Standard_Address)anExitCode; result = ULongToPtr (anExitCode);
return Standard_True; return Standard_True;
#else #else
@ -273,7 +273,7 @@ Standard_Boolean OSD_Thread::Wait (const Standard_Integer time, Standard_Address
{ {
DWORD anExitCode; DWORD anExitCode;
if ( GetExitCodeThread ( myThread, &anExitCode ) ) if ( GetExitCodeThread ( myThread, &anExitCode ) )
result = (Standard_Address)anExitCode; result = ULongToPtr (anExitCode);
return Standard_True; return Standard_True;
} }
else if (ret == WAIT_TIMEOUT) else if (ret == WAIT_TIMEOUT)

View File

@ -28,13 +28,11 @@
/***/ /***/
static void Init ( void ); static void Init ( void );
/***/ /***/
static DWORD dwLevel;
/***/
class Init_OSD_WNT { // provides initialization class Init_OSD_WNT { // provides initialization
public: public:
Init_OSD_WNT () { Init (); dwLevel = TlsAlloc (); } Init_OSD_WNT () { Init (); }
}; // end Init_OSD_WNT }; // end Init_OSD_WNT
@ -897,7 +895,7 @@ void FreeAce ( PVOID pACE ) {
/* Returns : TRUE on success, FALSE otherwise */ /* 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; PWIN32_FIND_DATAW pFD;
LPWSTR pName; LPWSTR pName;
@ -909,12 +907,10 @@ BOOL MoveDirectory ( LPCWSTR oldDir, LPCWSTR newDir ) {
BOOL fFind; BOOL fFind;
BOOL retVal = FALSE; BOOL retVal = FALSE;
DIR_RESPONSE response; DIR_RESPONSE response;
DWORD level;
if ( ( level = ( DWORD )TlsGetValue ( dwLevel ) ) == NULL ) { if (theRecurseLevel == 0) {
++level; ++theRecurseLevel;
TlsSetValue ( dwLevel, ( LPVOID )level );
fFind = FALSE; fFind = FALSE;
driveSrc = driveDst = pathSrc = pathDst = NULL; driveSrc = driveDst = pathSrc = pathDst = NULL;
@ -968,16 +964,14 @@ retry:
if ( fFind ) { if ( fFind ) {
--level; --theRecurseLevel;
TlsSetValue ( dwLevel, ( LPVOID )level );
return retVal; return retVal;
} // end if } // end if
} else { } else {
++level; ++theRecurseLevel;
TlsSetValue ( dwLevel, ( LPVOID )level );
} // end else } // end else
@ -1039,7 +1033,7 @@ retry:
if ( pFD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { if ( pFD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
retVal = MoveDirectory ( pFullNameSrc, pFullNameDst ); retVal = MoveDirectory ( pFullNameSrc, pFullNameDst, theRecurseLevel );
if (!retVal) break; if (!retVal) break;
} else { } else {
@ -1121,12 +1115,18 @@ retry_2:
} /* end if */ } /* end if */
--level; --theRecurseLevel;
TlsSetValue ( dwLevel, ( LPVOID )level );
return retVal; return retVal;
} /* end MoveDirectory */ } /* end MoveDirectory */
BOOL MoveDirectory (LPCWSTR oldDir, LPCWSTR newDir)
{
DWORD aRecurseLevel = 0;
return MoveDirectory (oldDir, newDir, aRecurseLevel);
}
/***/ /***/
/******************************************************************************/ /******************************************************************************/
/* Function : CopyDirectory */ /* Function : CopyDirectory */

View File

@ -224,7 +224,7 @@ Handle(StepBasic_PersonAndOrganization) STEPConstruct_AP203Context::DefaultPerso
Handle(StepBasic_Person) aPerson = new StepBasic_Person; Handle(StepBasic_Person) aPerson = new StepBasic_Person;
Handle(TCollection_HAsciiString) uid = new TCollection_HAsciiString ( orgId ); Handle(TCollection_HAsciiString) uid = new TCollection_HAsciiString ( orgId );
uid->AssignCat ( "," ); uid->AssignCat ( "," );
uid->AssignCat ( TCollection_AsciiString ( sys.UserId() ).ToCString() ); uid->AssignCat (sys.UserName().ToCString());
Handle(Interface_HArray1OfHAsciiString) suffix, prefix; Handle(Interface_HArray1OfHAsciiString) suffix, prefix;
aPerson->Init ( uid, Standard_True, lname, Standard_True, fname, ( ! mname.IsNull() ), aPerson->Init ( uid, Standard_True, lname, Standard_True, fname, ( ! mname.IsNull() ),
mname, Standard_False, suffix, Standard_False, prefix ); mname, Standard_False, suffix, Standard_False, prefix );

View File

@ -80,9 +80,7 @@ TDF_LabelIndexedMap.hxx
TDF_LabelIntegerMap.hxx TDF_LabelIntegerMap.hxx
TDF_LabelList.hxx TDF_LabelList.hxx
TDF_LabelMap.hxx TDF_LabelMap.hxx
TDF_LabelMapHasher.cxx
TDF_LabelMapHasher.hxx TDF_LabelMapHasher.hxx
TDF_LabelMapHasher.lxx
TDF_LabelNode.cxx TDF_LabelNode.cxx
TDF_LabelNode.hxx TDF_LabelNode.hxx
TDF_LabelNodePtr.hxx TDF_LabelNodePtr.hxx

View File

@ -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 <TDF_Label.hxx>
#include <TDF_LabelMapHasher.hxx>

View File

@ -16,54 +16,26 @@
#ifndef _TDF_LabelMapHasher_HeaderFile #ifndef _TDF_LabelMapHasher_HeaderFile
#define _TDF_LabelMapHasher_HeaderFile #define _TDF_LabelMapHasher_HeaderFile
#include <Standard.hxx> #include <TDF_Label.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
class TDF_Label;
//! A label hasher for label maps. //! A label hasher for label maps.
class TDF_LabelMapHasher class TDF_LabelMapHasher
{ {
public: public:
DEFINE_STANDARD_ALLOC //! Returns a HasCode value for the Key <K> in the range 0..Upper.
static Standard_Integer HashCode(const TDF_Label& aLab, const Standard_Integer Upper)
{
//! Returns a HasCode value for the Key <K> in the return ::HashCode((Standard_Address)aLab.myLabelNode, Upper);
//! 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 //! Returns True when the two keys are the same. Two
//! same keys must have the same hashcode, the //! same keys must have the same hashcode, the
//! contrary is not necessary. //! contrary is not necessary.
static Standard_Boolean IsEqual (const TDF_Label& aLab1, const TDF_Label& aLab2); static Standard_Boolean IsEqual(const TDF_Label& aLab1, const TDF_Label& aLab2)
{
return aLab1.IsEqual(aLab2);
}
protected:
private:
}; };
#include <TDF_LabelMapHasher.lxx>
#endif // _TDF_LabelMapHasher_HeaderFile #endif // _TDF_LabelMapHasher_HeaderFile

View File

@ -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); }