From 74847bd6f54cddba904233cffad3f0b0cc701b19 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Fri, 20 Oct 2006 20:09:29 +0000 Subject: [PATCH] - avoid using _tprintf - use EnvironmentVariable as a singleton svn path=/trunk/; revision=24586 --- reactos/tools/sysreg/conf_parser.cpp | 15 +++++++++++--- reactos/tools/sysreg/conf_parser.h | 2 ++ reactos/tools/sysreg/env_var.cpp | 19 +++++++++++++----- reactos/tools/sysreg/env_var.h | 23 +++++++++++---------- reactos/tools/sysreg/pipe_reader.cpp | 29 ++++++++++----------------- reactos/tools/sysreg/rosboot_test.cpp | 25 +++++++++++++++++------ reactos/tools/sysreg/sym_file.cpp | 24 +++++++++++++++++----- reactos/tools/sysreg/sysreg.cpp | 26 +++++++++++++++++------- 8 files changed, 108 insertions(+), 55 deletions(-) diff --git a/reactos/tools/sysreg/conf_parser.cpp b/reactos/tools/sysreg/conf_parser.cpp index f09ba2fe0d3..d6020bf64bb 100644 --- a/reactos/tools/sysreg/conf_parser.cpp +++ b/reactos/tools/sysreg/conf_parser.cpp @@ -14,9 +14,20 @@ namespace Sysreg_ { - using std::cout; +#ifdef UNICODE + + using std::wcerr; + using std::endl; + +#define cerr wcerr + +#else + using std::cerr; using std::endl; + +#endif + using std::ifstream; //--------------------------------------------------------------------------------------- ConfigParser::ConfigParser() @@ -84,9 +95,7 @@ namespace Sysreg_ ConfigMap::iterator it = m_Map.find (ConfVariable); if (it == m_Map.end ()) { -#ifdef NDEBUG cerr << "ConfigParser::getValue failed to find " << ConfVariable << endl; -#endif return false; } diff --git a/reactos/tools/sysreg/conf_parser.h b/reactos/tools/sysreg/conf_parser.h index 2fa9c9ece62..b8e331bce32 100644 --- a/reactos/tools/sysreg/conf_parser.h +++ b/reactos/tools/sysreg/conf_parser.h @@ -18,6 +18,7 @@ namespace Sysreg_ { using std::map; + using std::wstring; //--------------------------------------------------------------------------------------- /// /// class ConfigParser @@ -34,6 +35,7 @@ namespace Sysreg_ class ConfigParser { public: + typedef std::basic_string string; typedef std::basic_istringstream istringstream; typedef map ConfigMap; diff --git a/reactos/tools/sysreg/env_var.cpp b/reactos/tools/sysreg/env_var.cpp index f67f48ce516..5ef740a4f0c 100644 --- a/reactos/tools/sysreg/env_var.cpp +++ b/reactos/tools/sysreg/env_var.cpp @@ -13,9 +13,22 @@ namespace System_ { - using std::cout; +#ifdef UNICODE + + using std::wcerr; using std::endl; + +#define cerr wcerr + +#else + using std::cerr; + using std::endl; + +#endif + + + EnvironmentVariable::EnvironmentMap EnvironmentVariable::m_Map; //--------------------------------------------------------------------------------------- EnvironmentVariable::EnvironmentVariable() @@ -44,17 +57,13 @@ namespace System_ if (!value) { -#ifdef NDEBUG cerr << "EnvironmentVariable::getValue found no value for " << EnvName << endl; -#endif return false; } if (!_tcslen(value)) { -#ifdef NDEBUG cerr << "EnvironmentVariable::getValue found no value for " << EnvName << endl; -#endif return false; } diff --git a/reactos/tools/sysreg/env_var.h b/reactos/tools/sysreg/env_var.h index 45b38d32bd0..9cc68c83558 100644 --- a/reactos/tools/sysreg/env_var.h +++ b/reactos/tools/sysreg/env_var.h @@ -28,16 +28,8 @@ namespace System_ class EnvironmentVariable { - typedef map EnvironmentMap; public: -//--------------------------------------------------------------------------------------- -/// -/// EnvironmentVariable -/// -/// Description: constructor of class EnvironmentVariable - - EnvironmentVariable(); - + typedef map EnvironmentMap; //--------------------------------------------------------------------------------------- /// /// ~EnvironmentVariable @@ -58,11 +50,20 @@ namespace System_ /// @param EnvValue value of the environment variable /// @return bool - bool getValue(const string & EnvName, string & EnvValue); + static bool getValue(const string & EnvName, string & EnvValue); protected: - EnvironmentMap m_Map; + +//--------------------------------------------------------------------------------------- +/// +/// EnvironmentVariable +/// +/// Description: constructor of class EnvironmentVariable + + EnvironmentVariable(); + + static EnvironmentMap m_Map; }; // end of class EnvironmentVariable diff --git a/reactos/tools/sysreg/pipe_reader.cpp b/reactos/tools/sysreg/pipe_reader.cpp index b2739775b2a..0299db6189b 100644 --- a/reactos/tools/sysreg/pipe_reader.cpp +++ b/reactos/tools/sysreg/pipe_reader.cpp @@ -14,9 +14,19 @@ namespace System_ { - using std::cout; +#ifdef UNICODE + + using std::wcerr; using std::endl; + +#define cerr wcerr + +#else + using std::cerr; + using std::endl; + +#endif //--------------------------------------------------------------------------------------- PipeReader::PipeReader() : m_File(NULL) @@ -36,24 +46,18 @@ namespace System_ { if (m_File != NULL) { -#ifdef NDEBUG cerr << "PipeReader::openPipe> pipe already open" << endl; -#endif return false; } // m_File = _tpopen(PipeCmd.c_str(), AccessMode.c_str()); if (m_File) { -#ifdef NDEBUG cerr << "PipeReader::openPipe> successfully opened pipe" << endl; -#endif return true; } -#ifdef NDEBUG cerr << "PipeReader::openPipe> failed to open pipe " << PipeCmd << endl; -#endif return false; } @@ -63,9 +67,7 @@ namespace System_ { if (!m_File) { -#ifdef NDEBUG cerr << "PipeReader::closePipe> pipe is not open" << endl; -#endif return false; } @@ -73,9 +75,7 @@ namespace System_ if (res == UINT_MAX) { -#ifdef NDEBUG cerr << "Error: _pclose failed " < res: " << Buffer << endl; -#endif - return _tcslen(buf); } diff --git a/reactos/tools/sysreg/rosboot_test.cpp b/reactos/tools/sysreg/rosboot_test.cpp index 5362c86e3df..ac27ad05055 100644 --- a/reactos/tools/sysreg/rosboot_test.cpp +++ b/reactos/tools/sysreg/rosboot_test.cpp @@ -16,9 +16,20 @@ namespace Sysreg_ { - using std::cout; +#ifdef UNICODE + + using std::wcerr; using std::endl; + +#define cerr wcerr + +#else + using std::cerr; + using std::endl; + +#endif + using System_::PipeReader; @@ -72,7 +83,8 @@ namespace Sysreg_ } else { - _tprintf(_T("Error: unknown debug port %s Currently only file|pipe is supported\n"), debug_port); + cerr <<"Error: unknown debug port " << debug_port < vect; - EnvironmentVariable envvar; string current_dir; if (Path == _T("")) { current_dir = _T("output-i386"); - envvar.getValue(SymbolFile::VAR_ROS_OUTPUT, current_dir); + EnvironmentVariable::getValue(SymbolFile::VAR_ROS_OUTPUT, current_dir); } else { @@ -101,6 +113,8 @@ namespace System_ string path = current_dir; path.insert (path.length () -1, _T("\\")); path.insert (path.length () -1, filename); + + cerr << "Module Name " << modulename << endl << "File Name " << filename << endl; m_Map.insert(std::make_pair(modulename, path)); @@ -168,7 +182,7 @@ namespace System_ if (!pipe_reader.openPipe (pipe_cmd)) { - _tprintf(_T("SymbolFile::resolveAddress> failed to open pipe %s"), pipe_cmd); + cerr << "SymbolFile::resolveAddress> failed to open pipe" < no symbol file found for module %s"), ModuleName.c_str()); + cerr << "SymbolFile::resolveAddress> no symbol file found for module " << ModuleName << endl; return false; } diff --git a/reactos/tools/sysreg/sysreg.cpp b/reactos/tools/sysreg/sysreg.cpp index 75f90885ef3..64ea598cc3d 100644 --- a/reactos/tools/sysreg/sysreg.cpp +++ b/reactos/tools/sysreg/sysreg.cpp @@ -11,13 +11,25 @@ #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 string; -using std::cout; -using std::endl; -using std::cerr; - using System_::EnvironmentVariable; using System_::ComponentFactoryTemplate; @@ -63,7 +75,7 @@ int _tmain(int argc, TCHAR * argv[]) RegressionTest * regtest = comp_factory.createComponent (argv[2]); if (!regtest) { - _tprintf(_T("Error: the requested regression test does not exist")); + cerr << "Error: the requested regression test does not exist" << endl; return -1; } @@ -75,11 +87,11 @@ int _tmain(int argc, TCHAR * argv[]) 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 { - _tprintf(_T("The regression test %s failed\n"), regtest->getName ().c_str ()); + cout << "The regression test " << regtest->getName () << "failed" << endl; } return 0;