From dacb205b73c6584f56ff55ce7c881ddedbf23364 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sat, 13 Sep 2014 21:24:52 +0000 Subject: [PATCH] Include : - aggiunto corpo di ToString per interi - aggiunte dichiarazioni per EgtLock (libreria statica). --- EGnStringUtils.h | 23 ++++++++++++++++++++++- SELkBase64.h | 20 ++++++++++++++++++++ SELkCrc32.h | 22 ++++++++++++++++++++++ SELkKeyProc.h | 41 +++++++++++++++++++++++++++++++++++++++++ SELkMachineId.h | 24 ++++++++++++++++++++++++ 5 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 SELkBase64.h create mode 100644 SELkCrc32.h create mode 100644 SELkKeyProc.h create mode 100644 SELkMachineId.h diff --git a/EGnStringUtils.h b/EGnStringUtils.h index b88586d..66d4813 100644 --- a/EGnStringUtils.h +++ b/EGnStringUtils.h @@ -129,7 +129,28 @@ bool FromString( const std::string& sVal, double (&dVal)[size]) } return ( *pStop == '\0' && errno == 0) ; } -EGN_EXPORT const std::string ToString( int nVal, int nPrec = 1) ; + +//---------------------------------------------------------------------------- +inline const std::string +ToString( int nVal, int nPrec = 1) + { + // eseguo conversione + char szBuff[24] ; + int nErr = _itoa_s( nVal, szBuff, 10) ; + // se errore, ritorno stringa opportuna + if ( nErr != 0) { + _ASSERT( 0) ; + return "#Error" ; + } + // verifico lunghezza minima + int nLen = (int) strlen( szBuff) ; + if ( nLen >= nPrec) + return szBuff ; + // porto la stringa alla minima lunghezza + std::string sBuff( szBuff) ; + sBuff.insert( 0, ( nPrec - nLen), '0') ; + return sBuff ; + } inline const std::string ToString( bool bVal) { return std::string( ( bVal ? "1" : "0")) ; } diff --git a/SELkBase64.h b/SELkBase64.h new file mode 100644 index 0000000..c892f38 --- /dev/null +++ b/SELkBase64.h @@ -0,0 +1,20 @@ +//---------------------------------------------------------------------------- +// EgalTech 2014-2014 +//---------------------------------------------------------------------------- +// File : SELkBase64.h Data : 10.09.14 Versione : 1.5i1 +// Contenuto : Dichiarazione funzioni per codifica/decodifica Base64. +// +// +// +// Modifiche : 10.09.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include + +//----------------------------------------------------------------------------- +bool B64Encode( const std::string& sSou, std::string& sB64Dest) ; +bool B64Decode( const std::string& sB64Sou, std::string& sDest) ; diff --git a/SELkCrc32.h b/SELkCrc32.h new file mode 100644 index 0000000..4a847be --- /dev/null +++ b/SELkCrc32.h @@ -0,0 +1,22 @@ +//---------------------------------------------------------------------------- +// EgalTech 2014-2014 +//---------------------------------------------------------------------------- +// File : SELkCrc32.h Data : 08.09.14 Versione : 1.5i1 +// Contenuto : Dichiarazione funzioni per calcolo CRC32. +// +// +// +// Modifiche : 08.09.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include + +//----------------------------------------------------------------------------- +void AddCrc32ToString( std::string& sVal) ; +bool TestCrc32AndRemoveFromString( std::string& sVal) ; +bool TestCrc32OfString( const std::string& sVal) ; +unsigned int GetCrc32( unsigned int current_remainder, size_t count, const void* p) ; diff --git a/SELkKeyProc.h b/SELkKeyProc.h new file mode 100644 index 0000000..d506405 --- /dev/null +++ b/SELkKeyProc.h @@ -0,0 +1,41 @@ +//---------------------------------------------------------------------------- +// EgalTech 2014-2014 +//---------------------------------------------------------------------------- +// File : SELkKeyProc.h Data : 10.09.14 Versione : 1.5i2 +// Contenuto : Dichiarazione funzioni per la gestione della chiave. +// +// +// +// Modifiche : 10.09.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include + +//----------------------------------------------------------------------------- +bool MakeKey( int nProd, int nVer, int nLev, int nExpDays, + unsigned int nOpt1, unsigned int nOpt2, int nOptExpDays, + const std::string& sScramKey, std::string& sKey) ; +bool ReadKey( const std::string& sKey, const std::string& sScramKey, + unsigned int& nProd, unsigned int& nVer, int& nLev, int& nExpDays, + int& nOpt1, int& nOpt2, int& nOptExpDays) ; +int VerifyKey( const std::string& sKey, int nProd, int nVer, int nLev) ; +int GetKeyLevel( const std::string& sKey, int nProd, int nVer, int nLev, + int& nKLev, int& nKExpDays) ; +int GetKeyOptions( const std::string& sKey, int nProd, int nVer, int nLev, + unsigned int& nKOpt1, unsigned int& nKOpt2, int& nKOptExpDays) ; +int GetCurrDay( void) ; + +//-------------------------- Constants ---------------------------------------- +const int KEY_OK = 0 ; +const int KEY_ERR_MACHID = 1 ; +const int KEY_ERR_SCRAMKEY = 2 ; +const int KEY_ERR_KEYDECODE = 3 ; +const int KEY_ERR_PROD = 4 ; +const int KEY_ERR_VER = 5 ; +const int KEY_ERR_LEV = 6 ; +const int KEY_ERR_WRONG_TIME = 7 ; +const int KEY_ERR_TIME = 8 ; diff --git a/SELkMachineId.h b/SELkMachineId.h new file mode 100644 index 0000000..019b20e --- /dev/null +++ b/SELkMachineId.h @@ -0,0 +1,24 @@ +//---------------------------------------------------------------------------- +// EgalTech 2014-2014 +//---------------------------------------------------------------------------- +// File : SELkMachineId.cpp Data : 10.09.14 Versione : 1.5i2 +// Contenuto : Dichiarazione funzioni per gestione/calcolo Id macchina. +// +// +// +// Modifiche : 10.09.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include + +//------------------------------------------------------------------------------- +bool CalcMachineId( bool bForceNew) ; +bool GetMachineId( std::string& sMachineId) ; +bool GetMachineId2( std::string& sMachineId) ; +bool GetMachineId3( std::string& sMachineId) ; +bool ConvertMachineId2ToMachineId( const std::string& sMachId2, std::string& sMachId) ; +bool ConvertMachineId2ToScramKey( const std::string& sMachId2, std::string& sScramKey) ;