X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHUtils%2FSMESH_MGLicenseKeyGen.cxx;h=1b5655e0c934686e5ab8345af3295ed7d473af85;hp=b058e86a2d607bc6bc66d0d5734873d94b622d39;hb=dacd89c7dfc779f4a8249ff08ca15f7b963408a5;hpb=890187d6e15e3e11cff8f2f6323eb656d9d51f33 diff --git a/src/SMESHUtils/SMESH_MGLicenseKeyGen.cxx b/src/SMESHUtils/SMESH_MGLicenseKeyGen.cxx index b058e86a2..1b5655e0c 100644 --- a/src/SMESHUtils/SMESH_MGLicenseKeyGen.cxx +++ b/src/SMESHUtils/SMESH_MGLicenseKeyGen.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -60,6 +60,8 @@ namespace boofs = boost::filesystem; #undef SMESH_CAUGHT #define SMESH_CAUGHT error = +constexpr char MESHGEMS_OLD_STYLE[] = "MESHGEMS_OLD_STYLE"; + namespace { @@ -273,7 +275,7 @@ namespace std::string outFile = tmpDir + "libMeshGemsKeyGenerator.so"; - std::string cmd = "wget " + url + " -O " + outFile; + std::string cmd = "smesh_wget.py " + url + " -O " + outFile; #endif @@ -287,8 +289,34 @@ namespace } } +#ifndef WIN32 + //[EDF25906] + std::string redirect = tmpDir + "redirect.out"; + std::ostringstream oss; + oss << cmd << " " << redirect; + cmd = oss.str(); +#endif + system( cmd.c_str() ); // download +#ifndef WIN32 + {//[EDF25906] + std::ifstream infile(redirect); + infile.seekg(0, std::ios::end); + size_t length = infile.tellg(); + infile.seekg(0, std::ios::beg); + std::unique_ptr buffer(new char[length+1]); + buffer[length] = '\0'; + infile.read(const_cast( buffer.get() ),length); + + MESSAGE( buffer.get() ) + } + { + SMESH_File redirectFile( redirect, /*open=*/false ); + redirectFile.remove(); + } +#endif + SMESH_File resultFile( outFile, /*open=*/false ); bool ok = ( resultFile.exists() && resultFile.size() > 0 ); @@ -372,7 +400,7 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation */ //================================================================================ - bool SignCAD( void* meshgems_cad, std::string& error ) + bool SignCAD_After( void* meshgems_cad, std::string& error ) { LibraryFile libraryFile; if ( !loadLibrary( error, libraryFile )) @@ -401,6 +429,15 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation } return ok; } + + bool SignCAD( void* meshgems_cad, std::string& error ) + { + const char *meshGemsOldStyleEnvVar( getenv( MESHGEMS_OLD_STYLE ) ); + if ( !meshGemsOldStyleEnvVar || strlen(meshGemsOldStyleEnvVar) == 0 ) + return SignCAD_After(meshgems_cad, error); + else + return true; + } //================================================================================ /*! @@ -411,7 +448,7 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation */ //================================================================================ - bool SignMesh( void* meshgems_mesh, std::string& error ) + bool SignMesh_After( void* meshgems_mesh, std::string& error ) { LibraryFile libraryFile; if ( !loadLibrary( error, libraryFile )) @@ -440,6 +477,15 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation } return ok; } + + bool SignMesh( void* meshgems_mesh, std::string& error ) + { + const char *meshGemsOldStyleEnvVar( getenv( MESHGEMS_OLD_STYLE ) ); + if ( !meshGemsOldStyleEnvVar || strlen(meshGemsOldStyleEnvVar) == 0 ) + return SignMesh_After(meshgems_mesh, error); + else + return true; + } //================================================================================ /*! @@ -451,12 +497,12 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation */ //================================================================================ - std::string GetKey(const std::string& gmfFile, - int nbVertex, - int nbEdge, - int nbFace, - int nbVol, - std::string& error) + std::string GetKey_After(const std::string& gmfFile, + int nbVertex, + int nbEdge, + int nbFace, + int nbVol, + std::string& error) { std::string key; LibraryFile libraryFile; @@ -480,6 +526,20 @@ namespace SMESHUtils_MGLicenseKeyGen // API implementation return key; } + std::string GetKey(const std::string& gmfFile, + int nbVertex, + int nbEdge, + int nbFace, + int nbVol, + std::string& error) + { + const char *meshGemsOldStyleEnvVar( getenv( MESHGEMS_OLD_STYLE ) ); + if ( !meshGemsOldStyleEnvVar || strlen(meshGemsOldStyleEnvVar) == 0 ) + return GetKey_After(gmfFile,nbVertex,nbEdge,nbFace,nbVol,error); + else + return std::string("0"); + } + //================================================================================ /*! * \brief Return false if libMeshGemsKeyGenerator.so is not functional