EgtExecutor :
- aggiunte funzioni exe e lua Base64Encode e Base64Decode.
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2025-2025
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EXE_Base64.cpp Data : 03.11.25 Versione : 2.7k1
|
||||
// Contenuto : Funzioni per codificare/decodificare in Base64.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 03.11.25 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EgtStringConverter.h"
|
||||
#include "/EgtDev/Include/EgtBase64.h"
|
||||
#include <fstream>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeBase64Encode( const string& sFile, string& sB64Dest)
|
||||
{
|
||||
// apro il file in modo binario
|
||||
ifstream InFile( stringtoW( sFile), ios::in | ios::binary, _SH_DENYWR) ;
|
||||
if ( InFile.fail()) {
|
||||
if ( InFile.is_open())
|
||||
InFile.close() ;
|
||||
return false ;
|
||||
}
|
||||
// leggo il file
|
||||
string sSou( istreambuf_iterator<char>( InFile), {}) ;
|
||||
// lo chiudo
|
||||
if ( InFile.is_open())
|
||||
InFile.close() ;
|
||||
|
||||
// converto in Base64
|
||||
return B64Encode( sSou, sB64Dest) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeBase64Decode( const string& sB64Sou, const string& sFile)
|
||||
{
|
||||
// converto da Base64
|
||||
string sDest ;
|
||||
if ( ! B64Decode( sB64Sou, sDest))
|
||||
return false ;
|
||||
|
||||
// apro il file in modo binario
|
||||
ofstream OutFile( stringtoW( sFile), ios::out | ios::binary, _SH_DENYWR) ;
|
||||
if ( ! OutFile.good()) {
|
||||
if ( OutFile.is_open())
|
||||
OutFile.close() ;
|
||||
return false ;
|
||||
}
|
||||
// scrivo sul file
|
||||
OutFile.write( sDest.data(), sDest.size()) ;
|
||||
// lo chiudo
|
||||
if ( OutFile.is_open())
|
||||
OutFile.close() ;
|
||||
return true ;
|
||||
}
|
||||
@@ -251,6 +251,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="DllExch3dm.cpp" />
|
||||
<ClCompile Include="DllNesting.cpp" />
|
||||
<ClCompile Include="EXE_Base64.cpp" />
|
||||
<ClCompile Include="EXE_BeamMgr.cpp" />
|
||||
<ClCompile Include="EXE_CAvTool.cpp" />
|
||||
<ClCompile Include="EXE_CDeObjSolid.cpp" />
|
||||
@@ -306,6 +307,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="GenTools.cpp" />
|
||||
<ClCompile Include="GeoTools.cpp" />
|
||||
<ClCompile Include="GseContext.cpp" />
|
||||
<ClCompile Include="LUA_Base64.cpp" />
|
||||
<ClCompile Include="LUA_BeamMgr.cpp" />
|
||||
<ClCompile Include="LUA_CAvTool.cpp" />
|
||||
<ClCompile Include="LUA_CDeObjSolid.cpp" />
|
||||
|
||||
@@ -419,6 +419,12 @@
|
||||
<ClCompile Include="LUA_Redis.cpp">
|
||||
<Filter>File di origine\LUA</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EXE_Base64.cpp">
|
||||
<Filter>File di origine\EXE</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_Base64.cpp">
|
||||
<Filter>File di origine\LUA</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtExecutor.rc">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2025
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA.h Data : 24.03.24 Versione : 2.6c2
|
||||
// File : LUA.h Data : 03.11.25 Versione : 2.7k1
|
||||
// Contenuto : Dichiarazioni locali per moduli LUA.
|
||||
//
|
||||
//
|
||||
@@ -138,3 +138,6 @@ bool LuaInstallCAvTool( LuaMgr& luaMgr) ;
|
||||
//---------------------------------- Redis ----------------------------------
|
||||
bool LuaInstallRedis( LuaMgr& luaMgr) ;
|
||||
|
||||
//-------------------------- Base64 ------------------------------------------
|
||||
bool LuaInstallBase64( LuaMgr& luaMgr) ;
|
||||
|
||||
|
||||
@@ -190,6 +190,11 @@ LuaInstallEgtFunctions( LuaMgr& LuaMgr)
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallRedis (LuaInstallEgtFunctions)")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallBase64( LuaMgr)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallBase64 (LuaInstallEgtFunctions)")
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2025-2025
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_Base64.cpp Data : 03.11.25 Versione : 2.7k1
|
||||
// Contenuto : Funzioni per codificare/decodificare in Base64 per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 03.11.25 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaBase64Encode( lua_State* L)
|
||||
{
|
||||
// 1 parametro : sFile
|
||||
string sFile ;
|
||||
LuaCheckParam( L, 1, sFile) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo la codifica del contenuto del file
|
||||
string sB64Dest ;
|
||||
bool bOk = ExeBase64Encode( sFile, sB64Dest) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, sB64Dest) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaBase64Decode( lua_State* L)
|
||||
{
|
||||
// 2 parametro : sB64Sou, sFile
|
||||
string sB64Sou ;
|
||||
LuaCheckParam( L, 1, sB64Sou) ;
|
||||
string sFile ;
|
||||
LuaCheckParam( L, 2, sFile) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo la decodifica della stringa nel file
|
||||
bool bOk = ExeBase64Decode( sB64Sou, sFile) ;
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallBase64( LuaMgr& luaMgr)
|
||||
{
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtBase64Encode", LuaBase64Encode) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtBase64Decode", LuaBase64Decode) ;
|
||||
return bOk ;
|
||||
}
|
||||
Reference in New Issue
Block a user