[ros-diffs] [janderwald] 27645: - make sysreg compilable under linux

janderwald at svn.reactos.org janderwald at svn.reactos.org
Sat Jul 14 12:01:10 CEST 2007


Author: janderwald
Date: Sat Jul 14 14:01:09 2007
New Revision: 27645

URL: http://svn.reactos.org/svn/reactos?rev=27645&view=rev
Log:
- make sysreg compilable under linux

Modified:
    trunk/reactos/tools/sysreg/conf_parser.cpp
    trunk/reactos/tools/sysreg/data_source.h
    trunk/reactos/tools/sysreg/file_reader.cpp
    trunk/reactos/tools/sysreg/file_reader.h
    trunk/reactos/tools/sysreg/namedpipe_reader.cpp
    trunk/reactos/tools/sysreg/namedpipe_reader.h
    trunk/reactos/tools/sysreg/os_support.cpp
    trunk/reactos/tools/sysreg/pipe_reader.cpp
    trunk/reactos/tools/sysreg/pipe_reader.h
    trunk/reactos/tools/sysreg/rosboot_test.cpp
    trunk/reactos/tools/sysreg/rosboot_test.h
    trunk/reactos/tools/sysreg/sysreg.cpp
    trunk/reactos/tools/sysreg/sysreg.h
    trunk/reactos/tools/sysreg/user_types.h

Modified: trunk/reactos/tools/sysreg/conf_parser.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/conf_parser.cpp?rev=27645&r1=27644&r2=27645&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/conf_parser.cpp (original)
+++ trunk/reactos/tools/sysreg/conf_parser.cpp Sat Jul 14 14:01:09 2007
@@ -11,10 +11,12 @@
 #include <iostream>
 #include <sstream>
 #include <fstream>
+#include <cstdio>
 
 namespace Sysreg_
 {
 	using std::ifstream;
+	extern "C" FILE * open(char * filename, char* filemode);
 //---------------------------------------------------------------------------------------
 	ConfigParser::ConfigParser()
 	{
@@ -34,7 +36,7 @@
 #ifdef UNICODE
 		file = _tfopen(FileName, _T("rt,ccs=UNICODE"));
 #else
-		file = _tfopen(FileName, _T("rt"));
+		file = open(FileName, "rt");
 #endif
 		if (!file)
 		{

Modified: trunk/reactos/tools/sysreg/data_source.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/data_source.h?rev=27645&r1=27644&r2=27645&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/data_source.h (original)
+++ trunk/reactos/tools/sysreg/data_source.h Sat Jul 14 14:01:09 2007
@@ -28,11 +28,11 @@
     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<string> & vect) = 0;
+    virtual bool readSource(std::vector<string> & vect) = 0;
 
 }; // end of class DataSource
 

Modified: trunk/reactos/tools/sysreg/file_reader.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/file_reader.cpp?rev=27645&r1=27644&r2=27645&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/file_reader.cpp (original)
+++ trunk/reactos/tools/sysreg/file_reader.cpp Sat Jul 14 14:01:09 2007
@@ -9,9 +9,10 @@
 
 #include "file_reader.h"
 #include <assert.h>
-
+#include <cstdio>
 namespace System_
 {
+	extern "C" FILE * open(char * filename, char* filemode);
 //---------------------------------------------------------------------------------------
     FileReader::FileReader() : DataSource(),  m_File(NULL)
 	{
@@ -21,12 +22,12 @@
 	{
 	}
 //---------------------------------------------------------------------------------------
-    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 @@
 		}
 	}
 //---------------------------------------------------------------------------------------
-	bool FileReader::close()
+	bool FileReader::closeSource()
 	{
 		if (!m_File)
 		{
@@ -55,7 +56,7 @@
 		return false;
 	}
 //---------------------------------------------------------------------------------------
-	bool FileReader::read(vector<string> & lines)
+	bool FileReader::readSource(vector<string> & lines)
 	{
 		if (!m_File)
 		{
@@ -135,7 +136,7 @@
 			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');

Modified: trunk/reactos/tools/sysreg/file_reader.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/file_reader.h?rev=27645&r1=27644&r2=27645&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/file_reader.h (original)
+++ trunk/reactos/tools/sysreg/file_reader.h Sat Jul 14 14:01:09 2007
@@ -14,7 +14,6 @@
 #include "user_types.h"
 #include "data_source.h"
 #include <vector>
-
 namespace System_
 {
 	using std::vector;
@@ -52,8 +51,7 @@
 /// @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 @@
 ///
 /// @return bool
 
-	virtual bool close();
+	virtual bool closeSource();
 
 //---------------------------------------------------------------------------------------
 ///
@@ -73,7 +71,7 @@
 /// Note: returns true on success
 ///
 
-	virtual bool read(vector<string> & lines);
+	virtual bool readSource(vector<string> & lines);
 
 
 

Modified: trunk/reactos/tools/sysreg/namedpipe_reader.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/namedpipe_reader.cpp?rev=27645&r1=27644&r2=27645&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/namedpipe_reader.cpp (original)
+++ trunk/reactos/tools/sysreg/namedpipe_reader.cpp Sat Jul 14 14:01:09 2007
@@ -33,7 +33,7 @@
 
 //---------------------------------------------------------------------------------------
 
-	bool NamedPipeReader::open(const string & PipeCmd)
+	bool NamedPipeReader::openSource(const string & PipeCmd)
 	{
 		if (h_Pipe != NULLVAL)
 		{
@@ -68,7 +68,7 @@
 
 //---------------------------------------------------------------------------------------
 
-	bool NamedPipeReader::close() 
+	bool NamedPipeReader::closeSource() 
 	{
 		if (!h_Pipe)
 		{
@@ -171,7 +171,7 @@
 
 //---------------------------------------------------------------------------------------
 
-	bool NamedPipeReader::read(vector<string> & vect)
+	bool NamedPipeReader::readSource(vector<string> & vect)
 	{
 		char * localbuf;
 		DWORD localsize = 100;

Modified: trunk/reactos/tools/sysreg/namedpipe_reader.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/namedpipe_reader.h?rev=27645&r1=27644&r2=27645&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/namedpipe_reader.h (original)
+++ trunk/reactos/tools/sysreg/namedpipe_reader.h Sat Jul 14 14:01:09 2007
@@ -74,7 +74,7 @@
 ///
 /// @return bool
 
-		virtual bool open(const string & PipeCmd);
+		virtual bool openSource(const string & PipeCmd);
 
 //---------------------------------------------------------------------------------------
 ///
@@ -84,7 +84,7 @@
 ///
 /// @return bool
 
-		virtual bool close();
+		virtual bool closeSource();
 
 //---------------------------------------------------------------------------------------
 ///
@@ -96,7 +96,7 @@
 /// @param Buffer to be written to
 /// @return size_t
 
-	virtual bool read(std::vector<string> & vect);
+	virtual bool readSource(std::vector<string> & vect);
 
 //---------------------------------------------------------------------------------------
 ///

Modified: trunk/reactos/tools/sysreg/os_support.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/os_support.cpp?rev=27645&r1=27644&r2=27645&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/os_support.cpp (original)
+++ trunk/reactos/tools/sysreg/os_support.cpp Sat Jul 14 14:01:09 2007
@@ -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 @@
 		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 @@
 		return true;
 	}
 
-    void OsSupport::sleep(long value)
-    {
-        sleep(value);
-    }
+    	void OsSupport::sleep(long value)
+    	{
+        	sleep(value);
+    	}
 
 
 #endif

Modified: trunk/reactos/tools/sysreg/pipe_reader.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/pipe_reader.cpp?rev=27645&r1=27644&r2=27645&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/pipe_reader.cpp (original)
+++ trunk/reactos/tools/sysreg/pipe_reader.cpp Sat Jul 14 14:01:09 2007
@@ -14,6 +14,7 @@
 
 namespace System_
 {
+	using std::vector;
 //---------------------------------------------------------------------------------------
 	PipeReader::PipeReader() : m_File(NULL)
 	{
@@ -28,7 +29,7 @@
 
 //---------------------------------------------------------------------------------------
 
-	bool PipeReader::openPipe(string const & PipeCmd, string AccessMode)
+	bool PipeReader::openSource(string const & PipeCmd)
 	{
 		if (m_File != NULL)
 		{
@@ -49,7 +50,7 @@
 
 //---------------------------------------------------------------------------------------
 
-	bool PipeReader::closePipe() 
+	bool PipeReader::closeSource() 
 	{
 		if (!m_File)
 		{
@@ -78,34 +79,23 @@
 
 //---------------------------------------------------------------------------------------
 
-	string::size_type PipeReader::readPipe(string &Buffer)
+	bool PipeReader::readSource(vector<string> & 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_

Modified: trunk/reactos/tools/sysreg/pipe_reader.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/pipe_reader.h?rev=27645&r1=27644&r2=27645&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/pipe_reader.h (original)
+++ trunk/reactos/tools/sysreg/pipe_reader.h Sat Jul 14 14:01:09 2007
@@ -14,8 +14,8 @@
 
 #include "user_types.h"
 #include "data_source.h"
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
+//#include <stdlib.h>
 
 namespace System_
 {
@@ -61,7 +61,7 @@
 ///                           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 @@
 ///
 /// @return bool
 
-		bool closePipe();
+		bool closeSource();
 
 //---------------------------------------------------------------------------------------
 ///
@@ -83,17 +83,7 @@
 /// @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<string> & lines);
 
 //---------------------------------------------------------------------------------------
 ///

Modified: trunk/reactos/tools/sysreg/rosboot_test.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/rosboot_test.cpp?rev=27645&r1=27644&r2=27645&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/rosboot_test.cpp (original)
+++ trunk/reactos/tools/sysreg/rosboot_test.cpp Sat Jul 14 14:01:09 2007
@@ -55,7 +55,7 @@
 	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 @@
     void RosBootTest::getPidFromFile()
     {
 		FileReader file;
-		if (file.open(m_PidFile.c_str ()))
+		if (file.openSource(m_PidFile.c_str ()))
         {
 			vector<string> 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 @@
             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 @@
 
         bool ret = analyzeDebugData();
 
-        m_DataSource->close();
+        m_DataSource->closeSource();
         OsSupport::sleep(3 * CLOCKS_PER_SEC);
         if (m_Pid)
         {
@@ -522,7 +522,7 @@
 			}
 			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 @@
 			}
 			lines += (vect.size() -prev_count); //WTF?
         }
-		m_DataSource->close();
+		m_DataSource->closeSource();
 		if (write_log)
 		{
 			file.close();

Modified: trunk/reactos/tools/sysreg/rosboot_test.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/rosboot_test.h?rev=27645&r1=27644&r2=27645&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/rosboot_test.h (original)
+++ trunk/reactos/tools/sysreg/rosboot_test.h Sat Jul 14 14:01:09 2007
@@ -9,19 +9,17 @@
  * PURPOSE:     ReactOS boot test
  * PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
  */
+#include "data_source.h"
+#include "conf_parser.h"
+#include <vector>
+#include <unistd.h>
 
-
-#include "reg_test.h"
-#include "data_source.h"
-#include <vector>
-#ifndef WIN32
-#include <unistd.h>
-#endif
 
 namespace Sysreg_
 {
 	using std::vector;
     using System_::DataSource;
+
 //---------------------------------------------------------------------------------------
 ///
 /// class RosBootTest
@@ -29,7 +27,7 @@
 /// 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;

Modified: trunk/reactos/tools/sysreg/sysreg.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/sysreg.cpp?rev=27645&r1=27644&r2=27645&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/sysreg.cpp (original)
+++ trunk/reactos/tools/sysreg/sysreg.cpp Sat Jul 14 14:01:09 2007
@@ -12,19 +12,15 @@
 #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<RegressionTest, string> ComponentFactory;
 
 static const TCHAR USAGE[] = 
 _T("sysreg.exe -l | [conf_file] <testname>\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 @@
 int _tmain(int argc, TCHAR * argv[])
 {
 	ConfigParser config;
-	ComponentFactory comp_factory;
 	TCHAR DefaultConfig[] = _T("sysreg.cfg");
 	TCHAR *ConfigFile;
 	TCHAR * TestName;
@@ -47,19 +42,6 @@
 	}
 
 //---------------------------------------------------------------------------------------
-	/// regression tests should be registered here
-	comp_factory.registerComponent<RosBootTest>(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 @@
 		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 @@
 #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;
 	}
 

Modified: trunk/reactos/tools/sysreg/sysreg.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/sysreg.h?rev=27645&r1=27644&r2=27645&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/sysreg.h (original)
+++ trunk/reactos/tools/sysreg/sysreg.h Sat Jul 14 14:01:09 2007
@@ -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

Modified: trunk/reactos/tools/sysreg/user_types.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/user_types.h?rev=27645&r1=27644&r2=27645&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/user_types.h (original)
+++ trunk/reactos/tools/sysreg/user_types.h Sat Jul 14 14:01:09 2007
@@ -28,10 +28,16 @@
  #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<TCHAR> string;
 	typedef std::basic_istringstream<TCHAR> istringstream;
+
 
 #ifdef UNICODE
 




More information about the Ros-diffs mailing list