//---------------------------------------------------------------------------- // EgalTech 2019-2019 //---------------------------------------------------------------------------- // File : ENsDllMain.h Data : 28.11.19 Versione : 2.1k6 // Contenuto : Prototipi funzioni generali della DLL. // // // // Modifiche : 28.11.19 DS Creazione modulo. // // //---------------------------------------------------------------------------- #pragma once #include class ILogger ; //----------------------- Macro per import/export ---------------------------- #undef ENS_EXPORT #if defined( I_AM_ENS) // da definirsi solo nella DLL #define ENS_EXPORT __declspec( dllexport) #else #define ENS_EXPORT __declspec( dllimport) #endif //----------------------------------------------------------------------------- // E' necessaria l'interfaccia in C per caricare queste funzioni dinamicamente extern "C" { // restituisce la versione della Dll ENS_EXPORT const char* GetENsVersion( void) ; // permette di impostare il logger per la Dll ENS_EXPORT void SetENsLogger( ILogger* pLogger) ; // imposta la chiave di protezione ENS_EXPORT void SetENsKey( const std::string& sKey) ; // imposta la seconda chiave di protezione ENS_EXPORT void SetENsKey2( const std::string& sKey2) ; } //----------------------------------------------------------------------------- #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EgtILogger.h" #include "/EgtDev/Include/EgtKeyCodes.h" #include "/EgtDev/Include/SELkKeyProc.h" //----------------------------------------------------------------------------- // Test della chiave per caricare la DLL inline bool TestKeyForENs( const std::string& sKey, int nKeyOpt, ILogger* pLogger) { // verifico la chiave e le opzioni unsigned int nOpt1, nOpt2 ; int nOptExpDays ; int nRet = GetKeyOptions( sKey, KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, nOpt1, nOpt2, nOptExpDays) ; if ( nRet != KEY_OK) { std::string sErr = "Error on Key (ENS/" + ToString( nRet) + ")" ; LOG_ERROR( pLogger, sErr.c_str()) ; return false ; } if ( ( nOpt1 & ( KEYOPT_ENS_BASE)) == 0 || ( nKeyOpt != 0 && ( nOpt1 & nKeyOpt) == 0) || nOptExpDays < GetCurrDay()) { std::string sErr = "Warning on Key (ENS/OPT)" ; LOG_ERROR( pLogger, sErr.c_str()) ; return false ; } return true ; }