mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 22:52:54 +00:00
- read lines into a vector of string lines
- move os specific functions into an own file - fix a bug in command line options parsing - add function for converting ansi2Unicode svn path=/trunk/; revision=24688
This commit is contained in:
parent
8be06d0e3b
commit
69722e926c
11 changed files with 407 additions and 101 deletions
|
@ -38,7 +38,7 @@ namespace Sysreg_
|
|||
#endif
|
||||
if (!file)
|
||||
{
|
||||
cerr << " Error: ConfigParser::parseFile failed to open configuration file " <<endl;
|
||||
cerr << "Error: ConfigParser::parseFile failed to open configuration file " << FileName << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
|
||||
#include "namedpipe_reader.h"
|
||||
#include "unicode.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <assert.h>
|
||||
|
@ -17,6 +18,7 @@ namespace System_
|
|||
{
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
using std::vector;
|
||||
//---------------------------------------------------------------------------------------
|
||||
NamedPipeReader::NamedPipeReader() : h_Pipe(NULL)
|
||||
{
|
||||
|
@ -90,71 +92,126 @@ namespace System_
|
|||
h_Pipe = NULL;
|
||||
return true;
|
||||
}
|
||||
//---------------------------------------------------------------------------------------
|
||||
void NamedPipeReader::extractLines(TCHAR * buffer, std::vector<string> & vect, bool & append_line, unsigned long cbRead)
|
||||
{
|
||||
TCHAR * offset = _tcsstr(buffer, _T("\x0D"));
|
||||
DWORD buf_offset = 0;
|
||||
while(offset)
|
||||
{
|
||||
offset[0] = _T('\0');
|
||||
string line = buffer;
|
||||
if (append_line)
|
||||
{
|
||||
assert(vect.empty () == false);
|
||||
string prev_line = vect[vect.size () -1];
|
||||
prev_line += line;
|
||||
vect.pop_back ();
|
||||
vect.push_back (prev_line);
|
||||
append_line = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
vect.push_back (line);
|
||||
}
|
||||
|
||||
offset += 2;
|
||||
|
||||
buf_offset += line.length () + 2;
|
||||
if (buf_offset >= cbRead)
|
||||
{
|
||||
break;
|
||||
}
|
||||
buffer = offset;
|
||||
offset = _tcsstr(buffer, _T("\n"));
|
||||
}
|
||||
if (buf_offset < cbRead)
|
||||
{
|
||||
string line = buffer;
|
||||
if (append_line)
|
||||
{
|
||||
assert(vect.empty () == false);
|
||||
string prev_line = vect[vect.size () -1];
|
||||
vect.pop_back ();
|
||||
prev_line += line;
|
||||
vect.push_back (prev_line);
|
||||
}
|
||||
else
|
||||
{
|
||||
vect.push_back (line);
|
||||
append_line = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
append_line = false;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
string::size_type NamedPipeReader::readPipe(string &Buffer)
|
||||
size_t NamedPipeReader::readPipe(vector<string> & vect)
|
||||
{
|
||||
TCHAR * buf = (TCHAR *)Buffer.c_str();
|
||||
string::size_type buffer_size = Buffer.capacity();
|
||||
string::size_type bytes_read = 0;
|
||||
DWORD cbRead;
|
||||
char * localbuf;
|
||||
DWORD localsize = 100;
|
||||
size_t lines = vect.size ();
|
||||
|
||||
#ifdef WIN32
|
||||
BOOL fSuccess;
|
||||
TCHAR * localbuf;
|
||||
DWORD localsize = MIN(100, buffer_size);
|
||||
|
||||
//#ifdef NDEBUG
|
||||
memset(buf, 0x0, sizeof(TCHAR) * buffer_size);
|
||||
//#endif
|
||||
|
||||
#ifdef __LINUX__
|
||||
|
||||
#else
|
||||
localbuf = (TCHAR*) HeapAlloc(GetProcessHeap(), 0, localsize * sizeof(TCHAR));
|
||||
localbuf = (char*) HeapAlloc(GetProcessHeap(), 0, localsize * sizeof(char));
|
||||
#ifdef UNICODE
|
||||
wchar_t * wbuf = (WCHAR*) HeapAlloc(GetProcessHeap(), 0, localsize * sizeof(wchar_t));
|
||||
#endif
|
||||
if (localbuf != NULL)
|
||||
{
|
||||
|
||||
bool append_line = false;
|
||||
do
|
||||
{
|
||||
DWORD cbRead;
|
||||
do
|
||||
{
|
||||
ZeroMemory(localbuf, localsize * sizeof(TCHAR));
|
||||
ZeroMemory(localbuf, localsize * sizeof(char));
|
||||
#ifdef UNICODE
|
||||
ZeroMemory(wbuf, localsize * sizeof(wchar_t));
|
||||
#endif
|
||||
|
||||
fSuccess = ReadFile(
|
||||
h_Pipe,
|
||||
localbuf,
|
||||
localsize * sizeof(TCHAR),
|
||||
(localsize-1) * sizeof(char),
|
||||
&cbRead,
|
||||
NULL);
|
||||
|
||||
if (! fSuccess && GetLastError() != ERROR_MORE_DATA)
|
||||
break;
|
||||
|
||||
if(bytes_read + cbRead > buffer_size)
|
||||
#ifdef UNICODE
|
||||
if (UnicodeConverter::ansi2Unicode(localbuf, wbuf, cbRead))
|
||||
{
|
||||
Buffer.reserve(bytes_read + localsize * 3);
|
||||
buf = (TCHAR *)Buffer.c_str();
|
||||
buffer_size = Buffer.capacity();
|
||||
extractLines(wbuf, vect, append_line, cbRead);
|
||||
}
|
||||
|
||||
memcpy(&buf[bytes_read], localbuf, cbRead);
|
||||
bytes_read += cbRead;
|
||||
#else
|
||||
extractLines(localbuf, vect, append_line, cbRead);
|
||||
#endif
|
||||
|
||||
} while (!fSuccess); // repeat loop if ERROR_MORE_DATA
|
||||
} while (localbuf[_tcslen(localbuf)-1] != '\n');
|
||||
} while (localbuf[strlen(localbuf)-1] != '\n');
|
||||
|
||||
if (!fSuccess)
|
||||
return 0;
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, localbuf);
|
||||
#ifdef UNICODE
|
||||
HeapFree(GetProcessHeap(), 0, wbuf);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
buf[_tcslen(buf)-_tcslen(_T("\n"))-1] = '\0';
|
||||
return _tcslen(buf);
|
||||
|
||||
return (vect.size () - lines);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,12 +14,13 @@
|
|||
|
||||
|
||||
#include "user_types.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __LINUX__
|
||||
|
||||
#else
|
||||
#elif defined(WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
@ -82,9 +83,9 @@ namespace System_
|
|||
/// false, call PipeReader::isEoF() to determine if the pipe should be closed
|
||||
///
|
||||
/// @param Buffer to be written to
|
||||
/// @return string::size_type
|
||||
/// @return size_t
|
||||
|
||||
string::size_type readPipe(string & Buffer);
|
||||
size_t readPipe(std::vector<string> & vect);
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
|
@ -96,6 +97,21 @@ namespace System_
|
|||
bool isEof();
|
||||
|
||||
protected:
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
/// extractLines
|
||||
///
|
||||
/// Description: this functions extract lines from a buffer and pushes them into the supplied vector
|
||||
///
|
||||
/// @param buffer from which the lines are extracted from
|
||||
/// @param vect vector storing the extracted lines
|
||||
/// @param append_line if the line isnt fully read, the line is appended
|
||||
|
||||
void extractLines(TCHAR * buffer, std::vector<string> & vect, bool & append_line, unsigned long cbRead);
|
||||
|
||||
|
||||
|
||||
|
||||
HANDLE h_Pipe;
|
||||
|
||||
}; // end of class NamedPipeReader
|
||||
|
|
76
reactos/tools/sysreg/os_support.cpp
Normal file
76
reactos/tools/sysreg/os_support.cpp
Normal file
|
@ -0,0 +1,76 @@
|
|||
/* $Id: os_support.h 24643 2006-10-24 11:45:21Z janderwald $
|
||||
*
|
||||
* PROJECT: System regression tool for ReactOS
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: tools/sysreg/conf_parser.h
|
||||
* PURPOSE: operating systems specific code
|
||||
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
|
||||
*/
|
||||
|
||||
#include "os_support.h"
|
||||
|
||||
namespace System_
|
||||
{
|
||||
#ifdef WIN32
|
||||
bool OsSupport::terminateProcess(OsSupport::ProcessID pid)
|
||||
{
|
||||
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
|
||||
if (!hProcess)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = TerminateProcess(hProcess, 0);
|
||||
CloseHandle(hProcess);
|
||||
return ret;
|
||||
}
|
||||
|
||||
OsSupport::ProcessID OsSupport::createProcess(TCHAR *procname, int procargsnum, TCHAR **procargs)
|
||||
{
|
||||
STARTUPINFO siStartInfo;
|
||||
PROCESS_INFORMATION piProcInfo;
|
||||
OsSupport::ProcessID pid;
|
||||
|
||||
UNREFERENCED_PARAMETER(procargsnum);
|
||||
UNREFERENCED_PARAMETER(procargs);
|
||||
|
||||
ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
|
||||
ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION));
|
||||
|
||||
siStartInfo.cb = sizeof(STARTUPINFO);
|
||||
siStartInfo.wShowWindow = SW_SHOWNORMAL;
|
||||
siStartInfo.dwFlags = STARTF_USESHOWWINDOW;
|
||||
|
||||
LPTSTR command = _tcsdup(procname);
|
||||
|
||||
if (!CreateProcess(NULL, procname, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &siStartInfo, &piProcInfo))
|
||||
{
|
||||
cerr << "Error: CreateProcess failed " << command <<endl;
|
||||
pid = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pid = piProcInfo.dwProcessId;
|
||||
CloseHandle(piProcInfo.hProcess);
|
||||
CloseHandle(piProcInfo.hThread);
|
||||
}
|
||||
free(command);
|
||||
return pid;
|
||||
}
|
||||
#elif defined (__LINUX__)
|
||||
/********************************************************************************************************************/
|
||||
OsSupport::ProcessID OsSupport::createProcess(TCHAR *procname, int procargsnum, TCHAR **procargs)
|
||||
{
|
||||
ProcessID pid;
|
||||
|
||||
if ((pid = fork()) < 0)
|
||||
{
|
||||
cerr << "OsSupport::createProcess> fork failed" << endl;
|
||||
return pid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // end of namespace System_
|
95
reactos/tools/sysreg/os_support.h
Normal file
95
reactos/tools/sysreg/os_support.h
Normal file
|
@ -0,0 +1,95 @@
|
|||
#ifndef OS_SUPPORT_H__
|
||||
#define OS_SUPPORT_H__
|
||||
|
||||
/* $Id: os_support.h 24643 2006-10-24 11:45:21Z janderwald $
|
||||
*
|
||||
* PROJECT: System regression tool for ReactOS
|
||||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* FILE: tools/sysreg/conf_parser.h
|
||||
* PURPOSE: operating systems specific code
|
||||
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald at sbox tugraz at)
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#elif defined(__LINUX__)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "user_types.h"
|
||||
|
||||
namespace System_
|
||||
{
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
/// class OsSupport
|
||||
///
|
||||
/// Description: this class encapsulates operating system specific functions
|
||||
///
|
||||
///
|
||||
|
||||
class OsSupport
|
||||
{
|
||||
public:
|
||||
#ifdef WIN32
|
||||
|
||||
typedef DWORD ProcessID;
|
||||
|
||||
#elif defined(__LINUX__)
|
||||
|
||||
typedef pid_t ProcessID;
|
||||
|
||||
#else
|
||||
#error you need to define pid handle type for your platform
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
/// OsSupport
|
||||
///
|
||||
/// Description: constructor of class OsSupport
|
||||
|
||||
virtual ~OsSupport()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
/// createProcess
|
||||
///
|
||||
/// Description: this functions creates a new process and returns its pid on success
|
||||
///
|
||||
/// @param procname name of the file to execute
|
||||
/// @param procargsnum num of arguments for the new process
|
||||
/// @param procargs arguments for the new process
|
||||
///
|
||||
///
|
||||
|
||||
static ProcessID createProcess(TCHAR * procname, int procargsnum, TCHAR ** procargs);
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
/// terminateProcess
|
||||
///
|
||||
/// Description: this function terminates a process given by its pid
|
||||
///
|
||||
/// Note: returns true if the process with the given pid was terminated
|
||||
///
|
||||
/// @param pid process id of the process to terminate
|
||||
|
||||
static bool terminateProcess(ProcessID pid);
|
||||
|
||||
protected:
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
/// OsSupport
|
||||
///
|
||||
/// Description: constructor of class OsSupport
|
||||
|
||||
OsSupport()
|
||||
{}
|
||||
|
||||
}; // end of class OsSupport
|
||||
|
||||
} // end of namespace System_
|
||||
|
||||
#endif /* end of OS_SUPPORT_H__ */
|
|
@ -14,6 +14,7 @@
|
|||
#include "namedpipe_reader.h"
|
||||
#include "sym_file.h"
|
||||
#include "file_reader.h"
|
||||
#include "os_support.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
@ -24,11 +25,6 @@
|
|||
#include <assert.h>
|
||||
|
||||
|
||||
#ifndef __LINUX__
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace Sysreg_
|
||||
{
|
||||
using std::vector;
|
||||
|
@ -36,6 +32,7 @@ namespace Sysreg_
|
|||
using System_::NamedPipeReader;
|
||||
using System_::SymbolFile;
|
||||
using System_::FileReader;
|
||||
using System_::OsSupport;
|
||||
|
||||
string RosBootTest::VARIABLE_NAME = _T("ROSBOOT_CMD");
|
||||
string RosBootTest::CLASS_NAME = _T("rosboot");
|
||||
|
@ -113,9 +110,11 @@ namespace Sysreg_
|
|||
///
|
||||
|
||||
conf_parser.getStringValue (RosBootTest::CHECK_POINT, m_Checkpoint);
|
||||
conf_parser.getStringValue (RosBootTest::PID_FILE, m_PidFile);
|
||||
conf_parser.getStringValue (RosBootTest::CRITICAL_APP, m_CriticalApp);
|
||||
|
||||
if (conf_parser.getStringValue (RosBootTest::PID_FILE, m_PidFile))
|
||||
{
|
||||
_tremove(m_PidFile.c_str ());
|
||||
}
|
||||
|
||||
if (!_tcscmp(debug_port.c_str(), _T("pipe")))
|
||||
{
|
||||
|
@ -319,39 +318,18 @@ namespace Sysreg_
|
|||
NamedPipeReader namedpipe_reader;
|
||||
string pipecmd = _T("");
|
||||
|
||||
#ifdef __LINUX__
|
||||
pid_t pid;
|
||||
#else
|
||||
STARTUPINFO siStartInfo;
|
||||
PROCESS_INFORMATION piProcInfo;
|
||||
DWORD pid;
|
||||
///
|
||||
/// FIXME
|
||||
/// split up arguments
|
||||
|
||||
ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
|
||||
ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION));
|
||||
|
||||
siStartInfo.cb = sizeof(STARTUPINFO);
|
||||
siStartInfo.wShowWindow = SW_SHOWNORMAL;
|
||||
siStartInfo.dwFlags = STARTF_USESHOWWINDOW;
|
||||
|
||||
LPTSTR command = _tcsdup(boot_cmd.c_str());
|
||||
|
||||
if (!CreateProcess(NULL, command, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &siStartInfo, &piProcInfo))
|
||||
{
|
||||
cerr << "Error: CreateProcess failed " << boot_cmd <<endl;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
pid = piProcInfo.dwProcessId;
|
||||
}
|
||||
#endif
|
||||
OsSupport::ProcessID pid = OsSupport::createProcess ((TCHAR*)boot_cmd.c_str (), 0, NULL);
|
||||
|
||||
string::size_type pipe_pos = boot_cmd.find (_T("serial pipe:"));
|
||||
pipe_pos += 12;
|
||||
string::size_type pipe_pos_end = boot_cmd.find (_T(" "), pipe_pos);
|
||||
if (pipe_pos != string::npos && pipe_pos > 0 && pipe_pos < boot_cmd.size())
|
||||
{
|
||||
pipecmd = "\\\\.\\pipe\\" + boot_cmd.substr (pipe_pos, pipe_pos_end - pipe_pos);
|
||||
pipecmd = _T("\\\\.\\pipe\\") + boot_cmd.substr (pipe_pos, pipe_pos_end - pipe_pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -385,10 +363,8 @@ namespace Sysreg_
|
|||
break;
|
||||
}
|
||||
|
||||
if (namedpipe_reader.readPipe (Buffer) != 0)
|
||||
if (namedpipe_reader.readPipe (vect) != 0)
|
||||
{
|
||||
vect.push_back (Buffer.c_str());
|
||||
|
||||
DebugState state = checkDebugData(vect);
|
||||
if (state == DebugStateBSODDetected || state == DebugStateUMEDetected)
|
||||
{
|
||||
|
@ -402,17 +378,8 @@ namespace Sysreg_
|
|||
}
|
||||
}
|
||||
namedpipe_reader.closePipe ();
|
||||
|
||||
#ifdef __LINUX__
|
||||
kill(pid, SIGTERM);
|
||||
#else
|
||||
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
|
||||
if (hProcess)
|
||||
{
|
||||
TerminateProcess(hProcess, 0);
|
||||
}
|
||||
CloseHandle(hProcess);
|
||||
#endif
|
||||
_sleep(3* CLOCKS_PER_SEC);
|
||||
OsSupport::terminateProcess (pid);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -421,7 +388,7 @@ namespace Sysreg_
|
|||
{
|
||||
PipeReader pipe_reader;
|
||||
_tremove(debug_log.c_str ());
|
||||
_tremove(m_PidFile.c_str ());
|
||||
|
||||
if (!pipe_reader.openPipe(boot_cmd, string(_T("rt"))))
|
||||
{
|
||||
cerr << "Error: failed to open pipe with cmd: " << boot_cmd << endl;
|
||||
|
@ -437,7 +404,7 @@ namespace Sysreg_
|
|||
_sleep( (clock_t)m_Delayread * CLOCKS_PER_SEC );
|
||||
}
|
||||
|
||||
int pid = 0;
|
||||
OsSupport::ProcessID pid = 0;
|
||||
|
||||
if (m_PidFile != _T(""))
|
||||
{
|
||||
|
@ -502,17 +469,9 @@ namespace Sysreg_
|
|||
|
||||
if (pid)
|
||||
{
|
||||
#ifdef __LINUX__
|
||||
kill(pid, SIGTERM);
|
||||
#else
|
||||
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
|
||||
if (hProcess)
|
||||
{
|
||||
TerminateProcess(hProcess, 0);
|
||||
}
|
||||
CloseHandle(hProcess);
|
||||
#endif
|
||||
OsSupport::terminateProcess (pid);
|
||||
}
|
||||
|
||||
pipe_reader.closePipe ();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ ROS_ADDR2LINE=addr2line.exe --exe=
|
|||
; This value is the command which is executed to gain debugging data
|
||||
; this value is mandatory
|
||||
|
||||
ROSBOOT_CMD=D:\sysreg\qemu\qemu.exe -serial file:debug.log -boot c -m 128 -L D:\sysreg\qemu\ D:\sysreg\qemu\RosVM.vmdk -cdrom D:\Reactos\ReactOS-RegTest.iso -pidfile pid.txt
|
||||
ROSBOOT_CMD=D:\sysreg\qemu\qemu.exe -serial pipe:qemu -boot c -m 128 -L D:\sysreg\qemu\ D:\sysreg\qemu\RosVM.vmdk -cdrom D:\Reactos\ReactOS-RegTest.iso -pidfile pid.txt
|
||||
|
||||
;
|
||||
; ROSBOOT_PIDFILE
|
||||
|
@ -47,8 +47,8 @@ ROSBOOT_PID_FILE=pid.txt
|
|||
; If the value is set to pipe, then sysreg will read from pipe created by the
|
||||
; ROSBOOT_CMD
|
||||
;
|
||||
;ROSBOOT_DEBUG_PORT=pipe
|
||||
ROSBOOT_DEBUG_PORT=file
|
||||
;ROSBOOT_DEBUG_PORT=file
|
||||
ROSBOOT_DEBUG_PORT=pipe
|
||||
|
||||
;
|
||||
; ROSBOOT_DEBUG_FILE
|
||||
|
|
|
@ -36,6 +36,7 @@ int _tmain(int argc, TCHAR * argv[])
|
|||
ComponentFactory comp_factory;
|
||||
TCHAR DefaultConfig[] = _T("sysreg.cfg");
|
||||
TCHAR *ConfigFile;
|
||||
TCHAR * TestName;
|
||||
|
||||
if ((argc != 3) && (argc != 2))
|
||||
{
|
||||
|
@ -59,9 +60,15 @@ int _tmain(int argc, TCHAR * argv[])
|
|||
}
|
||||
|
||||
if (argc == 2)
|
||||
_tcscpy(ConfigFile, DefaultConfig);
|
||||
{
|
||||
ConfigFile = DefaultConfig;
|
||||
TestName = argv[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
ConfigFile = argv[1];
|
||||
TestName = argv[2];
|
||||
}
|
||||
|
||||
|
||||
if (!config.parseFile (ConfigFile))
|
||||
|
@ -70,7 +77,7 @@ int _tmain(int argc, TCHAR * argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
RegressionTest * regtest = comp_factory.createComponent (argv[2]);
|
||||
RegressionTest * regtest = comp_factory.createComponent (TestName);
|
||||
if (!regtest)
|
||||
{
|
||||
cerr << "Error: the requested regression test does not exist" << endl;
|
||||
|
|
|
@ -27,6 +27,8 @@ SYSREGBUILD_SOURCES = $(addprefix $(SYSREGBUILD_BASE_),\
|
|||
sym_file.cpp \
|
||||
sysreg.cpp \
|
||||
file_reader.cpp \
|
||||
os_support.cpp \
|
||||
unicode.cpp \
|
||||
)
|
||||
|
||||
SYSREGBUILD_OBJECTS = \
|
||||
|
@ -76,6 +78,14 @@ $(SYSREGBUILD_INT_)file_reader.o: $(SYSREGBUILD_BASE_)file_reader.cpp | $(SYSREG
|
|||
$(ECHO_CC)
|
||||
${host_gpp} $(SYSREGBUILD_HOST_CFLAGS) -c $< -o $@
|
||||
|
||||
$(SYSREGBUILD_INT_)os_support.o: $(SYSREGBUILD_BASE_)os_support.cpp | $(SYSREGBUILD_INT)
|
||||
$(ECHO_CC)
|
||||
${host_gpp} $(SYSREGBUILD_HOST_CFLAGS) -c $< -o $@
|
||||
|
||||
$(SYSREGBUILD_INT_)unicode.o: $(SYSREGBUILD_BASE_)unicode.cpp | $(SYSREGBUILD_INT)
|
||||
$(ECHO_CC)
|
||||
${host_gpp} $(SYSREGBUILD_HOST_CFLAGS) -c $< -o $@
|
||||
|
||||
.PHONY: sysregbuild_clean
|
||||
sysreg_clean:
|
||||
-@$(rm) $(SYSREGBUILD_TARGET) $(SYSREGBUILD_OBJECTS) 2>$(NUL)
|
||||
|
|
31
reactos/tools/sysreg/unicode.cpp
Normal file
31
reactos/tools/sysreg/unicode.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "unicode.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace System_
|
||||
{
|
||||
//---------------------------------------------------------------------------------------
|
||||
bool UnicodeConverter::ansi2Unicode(char * abuf, wchar_t *outbuf, size_t length)
|
||||
{
|
||||
size_t i = 0;
|
||||
int conv;
|
||||
|
||||
while((conv = mbtowc(&outbuf[i], &abuf[i], length - i)))
|
||||
{
|
||||
i += conv;
|
||||
if (i == length)
|
||||
break;
|
||||
}
|
||||
outbuf[i] = L'\0';
|
||||
|
||||
if (i)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // end of namespace System_
|
55
reactos/tools/sysreg/unicode.h
Normal file
55
reactos/tools/sysreg/unicode.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
#ifndef UNICODE_H__
|
||||
#define UNICODE_H__ // unicode.h
|
||||
|
||||
#include "user_types.h"
|
||||
|
||||
namespace System_
|
||||
{
|
||||
|
||||
class UnicodeConverter
|
||||
{
|
||||
public:
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
/// UnicodeConverter
|
||||
///
|
||||
/// Description: destructor of class UnicodeConverter
|
||||
|
||||
virtual ~UnicodeConverter()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
/// UnicodeConverter
|
||||
///
|
||||
/// Description: converts an ANSI buffer to wide character buffer
|
||||
/// using standard c routines
|
||||
///
|
||||
/// Note: make sure before calling that outbuf is big enough to receive the result
|
||||
///
|
||||
/// @param abuf ansi buffer used a source
|
||||
/// @param outbuf wide character buffer receives result
|
||||
/// @param length length of abuf
|
||||
///
|
||||
/// @return bool
|
||||
|
||||
static bool ansi2Unicode(char * abuf, wchar_t * outbuf, size_t length);
|
||||
|
||||
|
||||
protected:
|
||||
//---------------------------------------------------------------------------------------
|
||||
///
|
||||
/// UnicodeConverter
|
||||
///
|
||||
/// Description: constructor of class UnicodeConverter
|
||||
|
||||
UnicodeConverter()
|
||||
{}
|
||||
|
||||
}; // end of class UnicodeConverter
|
||||
|
||||
|
||||
|
||||
} // end of namespace System_
|
||||
|
||||
#endif /* end of UNICODE_H__ */
|
Loading…
Add table
Add a link
Reference in a new issue