[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : gerry
Repository : xara
Revision   : 985
Date       : Tue May  9 19:22:38 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/xpfilter.cpp
   M /Trunk/XaraLX/wxOil/Makefile.am
   A /Trunk/XaraLX/wxOil/camprocess.cpp
   A /Trunk/XaraLX/wxOil/camprocess.h
   M /Trunk/XaraLX/wxOil/xpoilflt.cpp

Plugin export now correctly launches hardcoded plugin


Diff:
Index: Trunk/XaraLX/Kernel/xpfilter.cpp
===================================================================
--- Trunk/XaraLX/Kernel/xpfilter.cpp	(revision 984)
+++ Trunk/XaraLX/Kernel/xpfilter.cpp	(revision 985)
@@ -231,11 +231,19 @@
 						   UINT32 FileSize )
 {
 	// We ignore the passed in buffer and just pass the filename to the external object
-	PluginOILFilter* pPluginOILFilter = (PluginOILFilter*)pOILFilter;
-	INT32 HowCompatible = pPluginOILFilter->HowCompatible(Filename);
+	INT32 HowCompatible = 0;
 
+	// If we don't have a filename then don't bother for now	
+	String_256 sFilename = Filename.GetPath();
+	if (!sFilename.IsEmpty())
+	{
+		PluginOILFilter* pPluginOILFilter = (PluginOILFilter*)pOILFilter;
+// Temporarily removed to stop file loading problems
+//		HowCompatible = pPluginOILFilter->HowCompatible(Filename);
+	}
+
+	// Return the found value to the caller.
 	TRACEUSER( "GerryX", _T("PluginNativeFilter::HowCompatible returning = %d
"), HowCompatible);
-	// Return the found value to the caller.
 	return HowCompatible;
 }
 
@@ -278,6 +286,8 @@
 	ERROR2IF(FALSE, pFile == NULL,"PluginNativeFilter::DoImport null file!");
 	ERROR2IF(FALSE, pDestDoc == NULL,"PluginNativeFilter::DoImport null document!");
 
+	TRACEUSER( "Gerry", _T("PluginNativeFilter::DoImport"));
+
 	PluginOILFilter* pPluginOILFilter = (PluginOILFilter*)pOILFilter;
 
 	// Make sure the OIL filter gets cleaned up on exit
@@ -295,6 +305,8 @@
 	// Make sure the new file object gets deleted on exit
 	AutoDeleteCCObject TidyFile(pNewFile);
 
+	TRACEUSER( "Gerry", _T("Calling CamelotNativeFilter::DoImport
"));
+
 	// Call the baseclass DoImport method passing the new file
 	if (!CamelotNativeFilter::DoImport(pOp, pNewFile, pDestDoc, AutoChosen, pPos, ppImportedBitmap, pPosTranslate, URL))
 	{
@@ -431,6 +443,10 @@
 	// (just deleting the KernelBitmaps doesn't seem to do it)
 	Camelot.GetGlobalBitmapList()->DeleteAllUnusedBitmaps();
 
+	// Make sure this is closed
+	if (pNewFile->isOpen())
+		pNewFile->close();
+
 	if (!ok)
 	{
 		TRACEUSER( "Gerry", _T("Failed in baseclass DoExport
"));
Index: Trunk/XaraLX/wxOil/xpoilflt.cpp
===================================================================
--- Trunk/XaraLX/wxOil/xpoilflt.cpp	(revision 984)
+++ Trunk/XaraLX/wxOil/xpoilflt.cpp	(revision 985)
@@ -114,6 +114,8 @@
 #include "ncntrcnt.h"
 //#include "nev.h"		// For _R(IDN_USER_CANCELLED)
 
+#include "camprocess.h"
+
 CC_IMPLEMENT_MEMDUMP(PluginOILFilter, OILFilter)
 CC_IMPLEMENT_DYNAMIC(PathNameListItem, ListItem)
 
@@ -779,7 +781,7 @@
 	// This should be set to some sensible path but I've hardcoded it for now
 	// We should change to making ~/.XaraLX into a directory and store the main config
 	// file and these filter config files in there
-	m_XMLFile.SetPathName(_T("~/.XPFilters/XPFilter.xml"));
+	m_XMLFile.SetPathName(_T("/home/gerry/.XPFilters/XPFilter.xml"));
 
 //	Size = 32;
 //	TCHAR Exts[32];
@@ -878,17 +880,16 @@
 	// Check stderr for errors
 	// Get HowCompatible from stdout
 
-// Temporarily remove this as it is interferring with file loading
-// Looks like the loading code is using the first filter that doesn't return 0
-// rather than using the filter that returns the best score
-#if FALSE
 	wxString sCommand;
 	// Does this need double quotes to cope with spaces in filenames?
 	sCommand.Printf(_T("%s -c -f %s"), (LPCTSTR)m_FilterPath.GetPath(), (LPCTSTR)FileName.GetPath());
 
+	TRACE(_T("Running '%s'"), sCommand.c_str());
+
 	wxArrayString saOutput;
 	wxArrayString saErrors;
 	int code = wxExecute(sCommand, saOutput, saErrors);
+	TRACE(_T("wxExecute returned %d"), code);
 	if (code == 0)
 	{
 		// Extract the value from saOutput
@@ -911,7 +912,7 @@
 	{
 		TRACE(_T("Command '%s' exited with code %d"), sCommand.c_str(), code);
 	}
-#endif
+
 	return(HowCompatible);
 }
 
@@ -994,28 +995,32 @@
 	// Redirect stdout to a CCLexFile
 	// Check stderr during the Xar import and abort if an error is reported
 
-	// However to get it working quickly I shall instead:
-	// Run the plugin synchronously with the following options
-	// -i -g -f <filename> ><tempfilename>
+	m_TempXarFile.SetPathName(_T("/tmp/xpftemp.xar"));
 
-	// Check stderr for errors
+	CCDiskFile TempFile;
+	if (!TempFile.open(m_TempXarFile, ios::out | ios::trunc | ios::binary))
+	{
+		// report an error here
+		return FALSE;
+	}
 
-	// Once complete create a CCDiskFile attached to the temporary file
-	m_TempXarFile.SetPathName(_T("/tmp/xpftemp.xar"));
-
 	PathName FileName = pFile->GetPathName();
 
 	wxString sCommand;
 	// Does this need double quotes to cope with spaces in filenames?
-	sCommand.Printf(_T("%s -i -f %s > %s"), (LPCTSTR)m_FilterPath.GetPath(), (LPCTSTR)FileName.GetPath(), (LPCTSTR)m_TempXarFile.GetPath());
+	sCommand.Printf(_T("%s -i -f %s"), (LPCTSTR)m_FilterPath.GetPath(), (LPCTSTR)FileName.GetPath());
 
-	wxArrayString saOutput;
-	wxArrayString saErrors;
-	int code = wxExecute(sCommand, saOutput, saErrors);
+	// Create a process with the TempFile as the stdout
+	// We will need to derive a new class from CamProcess to handle
+	// the processing of stderr for errors, warnings and progress
+	CamProcess TheProc(NULL, &TempFile);
+
+	int code = TheProc.Execute(sCommand);
+	TempFile.close();
 	if (code != 0)
 	{
 		TRACE(_T("Execution of '%s' failed."), sCommand.c_str());
-		// Extract error from saErrors and report it
+		// Extract error from a derived CamProcess class and report it
 		return(FALSE);
 	}
 
@@ -1180,7 +1185,7 @@
 	wxArrayString saErrors;
 	int code = wxExecute(sCommand, saOutput, saErrors);
 
-	for (INT32 i = 0; i < saErrors.GetCount(); i++)
+	for (UINT32 i = 0; i < saErrors.GetCount(); i++)
 	{
 		TRACE(_T("stderr: %s"), saErrors[i].c_str());
 	}
@@ -1195,6 +1200,7 @@
 		TRACE(_T("Command '%s' exited with code %d"), sCommand.c_str(), code);
 
 		// Get error message from saErrors
+		return(FALSE);
 	}
 
 	return(TRUE);
@@ -1250,8 +1256,8 @@
 	// Check stderr for errors and progress
 
 	// However for now we will instead
-	// Run the plugin synchronously with the following options
-	// -e -g -f <filename> -x <xmlfilename> < <tempfilename>
+	// Run the plugin with the following options
+	// -e -g -f <filename> -x <xmlfilename>
 
 	// The xmlfilename is a path to a user and filter specific file
 	// e.g. ~/.XaraLX/filtername.xml
@@ -1260,19 +1266,26 @@
 
 	wxString sCommand;
 	// Does this need double quotes to cope with spaces in filenames?
-	sCommand.Printf(_T("%s -e -f %s -x %s < %s"), (LPCTSTR)m_FilterPath.GetPath(), (LPCTSTR)pPath->GetPath(), (LPCTSTR)m_XMLFile.GetPath(), (LPCTSTR)m_TempXarFile.GetPath());
+	sCommand.Printf(_T("%s -e -f %s -x %s"), (LPCTSTR)m_FilterPath.GetPath(), (LPCTSTR)pPath->GetPath(), (LPCTSTR)m_XMLFile.GetPath());
 
-	wxArrayString saOutput;
-	wxArrayString saErrors;
-	int code = wxExecute(sCommand, saOutput, saErrors);
-	for (INT32 i = 0; i < saErrors.GetCount(); i++)
+	CCDiskFile TempFile(CCFILE_DEFAULTSIZE, FALSE, FALSE);
+	if (!TempFile.open(m_TempXarFile, ios::in | ios::binary))
 	{
-		TRACE(_T("stderr: %s"), saErrors[i].c_str());
+		// report an error here
+		return FALSE;
 	}
+
+	// Create a process with the TempFile as the stdin
+	// We will need to derive a new class from CamProcess to handle
+	// the processing of stderr for errors, warnings and progress
+	CamProcess TheProc(&TempFile, NULL);
+
+	int code = TheProc.Execute(sCommand);
+	TempFile.close();
 	if (code != 0)
 	{
 		TRACE(_T("Execution of '%s' failed."), sCommand.c_str());
-		// Extract error from saErrors and report it
+		// Extract error from a derived CamProcess class and report it
 		return(FALSE);
 	}
 
Index: Trunk/XaraLX/wxOil/Makefile.am
===================================================================
--- Trunk/XaraLX/wxOil/Makefile.am	(revision 984)
+++ Trunk/XaraLX/wxOil/Makefile.am	(revision 985)
@@ -43,7 +43,7 @@
 	drawctl.cpp filedlgs.cpp fileutil.cpp ktimer.cpp camplatform.cpp \
 	outptdib.cpp outptpng.cpp outptgif.cpp gpalopt.cpp bmpfiltr.cpp giffiltr.cpp \
 	fontbase.cpp ftfonts.cpp textfuns.cpp dragbmp.cpp xpoilflt.cpp \
-	fltrdisc.cpp \
+	fltrdisc.cpp camprocess.cpp \
 	resources.cpp
 
 # Keep resources.cpp (the autogenerated resource file) on a separate line.
Index: Trunk/XaraLX/wxOil/camprocess.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camprocess.cpp	(revision 0)
+++ Trunk/XaraLX/wxOil/camprocess.cpp	(revision 985)
@@ -0,0 +1,337 @@
+// $Id: xpoilflt.cpp 836 2006-04-18 16:06:15Z gerry $
+/* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
+================================XARAHEADERSTART===========================
+ 
+               Xara LX, a vector drawing and manipulation program.
+                    Copyright (C) 1993-2006 Xara Group Ltd.
+       Copyright on certain contributions may be held in joint with their
+              respective authors. See AUTHORS file for details.
+
+LICENSE TO USE AND MODIFY SOFTWARE
+----------------------------------
+
+This file is part of Xara LX.
+
+Xara LX is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 2 as published
+by the Free Software Foundation.
+
+Xara LX and its component source files are distributed in the hope
+that it will be useful, but WITHOUT ANY WARRANTY; without even the
+implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with Xara LX (see the file GPL in the root directory of the
+distribution); if not, write to the Free Software Foundation, Inc., 51
+Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+
+ADDITIONAL RIGHTS
+-----------------
+
+Conditional upon your continuing compliance with the GNU General Public
+License described above, Xara Group Ltd grants to you certain additional
+rights. 
+
+The additional rights are to use, modify, and distribute the software
+together with the wxWidgets library, the wxXtra library, and the "CDraw"
+library and any other such library that any version of Xara LX relased
+by Xara Group Ltd requires in order to compile and execute, including
+the static linking of that library to XaraLX. In the case of the
+"CDraw" library, you may satisfy obligation under the GNU General Public
+License to provide source code by providing a binary copy of the library
+concerned and a copy of the license accompanying it.
+
+Nothing in this section restricts any of the rights you have under
+the GNU General Public License.
+
+
+SCOPE OF LICENSE
+----------------
+
+This license applies to this program (XaraLX) and its constituent source
+files only, and does not necessarily apply to other Xara products which may
+in part share the same code base, and are subject to their own licensing
+terms.
+
+This license does not apply to files in the wxXtra directory, which
+are built into a separate library, and are subject to the wxWindows
+license contained within that directory in the file "WXXTRA-LICENSE".
+
+This license does not apply to the binary libraries (if any) within
+the "libs" directory, which are subject to a separate license contained
+within that directory in the file "LIBS-LICENSE".
+
+
+ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
+----------------------------------------------
+
+Subject to the terms of the GNU Public License (see above), you are
+free to do whatever you like with your modifications. However, you may
+(at your option) wish contribute them to Xara's source tree. You can
+find details of how to do this at:
+  http://www.xaraxtreme.org/developers/
+
+Prior to contributing your modifications, you will need to complete our
+contributor agreement. This can be found at:
+  http://www.xaraxtreme.org/developers/contribute/
+
+Please note that Xara will not accept modifications which modify any of
+the text between the start and end of this header (marked
+XARAHEADERSTART and XARAHEADEREND).
+
+
+MARKS
+-----
+
+Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
+designs are registered or unregistered trademarks, design-marks, and/or
+service marks of Xara Group Ltd. All rights in these marks are reserved.
+
+
+      Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
+                        http://www.xara.com/
+
+=================================XARAHEADEREND============================
+ */
+
+// The module that controls the OIL side of import/export filters.
+
+
+#include "camtypes.h"
+
+#include "camprocess.h"
+
+
+
+CamProcess::CamProcess(CCLexFile* pInFile, CCLexFile* pOutFile)
+{
+	m_bDead = true;
+	m_ReturnCode = -1;
+	m_pInFile = pInFile;
+	m_pOutFile = pOutFile;
+	m_BytesIn = 0;
+	m_BytesOut = 0;
+}
+
+CamProcess::~CamProcess()
+{
+	if (!m_bDead)
+	{
+		TRACEUSER("Gerry", _T("Process not dead in ~CamProcess"));
+	}
+}
+
+
+INT32 CamProcess::Execute(const wxString& cmd)
+{
+	// We're now running
+	m_bDead = false;
+
+	// Make sure redirection happens
+	Redirect();
+
+	if (!wxExecute(cmd, wxEXEC_ASYNC, this))
+	{
+		// Report problem
+		m_bDead = true;
+		return 123;
+	}
+
+	BYTE ReadBuffer[4096];
+	size_t ReadBytes = 0;
+	BYTE* ReadPtr = NULL;
+	bool bMoreInput = true;
+	size_t InFileLeft = 0;
+	if (m_pInFile)
+	{
+		InFileLeft = m_pInFile->Size();
+		TRACEUSER("Gerry", _T("InFileSize = %d"), InFileLeft);
+	}
+
+	// Loop until m_bDead is true
+
+	while (!m_bDead)
+	{
+		// Call the virtual function to process any output on stderr
+		ProcessStdErr();
+
+		// If we have an output file
+		if (m_pOutFile)
+		{
+			// If there is output from the process
+			if (IsInputAvailable())
+			{
+				// Copy the data to the file
+
+				size_t NumRead = 4096;
+				BYTE Buffer[4096];
+
+				while (NumRead > 0)
+				{
+					// Read a buffer full
+					GetInputStream()->Read(Buffer, 4096);
+
+					NumRead = GetInputStream()->LastRead();
+
+					// Write the buffer to the file
+					if (NumRead > 0)
+					{
+						m_pOutFile->write(Buffer, NumRead);
+					}
+				}
+			}
+		}
+		else
+		{
+			// Call the virtual function to process the output
+			ProcessStdOut();
+		}
+
+		// If we have an input file
+		if (m_pInFile)
+		{
+			// Copy some data to the process
+			while (bMoreInput)
+			{
+				// If there is nothing in the buffer
+				if (ReadBytes == 0)
+				{
+					ReadBytes = 4096;
+					if (ReadBytes > InFileLeft)
+						ReadBytes = InFileLeft;
+
+					if (ReadBytes > 0)
+					{
+						// Read a buffer full
+						TRACEUSER("Gerry", _T("Reading %d"), ReadBytes);
+						m_pInFile->read(ReadBuffer, ReadBytes);
+
+						InFileLeft -= ReadBytes;
+						ReadPtr = ReadBuffer;
+					}
+				}
+
+				// If there is something in the buffer
+				if (ReadBytes > 0)
+				{
+					TRACEUSER("Gerry", _T("Buffer contains %d"), ReadBytes);
+					// Try to write it to the process
+					GetOutputStream()->Write(ReadPtr, ReadBytes);
+
+					size_t Done = GetOutputStream()->LastWrite();
+					TRACEUSER("Gerry", _T("Written %d"), Done);
+					// If we couldn't write it all
+					if (Done < ReadBytes)
+					{
+						// Update the buffer pointer and size
+						ReadBytes -= Done;
+						ReadPtr += Done;
+						break;				// go and process the other streams
+					}
+					ReadBytes = 0;
+				}
+				else
+				{
+					// Indicate there is no more stdin
+					TRACEUSER("Gerry", _T("Buffer is empty - closing"));
+					CloseOutput();
+					bMoreInput = false;
+				}
+			}
+		}
+		else
+		{
+			// Call the virtual function to process the input
+			ProcessStdIn();
+		}
+
+		wxYield();
+	}
+
+	TRACEUSER("Gerry", _T("Exiting with %d"), m_ReturnCode);
+	return m_ReturnCode;
+}
+
+void CamProcess::ProcessStdIn()
+{
+	// Do nothing in here
+}
+
+
+void CamProcess::ProcessStdOut()
+{
+	if (IsInputAvailable())
+	{
+		wxTextInputStream tis(*GetInputStream());
+
+		// This assumes that the output is always line buffered
+		while (!GetInputStream()->Eof())
+		{
+			wxString line;
+			line << tis.ReadLine();
+			TRACEUSER("Gerry", _T("(stdout):%s"), line.c_str());
+		}
+	}
+
+}
+
+
+void CamProcess::ProcessStdErr()
+{
+	if (IsErrorAvailable())
+	{
+		wxTextInputStream tis(*GetErrorStream());
+
+		// This assumes that the output is always line buffered
+		while (!GetErrorStream()->Eof())
+		{
+			wxString line;
+			line << tis.ReadLine();
+			TRACEUSER("Gerry", _T("(stderr):%s"), line.c_str());
+		}
+	}
+}
+
+
+void CamProcess::OnTerminate(int pid, int status)
+{
+	TRACEUSER("Gerry", _T("CamProcess::OnTerminate pid = %d  status = %d"), pid, status);
+	m_bDead = true;
+	m_ReturnCode = status;
+
+	// Process anything remaining on stderr and stdout
+	// If we have an output file
+	if (m_pOutFile)
+	{
+		// If there is output from the process
+		if (IsInputAvailable())
+		{
+			// Copy the data to the file
+			size_t NumRead = 4096;
+			BYTE Buffer[4096];
+
+			while (NumRead > 0)
+			{
+				// Read a buffer full
+				GetInputStream()->Read(Buffer, 4096);
+
+				NumRead = GetInputStream()->LastRead();
+
+				// Write the buffer to the file
+				if (NumRead > 0)
+				{
+					m_pOutFile->write(Buffer, NumRead);
+				}
+			}
+		}
+	}
+	else
+	{
+		// Call the virtual function to process the output
+		ProcessStdOut();
+	}
+
+	ProcessStdErr();
+}
Index: Trunk/XaraLX/wxOil/camprocess.h
===================================================================
--- Trunk/XaraLX/wxOil/camprocess.h	(revision 0)
+++ Trunk/XaraLX/wxOil/camprocess.h	(revision 985)
@@ -0,0 +1,135 @@
+// $Id: xpoilflt.h 751 2006-03-31 15:43:49Z alex $
+/* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
+================================XARAHEADERSTART===========================
+ 
+               Xara LX, a vector drawing and manipulation program.
+                    Copyright (C) 1993-2006 Xara Group Ltd.
+       Copyright on certain contributions may be held in joint with their
+              respective authors. See AUTHORS file for details.
+
+LICENSE TO USE AND MODIFY SOFTWARE
+----------------------------------
+
+This file is part of Xara LX.
+
+Xara LX is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 2 as published
+by the Free Software Foundation.
+
+Xara LX and its component source files are distributed in the hope
+that it will be useful, but WITHOUT ANY WARRANTY; without even the
+implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with Xara LX (see the file GPL in the root directory of the
+distribution); if not, write to the Free Software Foundation, Inc., 51
+Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+
+ADDITIONAL RIGHTS
+-----------------
+
+Conditional upon your continuing compliance with the GNU General Public
+License described above, Xara Group Ltd grants to you certain additional
+rights. 
+
+The additional rights are to use, modify, and distribute the software
+together with the wxWidgets library, the wxXtra library, and the "CDraw"
+library and any other such library that any version of Xara LX relased
+by Xara Group Ltd requires in order to compile and execute, including
+the static linking of that library to XaraLX. In the case of the
+"CDraw" library, you may satisfy obligation under the GNU General Public
+License to provide source code by providing a binary copy of the library
+concerned and a copy of the license accompanying it.
+
+Nothing in this section restricts any of the rights you have under
+the GNU General Public License.
+
+
+SCOPE OF LICENSE
+----------------
+
+This license applies to this program (XaraLX) and its constituent source
+files only, and does not necessarily apply to other Xara products which may
+in part share the same code base, and are subject to their own licensing
+terms.
+
+This license does not apply to files in the wxXtra directory, which
+are built into a separate library, and are subject to the wxWindows
+license contained within that directory in the file "WXXTRA-LICENSE".
+
+This license does not apply to the binary libraries (if any) within
+the "libs" directory, which are subject to a separate license contained
+within that directory in the file "LIBS-LICENSE".
+
+
+ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
+----------------------------------------------
+
+Subject to the terms of the GNU Public License (see above), you are
+free to do whatever you like with your modifications. However, you may
+(at your option) wish contribute them to Xara's source tree. You can
+find details of how to do this at:
+  http://www.xaraxtreme.org/developers/
+
+Prior to contributing your modifications, you will need to complete our
+contributor agreement. This can be found at:
+  http://www.xaraxtreme.org/developers/contribute/
+
+Please note that Xara will not accept modifications which modify any of
+the text between the start and end of this header (marked
+XARAHEADERSTART and XARAHEADEREND).
+
+
+MARKS
+-----
+
+Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
+designs are registered or unregistered trademarks, design-marks, and/or
+service marks of Xara Group Ltd. All rights in these marks are reserved.
+
+
+      Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
+                        http://www.xara.com/
+
+=================================XARAHEADEREND============================
+ */
+
+// wxProcess derived classes for attaching to child process streams
+
+#ifndef INC_CAMPROCESS
+#define INC_CAMPROCESS
+
+// Move these to stdwx.h once it works
+#include <wx/process.h>
+#include <wx/txtstrm.h>
+
+
+class CamProcess : public wxProcess
+{
+public:
+	CamProcess(CCLexFile* pInFile = NULL, CCLexFile* pOutFile = NULL);
+	virtual ~CamProcess();
+
+	virtual void OnTerminate(int pid, int status);
+
+	// These are called to handle the various streams
+	// StdIn and StdOut are only called when a file isn't being used
+	virtual void ProcessStdIn();
+	virtual void ProcessStdOut();
+	virtual void ProcessStdErr();
+
+	// These functions run the command optionally redirecting stdin and stdout
+	INT32 Execute(const wxString& cmd);
+
+protected:
+	bool m_bDead;
+	INT32 m_ReturnCode;
+	CCLexFile* m_pInFile;
+	CCLexFile* m_pOutFile;
+	INT32 m_BytesIn;
+	INT32 m_BytesOut;
+};
+
+#endif // INC_CAMPROCESS


Xara