- randomize named pipe name

- remove hardcoded path in named pipe reader class

svn path=/trunk/; revision=29453
This commit is contained in:
Johannes Anderwald 2007-10-08 09:01:33 +00:00
parent 1d1547fcc3
commit 6cd6fc2c8c
2 changed files with 31 additions and 9 deletions

View file

@ -50,7 +50,7 @@ namespace System_
return false;
}
#ifndef __LINUX__
h_Pipe = CreateFile("\\\\.\\pipe\\qemu", //PipeCmd.c_str(),
h_Pipe = CreateFile(PipeCmd.c_str(),
GENERIC_WRITE | GENERIC_READ,
0,
NULL,
@ -139,7 +139,7 @@ namespace System_
long offset = 0;
size_t start_size = vect.size ();
char * start = buffer;
buffer[cbRead] = _T('\0');
buffer[cbRead] = '\0';
char * end = strstr(buffer, s_LineBreak);
//cout << "extractLines entered with append_line: " << append_line << " cbRead: " << cbRead << "buffer: " << buffer << endl;
@ -148,7 +148,7 @@ namespace System_
{
if (end)
{
end[0] = _T('\0');
end[0] = '\0';
string line = start;
end += (sizeof(s_LineBreak) / sizeof(char));
start = end;

View file

@ -27,7 +27,8 @@
#include <assert.h>
#include <math.h>
#include <signal.h>
#include <io.h>
namespace Sysreg_
{
using std::vector;
@ -273,7 +274,7 @@ namespace Sysreg_
{
string pipe;
string qemudir;
char pipename[] = "qemuXXXXXX";
if (m_MaxMem.length() == 0)
{
/* set default memory size to 64M */
@ -281,14 +282,35 @@ namespace Sysreg_
}
#ifdef __LINUX__
pipe = "pipe:/tmp/qemu";
m_Src = "/tmp/qemu";
if (_mktemp(pipename))
{
string temp = pipename;
m_Src = "/tmp/" + temp;
pipe = "pipe:" + m_Src;
}
else
{
pipe = "pipe:/tmp/qemu";
m_Src = "/tmp/qemu";
}
qemudir = "/usr/share/qemu";
m_DebugPort = "pipe";
#else
pipe = "pipe:qemu";
m_Src = "\\\\.\\pipe\\qemu";
if (_mktemp(pipename))
{
string temp = pipename;
pipe = "pipe:" + temp;
m_Src = "\\\\.\\pipe\\" + temp;
}
else
{
pipe = "pipe:qemu";
m_Src = "\\\\.\\pipe\\qemu";
}
m_DebugPort = "pipe";
if (!getQemuDir(qemudir))
{
return false;