X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHUtils%2FSMESH_MGLicenseKeyGen.cxx;h=c86bad807ba73776683187f5556b06212642e422;hp=fa5b78858ad6766ce2b9beb1fdc357fcd4735865;hb=d9f4b53e489dd5857db264ede6acded7b076c9f1;hpb=499331b2078ac4207194e8a416c06a5c81cb6501 diff --git a/src/SMESHUtils/SMESH_MGLicenseKeyGen.cxx b/src/SMESHUtils/SMESH_MGLicenseKeyGen.cxx index fa5b78858..c86bad807 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 @@ -29,10 +29,10 @@ #include #include -#include #include // getenv, system #include +#include namespace boofs = boost::filesystem; #ifdef WIN32 @@ -60,6 +60,8 @@ namespace boofs = boost::filesystem; #undef SMESH_CAUGHT #define SMESH_CAUGHT error = +constexpr char MESHGEMS_OLD_STYLE[] = "MESHGEMS_OLD_STYLE"; + namespace { @@ -201,17 +203,32 @@ namespace bool isURL( LibraryFile & libraryFile ) { - enum { SCHEME = 2, AUTHORITY = 4, PATH = 5 }; // sub-strings - std::regex urlRegex ( R"(^(([^:\/?#]+):)?(//([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)", - std::regex::extended ); - std::smatch matchResult; - - libraryFile._isURL = false; - if ( std::regex_match( libraryFile._name, matchResult, urlRegex )) - libraryFile._isURL = ( !matchResult.str( SCHEME ).empty() && - !matchResult.str( AUTHORITY ).empty() && - !matchResult.str( PATH ).empty() ); - + {// round1 + enum { SCHEME = 2, AUTHORITY = 4, PATH = 5 }; // sub-strings + boost::regex urlRegex ( R"(^(([^:\/?#]+):)?(//([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)", + boost::regex::extended ); + boost::smatch matchResult; + + libraryFile._isURL = false; + if ( boost::regex_match( libraryFile._name, matchResult, urlRegex )) + libraryFile._isURL = ( !matchResult.str( SCHEME ).empty() && + !matchResult.str( AUTHORITY ).empty() && + !matchResult.str( PATH ).empty() ); + } + if(libraryFile._isURL) + return true; + {// round2 + enum { HOST = 2, PORT = 3, PATH = 4 }; // sub-strings + boost::regex urlRegex ( R"(^(([^:\/?#]+):)?([^/]+)?(/[^#]*))", + boost::regex::extended ); + boost::smatch matchResult; + + libraryFile._isURL = false; + if ( boost::regex_match( libraryFile._name, matchResult, urlRegex )) + libraryFile._isURL = ( !matchResult.str( HOST ).empty() && + !matchResult.str( PORT ).empty() && + !matchResult.str( PATH ).empty() ); + } return libraryFile._isURL; } @@ -357,7 +374,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 )) @@ -386,6 +403,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; + } //================================================================================ /*! @@ -396,7 +422,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 )) @@ -425,6 +451,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; + } //================================================================================ /*! @@ -436,12 +471,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; @@ -465,6 +500,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