Author: janderwald Date: Mon Oct 8 04:18:01 2007 New Revision: 29450
URL: http://svn.reactos.org/svn/reactos?rev=29450&view=rev Log: - remove unicode support (it was mess, a few places only accepting char and then another using wchar compatibel) - rewrite line extraction (currently if'0) - add Wine gettimeofday implementation (currently if'0) - apply sources changes to SymbolFile class - remove unicode support class - fix a bug in the createProcess version for windows hosts which randomly led to invalid boot hdd error messages
Removed: trunk/reactos/tools/sysreg/unicode.cpp trunk/reactos/tools/sysreg/unicode.h Modified: trunk/reactos/tools/sysreg/conf_parser.cpp trunk/reactos/tools/sysreg/conf_parser.h trunk/reactos/tools/sysreg/env_var.cpp trunk/reactos/tools/sysreg/file_reader.cpp 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/os_support.h trunk/reactos/tools/sysreg/pipe_reader.cpp trunk/reactos/tools/sysreg/rosboot_test.cpp trunk/reactos/tools/sysreg/sym_file.cpp trunk/reactos/tools/sysreg/sysreg.cpp trunk/reactos/tools/sysreg/sysreg.mak 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.cp... ============================================================================== --- trunk/reactos/tools/sysreg/conf_parser.cpp (original) +++ trunk/reactos/tools/sysreg/conf_parser.cpp Mon Oct 8 04:18:01 2007 @@ -29,14 +29,9 @@ }
//--------------------------------------------------------------------------------------- - bool ConfigParser::parseFile(TCHAR * FileName) + bool ConfigParser::parseFile(char * FileName) { - FILE * file; -#ifdef UNICODE - file = _tfopen(FileName, _T("rt,ccs=UNICODE")); -#else - file = fopen(FileName, "rt"); -#endif + FILE * file = fopen(FileName, "rt"); if (!file) { cerr << "Error: ConfigParser::parseFile failed to open configuration file " << FileName << endl; @@ -45,16 +40,16 @@ bool ret = false; while (!feof(file)) { - TCHAR buffer[500]; - TCHAR * buf; + char buffer[500]; + char * buf;
- buf = _fgetts(buffer, sizeof(buffer) / sizeof(TCHAR), file); + buf = fgets(buffer, sizeof(buffer) / sizeof(char), file); if (buf) { - if (buffer[0] != _T(';')) + if (buffer[0] != ';') { string s_buffer = string(buffer); - string::size_type ws_pos = s_buffer.find_first_of (_T("=")); + string::size_type ws_pos = s_buffer.find_first_of ("=");
if (ws_pos != string::npos && ws_pos > 0 && ws_pos < s_buffer.size()) { @@ -101,7 +96,7 @@ return false; }
- ConfValue = _tcstod(it->second.c_str(), NULL); + ConfValue = strtod(it->second.c_str(), NULL); return true; } //----------------------------------------------------------------------------------------- @@ -114,7 +109,7 @@ return false; }
- ConfValue = _tcstol(it->second.c_str(), NULL, 10); + ConfValue = strtol(it->second.c_str(), NULL, 10); return true; }
Modified: trunk/reactos/tools/sysreg/conf_parser.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/conf_parser.h?... ============================================================================== --- trunk/reactos/tools/sysreg/conf_parser.h (original) +++ trunk/reactos/tools/sysreg/conf_parser.h Mon Oct 8 04:18:01 2007 @@ -62,7 +62,7 @@ /// @param FileName path to configuration file /// @return bool
- bool parseFile(TCHAR * FileName); + bool parseFile(char * FileName);
//-------------------------------------------------------------------------------------- ///
Modified: trunk/reactos/tools/sysreg/env_var.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/env_var.cpp?re... ============================================================================== --- trunk/reactos/tools/sysreg/env_var.cpp (original) +++ trunk/reactos/tools/sysreg/env_var.cpp Mon Oct 8 04:18:01 2007 @@ -39,7 +39,7 @@ return true; } - TCHAR * value = _tgetenv(EnvName.c_str ()); + char * value = getenv(EnvName.c_str ()); if (!value) { @@ -47,7 +47,7 @@ return false; }
- if (!_tcslen(value)) + if (!strlen(value)) { cerr << "EnvironmentVariable::getValue found no value for " << EnvName << endl; return false;
Modified: trunk/reactos/tools/sysreg/file_reader.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/file_reader.cp... ============================================================================== --- trunk/reactos/tools/sysreg/file_reader.cpp (original) +++ trunk/reactos/tools/sysreg/file_reader.cpp Mon Oct 8 04:18:01 2007 @@ -23,11 +23,7 @@ //--------------------------------------------------------------------------------------- bool FileReader::openSource(const string & filename) { -#ifdef UNICODE - m_File = (FILE*)_tfopen(filename.c_str(), _T("rb,ccs=UNICODE")); -#else m_File = fopen((char*)filename.c_str(), (char*)"rb"); -#endif
if (m_File) { @@ -69,34 +65,18 @@ char szBuffer[256]; int readoffset = 0;
-#ifdef UNICODE - wchar_t wbuf[512]; - int wbuf_offset = 0; - - if (m_BufferedLines.length ()) - { - wcscpy(wbuf, m_BufferedLines.c_str ()); - wbuf_offset = m_BufferedLines.length (); - } -#else if (m_BufferedLines.length()) { strcpy(szBuffer, m_BufferedLines.c_str()); readoffset = m_BufferedLines.length(); } -#endif
do { if (total_length < num) { -#ifdef UNICODE - memmove(wbuf, &wbuf[total_length], (num - total_length) * sizeof(wchar_t)); - wbuf_offset = num - total_length; -#else memmove(szBuffer, &szBuffer[total_length], num - total_length); readoffset = num - total_length; -#endif }
num = fread(&szBuffer[readoffset], @@ -113,32 +93,16 @@ } break; } - TCHAR * ptr; -#ifdef UNICODE - int i = 0; - int conv; - while((conv = mbtowc(&wbuf[wbuf_offset+i], &szBuffer[i], num))) - { - i += conv; - if (i == num) - break; + char * ptr; + char * offset = szBuffer;
- assert(wbuf_offset + i < 512); - } - wbuf[wbuf_offset + num] = L'\0'; - - TCHAR * offset = wbuf; -#else - - TCHAR * offset = szBuffer; -#endif total_length = 0; - while((ptr = _tcsstr(offset, _T("\x0D\x0A"))) != NULL) + while((ptr = strstr(offset, "\x0D\x0A")) != NULL) { long length = ((long )ptr - (long)offset); - length /= sizeof(TCHAR); + length /= sizeof(char);
- offset[length] = _T('\0'); + offset[length] = '\0';
string line = offset; lines.push_back (line); @@ -155,11 +119,7 @@
if (total_length < num) { -#ifdef UNICODE - m_BufferedLines = &wbuf[total_length]; -#else - m_BufferedLines = &szBuffer[total_length]; -#endif + m_BufferedLines = &szBuffer[total_length]; }
return ret;
Modified: trunk/reactos/tools/sysreg/namedpipe_reader.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/namedpipe_read... ============================================================================== --- trunk/reactos/tools/sysreg/namedpipe_reader.cpp (original) +++ trunk/reactos/tools/sysreg/namedpipe_reader.cpp Mon Oct 8 04:18:01 2007 @@ -9,7 +9,6 @@ */
#include "namedpipe_reader.h" -#include "unicode.h"
#include <iostream> #include <assert.h> @@ -18,13 +17,15 @@ { #define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#ifdef __LINUX__ + const char * NamedPipeReader::s_LineBreak = "\x0A\0"; +#else + const char * NamedPipeReader::s_LineBreak = "\x0D\x0A\0"; +#endif using std::vector; //--------------------------------------------------------------------------------------- NamedPipeReader::NamedPipeReader() : DataSource(), h_Pipe(NULLVAL), m_Buffer(0) { -#ifdef UNICODE - m_WBuffer = 0; -#endif }
//--------------------------------------------------------------------------------------- @@ -32,10 +33,6 @@ { if (m_Buffer) free(m_Buffer); -#ifdef UNICODE - if (m_WBuffer) - free(m_WBuffer); -#endif }
bool NamedPipeReader::isSourceOpen() @@ -76,14 +73,7 @@ m_BufferLength = 100; m_Buffer = (char*)malloc(sizeof(char) * m_BufferLength); } - -#ifdef UNICODE - if (!m_WBuffer) - { - m_WBuffer = (WCHAR*)malloc(sizeof(WCHAR) * m_BufferLength); - } -#endif - ConnectNamedPipe(h_Pipe, + ConnectNamedPipe(h_Pipe, 0); return true; } @@ -112,6 +102,7 @@
bool NamedPipeReader::closeSource() { + cerr << "NamedPipeReader::closePipe> entered" << endl; if (h_Pipe == NULLVAL) { cerr << "NamedPipeReader::closePipe> pipe is not open" << endl; @@ -127,19 +118,87 @@ return true; } //--------------------------------------------------------------------------------------- - void NamedPipeReader::extractLines(TCHAR * buffer, std::vector<string> & vect, bool & append_line, unsigned long cbRead) - { - TCHAR * offset = _tcschr(buffer, _T('\x0D')); - DWORD buf_offset = 0; + void NamedPipeReader::insertLine(std::vector<string> & vect, string line, bool append_line) + { + if (append_line && vect.size ()) + { + string prev = vect[vect.size () - 1]; + prev += line; + vect[vect.size () - 1] = prev; + } + else + { + vect.push_back (line); + } + + } +//--------------------------------------------------------------------------------------- + void NamedPipeReader::extractLines(char * buffer, std::vector<string> & vect, bool & append_line, unsigned long cbRead) + { +#if 0 + long offset = 0; + size_t start_size = vect.size (); + char * start = buffer; + buffer[cbRead] = _T('\0'); + char * end = strstr(buffer, s_LineBreak); + + //cout << "extractLines entered with append_line: " << append_line << " cbRead: " << cbRead << "buffer: " << buffer << endl; + + do + { + if (end) + { + end[0] = _T('\0'); + string line = start; + end += (sizeof(s_LineBreak) / sizeof(char)); + start = end; + offset += line.length() + (sizeof(s_LineBreak) / sizeof(char)); + + // cout << "Offset: "<< offset << "cbRead: " << cbRead << "line: " << line << endl; + insertLine(vect, line, append_line); + if (append_line) + { + append_line = false; + } + } + else + { + string line = start; +// cout << "inserting line start_size: " << start_size << "current: " << vect.size () << "line length: "<< line.length () << endl; + if (!line.length ()) + { + if (start_size == vect.size ()) + append_line = true; + break; + } + if (start_size == vect.size ()) + { + insertLine(vect, line, true); + } + else + { + insertLine(vect, line, false); + } + append_line = true; + break; + } + + end = strstr(end, s_LineBreak); + + }while(append_line); + +#else + DWORD buf_offset = 0; + char * offset = strchr(buffer, '\x0D'); while(offset) { /// /// HACKHACK - /// due to some mysterious reason, _tcschr / _tcsstr sometimes returns + /// due to some mysterious reason, strchr / strstr sometimes returns /// not always the offset to the CR character but to the next LF /// in MSVC 2005 (Debug Modus)
- if (offset[0] == _T('\x0A')) + if (offset[0] == '\x0A') { if (buf_offset) { @@ -152,10 +211,10 @@ } }
- if (offset[0] == _T('\x0D')) + if (offset[0] == '\x0D') { buf_offset += 2; - offset[0] = _T('\0'); + offset[0] = '\0'; offset +=2; } else @@ -188,11 +247,11 @@ } buffer = offset;
- offset = _tcsstr(buffer, _T("\n")); + offset = strstr(buffer, "\n"); } if (buf_offset < cbRead) { - buffer[cbRead - buf_offset] = _T('\0'); + buffer[cbRead - buf_offset] = '\0'; string line = buffer; if (append_line) { @@ -212,6 +271,7 @@ { append_line = false; } +#endif } //--------------------------------------------------------------------------------------- bool NamedPipeReader::readPipe(char * buffer, int bufferlength, long & bytesread) @@ -254,32 +314,16 @@ return false; }
-#ifdef UNICODE - if (!m_WBuffer) - { - cerr << "Error: no memory" << endl; - return false; - } -#endif - bool append_line = false; do { memset(m_Buffer, 0x0, m_BufferLength * sizeof(char)); long cbRead = 0; - + if (!readPipe(m_Buffer, m_BufferLength-1, cbRead)) break;
-#ifdef UNICODE - memset(m_WBuffer, 0x0, m_BufferLength * sizeof(WCHAR)); - if (!UnicodeConverter::ansi2Unicode(m_Buffer, m_WBuffer, cbRead)) - break; - extractLines(m_WBuffer, vect, append_line, cbRead); -#else extractLines(m_Buffer, vect, append_line, cbRead); -#endif - }while (append_line);
return (vect.size () - lines);
Modified: trunk/reactos/tools/sysreg/namedpipe_reader.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/namedpipe_read... ============================================================================== --- trunk/reactos/tools/sysreg/namedpipe_reader.h (original) +++ trunk/reactos/tools/sysreg/namedpipe_reader.h Mon Oct 8 04:18:01 2007 @@ -118,7 +118,8 @@ /// @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); + void extractLines(char * buffer, std::vector<string> & vect, bool & append_line, unsigned long cbRead); + void insertLine(std::vector<string> & vect, string line, bool append_line);
bool readPipe(char * buffer, int bufferlength, long & read);
@@ -130,6 +131,7 @@ WCHAR * m_WBuffer; #endif
+ static const char * s_LineBreak; }; // end of class NamedPipeReader
} // end of namespace System_
Modified: trunk/reactos/tools/sysreg/os_support.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/os_support.cpp... ============================================================================== --- trunk/reactos/tools/sysreg/os_support.cpp (original) +++ trunk/reactos/tools/sysreg/os_support.cpp Mon Oct 8 04:18:01 2007 @@ -14,11 +14,15 @@
OsSupport::TimeEntryVector OsSupport::s_Entries;
+ //int gettimeofday(struct timeval *tv, void * tz); + void OsSupport::checkAlarms() { struct timeval tm; size_t i; - gettimeofday(&tm, 0); +#if 0 +// gettimeofday(&tm, 0); +#endif for (i = 0; i < s_Entries.size(); i++) { long diffsec = s_Entries[i]->tm.tv_sec - tm.tv_sec; @@ -67,6 +71,40 @@
HANDLE OsSupport::s_hThread = 0; static HANDLE hTimer; +#if 0 +__inline int gettimeofday(struct timeval *tv, struct timezone *tz) +{ + FILETIME ft; + LARGE_INTEGER li; + __int64 t; + static int tzflag; + + if (tv) + { + GetSystemTimeAsFileTime(&ft); + li.LowPart = ft.dwLowDateTime; + li.HighPart = ft.dwHighDateTime; + t = li.QuadPart; /* In 100-nanosecond intervals */ + t -= EPOCHFILETIME; /* Offset to the Epoch time */ + t /= 10; /* In microseconds */ + tv->tv_sec = (long)(t / 1000000); + tv->tv_usec = (long)(t % 1000000); + } + + if (tz) + { + if (!tzflag) + { + _tzset(); + tzflag++; + } + tz->tz_minuteswest = _timezone / 60; + tz->tz_dsttime = _daylight; + } + + return 0; +} +#endif bool OsSupport::terminateProcess(OsSupport::ProcessID pid, int exitcode) { HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pid); @@ -80,14 +118,14 @@ return ret; }
- OsSupport::ProcessID OsSupport::createProcess(TCHAR *procname, int procargsnum, TCHAR **procargs, bool wait) + OsSupport::ProcessID OsSupport::createProcess(char *procname, int procargsnum, char **procargs, bool wait) { STARTUPINFO siStartInfo; PROCESS_INFORMATION piProcInfo; OsSupport::ProcessID pid; DWORD length = 0; - TCHAR * szBuffer; - TCHAR * cmd; + char * szBuffer; + char * cmd; ZeroMemory(&siStartInfo, sizeof(STARTUPINFO)); ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION));
@@ -99,29 +137,36 @@ { for (int i = 1; i < procargsnum; i++) { - length += _tcslen(procargs[i]); + length += strlen(procargs[i]); }
length += procargsnum; - szBuffer = (TCHAR*)malloc(length * sizeof(TCHAR)); + szBuffer = (char*)malloc(length * sizeof(char)); length = 0; for (int i = 1; i < procargsnum; i++) { - _tcscpy(&szBuffer[length], procargs[i]); - length += _tcslen(procargs[i]); - szBuffer[length] = _T(' '); + strcpy(&szBuffer[length], procargs[i]); + length += strlen(procargs[i]); + if (i + 1 < procargsnum) + { + szBuffer[length] = ' '; + } + else + { + szBuffer[length] = '\0'; + } length++; } - length = _tcslen(procname) + _tcslen(szBuffer) + 2; - cmd = (TCHAR*)malloc(length * sizeof(TCHAR)); - _tcscpy(cmd, procname); - _tcscat(cmd, _T(" ")); - _tcscat(cmd, szBuffer); + length = strlen(procname) + strlen(szBuffer) + 2; + cmd = (char*)malloc(length * sizeof(char)); + strcpy(cmd, procname); + strcat(cmd, " "); + strcat(cmd, szBuffer); free(szBuffer); } else { - cmd = _tcsdup(procname); + cmd = _strdup(procname);
} if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &siStartInfo, &piProcInfo)) @@ -151,7 +196,7 @@ { LARGE_INTEGER liDueTime;
- hTimer = CreateWaitableTimer(NULL, TRUE, _T("SysRegTimer")); + hTimer = CreateWaitableTimer(NULL, TRUE, "SysRegTimer"); if (!hTimer) { return 0; @@ -168,13 +213,16 @@
void OsSupport::setAlarm(long secs, OsSupport::ProcessID pid) { - + return; PTIME_ENTRY entry = (PTIME_ENTRY) malloc(sizeof(TIME_ENTRY)); if (entry) { cout << "secs: " << secs << endl; struct timeval tm; +#if 0 gettimeofday(&tm, 0); +#else +#endif tm.tv_sec += secs;
entry->tm = tm; @@ -194,7 +242,7 @@ struct sigaction OsSupport::s_sact;
- OsSupport::ProcessID OsSupport::createProcess(TCHAR *procname, int procargsnum, TCHAR **procargs, bool bWait) + OsSupport::ProcessID OsSupport::createProcess(char *procname, int procargsnum, char **procargs, bool bWait) { ProcessID pid;
Modified: trunk/reactos/tools/sysreg/os_support.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/os_support.h?r... ============================================================================== --- trunk/reactos/tools/sysreg/os_support.h (original) +++ trunk/reactos/tools/sysreg/os_support.h Mon Oct 8 04:18:01 2007 @@ -22,7 +22,10 @@ #include "user_types.h" #include <ctime> #include <vector> + +#ifndef _MSC_VER #include <sys/time.h> +#endif
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
@@ -66,7 +69,7 @@ /// ///
- static ProcessID createProcess(TCHAR * procname, int procargsnum, TCHAR ** procargs, bool wait); + static ProcessID createProcess(char * procname, int procargsnum, char ** procargs, bool wait);
//--------------------------------------------------------------------------------------- ///
Modified: trunk/reactos/tools/sysreg/pipe_reader.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/pipe_reader.cp... ============================================================================== --- trunk/reactos/tools/sysreg/pipe_reader.cpp (original) +++ trunk/reactos/tools/sysreg/pipe_reader.cpp Mon Oct 8 04:18:01 2007 @@ -83,12 +83,12 @@
bool PipeReader::readSource(vector<string> & lines) { - TCHAR * buf = (TCHAR*)malloc(100 * sizeof(TCHAR)); + char * buf = (char*)malloc(100 * sizeof(char)); //#ifdef NDEBUG - memset(buf, 0x0, sizeof(TCHAR) * 100); + memset(buf, 0x0, sizeof(char) * 100); //#endif
- TCHAR * res = _fgetts(buf, 100, m_File); + char * res = fgets(buf, 100, m_File); if (!res) { //cerr << "Error: PipeReader::readPipe failed" << endl;
Modified: trunk/reactos/tools/sysreg/rosboot_test.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/rosboot_test.c... ============================================================================== --- trunk/reactos/tools/sysreg/rosboot_test.cpp (original) +++ trunk/reactos/tools/sysreg/rosboot_test.cpp Mon Oct 8 04:18:01 2007 @@ -45,25 +45,25 @@ using std::ofstream; #endif
- string RosBootTest::ROS_EMU_TYPE= _T("ROS_EMU_TYPE"); - string RosBootTest::EMU_TYPE_QEMU = _T("qemu"); - string RosBootTest::EMU_TYPE_VMWARE = _T("vmware"); - string RosBootTest::ROS_HDD_IMAGE= _T("ROS_HDD_IMAGE"); - string RosBootTest::ROS_CD_IMAGE = _T("ROS_CD_IMAGE"); - string RosBootTest::ROS_MAX_TIME = _T("ROS_MAX_TIME"); - string RosBootTest::ROS_LOG_FILE = _T("ROS_LOG_FILE"); - string RosBootTest::ROS_SYM_DIR = _T("ROS_SYM_DIR"); - string RosBootTest::ROS_DELAY_READ = _T("ROS_DELAY_READ"); - string RosBootTest::ROS_SYSREG_CHECKPOINT = _T("SYSREG_CHECKPOINT:"); - string RosBootTest::ROS_CRITICAL_IMAGE = _T("ROS_CRITICAL_IMAGE"); - string RosBootTest::ROS_EMU_KILL = _T("ROS_EMU_KILL"); - string RosBootTest::ROS_EMU_MEM = _T("ROS_EMU_MEM"); - string RosBootTest::ROS_BOOT_CMD = _T("ROS_BOOT_CMD"); - -#ifdef __LINUX__ - string RosBootTest::ROS_EMU_PATH = _T("ROS_EMU_PATH_LIN"); + string RosBootTest::ROS_EMU_TYPE= "ROS_EMU_TYPE"; + string RosBootTest::EMU_TYPE_QEMU = "qemu"; + string RosBootTest::EMU_TYPE_VMWARE = "vmware"; + string RosBootTest::ROS_HDD_IMAGE= "ROS_HDD_IMAGE"; + string RosBootTest::ROS_CD_IMAGE = "ROS_CD_IMAGE"; + string RosBootTest::ROS_MAX_TIME = "ROS_MAX_TIME"; + string RosBootTest::ROS_LOG_FILE = "ROS_LOG_FILE"; + string RosBootTest::ROS_SYM_DIR = "ROS_SYM_DIR"; + string RosBootTest::ROS_DELAY_READ = "ROS_DELAY_READ"; + string RosBootTest::ROS_SYSREG_CHECKPOINT = "SYSREG_CHECKPOINT:"; + string RosBootTest::ROS_CRITICAL_IMAGE = "ROS_CRITICAL_IMAGE"; + string RosBootTest::ROS_EMU_KILL = "ROS_EMU_KILL"; + string RosBootTest::ROS_EMU_MEM = "ROS_EMU_MEM"; + string RosBootTest::ROS_BOOT_CMD = "ROS_BOOT_CMD"; + +#ifdef __LINUX__ + string RosBootTest::ROS_EMU_PATH = "ROS_EMU_PATH_LIN"; #else - string RosBootTest::ROS_EMU_PATH = _T("ROS_EMU_PATH_WIN"); + string RosBootTest::ROS_EMU_PATH = "ROS_EMU_PATH_WIN"; #endif
//--------------------------------------------------------------------------------------- @@ -88,7 +88,7 @@ pBuf = (char*)m_BootCmd.c_str (); if (pBuf) { - pBuf = strtok(pBuf, _T(" ")); + pBuf = strtok(pBuf, " "); while(pBuf != NULL) { if (!numargs) @@ -96,7 +96,7 @@
args[numargs] = pBuf; numargs++; - pBuf = _tcstok(NULL, _T(" ")); + pBuf = strtok(NULL, " "); } args[numargs++] = 0; } @@ -128,20 +128,30 @@ //--------------------------------------------------------------------------------------- void RosBootTest::getDefaultHDDImage(string & img) { +#ifndef __LINUX__ + char buffer[MAX_PATH]; + if (GetCurrentDirectory(MAX_PATH, buffer)) + { + img = buffer; + img += "\output-i386"; + + } + else +#endif img = "output-i386";
- EnvironmentVariable::getValue(_T("ROS_OUTPUT"), img); -#ifdef __LINUX__ - img += _T("/ros.hd"); + EnvironmentVariable::getValue("ROS_OUTPUT", img); +#ifdef __LINUX__ + img += "/ros.hd"; #else - img += _T("\ros.hd"); + img += "\ros.hd"; #endif } //--------------------------------------------------------------------------------------- bool RosBootTest::isFileExisting(string output) { FILE * file; - file = _tfopen(output.c_str(), _T("r")); + file = fopen(output.c_str(), "r");
if (file) { @@ -174,38 +184,38 @@
#ifdef __LINUX__ - qemuimgdir += _T("/qemu-img"); + qemuimgdir += "/qemu-img";
#else - qemuimgdir += _T("\qemu-img.exe"); + qemuimgdir += "\qemu-img.exe"; #endif
if (!isFileExisting(qemuimgdir)) { - cerr << "Error: ROS_EMU_PATH must contain the path to qemu and qemu-img " << qemuimgdir << endl; - return false; - } - _tremove(image.c_str ()); - - TCHAR * options[] = {NULL, - _T("create"), - _T("-f"), + cerr << "Error: ROS_EMU_PATH must contain the path to qemu and qemu-img " << qemuimgdir << endl; + return false; + } + remove(image.c_str ()); + + char * options[] = {NULL, + "create", + "-f", #ifdef __LINUX__ _T("raw"), #else - _T("vmdk"), + "vmdk", #endif NULL, - _T("100M"), + "100M", NULL };
- options[0] = (TCHAR*)qemuimgdir.c_str(); - options[4] = (TCHAR*)image.c_str(); + options[0] = (char*)qemuimgdir.c_str(); + options[4] = (char*)image.c_str();
cerr << "Creating HDD Image ..." << image << endl; - OsSupport::createProcess ((TCHAR*)qemuimgdir.c_str(), 6, options, true); + OsSupport::createProcess ((char*)qemuimgdir.c_str(), 6, options, true); if (isFileExisting(image)) { m_HDDImage = image; @@ -223,7 +233,7 @@ /* the boot cmd is already provided * check if path to qemu is valid */ - string::size_type pos = m_BootCmd.find_first_of(_T(" ")); + string::size_type pos = m_BootCmd.find_first_of(" "); if (pos == string::npos) { /* the bootcmd is certainly not valid */ @@ -256,9 +266,9 @@ string::size_type pos;
#ifdef __LINUX__ - pos = m_EmuPath.find_last_of(_T("/")); + pos = m_EmuPath.find_last_of("/"); #else - pos = m_EmuPath.find_last_of(_T("\")); + pos = m_EmuPath.find_last_of("\"); #endif if (pos == string::npos) { @@ -281,14 +291,14 @@ }
#ifdef __LINUX__ - pipe = _T("pipe:/tmp/qemu"); - m_Src = _T("/tmp/qemu"); - qemudir = _T("/usr/share/qemu"); - m_DebugPort = _T("pipe"); + pipe = "pipe:/tmp/qemu"; + m_Src = "/tmp/qemu"; + qemudir = "/usr/share/qemu"; + m_DebugPort = "pipe"; #else - pipe = _T("pipe:qemu"); - m_Src = _T("\\.\pipe\qemu"); - m_DebugPort = _T("pipe"); + pipe = "pipe:qemu"; + m_Src = "\\.\pipe\qemu"; + m_DebugPort = "pipe"; if (!getQemuDir(qemudir)) { return false; @@ -296,24 +306,24 @@ #endif
- m_BootCmd = m_EmuPath + _T(" -L ") + qemudir + _T(" -m ") + m_MaxMem + _T(" -serial ") + pipe; + m_BootCmd = m_EmuPath + " -L " + qemudir + " -m " + m_MaxMem + " -serial " + pipe;
if (m_CDImage.length()) { /* boot from cdrom */ - m_BootCmd += _T(" -boot d -cdrom ") + m_CDImage; + m_BootCmd += " -boot d -cdrom " + m_CDImage;
if (m_HDDImage.length ()) { /* add disk when specified */ - m_BootCmd += _T(" -hda ") + m_HDDImage; + m_BootCmd += " -hda " + m_HDDImage; }
} else if (m_HDDImage.length ()) { /* boot from hdd */ - m_BootCmd += _T(" -boot c -hda ") + m_HDDImage; + m_BootCmd += " -boot c -hda " + m_HDDImage; } else { @@ -329,17 +339,17 @@ * to terminate the emulator in case of errors * on windows we can get pid as return of CreateProcess */ - m_PidFile = _T("output-i386"); - EnvironmentVariable::getValue(_T("ROS_OUTPUT"), m_PidFile); - m_PidFile += _T("/pid.txt"); - m_BootCmd += _T(" -pidfile "); + m_PidFile = "output-i386"; + EnvironmentVariable::getValue("ROS_OUTPUT", m_PidFile); + m_PidFile += "/pid.txt"; + m_BootCmd += " -pidfile "; m_BootCmd += m_PidFile; - m_BootCmd += _T(" -vnc :0"); + m_BootCmd += " -vnc :0"; #else
if (hasQemuNoRebootOption()) { - m_BootCmd += _T(" -no-reboot "); + m_BootCmd += " -no-reboot "; } #endif return true; @@ -347,7 +357,7 @@ //---------------------------------------------------------------------------------------- bool RosBootTest::extractPipeFromBootCmd() { - string::size_type pos = m_BootCmd.find(_T("-serial")); + string::size_type pos = m_BootCmd.find("-serial"); if (pos == string::npos) { /* no debug options provided */ @@ -355,11 +365,11 @@ }
string pipe = m_BootCmd.substr(pos + 7, m_BootCmd.size() - pos -7); - pos = pipe.find(_T("pipe:")); + pos = pipe.find("pipe:"); if (pos == 0) { pipe = pipe.substr(pos + 5, pipe.size() - pos - 5); - pos = pipe.find(_T(" ")); + pos = pipe.find(" "); if (pos != string::npos) { pipe = pipe.substr(0, pos); @@ -367,17 +377,17 @@ #ifdef __LINUX__ m_Src = pipe; #else - m_Src = _T("\\.\pipe\") + pipe.substr(0, pos); -#endif - m_DebugPort = _T("pipe"); + m_Src = "\\.\pipe\" + pipe.substr(0, pos); +#endif + m_DebugPort = "pipe"; return true; } - pos = pipe.find(_T("stdio")); + pos = pipe.find("stdio"); if (pos == 0) { #ifdef __LINUX__ m_Src = m_BootCmd; - m_DebugPort = _T("stdio"); + m_DebugPort = "stdio"; return true; #else cerr << "Error: reading from stdio is not supported for windows hosts - use pipes" << endl; @@ -433,13 +443,13 @@ */
bool hdaboot = false; - string::size_type pos = m_BootCmd.find (_T("-boot c")); + string::size_type pos = m_BootCmd.find ("-boot c"); if (pos != string::npos) { hdaboot = true; }
- pos = m_BootCmd.find(_T("-hda ")); + pos = m_BootCmd.find("-hda "); if (pos != string::npos) { string hdd = m_BootCmd.substr(pos + 5, m_BootCmd.length() - pos - 5); @@ -486,18 +496,18 @@ return true; } } - if (isFileExisting(_T("ReactOS-RegTest.iso"))) - { - m_CDImage = _T("ReactOS-RegTest.iso"); + if (isFileExisting("ReactOS-RegTest.iso")) + { + m_CDImage = "ReactOS-RegTest.iso"; cerr << "Falling back to default CDROM image " << m_CDImage << endl; return true; } cerr << "No CDROM image found, boot device is HDD" << endl; - m_CDImage = _T(""); + m_CDImage = ""; return true; }
- string::size_type pos = m_BootCmd.find(_T("-boot ")); + string::size_type pos = m_BootCmd.find("-boot "); if (pos == string::npos) { /* ROS_BOOT_CMD must provide a boot parameter*/ @@ -512,19 +522,19 @@ cerr << "Error: ROS_BOOT_CMD misses boot parameter" << endl; return false; } - if (rest[0] != _T('c') && rest[0] != _T('d')) + if (rest[0] != 'c' && rest[0] != 'd') { cerr << "Error: ROS_BOOT_CMD has invalid boot parameter" << endl; return false; }
- if (rest[0] == _T('c')) + if (rest[0] == 'c') { /* ROS_BOOT_CMD boots from hdd */ return true; }
- pos = m_BootCmd.find(_T("-cdrom ")); + pos = m_BootCmd.find("-cdrom "); if (pos == string::npos) { cerr << "Error: ROS_BOOT_CMD misses cdrom parameter" << endl; @@ -536,7 +546,7 @@ cerr << "Error: ROS_BOOT_CMD misses cdrom parameter" << endl; return false; } - pos = rest.find(_T(" ")); + pos = rest.find(" "); if (pos != string::npos) { rest = rest.substr(0, pos); @@ -591,7 +601,7 @@ if (m_PidFile.length () && isFileExisting(m_PidFile)) { cerr << "Deleting pid file " << m_PidFile << endl; - _tremove(m_PidFile.c_str ()); + remove(m_PidFile.c_str ()); }
cerr << "Opening Data Source:" << m_BootCmd << endl; @@ -638,7 +648,7 @@ conf_parser.getStringValue (RosBootTest::ROS_CD_IMAGE, m_CDImage); } /* reset boot cmd */ - m_BootCmd = _T(""); + m_BootCmd = "";
conf_parser.getIntValue (RosBootTest::ROS_MAX_TIME, m_MaxTime); @@ -668,7 +678,7 @@
if (m_PidFile.length ()) { - _tremove(m_PidFile.c_str ()); + remove(m_PidFile.c_str ()); } }
@@ -797,7 +807,7 @@ { line.erase (0, line.find (RosBootTest::ROS_SYSREG_CHECKPOINT) + RosBootTest::ROS_SYSREG_CHECKPOINT.length ()); - if (!_tcsncmp(line.c_str (), m_Checkpoint.c_str (), m_Checkpoint.length ())) + if (!strncmp(line.c_str (), m_Checkpoint.c_str (), m_Checkpoint.length ())) { state = DebugStateCPReached; break; @@ -806,7 +816,7 @@ }
- if (line.find (_T("*** Fatal System Error")) != string::npos) + if (line.find ("*** Fatal System Error") != string::npos) { cerr << "Blue Screen of Death detected" <<endl; if (m_Checkpoints.size ()) @@ -818,7 +828,7 @@ m_Checkpoints.erase (m_Checkpoints.begin ()); cerr << cp << endl; }while(m_Checkpoints.size ()); - cerr << _T("----------------------------------") << endl; + cerr << "----------------------------------" << endl; } if (i + 1 < debug_data.size () ) { @@ -829,14 +839,14 @@ cerr << data << endl; i++; } - cerr << _T("----------------------------------") << endl; + cerr << "----------------------------------" << endl; } state = DebugStateBSODDetected; break; } - else if (line.find (_T("Unhandled exception")) != string::npos) + else if (line.find ("Unhandled exception") != string::npos) { - if (m_CriticalImage == _T("IGNORE")) + if (m_CriticalImage == "IGNORE") { /// /// ignoring all user-mode exceptions @@ -859,7 +869,7 @@ ///
string address = debug_data[i+2]; - string::size_type pos = address.find_last_of (_T(" ")); + string::size_type pos = address.find_last_of (" "); if (pos == string::npos) { cerr << "Error: trace is not available (corrupted debug info" << endl; @@ -874,7 +884,7 @@ /// string modulename = debug_data[i+3]; - pos = modulename.find_last_of (_T("\")); + pos = modulename.find_last_of ("\"); if (pos == string::npos) { cerr << "Error: trace is not available (corrupted debug info" << endl; @@ -891,7 +901,7 @@ continue; }
- pos = appname.find_last_of (_T(".")); + pos = appname.find_last_of ("."); if (pos == string::npos) { cerr << "Error: trace is not available (corrupted debug info" << endl; @@ -940,7 +950,7 @@
if (m_DebugFile.length ()) { - _tremove(m_DebugFile.c_str ()); + remove(m_DebugFile.c_str ()); file.open (m_DebugFile.c_str ()); }
@@ -973,7 +983,6 @@ } lines += (vect.size() -prev_count); //WTF? } - m_DataSource->closeSource(); if (write_log) { file.close();
Modified: trunk/reactos/tools/sysreg/sym_file.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/sym_file.cpp?r... ============================================================================== --- trunk/reactos/tools/sysreg/sym_file.cpp (original) +++ trunk/reactos/tools/sysreg/sym_file.cpp Mon Oct 8 04:18:01 2007 @@ -27,10 +27,10 @@ {
using std::vector; - string SymbolFile::VAR_ROS_OUTPUT = _T("ROS_OUTPUT"); - string SymbolFile::ROS_ADDR2LINE = _T("ROS_ADDR2LINE"); - string SymbolFile::m_SymbolPath= _T(""); - string SymbolFile::m_SymResolver= _T(""); + string SymbolFile::VAR_ROS_OUTPUT = "ROS_OUTPUT"; + string SymbolFile::ROS_ADDR2LINE = "ROS_ADDR2LINE"; + string SymbolFile::m_SymbolPath= ""; + string SymbolFile::m_SymResolver= ""; SymbolFile::SymbolMap SymbolFile::m_Map;
//--------------------------------------------------------------------------------------- @@ -51,9 +51,9 @@ vector<string> vect; string current_dir;
- if (Path == _T("")) + if (Path == "") { - current_dir = _T("output-i386"); + current_dir = "output-i386"; EnvironmentVariable::getValue(SymbolFile::VAR_ROS_OUTPUT, current_dir); } else @@ -70,10 +70,10 @@ }
string val = current_dir; - val.insert (val.length()-1, _T("\*")); + val.insert (val.length()-1, "\*");
- struct _tfinddatai64_t c_file; - intptr_t hFile = _tfindfirsti64(val.c_str(), &c_file); + struct _finddatai64_t c_file; + intptr_t hFile = _findfirsti64(val.c_str(), &c_file);
if (hFile == -1L) { @@ -86,16 +86,16 @@
do { - TCHAR * pos; - if ((pos = _tcsstr(c_file.name, _T(".nostrip.")))) + char * pos; + if ((pos = strstr(c_file.name, ".nostrip."))) { - size_t len = _tcslen(pos); + size_t len = strlen(pos); string modulename = c_file.name; string filename = modulename; modulename.erase(modulename.length() - len, len);
string path = current_dir; - path.insert (path.length () -1, _T("\")); + path.insert (path.length () -1, "\"); path.insert (path.length () -1, filename); #ifdef NDEBUG cerr << "Module Name " << modulename << endl << "File Name " << path << endl; @@ -109,7 +109,7 @@ if (c_file.name[0] != _T('.')) { string path = current_dir; - path.insert (path.length ()-1, _T("\")); + path.insert (path.length ()-1, "\"); path.insert (path.length ()-1, c_file.name); vect.push_back (path); } @@ -125,7 +125,7 @@ current_dir = vect.front (); vect.erase (vect.begin()); val = current_dir; - val.insert (val.length() -1, _T("\*")); + val.insert (val.length() -1, "\*"); hFile = _tfindfirsti64(val.c_str(), &c_file); if (hFile != -1L) { @@ -149,32 +149,27 @@ { SymbolMap::const_iterator it = m_Map.find (module_name);
- if (it == m_Map.end () || m_SymResolver == _T("")) + if (it == m_Map.end () || m_SymResolver == "") { cerr << "SymbolFile::resolveAddress> no symbol file or ROS_ADDR2LINE not set" << endl; return false; }
- TCHAR szCmd[300]; + char szCmd[300];
- _stprintf(szCmd, _T("%s %s %s"), m_SymResolver.c_str (), it->second.c_str (), module_address.c_str()); + sprintf(szCmd, "%s %s %s", m_SymResolver.c_str (), it->second.c_str (), module_address.c_str()); string pipe_cmd(szCmd); - + vector<string> vect; PipeReader pipe_reader;
- if (!pipe_reader.openPipe (pipe_cmd)) + if (!pipe_reader.openSource(pipe_cmd)) { cerr << "SymbolFile::resolveAddress> failed to open pipe" <<pipe_cmd <<endl; return false; }
- if (Buffer.capacity () < 100) - { - Buffer.reserve (500); - } - - bool ret = pipe_reader.readPipe (Buffer); - pipe_reader.closePipe (); + bool ret = pipe_reader.readSource (vect); + pipe_reader.closeSource (); return ret; }
Modified: trunk/reactos/tools/sysreg/sysreg.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/sysreg.cpp?rev... ============================================================================== --- trunk/reactos/tools/sysreg/sysreg.cpp (original) +++ trunk/reactos/tools/sysreg/sysreg.cpp Mon Oct 8 04:18:01 2007 @@ -22,17 +22,17 @@ using System_::SymbolFile; #endif
-static const TCHAR USAGE[] = -_T("sysreg.exe [conf_file]\nconfiguration file (default: sysreg.cfg)"); +static const char USAGE[] = +"sysreg.exe [conf_file]\nconfiguration file (default: sysreg.cfg)";
-int _tmain(int argc, TCHAR * argv[]) +int main(int argc, char * argv[]) { ConfigParser config; - TCHAR DefaultConfig[] = _T("sysreg.cfg"); - TCHAR *ConfigFile; + char DefaultConfig[] = "sysreg.cfg"; + char *ConfigFile;
if ((argc > 2)) { @@ -65,7 +65,7 @@ } string envvar; - string ros = _T("ROS_OUTPUT"); + string ros = "ROS_OUTPUT"; config.getStringValue (ros, envvar); #if 0 SymbolFile::initialize (config, envvar);
Modified: trunk/reactos/tools/sysreg/sysreg.mak URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/sysreg.mak?rev... ============================================================================== --- trunk/reactos/tools/sysreg/sysreg.mak (original) +++ trunk/reactos/tools/sysreg/sysreg.mak Mon Oct 8 04:18:01 2007 @@ -26,7 +26,6 @@ sysreg.cpp \ file_reader.cpp \ os_support.cpp \ - unicode.cpp \ )
SYSREGBUILD_OBJECTS = \ @@ -85,10 +84,6 @@ $(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)
Removed: trunk/reactos/tools/sysreg/unicode.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/unicode.cpp?re... ============================================================================== --- trunk/reactos/tools/sysreg/unicode.cpp (original) +++ trunk/reactos/tools/sysreg/unicode.cpp (removed) @@ -1,31 +1,0 @@ -#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_
Removed: trunk/reactos/tools/sysreg/unicode.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/unicode.h?rev=... ============================================================================== --- trunk/reactos/tools/sysreg/unicode.h (original) +++ trunk/reactos/tools/sysreg/unicode.h (removed) @@ -1,55 +1,0 @@ -#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__ */
Modified: trunk/reactos/tools/sysreg/user_types.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/user_types.h?r... ============================================================================== --- trunk/reactos/tools/sysreg/user_types.h (original) +++ trunk/reactos/tools/sysreg/user_types.h Mon Oct 8 04:18:01 2007 @@ -14,32 +14,12 @@ #include <iostream>
#ifndef __LINUX__ - #include <tchar.h> -#else - #define TCHAR char - #define tstrcpy strcpy - #define _tcstok strtok - #define _tcschr strchr - #define _tcscat strcat - #define _tcscpy(str1, str2) strcpy(str1, str2) - #define _tcslen(str1) strlen(str1) - #define _tcstod strtod - #define _tcscmp strcmp - #define _tcstoul strtoul - #define _tcsncmp strncmp - #define _tremove remove - #define _ttoi atoi - #define _T(x) x - #define _tfopen fopen - #define _tcsstr strstr - #define _fgetts fgets - #define _tgetenv getenv - #define _tmain main - #define _tcstol strtol +#define popen _popen +#define pclose _pclose #endif
- typedef std::basic_string<TCHAR> string; - typedef std::basic_istringstream<TCHAR> istringstream; + typedef std::basic_string<char> string; + typedef std::basic_istringstream<char> istringstream;
#ifdef UNICODE