parent
577a7e0af8
commit
9735b7d047
@ -0,0 +1,42 @@ |
||||
#include <set> |
||||
|
||||
#include "globals.hpp" |
||||
|
||||
using namespace std ; |
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
HMODULE ghInterceptionDll = NULL ; |
||||
|
||||
DeviceTable gDeviceTable ; |
||||
DeviceConfigTable gDeviceConfigTable ; |
||||
|
||||
bool gEnableConsole = false ; |
||||
wstring gLogFilename ; |
||||
ofstream gLogFile ; |
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
typedef set<string> StringSet ; |
||||
static StringSet gLogging ; |
||||
|
||||
void initLogging( const wchar_t* pLogging ) |
||||
{ |
||||
// initialize logging
|
||||
gLogging.clear() ; |
||||
if ( pLogging == NULL ) |
||||
return ; |
||||
for ( const wchar_t* p=pLogging ; ; ) |
||||
{ |
||||
const wchar_t* q = wcschr( p , L'|' ) ; |
||||
if ( q == NULL ) |
||||
{ |
||||
gLogging.insert( toUtf8(p) ) ; |
||||
break ; |
||||
} |
||||
gLogging.insert( toUtf8(p,q-p) ) ; |
||||
p = q + 1 ; |
||||
} |
||||
} |
||||
|
||||
bool isLoggingEnabled( const string& s ) { return gLogging.find(s) != gLogging.end() ; } |
@ -0,0 +1,45 @@ |
||||
#ifndef GLOBALS_HPP |
||||
#define GLOBALS_HPP |
||||
|
||||
#include <windows.h> |
||||
#include <iostream> |
||||
#include <fstream> |
||||
|
||||
#include "device.hpp" |
||||
#include "deviceConfig.hpp" |
||||
#include "utils.hpp" |
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
extern HMODULE ghInterceptionDll ; |
||||
|
||||
typedef IntPtrMap<Device> DeviceTable ; |
||||
extern DeviceTable gDeviceTable ; |
||||
|
||||
typedef IntPtrMap<DeviceConfig> DeviceConfigTable ; |
||||
extern DeviceConfigTable gDeviceConfigTable ; |
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
#define LOG_MSG( msg ) \ |
||||
{ \
|
||||
if ( gEnableConsole || gLogFile.is_open() ) \
|
||||
{ \
|
||||
string _buf_ = MAKE_STRING( msg ) ; \
|
||||
if ( gEnableConsole ) \
|
||||
cout << _buf_ << endl ; \
|
||||
if ( gLogFile.is_open() ) \
|
||||
gLogFile << _buf_ << endl ; \
|
||||
} \
|
||||
} |
||||
|
||||
extern void initLogging( const wchar_t* ) ; |
||||
extern bool isLoggingEnabled( const std::string& ) ; |
||||
|
||||
extern bool gEnableConsole ; |
||||
extern std::wstring gLogFilename ; |
||||
extern std::ofstream gLogFile ; |
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
#endif // GLOBALS_HPP
|
Loading…
Reference in new issue