diff --git a/reactos/tools/sysreg/conf_parser.cpp b/reactos/tools/sysreg/conf_parser.cpp index b82ae1a1f7a..fbf65d4d7bd 100644 --- a/reactos/tools/sysreg/conf_parser.cpp +++ b/reactos/tools/sysreg/conf_parser.cpp @@ -11,10 +11,12 @@ #include #include #include +#include namespace Sysreg_ { using std::ifstream; + extern "C" FILE * open(char * filename, char* filemode); //--------------------------------------------------------------------------------------- ConfigParser::ConfigParser() { @@ -34,7 +36,7 @@ namespace Sysreg_ #ifdef UNICODE file = _tfopen(FileName, _T("rt,ccs=UNICODE")); #else - file = _tfopen(FileName, _T("rt")); + file = open(FileName, "rt"); #endif if (!file) { diff --git a/reactos/tools/sysreg/data_source.h b/reactos/tools/sysreg/data_source.h index 859e5159794..a21e19771b7 100644 --- a/reactos/tools/sysreg/data_source.h +++ b/reactos/tools/sysreg/data_source.h @@ -28,11 +28,11 @@ public: virtual ~DataSource() {} - virtual bool open(const string & opencmd) = 0; + virtual bool openSource(const string & opencmd) = 0; - virtual bool close() = 0; + virtual bool closeSource() = 0; - virtual bool read(std::vector & vect) = 0; + virtual bool readSource(std::vector & vect) = 0; }; // end of class DataSource diff --git a/reactos/tools/sysreg/file_reader.cpp b/reactos/tools/sysreg/file_reader.cpp index a52db9ba374..4b2d2b055af 100644 --- a/reactos/tools/sysreg/file_reader.cpp +++ b/reactos/tools/sysreg/file_reader.cpp @@ -9,9 +9,10 @@ #include "file_reader.h" #include - +#include namespace System_ { + extern "C" FILE * open(char * filename, char* filemode); //--------------------------------------------------------------------------------------- FileReader::FileReader() : DataSource(), m_File(NULL) { @@ -21,12 +22,12 @@ namespace System_ { } //--------------------------------------------------------------------------------------- - bool FileReader::open(const string & filename) + bool FileReader::openSource(const string & filename) { #ifdef UNICODE - m_File = _tfopen(filename.c_str(), _T("rb,ccs=UNICODE")); + m_File = (FILE*)_tfopen(filename.c_str(), _T("rb,ccs=UNICODE")); #else - m_File = _tfopen(filename.c_str(), _T("rb")); + m_File = open((char*)filename.c_str(), (char*)"rb"); #endif if (m_File) @@ -39,7 +40,7 @@ namespace System_ } } //--------------------------------------------------------------------------------------- - bool FileReader::close() + bool FileReader::closeSource() { if (!m_File) { @@ -55,7 +56,7 @@ namespace System_ return false; } //--------------------------------------------------------------------------------------- - bool FileReader::read(vector & lines) + bool FileReader::readSource(vector & lines) { if (!m_File) { @@ -135,7 +136,7 @@ namespace System_ total_length = 0; while((ptr = _tcsstr(offset, _T("\x0D\x0A"))) != NULL) { - long long length = ((long long)ptr - (long long)offset); + long length = ((long )ptr - (long)offset); length /= sizeof(TCHAR); offset[length] = _T('\0'); diff --git a/reactos/tools/sysreg/file_reader.h b/reactos/tools/sysreg/file_reader.h index dcebb77d1c8..146e70a2267 100644 --- a/reactos/tools/sysreg/file_reader.h +++ b/reactos/tools/sysreg/file_reader.h @@ -14,7 +14,6 @@ #include "user_types.h" #include "data_source.h" #include - namespace System_ { using std::vector; @@ -52,8 +51,7 @@ namespace System_ /// @param filename name of the file to open /// @return bool - virtual bool open(const string & filename); - + virtual bool openSource(const string & filename); //--------------------------------------------------------------------------------------- /// /// closeFile @@ -62,7 +60,7 @@ namespace System_ /// /// @return bool - virtual bool close(); + virtual bool closeSource(); //--------------------------------------------------------------------------------------- /// @@ -73,7 +71,7 @@ namespace System_ /// Note: returns true on success /// - virtual bool read(vector & lines); + virtual bool readSource(vector & lines); diff --git a/reactos/tools/sysreg/namedpipe_reader.cpp b/reactos/tools/sysreg/namedpipe_reader.cpp index 5638d72bd4a..16c71b8e324 100644 --- a/reactos/tools/sysreg/namedpipe_reader.cpp +++ b/reactos/tools/sysreg/namedpipe_reader.cpp @@ -33,7 +33,7 @@ namespace System_ //--------------------------------------------------------------------------------------- - bool NamedPipeReader::open(const string & PipeCmd) + bool NamedPipeReader::openSource(const string & PipeCmd) { if (h_Pipe != NULLVAL) { @@ -68,7 +68,7 @@ namespace System_ //--------------------------------------------------------------------------------------- - bool NamedPipeReader::close() + bool NamedPipeReader::closeSource() { if (!h_Pipe) { @@ -171,7 +171,7 @@ namespace System_ //--------------------------------------------------------------------------------------- - bool NamedPipeReader::read(vector & vect) + bool NamedPipeReader::readSource(vector & vect) { char * localbuf; DWORD localsize = 100; diff --git a/reactos/tools/sysreg/namedpipe_reader.h b/reactos/tools/sysreg/namedpipe_reader.h index 7de52992efb..27d734ddd3a 100644 --- a/reactos/tools/sysreg/namedpipe_reader.h +++ b/reactos/tools/sysreg/namedpipe_reader.h @@ -74,7 +74,7 @@ namespace System_ /// /// @return bool - virtual bool open(const string & PipeCmd); + virtual bool openSource(const string & PipeCmd); //--------------------------------------------------------------------------------------- /// @@ -84,7 +84,7 @@ namespace System_ /// /// @return bool - virtual bool close(); + virtual bool closeSource(); //--------------------------------------------------------------------------------------- /// @@ -96,7 +96,7 @@ namespace System_ /// @param Buffer to be written to /// @return size_t - virtual bool read(std::vector & vect); + virtual bool readSource(std::vector & vect); //--------------------------------------------------------------------------------------- /// diff --git a/reactos/tools/sysreg/os_support.cpp b/reactos/tools/sysreg/os_support.cpp index 327daaadac2..0b003e5dfda 100644 --- a/reactos/tools/sysreg/os_support.cpp +++ b/reactos/tools/sysreg/os_support.cpp @@ -11,7 +11,7 @@ namespace System_ { -#ifdef WIN32 +#ifndef __LINUX__ bool OsSupport::terminateProcess(OsSupport::ProcessID pid) { HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pid); @@ -57,10 +57,10 @@ namespace System_ free(command); return pid; } - void OsSupport::sleep(long value) - { - _sleep(value); - } + void OsSupport::sleep(long value) + { + _sleep(value); + } #else /********************************************************************************************************************/ OsSupport::ProcessID OsSupport::createProcess(TCHAR *procname, int procargsnum, TCHAR **procargs) @@ -87,10 +87,10 @@ namespace System_ return true; } - void OsSupport::sleep(long value) - { - sleep(value); - } + void OsSupport::sleep(long value) + { + sleep(value); + } #endif diff --git a/reactos/tools/sysreg/pipe_reader.cpp b/reactos/tools/sysreg/pipe_reader.cpp index 88de72e3a34..317337edf50 100644 --- a/reactos/tools/sysreg/pipe_reader.cpp +++ b/reactos/tools/sysreg/pipe_reader.cpp @@ -14,6 +14,7 @@ namespace System_ { + using std::vector; //--------------------------------------------------------------------------------------- PipeReader::PipeReader() : m_File(NULL) { @@ -28,7 +29,7 @@ namespace System_ //--------------------------------------------------------------------------------------- - bool PipeReader::openPipe(string const & PipeCmd, string AccessMode) + bool PipeReader::openSource(string const & PipeCmd) { if (m_File != NULL) { @@ -49,7 +50,7 @@ namespace System_ //--------------------------------------------------------------------------------------- - bool PipeReader::closePipe() + bool PipeReader::closeSource() { if (!m_File) { @@ -78,34 +79,23 @@ namespace System_ //--------------------------------------------------------------------------------------- - string::size_type PipeReader::readPipe(string &Buffer) + bool PipeReader::readSource(vector & lines) { - - TCHAR * buf = (TCHAR *)Buffer.c_str(); - string::size_type size = Buffer.capacity(); - + TCHAR * buf = (TCHAR*)malloc(100 * sizeof(TCHAR)); //#ifdef NDEBUG - memset(buf, 0x0, sizeof(TCHAR) * size); + memset(buf, 0x0, sizeof(TCHAR) * 100); //#endif - TCHAR * res = _fgetts(buf, size, m_File); + TCHAR * res = _fgetts(buf, 100, m_File); if (!res) { cerr << "Error: PipeReader::readPipe failed" << endl; - return 0; + free(buf); + return false; } - return _tcslen(buf); - } - -//--------------------------------------------------------------------------------------- - - bool PipeReader::writePipe(const string & Buffer) - { - //TODO - // implement me - cerr << "PipeReader::writePipe is not yet implemented" << endl; - - return false; + string line(buf); + lines.push_back(line); + return true; } } // end of namespace System_ diff --git a/reactos/tools/sysreg/pipe_reader.h b/reactos/tools/sysreg/pipe_reader.h index 033c1f41d59..1998df3673f 100644 --- a/reactos/tools/sysreg/pipe_reader.h +++ b/reactos/tools/sysreg/pipe_reader.h @@ -14,8 +14,8 @@ #include "user_types.h" #include "data_source.h" -#include -#include +#include +//#include namespace System_ { @@ -61,7 +61,7 @@ namespace System_ /// w ... allows writing to the pipe /// @return bool - bool openPipe(const string & PipeCmd, string AccessMode = _T("rt")); + bool openSource(const string & PipeCmd); //--------------------------------------------------------------------------------------- /// @@ -71,7 +71,7 @@ namespace System_ /// /// @return bool - bool closePipe(); + bool closeSource(); //--------------------------------------------------------------------------------------- /// @@ -83,17 +83,7 @@ namespace System_ /// @param Buffer to be written to /// @return string::size_type - string::size_type readPipe(string & Buffer); - -//--------------------------------------------------------------------------------------- -/// -/// writePipe -/// -/// Description: attempts to write to the pipe. Returns true on success. -/// -/// @param Buffer containing information which is written to the pipe - - bool writePipe(const string & Buffer); + bool readSource(std::vector & lines); //--------------------------------------------------------------------------------------- /// diff --git a/reactos/tools/sysreg/rosboot_test.cpp b/reactos/tools/sysreg/rosboot_test.cpp index d84900771a5..b2c3602a1f2 100644 --- a/reactos/tools/sysreg/rosboot_test.cpp +++ b/reactos/tools/sysreg/rosboot_test.cpp @@ -55,7 +55,7 @@ namespace Sysreg_ string RosBootTest::CRITICAL_APP = _T("ROSBOOT_CRITICAL_APP"); //--------------------------------------------------------------------------------------- - RosBootTest::RosBootTest() : RegressionTest(RosBootTest::CLASS_NAME), m_Timeout(60.0), m_Delayread(0) + RosBootTest::RosBootTest() : m_Timeout(60.0), m_Delayread(0) { } @@ -69,16 +69,16 @@ namespace Sysreg_ void RosBootTest::getPidFromFile() { FileReader file; - if (file.open(m_PidFile.c_str ())) + if (file.openSource(m_PidFile.c_str ())) { vector lines; - file.read(lines); + file.readSource(lines); if (lines.size() == 1) { string line = lines[0]; m_Pid = _ttoi(line.c_str ()); } - file.close(); + file.closeSource(); } } //--------------------------------------------------------------------------------------- @@ -292,7 +292,7 @@ namespace Sysreg_ src = m_File; } - if (!m_DataSource->open(src)) + if (!m_DataSource->openSource(src)) { cerr << "Error: failed to open data source with " << src << endl; return false; @@ -300,7 +300,7 @@ namespace Sysreg_ bool ret = analyzeDebugData(); - m_DataSource->close(); + m_DataSource->closeSource(); OsSupport::sleep(3 * CLOCKS_PER_SEC); if (m_Pid) { @@ -522,7 +522,7 @@ namespace Sysreg_ } size_t prev_count = vect.size (); - if (!m_DataSource->read (vect)) + if (!m_DataSource->readSource (vect)) { cerr << "No data read" << endl; continue; @@ -548,7 +548,7 @@ namespace Sysreg_ } lines += (vect.size() -prev_count); //WTF? } - m_DataSource->close(); + m_DataSource->closeSource(); if (write_log) { file.close(); diff --git a/reactos/tools/sysreg/rosboot_test.h b/reactos/tools/sysreg/rosboot_test.h index 383a643d30c..dbcfc04f755 100644 --- a/reactos/tools/sysreg/rosboot_test.h +++ b/reactos/tools/sysreg/rosboot_test.h @@ -9,19 +9,17 @@ * PURPOSE: ReactOS boot test * PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at) */ - - -#include "reg_test.h" #include "data_source.h" +#include "conf_parser.h" #include -#ifndef WIN32 #include -#endif + namespace Sysreg_ { using std::vector; using System_::DataSource; + //--------------------------------------------------------------------------------------- /// /// class RosBootTest @@ -29,7 +27,7 @@ namespace Sysreg_ /// Description: this class attempts to boot ReactOS in an emulator with console logging enabled. /// It - class RosBootTest : public RegressionTest + class RosBootTest { public: static string VARIABLE_NAME; diff --git a/reactos/tools/sysreg/sysreg.cpp b/reactos/tools/sysreg/sysreg.cpp index 0d4fde4ed9e..0b6e0e5ca0d 100644 --- a/reactos/tools/sysreg/sysreg.cpp +++ b/reactos/tools/sysreg/sysreg.cpp @@ -12,20 +12,16 @@ #include "sysreg.h" using System_::EnvironmentVariable; -using System_::ComponentFactoryTemplate; using Sysreg_::ConfigParser; //regression test classes -using Sysreg_::RegressionTest; using Sysreg_::RosBootTest; #if 0 using System_::SymbolFile; #endif -typedef ComponentFactoryTemplate ComponentFactory; - static const TCHAR USAGE[] = _T("sysreg.exe -l | [conf_file] \n\n-l - list available tests\nconf_file - (optional) path to a configuration file (default: sysreg.cfg)\ntest_name - name of test to execute\n"); @@ -35,7 +31,6 @@ _T("sysreg.exe -l | [conf_file] \n\n-l - list available tes int _tmain(int argc, TCHAR * argv[]) { ConfigParser config; - ComponentFactory comp_factory; TCHAR DefaultConfig[] = _T("sysreg.cfg"); TCHAR *ConfigFile; TCHAR * TestName; @@ -47,19 +42,6 @@ int _tmain(int argc, TCHAR * argv[]) } //--------------------------------------------------------------------------------------- - /// regression tests should be registered here - comp_factory.registerComponent(RosBootTest::CLASS_NAME); - -//--------------------------------------------------------------------------------------- - - if (argc == 2) - { - if (_tcscmp(argv[1], _T("-l")) == 0) - { - comp_factory.listComponentIds(); - return -1; - } - } if (argc == 2) { @@ -79,7 +61,7 @@ int _tmain(int argc, TCHAR * argv[]) return -1; } - RegressionTest * regtest = comp_factory.createComponent (TestName); + RosBootTest * regtest = new RosBootTest(); if (!regtest) { cerr << "Error: the requested regression test does not exist" << endl; @@ -94,11 +76,11 @@ int _tmain(int argc, TCHAR * argv[]) #endif if (regtest->execute (config)) { - cout << "The regression test " << regtest->getName () << " completed successfully" << endl; + cout << "The regression test completed successfully" << endl; } else { - cout << "The regression test " << regtest->getName () << " failed" << endl; + cout << "The regression test failed" << endl; return -2; } diff --git a/reactos/tools/sysreg/sysreg.h b/reactos/tools/sysreg/sysreg.h index e467e3ffb71..dc27283ccce 100644 --- a/reactos/tools/sysreg/sysreg.h +++ b/reactos/tools/sysreg/sysreg.h @@ -13,7 +13,6 @@ #include "user_types.h" #include "env_var.h" #include "sym_file.h" -#include "comp_factory.h" #include "conf_parser.h" // regression test classes diff --git a/reactos/tools/sysreg/user_types.h b/reactos/tools/sysreg/user_types.h index 7316138137c..ada3e690f06 100644 --- a/reactos/tools/sysreg/user_types.h +++ b/reactos/tools/sysreg/user_types.h @@ -28,11 +28,17 @@ #define _tremove remove #define _ttoi atoi #define _T(x) x + #define _tfopen _open + #define _tcsstr strstr + #define _fgetts fgets + #define _tgetenv getenv + #define _tmain main #endif typedef std::basic_string string; typedef std::basic_istringstream istringstream; + #ifdef UNICODE using std::wcout;