EgtInterface 1.6e2 :

- esecutore e lua scorporato in EgtExecutor.
This commit is contained in:
Dario Sassi
2015-05-05 22:14:56 +00:00
parent e7ee6d9255
commit 8bc0e986b2
60 changed files with 454 additions and 16260 deletions
+28 -205
View File
@@ -14,134 +14,44 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "API.h"
#include "LUA_Base.h"
#include "DllGraphics.h"
#include "DllExchange.h"
#include "DllMachKernel.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EInDllMain.h"
#include "/EgtDev/Include/EGnDllMain.h"
#include "/EgtDev/Include/ENkDllMain.h"
#include "/EgtDev/Include/EGkDllMain.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnStringConverter.h"
#include "/EgtDev/Include/EGnPcInfo.h"
#include "/EgtDev/Include/EgtLogger.h"
#include <fstream>
using namespace std ;
using namespace egtlogger ;
//----------------------------------------------------------------------------
static Logger* s_pGenLog = nullptr ;
static Logger* s_pCmdLog = nullptr ;
static bool s_bCmdLog = false ;
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtInit( int nDebug, const wchar_t* sLogFile, const wchar_t* sLogMsg)
__stdcall EgtInit( int nDebug, const wchar_t* wsLogFile, const wchar_t* wsLogMsg)
{
// cancello eventuali vecchi contesti
ClearAllGseContexts() ;
// cancello eventuale vecchio logger
if ( s_pGenLog != nullptr)
delete s_pGenLog ;
// creo il logger generale
s_pGenLog = new Logger( ( nDebug > 0 ? LL_DEBUG : LL_INFO), "EgtInterface") ;
if ( s_pGenLog == nullptr)
return FALSE ;
// assegno il file
s_pGenLog->AddOutputStream( new ofstream( sLogFile), true) ;
// lo passo alle DLL
SetEGnLogger( s_pGenLog) ;
SetENkLogger( s_pGenLog) ;
SetEGkLogger( s_pGenLog) ;
// carico librerie opzionali
LoadGraphicsDll() ;
MySetEGrLogger( s_pGenLog) ;
LoadExchangeDll() ;
MySetEExLogger( s_pGenLog) ;
LoadMachKernelDll() ;
MySetEMkLogger( s_pGenLog) ;
// dichiaro inizio programma
LOG_DATETIME( s_pGenLog, " Init")
// eventuale messaggio dall'applicazione
if ( sLogMsg != nullptr && sLogMsg[0] != L'\0')
LOG_INFO( s_pGenLog, LPSTR( WtoA( sLogMsg)))
// versione di interfaccia e componenti
string sVer ;
EgtGetVersionInfo( sVer, "\n") ;
LOG_INFO( s_pGenLog, sVer.c_str())
// Info sul sistema
string sTmp ;
if ( GetOsInfo( sTmp))
LOG_INFO( s_pGenLog, sTmp.c_str())
if ( GetCpuInfo( sTmp))
LOG_INFO( s_pGenLog, sTmp.c_str())
if ( GetMemoryInfo( sTmp))
LOG_INFO( s_pGenLog, sTmp.c_str())
// inizializzo l'interprete LUA
LuaInit() ;
return TRUE ;
string sLogMsg = wstrztoA( wsLogMsg) ;
sLogMsg += "\n" ;
sLogMsg += GetEInVersion() ;
return ( ExeInit( nDebug, wstrztoA( wsLogFile), sLogMsg) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtExit( void)
{
// cancello tutti i contesti
ClearAllGseContexts() ;
// termino l'interprete LUA
LuaExit() ;
// libero le librerie opzionali
FreeMachKernelDll() ;
FreeExchangeDll() ;
FreeGraphicsDll() ;
// fine programma
LOG_DATETIME( s_pGenLog, " Exit")
// cancello il logger dei comandi
if ( s_pCmdLog != nullptr) {
delete s_pCmdLog ;
s_pCmdLog = nullptr ;
}
// cancello il logger generale
if ( s_pGenLog != nullptr) {
delete s_pGenLog ;
s_pGenLog = nullptr ;
}
return TRUE ;
return ( ExeExit() ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtSetKey( const wchar_t* swKey)
__stdcall EgtSetKey( const wchar_t* wsKey)
{
string sKey = WtoA( swKey) ;
SetEGkKey( sKey) ;
MySetEGrKey( sKey) ;
MySetEExKey( sKey) ;
MySetEMkKey( sKey) ;
return TRUE ;
return ( ExeSetKey( wstrztoA( wsKey)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtSetFont( const wchar_t* wsNfeFontDir, const wchar_t* wsDefaultFont)
{
// inizializzazioni gestore font Nfe
InitFontManager( LPSTR( WtoA( wsNfeFontDir)), LPSTR( WtoA( wsDefaultFont))) ;
return TRUE ;
return ( ExeSetFont( wstrztoA( wsNfeFontDir), wstrztoA( wsDefaultFont)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
@@ -149,9 +59,10 @@ BOOL
__stdcall EgtGetNfeFontDir( wchar_t*& wsNfeFontDir)
{
if ( &wsNfeFontDir == nullptr)
return false ;
// recupero il nome del font di default
string sNfeFontDir = GetNfeFontDir() ;
return FALSE ;
// recupero il nome del direttorio dei font Nfe
string sNfeFontDir ;
ExeGetNfeFontDir( sNfeFontDir) ;
wsNfeFontDir = _wcsdup( stringtoW( sNfeFontDir)) ;
return (( wsNfeFontDir == nullptr) ? FALSE : TRUE) ;
}
@@ -163,56 +74,37 @@ __stdcall EgtGetDefaultFont( wchar_t*& wsDefaultFont)
if ( &wsDefaultFont == nullptr)
return false ;
// recupero il nome del font di default
string sDefaultFont = GetDefaultFont() ;
string sDefaultFont ;
ExeGetDefaultFont( sDefaultFont) ;
wsDefaultFont = _wcsdup( stringtoW( sDefaultFont)) ;
return (( wsDefaultFont == nullptr) ? FALSE : TRUE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtSetLuaLibs( const wchar_t* wsLuaLibsDir)
{
if ( LuaSetLuaLibsDir( LPSTR( WtoA( wsLuaLibsDir))))
return TRUE ;
else
return FALSE ;
return ( ExeSetLuaLibs( wstrztoA( wsLuaLibsDir)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtSetCommandLogger( const wchar_t* sLogFile)
__stdcall EgtSetCommandLogger( const wchar_t* wsLogFile)
{
// cancello eventuale vecchio logger e disabilito output
if ( s_pCmdLog != nullptr)
delete s_pCmdLog ;
s_bCmdLog = false ;
// creo il logger dei comandi
s_pCmdLog = new Logger( LL_INFO, "EgtCommandLog") ;
if ( s_pCmdLog == nullptr)
return FALSE ;
// assegno il file
ofstream* pLogFile = new ofstream( sLogFile) ;
if ( pLogFile == nullptr || pLogFile->bad())
return FALSE ;
s_pCmdLog->AddOutputStream( pLogFile, true) ;
// scrivo intestazione
string sOut = "-- " + CurrDateTime() + " EgtCommandLog" ;
LOG_INFO( s_pCmdLog, sOut.c_str())
return TRUE ;
return ( ExeSetCommandLogger( wstrztoA( wsLogFile)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
void
__stdcall EgtEnableCommandLogger( void)
{
SetCmdLog( true) ;
ExeEnableCommandLogger() ;
}
//-----------------------------------------------------------------------------
void
__stdcall EgtDisableCommandLogger( void)
{
SetCmdLog( false) ;
ExeDisableCommandLogger() ;
}
//-----------------------------------------------------------------------------
@@ -221,52 +113,21 @@ __stdcall EgtGetVersionInfo( wchar_t*& wsVer)
{
// recupero le informazioni sulle DLL
string sVer ;
if ( ! EgtGetVersionInfo( sVer, "\r\n"))
sVer = GetEInVersion() ;
sVer += "\r\n" ;
if ( ! ExeGetVersionInfo( sVer, "\r\n"))
return FALSE ;
wsVer = _wcsdup( stringtoW( sVer)) ;
return (( wsVer == nullptr) ? FALSE : TRUE) ;
}
//-----------------------------------------------------------------------------
bool
EgtGetVersionInfo( string& sVer, const char* szNewLine)
{
// verifico il parametro
if ( &sVer == nullptr)
return false ;
// recupero le informazioni sulle DLL sempre presenti
sVer += GetEInVersion() ;
sVer += szNewLine ;
sVer += GetEGnVersion() ;
sVer += szNewLine ;
sVer += GetENkVersion() ;
sVer += szNewLine ;
sVer += GetEGkVersion() ;
// recupero le informazioni sulle DLL opzionali
if ( IsLoadedGraphicsDll()) {
sVer += szNewLine ;
sVer += MyGetEGrVersion() ;
}
if ( IsLoadedExchangeDll()) {
sVer += szNewLine ;
sVer += MyGetEExVersion() ;
}
string sEMkVer = MyGetEMkVersion() ;
if ( ! sEMkVer.empty()) {
sVer += szNewLine ;
sVer += sEMkVer ;
}
return true ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtGetOsInfo( wchar_t*& wsOs)
{
// recupero le informazioni sul sistema operativo
string sOs ;
if ( ! GetOsInfo( sOs))
if ( ! ExeGetOsInfo( sOs))
return FALSE ;
wsOs = _wcsdup( stringtoW( sOs)) ;
return (( wsOs == nullptr) ? FALSE : TRUE) ;
@@ -278,7 +139,7 @@ __stdcall EgtGetCpuInfo( wchar_t*& wsCpu)
{
// recupero le informazioni sulla Cpu
string sCpu ;
if ( ! GetCpuInfo( sCpu))
if ( ! ExeGetCpuInfo( sCpu))
return FALSE ;
wsCpu = _wcsdup( stringtoW( sCpu)) ;
return (( wsCpu == nullptr) ? FALSE : TRUE) ;
@@ -290,7 +151,7 @@ __stdcall EgtGetMemoryInfo( wchar_t*& wsMem)
{
// recupero le informazioni sulla memoria presente
string sMem ;
if ( ! GetMemoryInfo( sMem))
if ( ! ExeGetMemoryInfo( sMem))
return FALSE ;
wsMem = _wcsdup( stringtoW( sMem)) ;
return (( wsMem == nullptr) ? FALSE : TRUE) ;
@@ -305,41 +166,3 @@ __stdcall EgtFreeMemory( void* pMem)
free( pMem) ;
return TRUE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtOutLog( const wchar_t* sMsg)
{
LOG_INFO( s_pGenLog, LPSTR( WtoA( sMsg)))
return ( s_pGenLog != nullptr) ;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
ILogger*
GetLogger( void)
{
return s_pGenLog ;
}
//-----------------------------------------------------------------------------
ILogger*
GetCmdLogger( void)
{
return s_pCmdLog ;
}
//-----------------------------------------------------------------------------
bool
SetCmdLog( bool bVal)
{
swap( bVal, s_bCmdLog) ;
return bVal ;
}
//-----------------------------------------------------------------------------
bool
IsCmdLog( void)
{
return s_bCmdLog ;
}