Explorar el Código

Use _WIN32 instead of WIN32. Reason: MinGW-W64 defines _WIN32 but not WIN32.


git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@51 d34b734f-a00e-4b39-a726-e4eeb87269ab
adeniz_1
adeniz hace 10 años
padre
commit
c31de176c5
Se han modificado 2 ficheros con 17 adiciones y 17 borrados
  1. 11
    11
      child.cpp
  2. 6
    6
      child.hpp

+ 11
- 11
child.cpp Ver fichero

// Place, Suite 330, Boston, MA 02111-1307 USA // Place, Suite 330, Boston, MA 02111-1307 USA
//============================================================================== //==============================================================================
#ifndef WIN32
#ifndef _WIN32
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
"run() was called"); "run() was called");
} }
#ifdef WIN32
#ifdef _WIN32
// Set the bInheritHandle flag so pipe handles are inherited. // Set the bInheritHandle flag so pipe handles are inherited.
SECURITY_ATTRIBUTES securityAttributes; SECURITY_ATTRIBUTES securityAttributes;
} }
#ifdef WIN32
#ifdef _WIN32
if (!TerminateProcess(childProcess, terminateExitCode)) { if (!TerminateProcess(childProcess, terminateExitCode)) {
#else #else
if (kill(childPid, SIGTERM) != 0) { if (kill(childPid, SIGTERM) != 0) {
int result; int result;
#ifdef WIN32
#ifdef _WIN32
if (!GetExitCodeProcess(childProcess, (LPDWORD) &result)) { if (!GetExitCodeProcess(childProcess, (LPDWORD) &result)) {
throw std::runtime_error("Error checking status of child process: " + throw std::runtime_error("Error checking status of child process: " +
getErrorText()); getErrorText());
std::string std::string
Child::getErrorText() { Child::getErrorText() {
#ifdef WIN32
#ifdef _WIN32
LPVOID winMsgBuf; LPVOID winMsgBuf;
DWORD lastError = GetLastError(); DWORD lastError = GetLastError();
} }
Child::ReadStreambuf::ReadStreambuf(std::size_t bufferSize) : Child::ReadStreambuf::ReadStreambuf(std::size_t bufferSize) :
#ifdef WIN32
#ifdef _WIN32
inputHandle(0), inputHandle(0),
#else #else
inputFileDescriptor(-1), inputFileDescriptor(-1),
} }
#ifdef WIN32
#ifdef _WIN32
void void
Child::ReadStreambuf::setInputHandle(HANDLE inHandle) { Child::ReadStreambuf::setInputHandle(HANDLE inHandle) {
} }
// start points to the start of the buffer. Fill buffer. // start points to the start of the buffer. Fill buffer.
#ifdef WIN32
#ifdef _WIN32
DWORD nBytesRead; DWORD nBytesRead;
if (!ReadFile(inputHandle, if (!ReadFile(inputHandle,
} }
Child::WriteStreambuf::WriteStreambuf(std::size_t bufferSize) : Child::WriteStreambuf::WriteStreambuf(std::size_t bufferSize) :
#ifdef WIN32
#ifdef _WIN32
outputHandle(0), outputHandle(0),
#else #else
outputFileDescriptor(-1), outputFileDescriptor(-1),
} }
#ifdef WIN32
#ifdef _WIN32
void void
Child::WriteStreambuf::setOutputHandle(HANDLE outHandle) { Child::WriteStreambuf::setOutputHandle(HANDLE outHandle) {
// Write. // Write.
std::ptrdiff_t nBytes = pptr() - pbase(); std::ptrdiff_t nBytes = pptr() - pbase();
#ifdef WIN32
#ifdef _WIN32
DWORD nBytesWritten; DWORD nBytesWritten;
if (!WriteFile(outputHandle, if (!WriteFile(outputHandle,

+ 6
- 6
child.hpp Ver fichero

#ifndef CHILD_HPP #ifndef CHILD_HPP
#define CHILD_HPP #define CHILD_HPP


#ifdef WIN32
#ifdef _WIN32
#include <windows.h> #include <windows.h>
#endif #endif


// //
explicit ReadStreambuf(std::size_t bufferSize = 4096); explicit ReadStreambuf(std::size_t bufferSize = 4096);


#ifdef WIN32
#ifdef _WIN32
/// Set the handle to read the standard output of the child /// Set the handle to read the standard output of the child
/// process. /// process.
// //
ReadStreambuf &operator=(const ReadStreambuf &); ReadStreambuf &operator=(const ReadStreambuf &);


/// Input handle. /// Input handle.
#ifdef WIN32
#ifdef _WIN32
HANDLE inputHandle; HANDLE inputHandle;
#else #else
int inputFileDescriptor; int inputFileDescriptor;
// //
explicit WriteStreambuf(std::size_t bufferSize = 4096); explicit WriteStreambuf(std::size_t bufferSize = 4096);


#ifdef WIN32
#ifdef _WIN32
/// Set the handle to write the standard input of the child /// Set the handle to write the standard input of the child
/// process. /// process.
// //
WriteStreambuf &operator=(const WriteStreambuf &); WriteStreambuf &operator=(const WriteStreambuf &);


/// Output handle. /// Output handle.
#ifdef WIN32
#ifdef _WIN32
HANDLE outputHandle; HANDLE outputHandle;
#else #else
int outputFileDescriptor; int outputFileDescriptor;
/// Child executable path and command-line parameters. /// Child executable path and command-line parameters.
std::string cmdline; std::string cmdline;


#ifdef WIN32
#ifdef _WIN32
/// Child's process handle. /// Child's process handle.
HANDLE childProcess; HANDLE childProcess;



Cargando…
Cancelar
Guardar