mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
- avoid using _tprintf
- use EnvironmentVariable as a singleton svn path=/trunk/; revision=24586
This commit is contained in:
parent
98aa4d7f47
commit
74847bd6f5
8 changed files with 108 additions and 55 deletions
|
@ -14,9 +14,20 @@
|
||||||
|
|
||||||
namespace Sysreg_
|
namespace Sysreg_
|
||||||
{
|
{
|
||||||
using std::cout;
|
#ifdef UNICODE
|
||||||
|
|
||||||
|
using std::wcerr;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
#define cerr wcerr
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
using std::ifstream;
|
using std::ifstream;
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
ConfigParser::ConfigParser()
|
ConfigParser::ConfigParser()
|
||||||
|
@ -84,9 +95,7 @@ namespace Sysreg_
|
||||||
ConfigMap::iterator it = m_Map.find (ConfVariable);
|
ConfigMap::iterator it = m_Map.find (ConfVariable);
|
||||||
if (it == m_Map.end ())
|
if (it == m_Map.end ())
|
||||||
{
|
{
|
||||||
#ifdef NDEBUG
|
|
||||||
cerr << "ConfigParser::getValue failed to find " << ConfVariable << endl;
|
cerr << "ConfigParser::getValue failed to find " << ConfVariable << endl;
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
namespace Sysreg_
|
namespace Sysreg_
|
||||||
{
|
{
|
||||||
using std::map;
|
using std::map;
|
||||||
|
using std::wstring;
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
/// class ConfigParser
|
/// class ConfigParser
|
||||||
|
@ -34,6 +35,7 @@ namespace Sysreg_
|
||||||
class ConfigParser
|
class ConfigParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef std::basic_string<TCHAR> string;
|
typedef std::basic_string<TCHAR> string;
|
||||||
typedef std::basic_istringstream<TCHAR> istringstream;
|
typedef std::basic_istringstream<TCHAR> istringstream;
|
||||||
typedef map<string, string> ConfigMap;
|
typedef map<string, string> ConfigMap;
|
||||||
|
|
|
@ -13,9 +13,22 @@
|
||||||
|
|
||||||
namespace System_
|
namespace System_
|
||||||
{
|
{
|
||||||
using std::cout;
|
#ifdef UNICODE
|
||||||
|
|
||||||
|
using std::wcerr;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
|
#define cerr wcerr
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
EnvironmentVariable::EnvironmentMap EnvironmentVariable::m_Map;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
EnvironmentVariable::EnvironmentVariable()
|
EnvironmentVariable::EnvironmentVariable()
|
||||||
|
@ -44,17 +57,13 @@ namespace System_
|
||||||
|
|
||||||
if (!value)
|
if (!value)
|
||||||
{
|
{
|
||||||
#ifdef NDEBUG
|
|
||||||
cerr << "EnvironmentVariable::getValue found no value for " << EnvName << endl;
|
cerr << "EnvironmentVariable::getValue found no value for " << EnvName << endl;
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_tcslen(value))
|
if (!_tcslen(value))
|
||||||
{
|
{
|
||||||
#ifdef NDEBUG
|
|
||||||
cerr << "EnvironmentVariable::getValue found no value for " << EnvName << endl;
|
cerr << "EnvironmentVariable::getValue found no value for " << EnvName << endl;
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,16 +28,8 @@ namespace System_
|
||||||
|
|
||||||
class EnvironmentVariable
|
class EnvironmentVariable
|
||||||
{
|
{
|
||||||
typedef map<string, string> EnvironmentMap;
|
|
||||||
public:
|
public:
|
||||||
//---------------------------------------------------------------------------------------
|
typedef map<string, string> EnvironmentMap;
|
||||||
///
|
|
||||||
/// EnvironmentVariable
|
|
||||||
///
|
|
||||||
/// Description: constructor of class EnvironmentVariable
|
|
||||||
|
|
||||||
EnvironmentVariable();
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
/// ~EnvironmentVariable
|
/// ~EnvironmentVariable
|
||||||
|
@ -58,11 +50,20 @@ namespace System_
|
||||||
/// @param EnvValue value of the environment variable
|
/// @param EnvValue value of the environment variable
|
||||||
/// @return bool
|
/// @return bool
|
||||||
|
|
||||||
bool getValue(const string & EnvName, string & EnvValue);
|
static bool getValue(const string & EnvName, string & EnvValue);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EnvironmentMap m_Map;
|
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
/// EnvironmentVariable
|
||||||
|
///
|
||||||
|
/// Description: constructor of class EnvironmentVariable
|
||||||
|
|
||||||
|
EnvironmentVariable();
|
||||||
|
|
||||||
|
static EnvironmentMap m_Map;
|
||||||
|
|
||||||
}; // end of class EnvironmentVariable
|
}; // end of class EnvironmentVariable
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,19 @@
|
||||||
|
|
||||||
namespace System_
|
namespace System_
|
||||||
{
|
{
|
||||||
using std::cout;
|
#ifdef UNICODE
|
||||||
|
|
||||||
|
using std::wcerr;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
|
#define cerr wcerr
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
PipeReader::PipeReader() : m_File(NULL)
|
PipeReader::PipeReader() : m_File(NULL)
|
||||||
|
@ -36,24 +46,18 @@ namespace System_
|
||||||
{
|
{
|
||||||
if (m_File != NULL)
|
if (m_File != NULL)
|
||||||
{
|
{
|
||||||
#ifdef NDEBUG
|
|
||||||
cerr << "PipeReader::openPipe> pipe already open" << endl;
|
cerr << "PipeReader::openPipe> pipe already open" << endl;
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
m_File = _tpopen(PipeCmd.c_str(), AccessMode.c_str());
|
m_File = _tpopen(PipeCmd.c_str(), AccessMode.c_str());
|
||||||
if (m_File)
|
if (m_File)
|
||||||
{
|
{
|
||||||
#ifdef NDEBUG
|
|
||||||
cerr << "PipeReader::openPipe> successfully opened pipe" << endl;
|
cerr << "PipeReader::openPipe> successfully opened pipe" << endl;
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NDEBUG
|
|
||||||
cerr << "PipeReader::openPipe> failed to open pipe " << PipeCmd << endl;
|
cerr << "PipeReader::openPipe> failed to open pipe " << PipeCmd << endl;
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,9 +67,7 @@ namespace System_
|
||||||
{
|
{
|
||||||
if (!m_File)
|
if (!m_File)
|
||||||
{
|
{
|
||||||
#ifdef NDEBUG
|
|
||||||
cerr << "PipeReader::closePipe> pipe is not open" << endl;
|
cerr << "PipeReader::closePipe> pipe is not open" << endl;
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,9 +75,7 @@ namespace System_
|
||||||
|
|
||||||
if (res == UINT_MAX)
|
if (res == UINT_MAX)
|
||||||
{
|
{
|
||||||
#ifdef NDEBUG
|
|
||||||
cerr << "Error: _pclose failed " <<endl;
|
cerr << "Error: _pclose failed " <<endl;
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,16 +105,9 @@ namespace System_
|
||||||
TCHAR * res = _fgetts(buf, size, m_File);
|
TCHAR * res = _fgetts(buf, size, m_File);
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
#ifdef NDEBUG
|
|
||||||
cerr << "Error: PipeReader::readPipe failed" << endl;
|
cerr << "Error: PipeReader::readPipe failed" << endl;
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NDEBUG
|
|
||||||
cerr << "PipeReader::readPipe> res: " << Buffer << endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return _tcslen(buf);
|
return _tcslen(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,20 @@
|
||||||
|
|
||||||
namespace Sysreg_
|
namespace Sysreg_
|
||||||
{
|
{
|
||||||
using std::cout;
|
#ifdef UNICODE
|
||||||
|
|
||||||
|
using std::wcerr;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
|
#define cerr wcerr
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
using System_::PipeReader;
|
using System_::PipeReader;
|
||||||
|
|
||||||
|
@ -72,7 +83,8 @@ namespace Sysreg_
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_tprintf(_T("Error: unknown debug port %s Currently only file|pipe is supported\n"), debug_port);
|
cerr <<"Error: unknown debug port " << debug_port <<endl
|
||||||
|
<<" Currently only file|pipe is supported" <<endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +102,7 @@ namespace Sysreg_
|
||||||
/// TBD the information needs to be written into an provided log object
|
/// TBD the information needs to be written into an provided log object
|
||||||
/// which writes the info into HTML/log / sends etc ....
|
/// which writes the info into HTML/log / sends etc ....
|
||||||
|
|
||||||
_tprintf(debug_data.c_str ());
|
cerr << debug_data << endl;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -102,7 +114,7 @@ namespace Sysreg_
|
||||||
|
|
||||||
if (!pipe_reader.openPipe(boot_cmd, string(_T("rt"))))
|
if (!pipe_reader.openPipe(boot_cmd, string(_T("rt"))))
|
||||||
{
|
{
|
||||||
_tprintf(_T("Error: failed to open pipe with cmd: %s\n"), boot_cmd.c_str ());
|
cerr << "Error: failed to open pipe with cmd: " << boot_cmd <<endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
string Buffer;
|
string Buffer;
|
||||||
|
@ -130,13 +142,13 @@ namespace Sysreg_
|
||||||
|
|
||||||
if (!pipe_reader.openPipe(boot_cmd, string(_T("rt"))))
|
if (!pipe_reader.openPipe(boot_cmd, string(_T("rt"))))
|
||||||
{
|
{
|
||||||
_tprintf(_T("Error: failed to open pipe with cmd: %s\n"), boot_cmd.c_str ());
|
cerr << "Error: failed to open pipe with cmd: " << boot_cmd << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FILE * file = _tfopen(debug_log.c_str (), _T("rt"));
|
FILE * file = _tfopen(debug_log.c_str (), _T("rt"));
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
_tprintf(_T("Error: failed to open debug log %s\n", debug_log.c_str ()));
|
cerr << "Error: failed to open debug log " << debug_log << endl;
|
||||||
pipe_reader.closePipe ();
|
pipe_reader.closePipe ();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -156,6 +168,7 @@ namespace Sysreg_
|
||||||
}while(!pipe_reader.isEof ());
|
}while(!pipe_reader.isEof ());
|
||||||
|
|
||||||
pipe_reader.closePipe ();
|
pipe_reader.closePipe ();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of namespace Sysreg_
|
} // end of namespace Sysreg_
|
|
@ -25,9 +25,22 @@
|
||||||
|
|
||||||
namespace System_
|
namespace System_
|
||||||
{
|
{
|
||||||
using std::cout;
|
|
||||||
|
#ifdef UNICODE
|
||||||
|
|
||||||
|
using std::wcerr;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
|
#define cerr wcerr
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
string SymbolFile::VAR_ROS_OUTPUT = _T("ROS_OUTPUT");
|
string SymbolFile::VAR_ROS_OUTPUT = _T("ROS_OUTPUT");
|
||||||
|
@ -52,13 +65,12 @@ namespace System_
|
||||||
bool SymbolFile::initialize(ConfigParser & conf_parser, const System_::string &Path)
|
bool SymbolFile::initialize(ConfigParser & conf_parser, const System_::string &Path)
|
||||||
{
|
{
|
||||||
vector<string> vect;
|
vector<string> vect;
|
||||||
EnvironmentVariable envvar;
|
|
||||||
string current_dir;
|
string current_dir;
|
||||||
|
|
||||||
if (Path == _T(""))
|
if (Path == _T(""))
|
||||||
{
|
{
|
||||||
current_dir = _T("output-i386");
|
current_dir = _T("output-i386");
|
||||||
envvar.getValue(SymbolFile::VAR_ROS_OUTPUT, current_dir);
|
EnvironmentVariable::getValue(SymbolFile::VAR_ROS_OUTPUT, current_dir);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -102,6 +114,8 @@ namespace System_
|
||||||
path.insert (path.length () -1, _T("\\"));
|
path.insert (path.length () -1, _T("\\"));
|
||||||
path.insert (path.length () -1, filename);
|
path.insert (path.length () -1, filename);
|
||||||
|
|
||||||
|
cerr << "Module Name " << modulename << endl << "File Name " << filename << endl;
|
||||||
|
|
||||||
m_Map.insert(std::make_pair<string, string>(modulename, path));
|
m_Map.insert(std::make_pair<string, string>(modulename, path));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -168,7 +182,7 @@ namespace System_
|
||||||
|
|
||||||
if (!pipe_reader.openPipe (pipe_cmd))
|
if (!pipe_reader.openPipe (pipe_cmd))
|
||||||
{
|
{
|
||||||
_tprintf(_T("SymbolFile::resolveAddress> failed to open pipe %s"), pipe_cmd);
|
cerr << "SymbolFile::resolveAddress> failed to open pipe" <<pipe_cmd <<endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +203,7 @@ namespace System_
|
||||||
|
|
||||||
if (it == m_Map.end ())
|
if (it == m_Map.end ())
|
||||||
{
|
{
|
||||||
_tprintf(_T("SymbolFile::resolveAddress> no symbol file found for module %s"), ModuleName.c_str());
|
cerr << "SymbolFile::resolveAddress> no symbol file found for module " << ModuleName << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,25 @@
|
||||||
|
|
||||||
#include "sysreg.h"
|
#include "sysreg.h"
|
||||||
|
|
||||||
|
#ifdef UNICODE
|
||||||
|
|
||||||
|
using std::wcerr;
|
||||||
|
using std::endl;
|
||||||
|
using std::wcout;
|
||||||
|
|
||||||
|
#define cerr wcerr
|
||||||
|
#define cout wcout
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
using std::cerr;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
typedef std::basic_string<TCHAR> string;
|
typedef std::basic_string<TCHAR> string;
|
||||||
|
|
||||||
using std::cout;
|
|
||||||
using std::endl;
|
|
||||||
using std::cerr;
|
|
||||||
|
|
||||||
|
|
||||||
using System_::EnvironmentVariable;
|
using System_::EnvironmentVariable;
|
||||||
using System_::ComponentFactoryTemplate;
|
using System_::ComponentFactoryTemplate;
|
||||||
|
@ -63,7 +75,7 @@ int _tmain(int argc, TCHAR * argv[])
|
||||||
RegressionTest * regtest = comp_factory.createComponent (argv[2]);
|
RegressionTest * regtest = comp_factory.createComponent (argv[2]);
|
||||||
if (!regtest)
|
if (!regtest)
|
||||||
{
|
{
|
||||||
_tprintf(_T("Error: the requested regression test does not exist"));
|
cerr << "Error: the requested regression test does not exist" << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,11 +87,11 @@ int _tmain(int argc, TCHAR * argv[])
|
||||||
|
|
||||||
if (regtest->execute (config))
|
if (regtest->execute (config))
|
||||||
{
|
{
|
||||||
_tprintf(_T("The regression test %s completed successfully\n"), regtest->getName ().c_str ());
|
cout << "The regression test " << regtest->getName () << " completed successfully" << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_tprintf(_T("The regression test %s failed\n"), regtest->getName ().c_str ());
|
cout << "The regression test " << regtest->getName () << "failed" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue